diff options
| author | John Wiegley | 2007-10-22 21:56:24 +0000 |
|---|---|---|
| committer | John Wiegley | 2007-10-22 21:56:24 +0000 |
| commit | 03f3cf356f7dbb95f8bdc3b26e9b66a9bfecee94 (patch) | |
| tree | 180bbd77c718efbc192a1f0c58f435240d76c943 | |
| parent | 7e780ff12c9e8a6cf30b7377232f1f214706e440 (diff) | |
| download | emacs-03f3cf356f7dbb95f8bdc3b26e9b66a9bfecee94.tar.gz emacs-03f3cf356f7dbb95f8bdc3b26e9b66a9bfecee94.zip | |
Installed org-mode 5.13d
| -rw-r--r-- | lisp/ChangeLog | 75 | ||||
| -rw-r--r-- | lisp/textmodes/org-export-latex.el | 34 | ||||
| -rw-r--r-- | lisp/textmodes/org-publish.el | 27 | ||||
| -rw-r--r-- | lisp/textmodes/org.el | 2456 |
4 files changed, 1817 insertions, 775 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 374fc19531d..ecdf3ffb467 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,78 @@ | |||
| 1 | 2007-10-22 Carsten Dominik <dominik@science.uva.nl> | ||
| 2 | |||
| 3 | * org.el (org-read-date-get-relative): New function. | ||
| 4 | (org-agenda-file-regexp): New variable. | ||
| 5 | (org-agenda-files): Allow directories in the variable. | ||
| 6 | (org-agenda-get-restriction-and-command): New function. | ||
| 7 | (org-agenda): Use `org-agenda-get-restriction-and-command'. | ||
| 8 | (org-todo-blocker-hook, org-todo-trigger-hook): New hook. | ||
| 9 | (org-entry-is-todo-p, org-entry-is-done-p, org-get-todo-state): | ||
| 10 | New functions. | ||
| 11 | (org-entry-add-to-multivalued-property) | ||
| 12 | (org-entry-remove-from-multivalued-property) | ||
| 13 | (org-entry-member-in-multivalued-property): New functions. | ||
| 14 | (org-remember-apply-template): Catch C-g and make sure window | ||
| 15 | configuration is restored. | ||
| 16 | (org-agenda-open-link): Make is work with several links in the | ||
| 17 | line. | ||
| 18 | (org-drawers, org-set-regexps-and-options) | ||
| 19 | (org-get-current-options): Added support for a DRAWERS in-buffer | ||
| 20 | option. | ||
| 21 | (org-agenda-window-frame-fractions): New option. | ||
| 22 | (org-fit-agenda-window): Use `org-agenda-window-frame-fractions'. | ||
| 23 | (org-columns-cleanup-item, org-find-entry-with-id) | ||
| 24 | (org-insert-columns-dblock, org-listtable-to-string) | ||
| 25 | (org-dblock-write:columnview, org-columns-capture-view) | ||
| 26 | (org-edit-headline): New functions. | ||
| 27 | (org-agenda-to-appt): Require calendar. | ||
| 28 | (org-entry-get-with-inheritance): Widen for search. | ||
| 29 | (org-columns-display-here): Don't mark buffer as modified when | ||
| 30 | adding space characters to accomodate column overlays. | ||
| 31 | (org-export-as-html): Better formatting of tags in the toc. | ||
| 32 | (org-columns-display-here): Make the ITEM column as compact as | ||
| 33 | possible. | ||
| 34 | (org-remember-templates): Customization interface improved. | ||
| 35 | (org-export-with-property-drawer): Variable removed. | ||
| 36 | (org-export-with-drawers): New option. | ||
| 37 | (org-complex-heading-regexp): New variable. | ||
| 38 | (org-sort-entries): Rewrite using `sort-subr'. | ||
| 39 | (org-set-property): More appropriate completion during interactive | ||
| 40 | use. | ||
| 41 | (org-sort-entries): Allow sorting by property. | ||
| 42 | (org-additional-option-like-keywords): Added more values. | ||
| 43 | (org-sort-entries-or-items): Renamed from `org-sort-entries'. | ||
| 44 | |||
| 45 | 2007-10-22 Carsten Dominik <dominik@science.uva.nl> | ||
| 46 | |||
| 47 | * org.texi: Small fixes. | ||
| 48 | |||
| 49 | 2007-10-22 Carsten Dominik <dominik@science.uva.nl> | ||
| 50 | |||
| 51 | * org.el (org-get-date-from-calendar): New function. | ||
| 52 | (org-at-timestamp-p, org-timestamp-change) | ||
| 53 | (org-remember-templates): First element of each entry is now a | ||
| 54 | name for the template. | ||
| 55 | (org-store-log-note): Check for `org-note-abort'. | ||
| 56 | (org-kill-note-or-show-branches): New command. | ||
| 57 | (org-fontify-priorities): New option. | ||
| 58 | (org-fontify-priorities): New function. | ||
| 59 | (org-cut-subtree, org-copy-subtree): New argument N to | ||
| 60 | act on N sequential subtrees. | ||
| 61 | (org-paste-subtree): Fix the level at which a tree is pasted. | ||
| 62 | (org-fit-agenda-window): Limitations on window size removed. | ||
| 63 | (org-agenda-find-same-or-today-or-agenda): Renamed from | ||
| 64 | `org-agenda-find-today-or-agenda'. | ||
| 65 | (org-scheduled-past-days): New option. | ||
| 66 | (org-agenda-scheduled-leaders) | ||
| 67 | (org-agenda-deadline-leaders): New options. | ||
| 68 | (org-agenda-get-deadlines): Use `org-agenda-deadline-leaders'. | ||
| 69 | (org-agenda-get-scheduled): Use `org-agenda-scheduled-leaders'. | ||
| 70 | (org-export-with-tags, org-export-plist-vars) | ||
| 71 | (org-infile-export-plist): New "tags" option. | ||
| 72 | (org-use-property-inheritance): New option. | ||
| 73 | (org-cached-entry-get): Use `org-use-property-inheritance'. | ||
| 74 | (org-remember-apply-template): Fixed typo. | ||
| 75 | |||
| 1 | 2007-10-22 Michael Albinus <michael.albinus@gmx.de> | 76 | 2007-10-22 Michael Albinus <michael.albinus@gmx.de> |
| 2 | 77 | ||
| 3 | * net/tramp.el (tramp-find-shell) | 78 | * net/tramp.el (tramp-find-shell) |
diff --git a/lisp/textmodes/org-export-latex.el b/lisp/textmodes/org-export-latex.el index 2cf08b399e6..e6c68f25c4c 100644 --- a/lisp/textmodes/org-export-latex.el +++ b/lisp/textmodes/org-export-latex.el | |||
| @@ -1,10 +1,10 @@ | |||
| 1 | ;;; org-export-latex.el --- LaTeX exporter for org-mode | 1 | ;;; org-export-latex.el --- LaTeX exporter for org-mode |
| 2 | ;; | 2 | ;; |
| 3 | ;; Copyright (C) 2007 Free Software Foundation, Inc. | 3 | ;; copyright (c) 2007 free software foundation, inc. |
| 4 | ;; | 4 | ;; |
| 5 | ;; Emacs Lisp Archive Entry | 5 | ;; Emacs Lisp Archive Entry |
| 6 | ;; Filename: org-export-latex.el | 6 | ;; Filename: org-export-latex.el |
| 7 | ;; Version: 5.11 | 7 | ;; Version: 5.12 |
| 8 | ;; Author: Bastien Guerry <bzg AT altern DOT org> | 8 | ;; Author: Bastien Guerry <bzg AT altern DOT org> |
| 9 | ;; Maintainer: Bastien Guerry <bzg AT altern DOT org> | 9 | ;; Maintainer: Bastien Guerry <bzg AT altern DOT org> |
| 10 | ;; Keywords: org, wp, tex | 10 | ;; Keywords: org, wp, tex |
| @@ -22,7 +22,7 @@ | |||
| 22 | ;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | 22 | ;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 23 | ;; FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | 23 | ;; FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
| 24 | ;; more details. | 24 | ;; more details. |
| 25 | ;; | 25 | ;; |
| 26 | ;; You should have received a copy of the GNU General Public License along | 26 | ;; You should have received a copy of the GNU General Public License along |
| 27 | ;; with GNU Emacs; see the file COPYING. If not, write to the Free Software | 27 | ;; with GNU Emacs; see the file COPYING. If not, write to the Free Software |
| 28 | ;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA | 28 | ;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
| @@ -58,7 +58,7 @@ | |||
| 58 | (defvar org-latex-add-level 0) | 58 | (defvar org-latex-add-level 0) |
| 59 | (defvar org-latex-sectioning-depth 0) | 59 | (defvar org-latex-sectioning-depth 0) |
| 60 | (defvar org-export-latex-list-beginning-re | 60 | (defvar org-export-latex-list-beginning-re |
| 61 | "^\\([ \t]*\\)\\([-+]\\|[0-9]+\\(?:\\.\\|)\\)\\) *?") | 61 | "^\\([ \t]*\\)\\([-+*]\\|[0-9]+[.)]\\) +?") |
| 62 | 62 | ||
| 63 | (defvar org-latex-special-string-regexps | 63 | (defvar org-latex-special-string-regexps |
| 64 | '(org-ts-regexp | 64 | '(org-ts-regexp |
| @@ -579,14 +579,16 @@ Argument OPT-PLIST is the options plist for current buffer." | |||
| 579 | ;; insert the title | 579 | ;; insert the title |
| 580 | (format | 580 | (format |
| 581 | "\\title{%s}\n" | 581 | "\\title{%s}\n" |
| 582 | (or (plist-get opt-plist :title) | 582 | ;; convert the title |
| 583 | (and (not | 583 | (org-export-latex-content |
| 584 | (plist-get opt-plist :skip-before-1st-heading)) | 584 | (or (plist-get opt-plist :title) |
| 585 | (org-export-grab-title-from-buffer)) | 585 | (and (not |
| 586 | (and buffer-file-name | 586 | (plist-get opt-plist :skip-before-1st-heading)) |
| 587 | (file-name-sans-extension | 587 | (org-export-grab-title-from-buffer)) |
| 588 | (file-name-nondirectory buffer-file-name))) | 588 | (and buffer-file-name |
| 589 | "UNTITLED")) | 589 | (file-name-sans-extension |
| 590 | (file-name-nondirectory buffer-file-name))) | ||
| 591 | "UNTITLED"))) | ||
| 590 | 592 | ||
| 591 | ;; insert author info | 593 | ;; insert author info |
| 592 | (if (plist-get opt-plist :author-info) | 594 | (if (plist-get opt-plist :author-info) |
| @@ -626,7 +628,9 @@ COMMENTS is either nil to replace them with the empty string or a | |||
| 626 | formatting string like %%%%s if we want to comment them out." | 628 | formatting string like %%%%s if we want to comment them out." |
| 627 | (save-excursion | 629 | (save-excursion |
| 628 | (goto-char (point-min)) | 630 | (goto-char (point-min)) |
| 629 | (let* ((end (if (re-search-forward "^\\*" nil t) | 631 | (let* ((pt (point)) |
| 632 | (end (if (and (re-search-forward "^\\*" nil t) | ||
| 633 | (not (eq pt (match-beginning 0)))) | ||
| 630 | (goto-char (match-beginning 0)) | 634 | (goto-char (match-beginning 0)) |
| 631 | (goto-char (point-max))))) | 635 | (goto-char (point-max))))) |
| 632 | (org-export-latex-content | 636 | (org-export-latex-content |
| @@ -954,7 +958,7 @@ Valid parameters are | |||
| 954 | (let* ((beg (org-table-begin)) | 958 | (let* ((beg (org-table-begin)) |
| 955 | (end (org-table-end)) | 959 | (end (org-table-end)) |
| 956 | (raw-table (buffer-substring-no-properties beg end)) | 960 | (raw-table (buffer-substring-no-properties beg end)) |
| 957 | fnum line lines olines gr colgropen line-fmt alignment) | 961 | fnum fields line lines olines gr colgropen line-fmt align) |
| 958 | (if org-export-latex-tables-verbatim | 962 | (if org-export-latex-tables-verbatim |
| 959 | (let* ((tbl (concat "\\begin{verbatim}\n" raw-table | 963 | (let* ((tbl (concat "\\begin{verbatim}\n" raw-table |
| 960 | "\\end{verbatim}\n"))) | 964 | "\\end{verbatim}\n"))) |
| @@ -1133,7 +1137,7 @@ Valid parameters are | |||
| 1133 | (when (and (re-search-forward (regexp-quote foot-prefix) nil t)) | 1137 | (when (and (re-search-forward (regexp-quote foot-prefix) nil t)) |
| 1134 | (replace-match "") | 1138 | (replace-match "") |
| 1135 | (let ((end (save-excursion | 1139 | (let ((end (save-excursion |
| 1136 | (if (re-search-forward "^$\\|\\[[0-9]+\\]" nil t) | 1140 | (if (re-search-forward "^$\\|^#.*$\\|\\[[0-9]+\\]" nil t) |
| 1137 | (match-beginning 0) (point-max))))) | 1141 | (match-beginning 0) (point-max))))) |
| 1138 | (setq footnote | 1142 | (setq footnote |
| 1139 | (concat | 1143 | (concat |
diff --git a/lisp/textmodes/org-publish.el b/lisp/textmodes/org-publish.el index 77b69a1f5a8..0eddd402812 100644 --- a/lisp/textmodes/org-publish.el +++ b/lisp/textmodes/org-publish.el | |||
| @@ -4,7 +4,7 @@ | |||
| 4 | 4 | ||
| 5 | ;; Author: David O'Toole <dto@gnu.org> | 5 | ;; Author: David O'Toole <dto@gnu.org> |
| 6 | ;; Keywords: hypermedia, outlines | 6 | ;; Keywords: hypermedia, outlines |
| 7 | ;; Version: 1.80 | 7 | ;; Version: 1.80a |
| 8 | 8 | ||
| 9 | ;; This file is free software; you can redistribute it and/or modify | 9 | ;; This file is free software; you can redistribute it and/or modify |
| 10 | ;; it under the terms of the GNU General Public License as published by | 10 | ;; it under the terms of the GNU General Public License as published by |
| @@ -426,7 +426,7 @@ nil if not found." | |||
| 426 | (defun org-publish-get-plist-from-filename (filename) | 426 | (defun org-publish-get-plist-from-filename (filename) |
| 427 | "Return publishing configuration plist for file FILENAME." | 427 | "Return publishing configuration plist for file FILENAME." |
| 428 | (let ((found nil)) | 428 | (let ((found nil)) |
| 429 | (mapc | 429 | (mapcar |
| 430 | (lambda (plist) | 430 | (lambda (plist) |
| 431 | (let ((files (org-publish-get-base-files plist))) | 431 | (let ((files (org-publish-get-base-files plist))) |
| 432 | (if (member (expand-file-name filename) files) | 432 | (if (member (expand-file-name filename) files) |
| @@ -438,20 +438,6 @@ nil if not found." | |||
| 438 | 438 | ||
| 439 | ;;;; Pluggable publishing back-end functions | 439 | ;;;; Pluggable publishing back-end functions |
| 440 | 440 | ||
| 441 | |||
| 442 | (defun org-publish-org-to-html (plist filename) | ||
| 443 | "Publish an org file to HTML. | ||
| 444 | PLIST is the property list for the given project. | ||
| 445 | FILENAME is the filename of the org file to be published." | ||
| 446 | (eval-and-compile (require 'org)) | ||
| 447 | (let* ((arg (plist-get plist :headline-levels))) | ||
| 448 | (progn | ||
| 449 | (find-file filename) | ||
| 450 | (org-export-as-html arg nil plist) | ||
| 451 | ;; get rid of HTML buffer | ||
| 452 | (kill-buffer (current-buffer))))) | ||
| 453 | |||
| 454 | |||
| 455 | (defun org-publish-org-to-latex (plist filename) | 441 | (defun org-publish-org-to-latex (plist filename) |
| 456 | "Publish an org file to LaTeX." | 442 | "Publish an org file to LaTeX." |
| 457 | (org-publish-org-to "latex" plist filename)) | 443 | (org-publish-org-to "latex" plist filename)) |
| @@ -464,7 +450,7 @@ FILENAME is the filename of the org file to be published." | |||
| 464 | "Publish an org file to FORMAT. | 450 | "Publish an org file to FORMAT. |
| 465 | PLIST is the property list for the given project. | 451 | PLIST is the property list for the given project. |
| 466 | FILENAME is the filename of the org file to be published." | 452 | FILENAME is the filename of the org file to be published." |
| 467 | (eval-and-compile (require 'org)) | 453 | (require 'org) |
| 468 | (let* ((arg (plist-get plist :headline-levels))) | 454 | (let* ((arg (plist-get plist :headline-levels))) |
| 469 | (progn | 455 | (progn |
| 470 | (find-file filename) | 456 | (find-file filename) |
| @@ -478,10 +464,9 @@ FILENAME is the filename of the org file to be published." | |||
| 478 | PLIST is the property list for the given project. | 464 | PLIST is the property list for the given project. |
| 479 | FILENAME is the filename of the file to be published." | 465 | FILENAME is the filename of the file to be published." |
| 480 | ;; make sure eshell/cp code is loaded | 466 | ;; make sure eshell/cp code is loaded |
| 481 | (eval-and-compile | 467 | (require 'eshell) |
| 482 | (require 'eshell) | 468 | (require 'esh-maint) |
| 483 | (require 'esh-maint) | 469 | (require 'em-unix) |
| 484 | (require 'em-unix)) | ||
| 485 | (let ((destination (file-name-as-directory (plist-get plist :publishing-directory)))) | 470 | (let ((destination (file-name-as-directory (plist-get plist :publishing-directory)))) |
| 486 | (eshell/cp filename destination))) | 471 | (eshell/cp filename destination))) |
| 487 | 472 | ||
diff --git a/lisp/textmodes/org.el b/lisp/textmodes/org.el index 5487609343b..d2461a0aaa1 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.11b | 8 | ;; Version: 5.13d |
| 9 | ;; | 9 | ;; |
| 10 | ;; This file is part of GNU Emacs. | 10 | ;; This file is part of GNU Emacs. |
| 11 | ;; | 11 | ;; |
| @@ -83,7 +83,7 @@ | |||
| 83 | 83 | ||
| 84 | ;;; Version | 84 | ;;; Version |
| 85 | 85 | ||
| 86 | (defconst org-version "5.11" | 86 | (defconst org-version "5.13d" |
| 87 | "The version number of the file org.el.") | 87 | "The version number of the file org.el.") |
| 88 | (defun org-version () | 88 | (defun org-version () |
| 89 | (interactive) | 89 | (interactive) |
| @@ -129,7 +129,7 @@ | |||
| 129 | (progn | 129 | (progn |
| 130 | (if pc-mode (partial-completion-mode -1)) | 130 | (if pc-mode (partial-completion-mode -1)) |
| 131 | ,@body) | 131 | ,@body) |
| 132 | (if pc-mode (partial-completion-mode 1))))) | 132 | (if pc-mode (partial-completion-mode 1))))) |
| 133 | 133 | ||
| 134 | ;;; The custom variables | 134 | ;;; The custom variables |
| 135 | 135 | ||
| @@ -251,7 +251,7 @@ Or return the original if not disputed." | |||
| 251 | "Define a key, possibly translated, as returned by `org-key'." | 251 | "Define a key, possibly translated, as returned by `org-key'." |
| 252 | (define-key keymap (org-key key) def)) | 252 | (define-key keymap (org-key key) def)) |
| 253 | 253 | ||
| 254 | (defcustom org-ellipsis nil | 254 | (defcustom org-ellipsis 'org-ellipsis |
| 255 | "The ellipsis to use in the Org-mode outline. | 255 | "The ellipsis to use in the Org-mode outline. |
| 256 | When nil, just use the standard three dots. When a string, use that instead, | 256 | When nil, just use the standard three dots. When a string, use that instead, |
| 257 | When a face, use the standart 3 dots, but with the specified face. | 257 | When a face, use the standart 3 dots, but with the specified face. |
| @@ -439,7 +439,11 @@ this: | |||
| 439 | ..... | 439 | ..... |
| 440 | :END: | 440 | :END: |
| 441 | The drawer \"PROPERTIES\" is special for capturing properties through | 441 | The drawer \"PROPERTIES\" is special for capturing properties through |
| 442 | the property API." | 442 | the property API. |
| 443 | |||
| 444 | Drawers can be defined on the per-file basis with a line like: | ||
| 445 | |||
| 446 | #+DRAWERS: HIDDEN STATE PROPERTIES" | ||
| 443 | :group 'org-structure | 447 | :group 'org-structure |
| 444 | :type '(repeat (string :tag "Drawer Name"))) | 448 | :type '(repeat (string :tag "Drawer Name"))) |
| 445 | 449 | ||
| @@ -1250,15 +1254,15 @@ if one was given like in <mailto:arthur@galaxy.org::this subject>." | |||
| 1250 | 1254 | ||
| 1251 | (defcustom org-confirm-shell-link-function 'yes-or-no-p | 1255 | (defcustom org-confirm-shell-link-function 'yes-or-no-p |
| 1252 | "Non-nil means, ask for confirmation before executing shell links. | 1256 | "Non-nil means, ask for confirmation before executing shell links. |
| 1253 | Shell links can be dangerous, just thing about a link | 1257 | Shell links can be dangerous: just think about a link |
| 1254 | 1258 | ||
| 1255 | [[shell:rm -rf ~/*][Google Search]] | 1259 | [[shell:rm -rf ~/*][Google Search]] |
| 1256 | 1260 | ||
| 1257 | This link would show up in your Org-mode document as \"Google Search\" | 1261 | This link would show up in your Org-mode document as \"Google Search\", |
| 1258 | but really it would remove your entire home directory. | 1262 | but really it would remove your entire home directory. |
| 1259 | Therefore I *definitely* advise against setting this variable to nil. | 1263 | Therefore we advise against setting this variable to nil. |
| 1260 | Just change it to `y-or-n-p' of you want to confirm with a single key press | 1264 | Just change it to `y-or-n-p' of you want to confirm with a |
| 1261 | rather than having to type \"yes\"." | 1265 | single keystroke rather than having to type \"yes\"." |
| 1262 | :group 'org-link-follow | 1266 | :group 'org-link-follow |
| 1263 | :type '(choice | 1267 | :type '(choice |
| 1264 | (const :tag "with yes-or-no (safer)" yes-or-no-p) | 1268 | (const :tag "with yes-or-no (safer)" yes-or-no-p) |
| @@ -1266,16 +1270,16 @@ rather than having to type \"yes\"." | |||
| 1266 | (const :tag "no confirmation (dangerous)" nil))) | 1270 | (const :tag "no confirmation (dangerous)" nil))) |
| 1267 | 1271 | ||
| 1268 | (defcustom org-confirm-elisp-link-function 'yes-or-no-p | 1272 | (defcustom org-confirm-elisp-link-function 'yes-or-no-p |
| 1269 | "Non-nil means, ask for confirmation before executing elisp links. | 1273 | "Non-nil means, ask for confirmation before executing Emacs Lisp links. |
| 1270 | Elisp links can be dangerous, just think about a link | 1274 | Elisp links can be dangerous: just think about a link |
| 1271 | 1275 | ||
| 1272 | [[elisp:(shell-command \"rm -rf ~/*\")][Google Search]] | 1276 | [[elisp:(shell-command \"rm -rf ~/*\")][Google Search]] |
| 1273 | 1277 | ||
| 1274 | This link would show up in your Org-mode document as \"Google Search\" | 1278 | This link would show up in your Org-mode document as \"Google Search\", |
| 1275 | but really it would remove your entire home directory. | 1279 | but really it would remove your entire home directory. |
| 1276 | Therefore I *definitely* advise against setting this variable to nil. | 1280 | Therefore we advise against setting this variable to nil. |
| 1277 | Just change it to `y-or-n-p' of you want to confirm with a single key press | 1281 | Just change it to `y-or-n-p' of you want to confirm with a |
| 1278 | rather than having to type \"yes\"." | 1282 | single keystroke rather than having to type \"yes\"." |
| 1279 | :group 'org-link-follow | 1283 | :group 'org-link-follow |
| 1280 | :type '(choice | 1284 | :type '(choice |
| 1281 | (const :tag "with yes-or-no (safer)" yes-or-no-p) | 1285 | (const :tag "with yes-or-no (safer)" yes-or-no-p) |
| @@ -1399,7 +1403,7 @@ When this variable is nil, `C-c C-c' give you the prompts, and | |||
| 1399 | `C-u C-c C-c' trigger the fasttrack." | 1403 | `C-u C-c C-c' trigger the fasttrack." |
| 1400 | :group 'org-remember | 1404 | :group 'org-remember |
| 1401 | :type 'boolean) | 1405 | :type 'boolean) |
| 1402 | 1406 | ||
| 1403 | (defcustom org-remember-default-headline "" | 1407 | (defcustom org-remember-default-headline "" |
| 1404 | "The headline that should be the default location in the notes file. | 1408 | "The headline that should be the default location in the notes file. |
| 1405 | When filing remember notes, the cursor will start at that position. | 1409 | When filing remember notes, the cursor will start at that position. |
| @@ -1411,11 +1415,12 @@ You can set this on a per-template basis with the variable | |||
| 1411 | (defcustom org-remember-templates nil | 1415 | (defcustom org-remember-templates nil |
| 1412 | "Templates for the creation of remember buffers. | 1416 | "Templates for the creation of remember buffers. |
| 1413 | When nil, just let remember make the buffer. | 1417 | When nil, just let remember make the buffer. |
| 1414 | When not nil, this is a list of 4-element lists. In each entry, the first | 1418 | When not nil, this is a list of 5-element lists. In each entry, the first |
| 1415 | element is a character, a unique key to select this template. | 1419 | element is a the name of the template, It should be a single short word. |
| 1416 | The second element is the template. The third element is optional and can | 1420 | The second element is a character, a unique key to select this template. |
| 1421 | The third element is the template. The forth element is optional and can | ||
| 1417 | specify a destination file for remember items created with this template. | 1422 | specify a destination file for remember items created with this template. |
| 1418 | The default file is given by `org-default-notes-file'. An optional forth | 1423 | The default file is given by `org-default-notes-file'. An optional fifth |
| 1419 | element can specify the headline in that file that should be offered | 1424 | element can specify the headline in that file that should be offered |
| 1420 | first when the user is asked to file the entry. The default headline is | 1425 | first when the user is asked to file the entry. The default headline is |
| 1421 | given in the variable `org-remember-default-headline'. | 1426 | given in the variable `org-remember-default-headline'. |
| @@ -1456,19 +1461,25 @@ w3, w3m | %:type %:url | |||
| 1456 | info | %:type %:file %:node | 1461 | info | %:type %:file %:node |
| 1457 | calendar | %:type %:date" | 1462 | calendar | %:type %:date" |
| 1458 | :group 'org-remember | 1463 | :group 'org-remember |
| 1459 | :get (lambda (var) ; Make sure all entries have 4 elements | 1464 | :get (lambda (var) ; Make sure all entries have 5 elements |
| 1460 | (mapcar (lambda (x) | 1465 | (mapcar (lambda (x) |
| 1461 | (cond ((= (length x) 3) (append x '(""))) | 1466 | (if (not (stringp (car x))) (setq x (cons "" x))) |
| 1462 | ((= (length x) 2) (append x '("" ""))) | 1467 | (cond ((= (length x) 4) (append x '(""))) |
| 1468 | ((= (length x) 3) (append x '("" ""))) | ||
| 1463 | (t x))) | 1469 | (t x))) |
| 1464 | (default-value var))) | 1470 | (default-value var))) |
| 1465 | :type '(repeat | 1471 | :type '(repeat |
| 1466 | :tag "enabled" | 1472 | :tag "enabled" |
| 1467 | (list :value (?a "\n" nil nil) | 1473 | (list :value ("" ?a "\n" nil nil) |
| 1474 | (string :tag "Name") | ||
| 1468 | (character :tag "Selection Key") | 1475 | (character :tag "Selection Key") |
| 1469 | (string :tag "Template") | 1476 | (string :tag "Template") |
| 1470 | (file :tag "Destination file (optional)") | 1477 | (choice |
| 1471 | (string :tag "Destination headline (optional)")))) | 1478 | (file :tag "Destination file") |
| 1479 | (const :tag "Prompt for file" nil)) | ||
| 1480 | (choice | ||
| 1481 | (string :tag "Destination headline") | ||
| 1482 | (const :tag "Selection interface for heading"))))) | ||
| 1472 | 1483 | ||
| 1473 | (defcustom org-reverse-note-order nil | 1484 | (defcustom org-reverse-note-order nil |
| 1474 | "Non-nil means, store new notes at the beginning of a file or entry. | 1485 | "Non-nil means, store new notes at the beginning of a file or entry. |
| @@ -1784,14 +1795,6 @@ end of the second format." | |||
| 1784 | (concat "[" (substring f 1 -1) "]") | 1795 | (concat "[" (substring f 1 -1) "]") |
| 1785 | f))) | 1796 | f))) |
| 1786 | 1797 | ||
| 1787 | (defcustom org-deadline-warning-days 14 | ||
| 1788 | "No. of days before expiration during which a deadline becomes active. | ||
| 1789 | This variable governs the display in sparse trees and in the agenda. | ||
| 1790 | When negative, it means use this number (the absolute value of it) | ||
| 1791 | even if a deadline has a different individual lead time specified." | ||
| 1792 | :group 'org-time | ||
| 1793 | :type 'number) | ||
| 1794 | |||
| 1795 | (defcustom org-popup-calendar-for-date-prompt t | 1798 | (defcustom org-popup-calendar-for-date-prompt t |
| 1796 | "Non-nil means, pop up a calendar when prompting for a date. | 1799 | "Non-nil means, pop up a calendar when prompting for a date. |
| 1797 | In the calendar, the date can be selected with mouse-1. However, the | 1800 | In the calendar, the date can be selected with mouse-1. However, the |
| @@ -1924,6 +1927,19 @@ lined-up with respect to each other." | |||
| 1924 | :group 'org-properties | 1927 | :group 'org-properties |
| 1925 | :type 'string) | 1928 | :type 'string) |
| 1926 | 1929 | ||
| 1930 | (defcustom org-use-property-inheritance nil | ||
| 1931 | "Non-nil means, properties apply also for sublevels. | ||
| 1932 | This can cause significant overhead when doing a search, so this is turned | ||
| 1933 | off by default. | ||
| 1934 | When nil, only the properties directly given in the current entry count. | ||
| 1935 | |||
| 1936 | However, note that some special properties use inheritance under special | ||
| 1937 | circumstances (not in searches). Examples are CATEGORY, ARCHIVE, COLUMNS, | ||
| 1938 | and the properties ending in \"_ALL\" when they are used as descriptor | ||
| 1939 | for valid values of a property." | ||
| 1940 | :group 'org-properties | ||
| 1941 | :type 'boolean) | ||
| 1942 | |||
| 1927 | (defcustom org-columns-default-format "%25ITEM %TODO %3PRIORITY %TAGS" | 1943 | (defcustom org-columns-default-format "%25ITEM %TODO %3PRIORITY %TAGS" |
| 1928 | "The default column format, if no other format has been defined. | 1944 | "The default column format, if no other format has been defined. |
| 1929 | This variable can be set on the per-file basis by inserting a line | 1945 | This variable can be set on the per-file basis by inserting a line |
| @@ -1971,20 +1987,37 @@ is used instead.") | |||
| 1971 | Entries may be added to this list with \\[org-agenda-file-to-front] and removed with | 1987 | Entries may be added to this list with \\[org-agenda-file-to-front] and removed with |
| 1972 | \\[org-remove-file]. You can also use customize to edit the list. | 1988 | \\[org-remove-file]. You can also use customize to edit the list. |
| 1973 | 1989 | ||
| 1990 | If an entry is a directory, all files in that directory that are matched by | ||
| 1991 | `org-agenda-file-regexp' will be part of the file list. | ||
| 1992 | |||
| 1974 | If the value of the variable is not a list but a single file name, then | 1993 | If the value of the variable is not a list but a single file name, then |
| 1975 | the list of agenda files is actually stored and maintained in that file, one | 1994 | the list of agenda files is actually stored and maintained in that file, one |
| 1976 | agenda file per line." | 1995 | agenda file per line." |
| 1977 | :group 'org-agenda | 1996 | :group 'org-agenda |
| 1978 | :type '(choice | 1997 | :type '(choice |
| 1979 | (repeat :tag "List of files" file) | 1998 | (repeat :tag "List of files and directories" file) |
| 1980 | (file :tag "Store list in a file\n" :value "~/.agenda_files"))) | 1999 | (file :tag "Store list in a file\n" :value "~/.agenda_files"))) |
| 1981 | 2000 | ||
| 2001 | (defcustom org-agenda-file-regexp "\\.org\\'" | ||
| 2002 | "Regular expression to match files for `org-agenda-files'. | ||
| 2003 | If ny element in the list in that variable contains a directory instead | ||
| 2004 | of a normal file, all files in that directory that are matched by this | ||
| 2005 | regular expression will be included." | ||
| 2006 | :group 'org-agenda | ||
| 2007 | :type 'regexp) | ||
| 2008 | |||
| 1982 | (defcustom org-agenda-skip-unavailable-files nil | 2009 | (defcustom org-agenda-skip-unavailable-files nil |
| 1983 | "t means to just skip non-reachable files in `org-agenda-files'. | 2010 | "t means to just skip non-reachable files in `org-agenda-files'. |
| 1984 | Nil means to remove them, after a query, from the list." | 2011 | Nil means to remove them, after a query, from the list." |
| 1985 | :group 'org-agenda | 2012 | :group 'org-agenda |
| 1986 | :type 'boolean) | 2013 | :type 'boolean) |
| 1987 | 2014 | ||
| 2015 | (defcustom org-agenda-multi-occur-extra-files nil | ||
| 2016 | "List of extra files to be searched by `org-occur-in-agenda-files'. | ||
| 2017 | The files in `org-agenda-files' are always searched." | ||
| 2018 | :group 'org-agenda | ||
| 2019 | :type '(repeat file)) | ||
| 2020 | |||
| 1988 | (defcustom org-agenda-confirm-kill 1 | 2021 | (defcustom org-agenda-confirm-kill 1 |
| 1989 | "When set, remote killing from the agenda buffer needs confirmation. | 2022 | "When set, remote killing from the agenda buffer needs confirmation. |
| 1990 | When t, a confirmation is always needed. When a number N, confirmation is | 2023 | When t, a confirmation is always needed. When a number N, confirmation is |
| @@ -2077,9 +2110,12 @@ you can \"misuse\" it to also add other text to the header. However, | |||
| 2077 | These commands will be offered on the splash screen displayed by the | 2110 | These commands will be offered on the splash screen displayed by the |
| 2078 | agenda dispatcher \\[org-agenda]. Each entry is a list like this: | 2111 | agenda dispatcher \\[org-agenda]. Each entry is a list like this: |
| 2079 | 2112 | ||
| 2080 | (key type match options files) | 2113 | (key desc type match options files) |
| 2081 | 2114 | ||
| 2082 | key The key (a single char as a string) to be associated with the command. | 2115 | key The key (one or more characters as a string) to be associated |
| 2116 | with the command. | ||
| 2117 | desc A description of the commend, when omitted or nil, a default | ||
| 2118 | description is built using MATCH. | ||
| 2083 | type The command type, any of the following symbols: | 2119 | type The command type, any of the following symbols: |
| 2084 | todo Entries with a specific TODO keyword, in all agenda files. | 2120 | todo Entries with a specific TODO keyword, in all agenda files. |
| 2085 | tags Tags match in all agenda files. | 2121 | tags Tags match in all agenda files. |
| @@ -2087,6 +2123,7 @@ type The command type, any of the following symbols: | |||
| 2087 | todo-tree Sparse tree of specific TODO keyword in *current* file. | 2123 | todo-tree Sparse tree of specific TODO keyword in *current* file. |
| 2088 | tags-tree Sparse tree with all tags matches in *current* file. | 2124 | tags-tree Sparse tree with all tags matches in *current* file. |
| 2089 | occur-tree Occur sparse tree for *current* file. | 2125 | occur-tree Occur sparse tree for *current* file. |
| 2126 | ... A user-defined function. | ||
| 2090 | match What to search for: | 2127 | match What to search for: |
| 2091 | - a single keyword for TODO keyword searches | 2128 | - a single keyword for TODO keyword searches |
| 2092 | - a tags match expression for tags searches | 2129 | - a tags match expression for tags searches |
| @@ -2119,12 +2156,23 @@ cmd An agenda command, similar to the above. However, tree commands | |||
| 2119 | 2156 | ||
| 2120 | Each command can carry a list of options, and another set of options can be | 2157 | Each command can carry a list of options, and another set of options can be |
| 2121 | given for the whole set of commands. Individual command options take | 2158 | given for the whole set of commands. Individual command options take |
| 2122 | precedence over the general options." | 2159 | precedence over the general options. |
| 2160 | |||
| 2161 | When using several characters as key to a command, the first characters | ||
| 2162 | are prefix commands. For the dispatcher to display useful information, you | ||
| 2163 | should provide a description for the prefix, like | ||
| 2164 | |||
| 2165 | (setq org-agenda-custom-commands | ||
| 2166 | '((\"h\" . \"HOME + Name tag searches\") ; describe prefix \"h\" | ||
| 2167 | (\"hl\" tags \"+HOME+Lisa\") | ||
| 2168 | (\"hp\" tags \"+HOME+Peter\") | ||
| 2169 | (\"hk\" tags \"+HOME+Kim\")))" | ||
| 2123 | :group 'org-agenda-custom-commands | 2170 | :group 'org-agenda-custom-commands |
| 2124 | :type '(repeat | 2171 | :type '(repeat |
| 2125 | (choice :value ("a" tags "" nil) | 2172 | (choice :value ("a" "" tags "" nil) |
| 2126 | (list :tag "Single command" | 2173 | (list :tag "Single command" |
| 2127 | (string :tag "Key") | 2174 | (string :tag "Access Key(s) ") |
| 2175 | (option (string :tag "Description")) | ||
| 2128 | (choice | 2176 | (choice |
| 2129 | (const :tag "Agenda" agenda) | 2177 | (const :tag "Agenda" agenda) |
| 2130 | (const :tag "TODO list" alltodo) | 2178 | (const :tag "TODO list" alltodo) |
| @@ -2135,14 +2183,14 @@ precedence over the general options." | |||
| 2135 | (const :tag "Tags sparse tree (current buffer)" tags-tree) | 2183 | (const :tag "Tags sparse tree (current buffer)" tags-tree) |
| 2136 | (const :tag "TODO keyword tree (current buffer)" todo-tree) | 2184 | (const :tag "TODO keyword tree (current buffer)" todo-tree) |
| 2137 | (const :tag "Occur tree (current buffer)" occur-tree) | 2185 | (const :tag "Occur tree (current buffer)" occur-tree) |
| 2138 | (symbol :tag "Other, user-defined function")) | 2186 | (sexp :tag "Other, user-defined function")) |
| 2139 | (string :tag "Match") | 2187 | (string :tag "Match") |
| 2140 | (repeat :tag "Local options" | 2188 | (repeat :tag "Local options" |
| 2141 | (list (variable :tag "Option") (sexp :tag "Value"))) | 2189 | (list (variable :tag "Option") (sexp :tag "Value"))) |
| 2142 | (option (repeat :tag "Export" (file :tag "Export to")))) | 2190 | (option (repeat :tag "Export" (file :tag "Export to")))) |
| 2143 | (list :tag "Command series, all agenda files" | 2191 | (list :tag "Command series, all agenda files" |
| 2144 | (string :tag "Key") | 2192 | (string :tag "Access Key(s)") |
| 2145 | (string :tag "Description") | 2193 | (string :tag "Description ") |
| 2146 | (repeat | 2194 | (repeat |
| 2147 | (choice | 2195 | (choice |
| 2148 | (const :tag "Agenda" (agenda)) | 2196 | (const :tag "Agenda" (agenda)) |
| @@ -2179,7 +2227,10 @@ precedence over the general options." | |||
| 2179 | (repeat :tag "General options" | 2227 | (repeat :tag "General options" |
| 2180 | (list (variable :tag "Option") | 2228 | (list (variable :tag "Option") |
| 2181 | (sexp :tag "Value"))) | 2229 | (sexp :tag "Value"))) |
| 2182 | (option (repeat :tag "Export" (file :tag "Export to"))))))) | 2230 | (option (repeat :tag "Export" (file :tag "Export to")))) |
| 2231 | (cons :tag "Prefix key documentation" | ||
| 2232 | (string :tag "Access Key(s)") | ||
| 2233 | (string :tag "Description "))))) | ||
| 2183 | 2234 | ||
| 2184 | (defcustom org-stuck-projects | 2235 | (defcustom org-stuck-projects |
| 2185 | '("+LEVEL=2/-DONE" ("TODO" "NEXT" "NEXTACTION") nil "") | 2236 | '("+LEVEL=2/-DONE" ("TODO" "NEXT" "NEXTACTION") nil "") |
| @@ -2220,10 +2271,22 @@ potentially much shorter TODO lists." | |||
| 2220 | :group 'org-todo | 2271 | :group 'org-todo |
| 2221 | :type 'boolean) | 2272 | :type 'boolean) |
| 2222 | 2273 | ||
| 2274 | (defcustom org-agenda-todo-ignore-with-date nil | ||
| 2275 | "Non-nil means, don't show entries with a date in the global todo list. | ||
| 2276 | You can use this if you prefer to mark mere appointments with a TODO keyword, | ||
| 2277 | but don't want them to show up in the TODO list. | ||
| 2278 | When this is set, it also covers deadlines and scheduled items, the settings | ||
| 2279 | of `org-agenda-todo-ignore-scheduled' and `org-agenda-todo-ignore-deadlines' | ||
| 2280 | will be ignored." | ||
| 2281 | :group 'org-agenda-skip | ||
| 2282 | :group 'org-todo | ||
| 2283 | :type 'boolean) | ||
| 2284 | |||
| 2223 | (defcustom org-agenda-todo-ignore-scheduled nil | 2285 | (defcustom org-agenda-todo-ignore-scheduled nil |
| 2224 | "Non-nil means, don't show scheduled entries in the global todo list. | 2286 | "Non-nil means, don't show scheduled entries in the global todo list. |
| 2225 | The idea behind this is that by scheduling it, you have already taken care | 2287 | The idea behind this is that by scheduling it, you have already taken care |
| 2226 | of this item." | 2288 | of this item. |
| 2289 | See also `org-agenda-todo-ignore-with-date'." | ||
| 2227 | :group 'org-agenda-skip | 2290 | :group 'org-agenda-skip |
| 2228 | :group 'org-todo | 2291 | :group 'org-todo |
| 2229 | :type 'boolean) | 2292 | :type 'boolean) |
| @@ -2231,7 +2294,8 @@ of this item." | |||
| 2231 | (defcustom org-agenda-todo-ignore-deadlines nil | 2294 | (defcustom org-agenda-todo-ignore-deadlines nil |
| 2232 | "Non-nil means, don't show near deadline entries in the global todo list. | 2295 | "Non-nil means, don't show near deadline entries in the global todo list. |
| 2233 | Near means closer than `org-deadline-warning-days' days. | 2296 | Near means closer than `org-deadline-warning-days' days. |
| 2234 | The idea behind this is that such items will appear in the agenda anyway." | 2297 | The idea behind this is that such items will appear in the agenda anyway. |
| 2298 | See also `org-agenda-todo-ignore-with-date'." | ||
| 2235 | :group 'org-agenda-skip | 2299 | :group 'org-agenda-skip |
| 2236 | :group 'org-todo | 2300 | :group 'org-todo |
| 2237 | :type 'boolean) | 2301 | :type 'boolean) |
| @@ -2311,6 +2375,13 @@ See also the variable `org-agenda-restore-windows-after-quit'." | |||
| 2311 | (const other-window) | 2375 | (const other-window) |
| 2312 | (const reorganize-frame))) | 2376 | (const reorganize-frame))) |
| 2313 | 2377 | ||
| 2378 | (defcustom org-agenda-window-frame-fractions '(0.5 . 0.75) | ||
| 2379 | "The min and max height of the agenda window as a fraction of frame height. | ||
| 2380 | The value of the variable is a cons cell with two numbers between 0 and 1. | ||
| 2381 | It only matters if `org-agenda-window-setup' is `reorganize-frame'." | ||
| 2382 | :group 'org-agenda-windows | ||
| 2383 | :type '(cons (number :tag "Minimum") (number :tag "Maximum"))) | ||
| 2384 | |||
| 2314 | (defcustom org-agenda-restore-windows-after-quit nil | 2385 | (defcustom org-agenda-restore-windows-after-quit nil |
| 2315 | "Non-nil means, restore window configuration open exiting agenda. | 2386 | "Non-nil means, restore window configuration open exiting agenda. |
| 2316 | Before the window configuration is changed for displaying the agenda, | 2387 | Before the window configuration is changed for displaying the agenda, |
| @@ -2402,6 +2473,23 @@ nearest into the future." | |||
| 2402 | :group 'org-agenda-daily/weekly | 2473 | :group 'org-agenda-daily/weekly |
| 2403 | :type 'boolean) | 2474 | :type 'boolean) |
| 2404 | 2475 | ||
| 2476 | (defcustom org-deadline-warning-days 14 | ||
| 2477 | "No. of days before expiration during which a deadline becomes active. | ||
| 2478 | This variable governs the display in sparse trees and in the agenda. | ||
| 2479 | When negative, it means use this number (the absolute value of it) | ||
| 2480 | even if a deadline has a different individual lead time specified." | ||
| 2481 | :group 'org-time | ||
| 2482 | :group 'org-agenda-daily/weekly | ||
| 2483 | :type 'number) | ||
| 2484 | |||
| 2485 | (defcustom org-scheduled-past-days 10000 | ||
| 2486 | "No. of days to continue listing scheduled items that are not marked DONE. | ||
| 2487 | When an item is scheduled on a date, it shows up in the agenda on this | ||
| 2488 | day and will be listed until it is marked done for the number of days | ||
| 2489 | given here." | ||
| 2490 | :group 'org-agenda-daily/weekly | ||
| 2491 | :type 'number) | ||
| 2492 | |||
| 2405 | (defgroup org-agenda-time-grid nil | 2493 | (defgroup org-agenda-time-grid nil |
| 2406 | "Options concerning the time grid in the Org-mode Agenda." | 2494 | "Options concerning the time grid in the Org-mode Agenda." |
| 2407 | :tag "Org Agenda Time Grid" | 2495 | :tag "Org Agenda Time Grid" |
| @@ -2585,6 +2673,28 @@ See also the variables `org-agenda-remove-times-when-in-prefix' and | |||
| 2585 | "The compiled version of the most recently used prefix format. | 2673 | "The compiled version of the most recently used prefix format. |
| 2586 | See the variable `org-agenda-prefix-format'.") | 2674 | See the variable `org-agenda-prefix-format'.") |
| 2587 | 2675 | ||
| 2676 | (defcustom org-agenda-scheduled-leaders '("Scheduled: " "Sched.%2dx: ") | ||
| 2677 | "Text preceeding scheduled items in the agenda view. | ||
| 2678 | THis is a list with two strings. The first applies when the item is | ||
| 2679 | scheduled on the current day. The second applies when it has been scheduled | ||
| 2680 | previously, it may contain a %d to capture how many days ago the item was | ||
| 2681 | scheduled." | ||
| 2682 | :group 'org-agenda-line-format | ||
| 2683 | :type '(list | ||
| 2684 | (string :tag "Scheduled today ") | ||
| 2685 | (string :tag "Scheduled previously"))) | ||
| 2686 | |||
| 2687 | (defcustom org-agenda-deadline-leaders '("Deadline: " "In %3d d.: ") | ||
| 2688 | "Text preceeding deadline items in the agenda view. | ||
| 2689 | This is a list with two strings. The first applies when the item has its | ||
| 2690 | deadline on the current day. The second applies when it is in the past or | ||
| 2691 | in the future, it may contain %d to capture how many days away the deadline | ||
| 2692 | is (was)." | ||
| 2693 | :group 'org-agenda-line-format | ||
| 2694 | :type '(list | ||
| 2695 | (string :tag "Deadline today ") | ||
| 2696 | (string :tag "Deadline relative"))) | ||
| 2697 | |||
| 2588 | (defcustom org-agenda-remove-times-when-in-prefix t | 2698 | (defcustom org-agenda-remove-times-when-in-prefix t |
| 2589 | "Non-nil means, remove duplicate time specifications in agenda items. | 2699 | "Non-nil means, remove duplicate time specifications in agenda items. |
| 2590 | When the format `org-agenda-prefix-format' contains a `%t' specifier, a | 2700 | When the format `org-agenda-prefix-format' contains a `%t' specifier, a |
| @@ -2638,6 +2748,19 @@ it means that the tags should be flushright to that column. For example, | |||
| 2638 | (if (fboundp 'defvaralias) | 2748 | (if (fboundp 'defvaralias) |
| 2639 | (defvaralias 'org-agenda-align-tags-to-column 'org-agenda-tags-column)) | 2749 | (defvaralias 'org-agenda-align-tags-to-column 'org-agenda-tags-column)) |
| 2640 | 2750 | ||
| 2751 | (defcustom org-agenda-fontify-priorities t | ||
| 2752 | "Non-nil means, highlight low and high priorities in agenda. | ||
| 2753 | When t, the highest priority entries are bold, lowest priority italic. | ||
| 2754 | This may also be an association list of priority faces. The face may be | ||
| 2755 | a names face, or a list like `(:background \"Red\")'." | ||
| 2756 | :group 'org-agenda-line-format | ||
| 2757 | :type '(choice | ||
| 2758 | (const :tag "Never" nil) | ||
| 2759 | (const :tag "Defaults" t) | ||
| 2760 | (repeat :tag "Specify" | ||
| 2761 | (list (character :tag "Priority" :value ?A) | ||
| 2762 | (sexp :tag "face"))))) | ||
| 2763 | |||
| 2641 | (defgroup org-latex nil | 2764 | (defgroup org-latex nil |
| 2642 | "Options for embedding LaTeX code into Org-mode" | 2765 | "Options for embedding LaTeX code into Org-mode" |
| 2643 | :tag "Org LaTeX" | 2766 | :tag "Org LaTeX" |
| @@ -2702,7 +2825,7 @@ directory where the exported Org-mode files lives." | |||
| 2702 | (repeat | 2825 | (repeat |
| 2703 | (cons | 2826 | (cons |
| 2704 | (choice :tag "Type" | 2827 | (choice :tag "Type" |
| 2705 | (const :html) (const :LaTeX) | 2828 | (const :html) (const :LaTeX) |
| 2706 | (const :ascii) (const :ical) (const :xoxo)) | 2829 | (const :ascii) (const :ical) (const :xoxo)) |
| 2707 | (directory))))) | 2830 | (directory))))) |
| 2708 | 2831 | ||
| @@ -2836,20 +2959,25 @@ e.g. \"timestamp:nil\"." | |||
| 2836 | (defcustom org-export-with-tags 'not-in-toc | 2959 | (defcustom org-export-with-tags 'not-in-toc |
| 2837 | "If nil, do not export tags, just remove them from headlines. | 2960 | "If nil, do not export tags, just remove them from headlines. |
| 2838 | If this is the symbol `not-in-toc', tags will be removed from table of | 2961 | If this is the symbol `not-in-toc', tags will be removed from table of |
| 2839 | contents entries, but still be shown in the headlines of the document." | 2962 | contents entries, but still be shown in the headlines of the document. |
| 2963 | |||
| 2964 | This option can also be set with the +OPTIONS line, e.g. \"tags:nil\"." | ||
| 2840 | :group 'org-export-general | 2965 | :group 'org-export-general |
| 2841 | :type '(choice | 2966 | :type '(choice |
| 2842 | (const :tag "Off" nil) | 2967 | (const :tag "Off" nil) |
| 2843 | (const :tag "Not in TOC" not-in-toc) | 2968 | (const :tag "Not in TOC" not-in-toc) |
| 2844 | (const :tag "On" t))) | 2969 | (const :tag "On" t))) |
| 2845 | 2970 | ||
| 2846 | (defcustom org-export-with-property-drawer nil | 2971 | (defcustom org-export-with-drawers nil |
| 2847 | "Non-nil means, export property drawers. | 2972 | "Non-nil means, export with drawers like the property drawer. |
| 2848 | When nil, these drawers are removed before export. | 2973 | When t, all drawers are exported. This may also be a list of |
| 2849 | 2974 | drawer names to export." | |
| 2850 | This option can also be set with the +OPTIONS line, e.g. \"p:t\"." | ||
| 2851 | :group 'org-export-general | 2975 | :group 'org-export-general |
| 2852 | :type 'boolean) | 2976 | :type '(choice |
| 2977 | (const :tag "All drawers" t) | ||
| 2978 | (const :tag "None" nil) | ||
| 2979 | (repeat :tag "Selected drawers" | ||
| 2980 | (string :tag "Drawer name")))) | ||
| 2853 | 2981 | ||
| 2854 | (defgroup org-export-translation nil | 2982 | (defgroup org-export-translation nil |
| 2855 | "Options for translating special ascii sequences for the export backends." | 2983 | "Options for translating special ascii sequences for the export backends." |
| @@ -3516,7 +3644,7 @@ color of the frame." | |||
| 3516 | ;; Make sure that a fixed-width face is used when we have a column table. | 3644 | ;; Make sure that a fixed-width face is used when we have a column table. |
| 3517 | (set-face-attribute 'org-column nil | 3645 | (set-face-attribute 'org-column nil |
| 3518 | :height (face-attribute 'default :height) | 3646 | :height (face-attribute 'default :height) |
| 3519 | :family (face-attribute 'default :family))) | 3647 | :family (face-attribute 'default :family))) |
| 3520 | 3648 | ||
| 3521 | (defface org-warning | 3649 | (defface org-warning |
| 3522 | (org-compatible-face | 3650 | (org-compatible-face |
| @@ -3550,6 +3678,13 @@ color of the frame." | |||
| 3550 | "Face for links." | 3678 | "Face for links." |
| 3551 | :group 'org-faces) | 3679 | :group 'org-faces) |
| 3552 | 3680 | ||
| 3681 | (defface org-ellipsis | ||
| 3682 | '((((class color) (background light)) (:foreground "DarkGoldenrod" :strike-through t)) | ||
| 3683 | (((class color) (background dark)) (:foreground "LightGoldenrod" :strike-through t)) | ||
| 3684 | (t (:strike-through t))) | ||
| 3685 | "Face for the ellipsis in folded text." | ||
| 3686 | :group 'org-faces) | ||
| 3687 | |||
| 3553 | (defface org-target | 3688 | (defface org-target |
| 3554 | '((((class color) (background light)) (:underline t)) | 3689 | '((((class color) (background light)) (:underline t)) |
| 3555 | (((class color) (background dark)) (:underline t)) | 3690 | (((class color) (background dark)) (:underline t)) |
| @@ -3762,6 +3897,14 @@ If it is less than 8, the level-1 face gets re-used for level N+1 etc." | |||
| 3762 | (defvar org-todo-line-regexp nil | 3897 | (defvar org-todo-line-regexp nil |
| 3763 | "Matches a headline and puts TODO state into group 2 if present.") | 3898 | "Matches a headline and puts TODO state into group 2 if present.") |
| 3764 | (make-variable-buffer-local 'org-todo-line-regexp) | 3899 | (make-variable-buffer-local 'org-todo-line-regexp) |
| 3900 | (defvar org-complex-heading-regexp nil | ||
| 3901 | "Matches a headline and puts everything into groups: | ||
| 3902 | group 1: the stars | ||
| 3903 | group 2: The todo keyword, maybe | ||
| 3904 | group 3: Priority cookie | ||
| 3905 | group 4: True headline | ||
| 3906 | group 5: Tags") | ||
| 3907 | (make-variable-buffer-local 'org-complex-heading-regexp) | ||
| 3765 | (defvar org-todo-line-tags-regexp nil | 3908 | (defvar org-todo-line-tags-regexp nil |
| 3766 | "Matches a headline and puts TODO state into group 2 if present. | 3909 | "Matches a headline and puts TODO state into group 2 if present. |
| 3767 | Also put tags into group 4 if tags are present.") | 3910 | Also put tags into group 4 if tags are present.") |
| @@ -3898,11 +4041,11 @@ means to push this value onto the list in the variable.") | |||
| 3898 | (let ((re (org-make-options-regexp | 4041 | (let ((re (org-make-options-regexp |
| 3899 | '("CATEGORY" "SEQ_TODO" "TYP_TODO" "TODO" "COLUMNS" | 4042 | '("CATEGORY" "SEQ_TODO" "TYP_TODO" "TODO" "COLUMNS" |
| 3900 | "STARTUP" "ARCHIVE" "TAGS" "LINK" "PRIORITIES" | 4043 | "STARTUP" "ARCHIVE" "TAGS" "LINK" "PRIORITIES" |
| 3901 | "CONSTANTS" "PROPERTY"))) | 4044 | "CONSTANTS" "PROPERTY" "DRAWERS"))) |
| 3902 | (splitre "[ \t]+") | 4045 | (splitre "[ \t]+") |
| 3903 | kwds kws0 kwsa key value cat arch tags const links hw dws | 4046 | kwds kws0 kwsa key value cat arch tags const links hw dws |
| 3904 | tail sep kws1 prio props | 4047 | tail sep kws1 prio props drawers |
| 3905 | ex log note) | 4048 | ex log) |
| 3906 | (save-excursion | 4049 | (save-excursion |
| 3907 | (save-restriction | 4050 | (save-restriction |
| 3908 | (widen) | 4051 | (widen) |
| @@ -3933,6 +4076,8 @@ means to push this value onto the list in the variable.") | |||
| 3933 | (when (string-match "\\(\\S-+\\)\\s-+\\(.*\\)" value) | 4076 | (when (string-match "\\(\\S-+\\)\\s-+\\(.*\\)" value) |
| 3934 | (push (cons (match-string 1 value) (match-string 2 value)) | 4077 | (push (cons (match-string 1 value) (match-string 2 value)) |
| 3935 | props))) | 4078 | props))) |
| 4079 | ((equal key "DRAWERS") | ||
| 4080 | (setq drawers (org-split-string value splitre))) | ||
| 3936 | ((equal key "CONSTANTS") | 4081 | ((equal key "CONSTANTS") |
| 3937 | (setq const (append const (org-split-string value splitre)))) | 4082 | (setq const (append const (org-split-string value splitre)))) |
| 3938 | ((equal key "STARTUP") | 4083 | ((equal key "STARTUP") |
| @@ -3961,6 +4106,7 @@ means to push this value onto the list in the variable.") | |||
| 3961 | (org-set-local 'org-lowest-priority (nth 1 prio)) | 4106 | (org-set-local 'org-lowest-priority (nth 1 prio)) |
| 3962 | (org-set-local 'org-default-priority (nth 2 prio))) | 4107 | (org-set-local 'org-default-priority (nth 2 prio))) |
| 3963 | (and props (org-set-local 'org-local-properties (nreverse props))) | 4108 | (and props (org-set-local 'org-local-properties (nreverse props))) |
| 4109 | (and drawers (org-set-local 'org-drawers drawers)) | ||
| 3964 | (and arch (org-set-local 'org-archive-location arch)) | 4110 | (and arch (org-set-local 'org-archive-location arch)) |
| 3965 | (and links (setq org-link-abbrev-alist-local (nreverse links))) | 4111 | (and links (setq org-link-abbrev-alist-local (nreverse links))) |
| 3966 | ;; Process the TODO keywords | 4112 | ;; Process the TODO keywords |
| @@ -4055,6 +4201,11 @@ means to push this value onto the list in the variable.") | |||
| 4055 | (concat "^\\(\\*+\\)[ \t]+\\(?:\\(" | 4201 | (concat "^\\(\\*+\\)[ \t]+\\(?:\\(" |
| 4056 | (mapconcat 'regexp-quote org-todo-keywords-1 "\\|") | 4202 | (mapconcat 'regexp-quote org-todo-keywords-1 "\\|") |
| 4057 | "\\)\\>\\)?[ \t]*\\(.*\\)") | 4203 | "\\)\\>\\)?[ \t]*\\(.*\\)") |
| 4204 | org-complex-heading-regexp | ||
| 4205 | (concat "^\\(\\*+\\)\\(?:[ \t]+\\(" | ||
| 4206 | (mapconcat 'regexp-quote org-todo-keywords-1 "\\|") | ||
| 4207 | "\\)\\>\\)?\\(?:[ \t]*\\(\\[#.\\]\\)\\)?[ \t]*\\(.*?\\)" | ||
| 4208 | "\\(?:[ \t]+\\(:[[:alnum:]_@:]+:\\)\\)?[ \t]*$") | ||
| 4058 | org-nl-done-regexp | 4209 | org-nl-done-regexp |
| 4059 | (concat "\n\\*+[ \t]+" | 4210 | (concat "\n\\*+[ \t]+" |
| 4060 | "\\(?:" (mapconcat 'regexp-quote org-done-keywords "\\|") | 4211 | "\\(?:" (mapconcat 'regexp-quote org-done-keywords "\\|") |
| @@ -4636,6 +4787,7 @@ will be prompted for." | |||
| 4636 | (defconst org-nonsticky-props | 4787 | (defconst org-nonsticky-props |
| 4637 | '(mouse-face highlight keymap invisible intangible help-echo org-linked-text)) | 4788 | '(mouse-face highlight keymap invisible intangible help-echo org-linked-text)) |
| 4638 | 4789 | ||
| 4790 | |||
| 4639 | (defun org-activate-plain-links (limit) | 4791 | (defun org-activate-plain-links (limit) |
| 4640 | "Run through the buffer and add overlays to links." | 4792 | "Run through the buffer and add overlays to links." |
| 4641 | (catch 'exit | 4793 | (catch 'exit |
| @@ -4652,6 +4804,13 @@ will be prompted for." | |||
| 4652 | )) | 4804 | )) |
| 4653 | (throw 'exit t)))))) | 4805 | (throw 'exit t)))))) |
| 4654 | 4806 | ||
| 4807 | (defun org-activate-code (limit) | ||
| 4808 | (if (re-search-forward "^[ \t]*\\(:.*\\)" limit t) | ||
| 4809 | (unless (get-text-property (match-beginning 1) 'face) | ||
| 4810 | (remove-text-properties (match-beginning 0) (match-end 0) | ||
| 4811 | '(display t invisible t intangible t)) | ||
| 4812 | t))) | ||
| 4813 | |||
| 4655 | (defun org-activate-angle-links (limit) | 4814 | (defun org-activate-angle-links (limit) |
| 4656 | "Run through the buffer and add overlays to links." | 4815 | "Run through the buffer and add overlays to links." |
| 4657 | (if (re-search-forward org-angle-link-re limit t) | 4816 | (if (re-search-forward org-angle-link-re limit t) |
| @@ -4823,7 +4982,20 @@ between words." | |||
| 4823 | (2 (org-get-level-face 2)) (3 (org-get-level-face 3))) | 4982 | (2 (org-get-level-face 2)) (3 (org-get-level-face 3))) |
| 4824 | ;; Table lines | 4983 | ;; Table lines |
| 4825 | '("^[ \t]*\\(\\(|\\|\\+-[-+]\\).*\\S-\\)" | 4984 | '("^[ \t]*\\(\\(|\\|\\+-[-+]\\).*\\S-\\)" |
| 4826 | (1 'org-table)) | 4985 | (1 'org-table t)) |
| 4986 | ;; Table internals | ||
| 4987 | '("| *\\(:?=[^|\n]*\\)" (1 'org-formula t)) | ||
| 4988 | '("^[ \t]*| *\\([#*]\\) *|" (1 'org-formula t)) | ||
| 4989 | '("^[ \t]*|\\( *\\([$!_^/]\\) *|.*\\)|" (1 'org-formula t)) | ||
| 4990 | ;; Drawers | ||
| 4991 | (list org-drawer-regexp '(0 'org-special-keyword t)) | ||
| 4992 | (list "^[ \t]*:END:" '(0 'org-special-keyword t)) | ||
| 4993 | ;; Properties | ||
| 4994 | (list org-property-re | ||
| 4995 | '(1 'org-special-keyword t) | ||
| 4996 | '(3 'org-property-value t)) | ||
| 4997 | (if org-format-transports-properties-p | ||
| 4998 | '("| *\\(<[0-9]+>\\) *" (1 'org-formula t))) | ||
| 4827 | ;; Links | 4999 | ;; Links |
| 4828 | (if (memq 'tag lk) '(org-activate-tags (1 'org-tag prepend))) | 5000 | (if (memq 'tag lk) '(org-activate-tags (1 'org-tag prepend))) |
| 4829 | (if (memq 'angle lk) '(org-activate-angle-links (0 'org-link t))) | 5001 | (if (memq 'angle lk) '(org-activate-angle-links (0 'org-link t))) |
| @@ -4855,7 +5027,7 @@ between words." | |||
| 4855 | (if (featurep 'xemacs) | 5027 | (if (featurep 'xemacs) |
| 4856 | '(org-do-emphasis-faces (0 nil append)) | 5028 | '(org-do-emphasis-faces (0 nil append)) |
| 4857 | '(org-do-emphasis-faces))) | 5029 | '(org-do-emphasis-faces))) |
| 4858 | ;; Checkboxes, similar to Frank Ruell's org-checklet.el | 5030 | ;; Checkboxes |
| 4859 | '("^[ \t]*\\([-+*]\\|[0-9]+[.)]\\) +\\(\\[[- X]\\]\\)" | 5031 | '("^[ \t]*\\([-+*]\\|[0-9]+[.)]\\) +\\(\\[[- X]\\]\\)" |
| 4860 | 2 'bold prepend) | 5032 | 2 'bold prepend) |
| 4861 | (if org-provide-checkbox-statistics | 5033 | (if org-provide-checkbox-statistics |
| @@ -4866,22 +5038,9 @@ between words." | |||
| 4866 | "\\|" org-quote-string "\\)\\>") | 5038 | "\\|" org-quote-string "\\)\\>") |
| 4867 | '(1 'org-special-keyword t)) | 5039 | '(1 'org-special-keyword t)) |
| 4868 | '("^#.*" (0 'font-lock-comment-face t)) | 5040 | '("^#.*" (0 'font-lock-comment-face t)) |
| 4869 | ;; Code | ||
| 4870 | '("^[ \t]*\\(:.*\\)" (1 'org-code t)) | ||
| 4871 | ;; Table internals | ||
| 4872 | '("| *\\(:?=[^|\n]*\\)" (1 'org-formula t)) | ||
| 4873 | '("^[ \t]*| *\\([#*]\\) *|" (1 'org-formula t)) | ||
| 4874 | '("^[ \t]*|\\( *\\([$!_^/]\\) *|.*\\)|" (1 'org-formula t)) | ||
| 4875 | ;; Drawers | ||
| 4876 | (list org-drawer-regexp '(0 'org-special-keyword t)) | ||
| 4877 | (list "^[ \t]*:END:" '(0 'org-special-keyword t)) | ||
| 4878 | ;; Properties | ||
| 4879 | (list org-property-re | ||
| 4880 | '(1 'org-special-keyword t) | ||
| 4881 | '(3 'org-property-value t)) | ||
| 4882 | (if org-format-transports-properties-p | ||
| 4883 | '("| *\\(<[0-9]+>\\) *" (1 'org-formula t))) | ||
| 4884 | '("^\\*+ \\(.*:ARCHIVE:.*\\)" (1 'org-archived prepend)) | 5041 | '("^\\*+ \\(.*:ARCHIVE:.*\\)" (1 'org-archived prepend)) |
| 5042 | ;; Code | ||
| 5043 | '(org-activate-code (1 'org-code t)) | ||
| 4885 | ))) | 5044 | ))) |
| 4886 | (setq org-font-lock-extra-keywords (delq nil org-font-lock-extra-keywords)) | 5045 | (setq org-font-lock-extra-keywords (delq nil org-font-lock-extra-keywords)) |
| 4887 | ;; Now set the full font-lock-keywords | 5046 | ;; Now set the full font-lock-keywords |
| @@ -5544,7 +5703,7 @@ Works for outline headings and for plain lists alike." | |||
| 5544 | (cond | 5703 | (cond |
| 5545 | ((org-on-heading-p) (org-do-demote)) | 5704 | ((org-on-heading-p) (org-do-demote)) |
| 5546 | ((org-at-item-p) (org-indent-item 1)))) | 5705 | ((org-at-item-p) (org-indent-item 1)))) |
| 5547 | 5706 | ||
| 5548 | ;;; Promotion and Demotion | 5707 | ;;; Promotion and Demotion |
| 5549 | 5708 | ||
| 5550 | (defun org-promote-subtree () | 5709 | (defun org-promote-subtree () |
| @@ -5717,7 +5876,7 @@ is signaled in this case." | |||
| 5717 | (save-excursion | 5876 | (save-excursion |
| 5718 | (goto-char (point-min)) | 5877 | (goto-char (point-min)) |
| 5719 | (while (re-search-forward "^\\*\\*+ " nil t) | 5878 | (while (re-search-forward "^\\*\\*+ " nil t) |
| 5720 | (setq n (/ (length (1- (match-string 0))) 2)) | 5879 | (setq n (/ (1- (length (match-string 0))) 2)) |
| 5721 | (while (>= (setq n (1- n)) 0) | 5880 | (while (>= (setq n (1- n)) 0) |
| 5722 | (org-promote)) | 5881 | (org-promote)) |
| 5723 | (end-of-line 1)))))) | 5882 | (end-of-line 1)))))) |
| @@ -5783,17 +5942,19 @@ ring. We need it to check if the kill was created by `org-copy-subtree'.") | |||
| 5783 | "Was the last copied subtree folded? | 5942 | "Was the last copied subtree folded? |
| 5784 | This is used to fold the tree back after pasting.") | 5943 | This is used to fold the tree back after pasting.") |
| 5785 | 5944 | ||
| 5786 | (defun org-cut-subtree () | 5945 | (defun org-cut-subtree (&optional n) |
| 5787 | "Cut the current subtree into the clipboard. | 5946 | "Cut the current subtree into the clipboard. |
| 5947 | With prefix arg N, cut this many sequential subtrees. | ||
| 5788 | This is a short-hand for marking the subtree and then cutting it." | 5948 | This is a short-hand for marking the subtree and then cutting it." |
| 5789 | (interactive) | 5949 | (interactive "p") |
| 5790 | (org-copy-subtree 'cut)) | 5950 | (org-copy-subtree n 'cut)) |
| 5791 | 5951 | ||
| 5792 | (defun org-copy-subtree (&optional cut) | 5952 | (defun org-copy-subtree (&optional n cut) |
| 5793 | "Cut the current subtree into the clipboard. | 5953 | "Cut the current subtree into the clipboard. |
| 5954 | With prefix arg N, cut this many sequential subtrees. | ||
| 5794 | This is a short-hand for marking the subtree and then copying it. | 5955 | This is a short-hand for marking the subtree and then copying it. |
| 5795 | If CUT is non-nil, actually cut the subtree." | 5956 | If CUT is non-nil, actually cut the subtree." |
| 5796 | (interactive) | 5957 | (interactive "p") |
| 5797 | (let (beg end folded) | 5958 | (let (beg end folded) |
| 5798 | (if (interactive-p) | 5959 | (if (interactive-p) |
| 5799 | (org-back-to-heading nil) ; take what looks like a subtree | 5960 | (org-back-to-heading nil) ; take what looks like a subtree |
| @@ -5802,15 +5963,17 @@ If CUT is non-nil, actually cut the subtree." | |||
| 5802 | (save-match-data | 5963 | (save-match-data |
| 5803 | (save-excursion (outline-end-of-heading) | 5964 | (save-excursion (outline-end-of-heading) |
| 5804 | (setq folded (org-invisible-p))) | 5965 | (setq folded (org-invisible-p))) |
| 5805 | (outline-end-of-subtree)) | 5966 | (condition-case nil |
| 5806 | (if (equal (char-after) ?\n) (forward-char 1)) | 5967 | (outline-forward-same-level (1- n)) |
| 5968 | (error nil)) | ||
| 5969 | (org-end-of-subtree t t)) | ||
| 5807 | (setq end (point)) | 5970 | (setq end (point)) |
| 5808 | (goto-char beg) | 5971 | (goto-char beg) |
| 5809 | (when (> end beg) | 5972 | (when (> end beg) |
| 5810 | (setq org-subtree-clip-folded folded) | 5973 | (setq org-subtree-clip-folded folded) |
| 5811 | (if cut (kill-region beg end) (copy-region-as-kill beg end)) | 5974 | (if cut (kill-region beg end) (copy-region-as-kill beg end)) |
| 5812 | (setq org-subtree-clip (current-kill 0)) | 5975 | (setq org-subtree-clip (current-kill 0)) |
| 5813 | (message "%s: Subtree with %d characters" | 5976 | (message "%s: Subtree(s) with %d characters" |
| 5814 | (if cut "Cut" "Copied") | 5977 | (if cut "Cut" "Copied") |
| 5815 | (length org-subtree-clip))))) | 5978 | (length org-subtree-clip))))) |
| 5816 | 5979 | ||
| @@ -5839,7 +6002,7 @@ If optional TREE is given, use this text instead of the kill ring." | |||
| 5839 | (let* ((txt (or tree (and kill-ring (current-kill 0)))) | 6002 | (let* ((txt (or tree (and kill-ring (current-kill 0)))) |
| 5840 | (^re (concat "^\\(" outline-regexp "\\)")) | 6003 | (^re (concat "^\\(" outline-regexp "\\)")) |
| 5841 | (re (concat "\\(" outline-regexp "\\)")) | 6004 | (re (concat "\\(" outline-regexp "\\)")) |
| 5842 | (^re_ (concat "\\(" outline-regexp "\\)[ \t]*")) | 6005 | (^re_ (concat "\\(\\*+\\)[ \t]*")) |
| 5843 | 6006 | ||
| 5844 | (old-level (if (string-match ^re txt) | 6007 | (old-level (if (string-match ^re txt) |
| 5845 | (- (match-end 0) (match-beginning 0) 1) | 6008 | (- (match-end 0) (match-beginning 0) 1) |
| @@ -5847,22 +6010,23 @@ If optional TREE is given, use this text instead of the kill ring." | |||
| 5847 | (force-level (cond (level (prefix-numeric-value level)) | 6010 | (force-level (cond (level (prefix-numeric-value level)) |
| 5848 | ((string-match | 6011 | ((string-match |
| 5849 | ^re_ (buffer-substring (point-at-bol) (point))) | 6012 | ^re_ (buffer-substring (point-at-bol) (point))) |
| 5850 | (- (match-end 0) (match-beginning 0))) | 6013 | (- (match-end 1) (match-beginning 1))) |
| 5851 | (t nil))) | 6014 | (t nil))) |
| 5852 | (previous-level (save-excursion | 6015 | (previous-level (save-excursion |
| 5853 | (condition-case nil | 6016 | (condition-case nil |
| 5854 | (progn | 6017 | (progn |
| 5855 | (outline-previous-visible-heading 1) | 6018 | (outline-previous-visible-heading 1) |
| 5856 | (if (looking-at re) | 6019 | (if (looking-at re) |
| 5857 | (- (match-end 0) (match-beginning 0)) | 6020 | (- (match-end 0) (match-beginning 0) 1) |
| 5858 | 1)) | 6021 | 1)) |
| 5859 | (error 1)))) | 6022 | (error 1)))) |
| 5860 | (next-level (save-excursion | 6023 | (next-level (save-excursion |
| 5861 | (condition-case nil | 6024 | (condition-case nil |
| 5862 | (progn | 6025 | (progn |
| 5863 | (outline-next-visible-heading 1) | 6026 | (or (looking-at outline-regexp) |
| 6027 | (outline-next-visible-heading 1)) | ||
| 5864 | (if (looking-at re) | 6028 | (if (looking-at re) |
| 5865 | (- (match-end 0) (match-beginning 0)) | 6029 | (- (match-end 0) (match-beginning 0) 1) |
| 5866 | 1)) | 6030 | 1)) |
| 5867 | (error 1)))) | 6031 | (error 1)))) |
| 5868 | (new-level (or force-level (max previous-level next-level))) | 6032 | (new-level (or force-level (max previous-level next-level))) |
| @@ -5871,7 +6035,6 @@ If optional TREE is given, use this text instead of the kill ring." | |||
| 5871 | (= old-level new-level)) | 6035 | (= old-level new-level)) |
| 5872 | 0 | 6036 | 0 |
| 5873 | (- new-level old-level))) | 6037 | (- new-level old-level))) |
| 5874 | (shift1 shift) | ||
| 5875 | (delta (if (> shift 0) -1 1)) | 6038 | (delta (if (> shift 0) -1 1)) |
| 5876 | (func (if (> shift 0) 'org-demote 'org-promote)) | 6039 | (func (if (> shift 0) 'org-demote 'org-promote)) |
| 5877 | (org-odd-levels-only nil) | 6040 | (org-odd-levels-only nil) |
| @@ -5936,13 +6099,16 @@ If optional TXT is given, check this string instead of the current kill." | |||
| 5936 | ;;; Outline Sorting | 6099 | ;;; Outline Sorting |
| 5937 | 6100 | ||
| 5938 | (defun org-sort (with-case) | 6101 | (defun org-sort (with-case) |
| 5939 | "Call `org-sort-entries' or `org-table-sort-lines', depending on context." | 6102 | "Call `org-sort-entries-or-items' or `org-table-sort-lines'. |
| 6103 | Optional argument WITH-CASE means sort case-sensitively." | ||
| 5940 | (interactive "P") | 6104 | (interactive "P") |
| 5941 | (if (org-at-table-p) | 6105 | (if (org-at-table-p) |
| 5942 | (org-call-with-arg 'org-table-sort-lines with-case) | 6106 | (org-call-with-arg 'org-table-sort-lines with-case) |
| 5943 | (org-call-with-arg 'org-sort-entries with-case))) | 6107 | (org-call-with-arg 'org-sort-entries-or-items with-case))) |
| 6108 | |||
| 6109 | (defvar org-priority-regexp) ; defined later in the file | ||
| 5944 | 6110 | ||
| 5945 | (defun org-sort-entries (&optional with-case sorting-type) | 6111 | (defun org-sort-entries-or-items (&optional with-case sorting-type getkey-func property) |
| 5946 | "Sort entries on a certain level of an outline tree. | 6112 | "Sort entries on a certain level of an outline tree. |
| 5947 | If there is an active region, the entries in the region are sorted. | 6113 | If there is an active region, the entries in the region are sorted. |
| 5948 | Else, if the cursor is before the first entry, sort the top-level items. | 6114 | Else, if the cursor is before the first entry, sort the top-level items. |
| @@ -5951,26 +6117,35 @@ Else, the children of the entry at point are sorted. | |||
| 5951 | Sorting can be alphabetically, numerically, and by date/time as given by | 6117 | Sorting can be alphabetically, numerically, and by date/time as given by |
| 5952 | the first time stamp in the entry. The command prompts for the sorting | 6118 | the first time stamp in the entry. The command prompts for the sorting |
| 5953 | type unless it has been given to the function through the SORTING-TYPE | 6119 | type unless it has been given to the function through the SORTING-TYPE |
| 5954 | argument, which needs to a character, any of (?n ?N ?a ?A ?t ?T). | 6120 | argument, which needs to a character, any of (?n ?N ?a ?A ?t ?T ?p ?P ?f ?F). |
| 6121 | If the SORTING-TYPE is ?f or ?F, then GETKEY-FUNC specifies a function to be | ||
| 6122 | called with point at the beginning of the record. It must return either | ||
| 6123 | a string or a number that should serve as the sorting key for that record. | ||
| 5955 | 6124 | ||
| 5956 | Comparing entries ignores case by default. However, with an optional argument | 6125 | Comparing entries ignores case by default. However, with an optional argument |
| 5957 | WITH-CASE, the sorting considers case as well. With two prefix arguments | 6126 | WITH-CASE, the sorting considers case as well." |
| 5958 | `C-u C-u', sorting is case-sensitive and duplicate entries will be removed." | ||
| 5959 | (interactive "P") | 6127 | (interactive "P") |
| 5960 | (let ((unique (equal with-case '(16))) | 6128 | (let ((case-func (if with-case 'identity 'downcase)) |
| 5961 | start beg end entries stars re re2 p nentries (nremoved 0) | 6129 | start beg end stars re re2 |
| 5962 | last txt what) | 6130 | txt what tmp plain-list-p) |
| 5963 | ;; Find beginning and end of region to sort | 6131 | ;; Find beginning and end of region to sort |
| 5964 | (cond | 6132 | (cond |
| 5965 | ((org-region-active-p) | 6133 | ((org-region-active-p) |
| 5966 | ;; we will sort the region | 6134 | ;; we will sort the region |
| 5967 | (setq end (region-end) | 6135 | (setq end (region-end) |
| 5968 | what "region") | 6136 | what "region") |
| 5969 | (goto-char (region-beginning)) | 6137 | (goto-char (region-beginning)) |
| 5970 | (if (not (org-on-heading-p)) (outline-next-heading)) | 6138 | (if (not (org-on-heading-p)) (outline-next-heading)) |
| 5971 | (setq start (point))) | 6139 | (setq start (point))) |
| 6140 | ((org-at-item-p) | ||
| 6141 | ;; we will sort this plain list | ||
| 6142 | (org-beginning-of-item-list) (setq start (point)) | ||
| 6143 | (org-end-of-item-list) (setq end (point)) | ||
| 6144 | (goto-char start) | ||
| 6145 | (setq plain-list-p t | ||
| 6146 | what "plain list")) | ||
| 5972 | ((or (org-on-heading-p) | 6147 | ((or (org-on-heading-p) |
| 5973 | (condition-case nil (progn (org-back-to-heading) t) (error nil))) | 6148 | (condition-case nil (progn (org-back-to-heading) t) (error nil))) |
| 5974 | ;; we will sort the children of the current headline | 6149 | ;; we will sort the children of the current headline |
| 5975 | (org-back-to-heading) | 6150 | (org-back-to-heading) |
| 5976 | (setq start (point) end (org-end-of-subtree) what "children") | 6151 | (setq start (point) end (org-end-of-subtree) what "children") |
| @@ -5984,46 +6159,129 @@ WITH-CASE, the sorting considers case as well. With two prefix arguments | |||
| 5984 | (setq start (point) end (point-max) what "top-level") | 6159 | (setq start (point) end (point-max) what "top-level") |
| 5985 | (goto-char start) | 6160 | (goto-char start) |
| 5986 | (show-all))) | 6161 | (show-all))) |
| 5987 | (setq beg (point)) | ||
| 5988 | (if (>= (point) end) (error "Nothing to sort")) | ||
| 5989 | (looking-at "\\(\\*+\\)") | ||
| 5990 | (setq stars (match-string 1) | ||
| 5991 | re (concat "^" (regexp-quote stars) " +") | ||
| 5992 | re2 (concat "^" (regexp-quote (substring stars 0 -1)) "[^*]") | ||
| 5993 | txt (buffer-substring beg end)) | ||
| 5994 | (if (not (equal (substring txt -1) "\n")) (setq txt (concat txt "\n"))) | ||
| 5995 | (if (and (not (equal stars "*")) (string-match re2 txt)) | ||
| 5996 | (error "Region to sort contains a level above the first entry")) | ||
| 5997 | ;; Make a list that can be sorted. | ||
| 5998 | ;; The car is the string for comparison, the cdr is the subtree | ||
| 5999 | (message "Sorting entries...") | ||
| 6000 | (setq entries | ||
| 6001 | (mapcar | ||
| 6002 | (lambda (x) | ||
| 6003 | (string-match "^.*\\(\n.*\\)?" x) ; take two lines | ||
| 6004 | (cons (match-string 0 x) x)) | ||
| 6005 | (org-split-string txt re))) | ||
| 6006 | 6162 | ||
| 6007 | ;; Sort the list | 6163 | (setq beg (point)) |
| 6008 | (save-excursion | 6164 | (if (>= beg end) (error "Nothing to sort")) |
| 6009 | (goto-char start) | 6165 | |
| 6010 | (setq entries (org-do-sort entries what with-case sorting-type))) | 6166 | (unless plain-list-p |
| 6167 | (looking-at "\\(\\*+\\)") | ||
| 6168 | (setq stars (match-string 1) | ||
| 6169 | re (concat "^" (regexp-quote stars) " +") | ||
| 6170 | re2 (concat "^" (regexp-quote (substring stars 0 -1)) "[^*]") | ||
| 6171 | txt (buffer-substring beg end)) | ||
| 6172 | (if (not (equal (substring txt -1) "\n")) (setq txt (concat txt "\n"))) | ||
| 6173 | (if (and (not (equal stars "*")) (string-match re2 txt)) | ||
| 6174 | (error "Region to sort contains a level above the first entry"))) | ||
| 6175 | |||
| 6176 | (unless sorting-type | ||
| 6177 | (message | ||
| 6178 | (if plain-list-p | ||
| 6179 | "Sort %s: [a]lpha [n]umeric [t]ime [f]unc A/N/T/F means reversed:" | ||
| 6180 | "Sort %s: [a]lpha [n]umeric [t]ime [p]riority p[r]operty [f]unc A/N/T/P/F means reversed:") | ||
| 6181 | what) | ||
| 6182 | (setq sorting-type (read-char-exclusive)) | ||
| 6183 | |||
| 6184 | (and (= (downcase sorting-type) ?f) | ||
| 6185 | (setq getkey-func | ||
| 6186 | (completing-read "Sort using function: " | ||
| 6187 | obarray 'fboundp t nil nil)) | ||
| 6188 | (setq getkey-func (intern getkey-func))) | ||
| 6189 | |||
| 6190 | (and (= (downcase sorting-type) ?r) | ||
| 6191 | (setq property | ||
| 6192 | (completing-read "Property: " | ||
| 6193 | (mapcar 'list (org-buffer-property-keys t)) | ||
| 6194 | nil t)))) | ||
| 6011 | 6195 | ||
| 6012 | ;; Delete the old stuff | 6196 | (message "Sorting entries...") |
| 6013 | (goto-char beg) | ||
| 6014 | (kill-region beg end) | ||
| 6015 | (setq nentries (length entries)) | ||
| 6016 | ;; Insert the sorted entries, and remove duplicates if this is required | ||
| 6017 | (while (setq p (pop entries)) | ||
| 6018 | (if (and unique (equal last (setq last (org-trim (cdr p))))) | ||
| 6019 | (setq nremoved (1+ nremoved)) ; same entry as before, skip it | ||
| 6020 | (insert stars " " (cdr p)))) | ||
| 6021 | (goto-char start) | ||
| 6022 | (message "Sorting entries...done (%d entries%s)" | ||
| 6023 | nentries | ||
| 6024 | (if unique (format ", %d duplicates removed" nremoved) "")))) | ||
| 6025 | 6197 | ||
| 6026 | (defvar org-priority-regexp) ; defined later in the file | 6198 | (save-restriction |
| 6199 | (narrow-to-region start end) | ||
| 6200 | |||
| 6201 | (let ((dcst (downcase sorting-type)) | ||
| 6202 | (now (current-time))) | ||
| 6203 | (sort-subr | ||
| 6204 | (/= dcst sorting-type) | ||
| 6205 | ;; This function moves to the beginning character of the "record" to | ||
| 6206 | ;; be sorted. | ||
| 6207 | (if plain-list-p | ||
| 6208 | (lambda nil | ||
| 6209 | (if (org-at-item-p) t (goto-char (point-max)))) | ||
| 6210 | (lambda nil | ||
| 6211 | (if (re-search-forward re nil t) | ||
| 6212 | (goto-char (match-beginning 0)) | ||
| 6213 | (goto-char (point-max))))) | ||
| 6214 | ;; This function moves to the last character of the "record" being | ||
| 6215 | ;; sorted. | ||
| 6216 | (if plain-list-p | ||
| 6217 | 'org-end-of-item | ||
| 6218 | (lambda nil | ||
| 6219 | (save-match-data | ||
| 6220 | (condition-case nil | ||
| 6221 | (outline-forward-same-level 1) | ||
| 6222 | (error | ||
| 6223 | (goto-char (point-max))))))) | ||
| 6224 | |||
| 6225 | ;; This function returns the value that gets sorted against. | ||
| 6226 | (if plain-list-p | ||
| 6227 | (lambda nil | ||
| 6228 | (when (looking-at "[ \t]*[-+*0-9.)]+[ \t]+") | ||
| 6229 | (cond | ||
| 6230 | ((= dcst ?n) | ||
| 6231 | (string-to-number (buffer-substring (match-end 0) | ||
| 6232 | (line-end-position)))) | ||
| 6233 | ((= dcst ?a) | ||
| 6234 | (buffer-substring (match-end 0) (line-end-position))) | ||
| 6235 | ((= dcst ?t) | ||
| 6236 | (if (re-search-forward org-ts-regexp | ||
| 6237 | (line-end-position) t) | ||
| 6238 | (org-time-string-to-time (match-string 0)) | ||
| 6239 | now)) | ||
| 6240 | ((= dcst ?f) | ||
| 6241 | (if getkey-func | ||
| 6242 | (progn | ||
| 6243 | (setq tmp (funcall getkey-func)) | ||
| 6244 | (if (stringp tmp) (setq tmp (funcall case-func tmp))) | ||
| 6245 | tmp) | ||
| 6246 | (error "Invalid key function `%s'" getkey-func))) | ||
| 6247 | (t (error "Invalid sorting type `%c'" sorting-type))))) | ||
| 6248 | (lambda nil | ||
| 6249 | (cond | ||
| 6250 | ((= dcst ?n) | ||
| 6251 | (if (looking-at outline-regexp) | ||
| 6252 | (string-to-number (buffer-substring (match-end 0) | ||
| 6253 | (line-end-position))) | ||
| 6254 | nil)) | ||
| 6255 | ((= dcst ?a) | ||
| 6256 | (funcall case-func (buffer-substring (line-beginning-position) | ||
| 6257 | (line-end-position)))) | ||
| 6258 | ((= dcst ?t) | ||
| 6259 | (if (re-search-forward org-ts-regexp | ||
| 6260 | (save-excursion | ||
| 6261 | (forward-line 2) | ||
| 6262 | (point)) t) | ||
| 6263 | (org-time-string-to-time (match-string 0)) | ||
| 6264 | now)) | ||
| 6265 | ((= dcst ?p) | ||
| 6266 | (if (re-search-forward org-priority-regexp (line-end-position) t) | ||
| 6267 | (string-to-char (match-string 2)) | ||
| 6268 | org-default-priority)) | ||
| 6269 | ((= dcst ?r) | ||
| 6270 | (or (org-entry-get nil property) "")) | ||
| 6271 | ((= dcst ?f) | ||
| 6272 | (if getkey-func | ||
| 6273 | (progn | ||
| 6274 | (setq tmp (funcall getkey-func)) | ||
| 6275 | (if (stringp tmp) (setq tmp (funcall case-func tmp))) | ||
| 6276 | tmp) | ||
| 6277 | (error "Invalid key function `%s'" getkey-func))) | ||
| 6278 | (t (error "Invalid sorting type `%c'" sorting-type))))) | ||
| 6279 | nil | ||
| 6280 | (cond | ||
| 6281 | ((= dcst ?a) 'string<) | ||
| 6282 | ((= dcst ?t) 'time-less-p) | ||
| 6283 | (t nil))))) | ||
| 6284 | (message "Sorting entries...done"))) | ||
| 6027 | 6285 | ||
| 6028 | (defun org-do-sort (table what &optional with-case sorting-type) | 6286 | (defun org-do-sort (table what &optional with-case sorting-type) |
| 6029 | "Sort TABLE of WHAT according to SORTING-TYPE. | 6287 | "Sort TABLE of WHAT according to SORTING-TYPE. |
| @@ -6034,7 +6292,7 @@ the car of the elements of the table. | |||
| 6034 | If WITH-CASE is non-nil, the sorting will be case-sensitive." | 6292 | If WITH-CASE is non-nil, the sorting will be case-sensitive." |
| 6035 | (unless sorting-type | 6293 | (unless sorting-type |
| 6036 | (message | 6294 | (message |
| 6037 | "Sort %s: [a]lphabetic. [n]umeric. [t]ime [p]riority. A/N/T/P means reversed:" | 6295 | "Sort %s: [a]lphabetic. [n]umeric. [t]ime. A/N/T means reversed:" |
| 6038 | what) | 6296 | what) |
| 6039 | (setq sorting-type (read-char-exclusive))) | 6297 | (setq sorting-type (read-char-exclusive))) |
| 6040 | (let ((dcst (downcase sorting-type)) | 6298 | (let ((dcst (downcase sorting-type)) |
| @@ -6058,13 +6316,6 @@ If WITH-CASE is non-nil, the sorting will be case-sensitive." | |||
| 6058 | (org-time-string-to-time (match-string 0 x))) | 6316 | (org-time-string-to-time (match-string 0 x))) |
| 6059 | 0)) | 6317 | 0)) |
| 6060 | comparefun (if (= dcst sorting-type) '< '>))) | 6318 | comparefun (if (= dcst sorting-type) '< '>))) |
| 6061 | ((= dcst ?p) | ||
| 6062 | (setq extractfun | ||
| 6063 | (lambda (x) | ||
| 6064 | (if (string-match org-priority-regexp x) | ||
| 6065 | (string-to-char (match-string 2 x)) | ||
| 6066 | org-default-priority)) | ||
| 6067 | comparefun (if (= dcst sorting-type) '< '>))) | ||
| 6068 | (t (error "Invalid sorting type `%c'" sorting-type))) | 6319 | (t (error "Invalid sorting type `%c'" sorting-type))) |
| 6069 | 6320 | ||
| 6070 | (sort (mapcar (lambda (x) (cons (funcall extractfun (car x)) (cdr x))) | 6321 | (sort (mapcar (lambda (x) (cons (funcall extractfun (car x)) (cdr x))) |
| @@ -6471,15 +6722,18 @@ If WHICH is a string, use that as the new bullet. If WHICH is an integer, | |||
| 6471 | (org-beginning-of-item-list) | 6722 | (org-beginning-of-item-list) |
| 6472 | (org-at-item-p) | 6723 | (org-at-item-p) |
| 6473 | (beginning-of-line 1) | 6724 | (beginning-of-line 1) |
| 6474 | (let ((current (match-string 0)) new) | 6725 | (let ((current (match-string 0)) |
| 6726 | (prevp (eq which 'previous)) | ||
| 6727 | new) | ||
| 6475 | (setq new (cond | 6728 | (setq new (cond |
| 6476 | ((and which (nth (1- which) '("-" "+" "*" "1." "1)")))) | 6729 | ((and (numberp which) |
| 6477 | ((string-match "-" current) "+") | 6730 | (nth (1- which) '("-" "+" "*" "1." "1)")))) |
| 6731 | ((string-match "-" current) (if prevp "1)" "+")) | ||
| 6478 | ((string-match "\\+" current) | 6732 | ((string-match "\\+" current) |
| 6479 | (if (looking-at "\\S-") "1." "*")) | 6733 | (if prevp "-" (if (looking-at "\\S-") "1." "*"))) |
| 6480 | ((string-match "\\*" current) "1.") | 6734 | ((string-match "\\*" current) (if prevp "+" "1.")) |
| 6481 | ((string-match "\\." current) "1)") | 6735 | ((string-match "\\." current) (if prevp "*" "1)")) |
| 6482 | ((string-match ")" current) "-") | 6736 | ((string-match ")" current) (if prevp "1." "-")) |
| 6483 | (t (error "This should not happen")))) | 6737 | (t (error "This should not happen")))) |
| 6484 | (and (looking-at "\\([ \t]*\\)\\S-+") (replace-match (concat "\\1" new))) | 6738 | (and (looking-at "\\([ \t]*\\)\\S-+") (replace-match (concat "\\1" new))) |
| 6485 | (org-fix-bullet-type) | 6739 | (org-fix-bullet-type) |
| @@ -6591,6 +6845,33 @@ I.e. to the first item in this list." | |||
| 6591 | (when (org-at-item-p) (setq pos (point-at-bol))))))) | 6845 | (when (org-at-item-p) (setq pos (point-at-bol))))))) |
| 6592 | (goto-char pos))) | 6846 | (goto-char pos))) |
| 6593 | 6847 | ||
| 6848 | |||
| 6849 | (defun org-end-of-item-list () | ||
| 6850 | "Go to the end of the current item list. | ||
| 6851 | I.e. to the text after the last item." | ||
| 6852 | (interactive) | ||
| 6853 | (org-beginning-of-item) | ||
| 6854 | (let ((pos (point-at-bol)) | ||
| 6855 | (ind (org-get-indentation)) | ||
| 6856 | ind1) | ||
| 6857 | ;; find where this list begins | ||
| 6858 | (catch 'exit | ||
| 6859 | (while t | ||
| 6860 | (catch 'next | ||
| 6861 | (beginning-of-line 2) | ||
| 6862 | (if (looking-at "[ \t]*$") | ||
| 6863 | (throw (if (eobp) 'exit 'next) t)) | ||
| 6864 | (skip-chars-forward " \t") (setq ind1 (current-column)) | ||
| 6865 | (if (or (< ind1 ind) | ||
| 6866 | (and (= ind1 ind) | ||
| 6867 | (not (org-at-item-p))) | ||
| 6868 | (eobp)) | ||
| 6869 | (progn | ||
| 6870 | (setq pos (point-at-bol)) | ||
| 6871 | (throw 'exit t)))))) | ||
| 6872 | (goto-char pos))) | ||
| 6873 | |||
| 6874 | |||
| 6594 | (defvar org-last-indent-begin-marker (make-marker)) | 6875 | (defvar org-last-indent-begin-marker (make-marker)) |
| 6595 | (defvar org-last-indent-end-marker (make-marker)) | 6876 | (defvar org-last-indent-end-marker (make-marker)) |
| 6596 | 6877 | ||
| @@ -6778,7 +7059,7 @@ off orgstruct-mode will *not* remove these additonal settings." | |||
| 6778 | (orgstruct-make-binding 'org-cycle 102 [(tab)] "\C-i")) | 7059 | (orgstruct-make-binding 'org-cycle 102 [(tab)] "\C-i")) |
| 6779 | (org-defkey orgstruct-mode-map "\C-i" | 7060 | (org-defkey orgstruct-mode-map "\C-i" |
| 6780 | (orgstruct-make-binding 'org-cycle 103 "\C-i" [(tab)])) | 7061 | (orgstruct-make-binding 'org-cycle 103 "\C-i" [(tab)])) |
| 6781 | 7062 | ||
| 6782 | (org-defkey orgstruct-mode-map "\M-\C-m" | 7063 | (org-defkey orgstruct-mode-map "\M-\C-m" |
| 6783 | (orgstruct-make-binding 'org-insert-heading 105 | 7064 | (orgstruct-make-binding 'org-insert-heading 105 |
| 6784 | "\M-\C-m" [(meta return)])) | 7065 | "\M-\C-m" [(meta return)])) |
| @@ -6789,10 +7070,10 @@ off orgstruct-mode will *not* remove these additonal settings." | |||
| 6789 | (org-defkey orgstruct-mode-map [(shift meta return)] | 7070 | (org-defkey orgstruct-mode-map [(shift meta return)] |
| 6790 | (orgstruct-make-binding 'org-insert-todo-heading 107 | 7071 | (orgstruct-make-binding 'org-insert-todo-heading 107 |
| 6791 | [(meta return)] "\M-\C-m")) | 7072 | [(meta return)] "\M-\C-m")) |
| 6792 | 7073 | ||
| 6793 | (unless org-local-vars | 7074 | (unless org-local-vars |
| 6794 | (setq org-local-vars (org-get-local-variables))) | 7075 | (setq org-local-vars (org-get-local-variables))) |
| 6795 | 7076 | ||
| 6796 | t)) | 7077 | t)) |
| 6797 | 7078 | ||
| 6798 | (defun orgstruct-make-binding (fun n &rest keys) | 7079 | (defun orgstruct-make-binding (fun n &rest keys) |
| @@ -6843,7 +7124,7 @@ Possible values in the list of contexts are `table', `headline', and `item'." | |||
| 6843 | (kill-buffer "*Org tmp*") | 7124 | (kill-buffer "*Org tmp*") |
| 6844 | (delq nil | 7125 | (delq nil |
| 6845 | (mapcar | 7126 | (mapcar |
| 6846 | (lambda (x) | 7127 | (lambda (x) |
| 6847 | (setq x | 7128 | (setq x |
| 6848 | (if (symbolp x) | 7129 | (if (symbolp x) |
| 6849 | (list x) | 7130 | (list x) |
| @@ -6891,12 +7172,15 @@ this heading." | |||
| 6891 | (this-buffer (current-buffer)) | 7172 | (this-buffer (current-buffer)) |
| 6892 | (org-archive-location org-archive-location) | 7173 | (org-archive-location org-archive-location) |
| 6893 | (re "^#\\+ARCHIVE:[ \t]+\\(\\S-.*\\S-\\)[ \t]*$") | 7174 | (re "^#\\+ARCHIVE:[ \t]+\\(\\S-.*\\S-\\)[ \t]*$") |
| 7175 | ;; start of variables that will be used for savind context | ||
| 6894 | (file (abbreviate-file-name (buffer-file-name))) | 7176 | (file (abbreviate-file-name (buffer-file-name))) |
| 6895 | (time (format-time-string | 7177 | (time (format-time-string |
| 6896 | (substring (cdr org-time-stamp-formats) 1 -1) | 7178 | (substring (cdr org-time-stamp-formats) 1 -1) |
| 6897 | (current-time))) | 7179 | (current-time))) |
| 6898 | afile heading buffer level newfile-p | 7180 | afile heading buffer level newfile-p |
| 6899 | category todo priority ltags itags prop) | 7181 | category todo priority |
| 7182 | ;; start of variables that will be used for savind context | ||
| 7183 | ltags itags prop) | ||
| 6900 | 7184 | ||
| 6901 | ;; Try to find a local archive location | 7185 | ;; Try to find a local archive location |
| 6902 | (save-excursion | 7186 | (save-excursion |
| @@ -7167,11 +7451,13 @@ If ONOFF is `on' or `off', don't toggle but set to this state." | |||
| 7167 | (setq res t) | 7451 | (setq res t) |
| 7168 | (push tag current)))) | 7452 | (push tag current)))) |
| 7169 | (end-of-line 1) | 7453 | (end-of-line 1) |
| 7170 | (when current | 7454 | (if current |
| 7171 | (insert " :" (mapconcat 'identity (nreverse current) ":") ":")) | 7455 | (progn |
| 7172 | (org-set-tags nil t) | 7456 | (insert " :" (mapconcat 'identity (nreverse current) ":") ":") |
| 7173 | res) | 7457 | (org-set-tags nil t)) |
| 7174 | (run-hooks 'org-after-tags-change-hook))) | 7458 | (delete-horizontal-space)) |
| 7459 | (run-hooks 'org-after-tags-change-hook)) | ||
| 7460 | res)) | ||
| 7175 | 7461 | ||
| 7176 | (defun org-toggle-archive-tag (&optional arg) | 7462 | (defun org-toggle-archive-tag (&optional arg) |
| 7177 | "Toggle the archive tag for the current headline. | 7463 | "Toggle the archive tag for the current headline. |
| @@ -7345,7 +7631,7 @@ nil When nil, the command tries to be smart and figure out the | |||
| 7345 | (interactive "rP") | 7631 | (interactive "rP") |
| 7346 | (let* ((beg (min beg0 end0)) | 7632 | (let* ((beg (min beg0 end0)) |
| 7347 | (end (max beg0 end0)) | 7633 | (end (max beg0 end0)) |
| 7348 | sep-re re) | 7634 | re) |
| 7349 | (goto-char beg) | 7635 | (goto-char beg) |
| 7350 | (beginning-of-line 1) | 7636 | (beginning-of-line 1) |
| 7351 | (setq beg (move-marker (make-marker) (point))) | 7637 | (setq beg (move-marker (make-marker) (point))) |
| @@ -8222,7 +8508,6 @@ In particular, this does handle wide and invisible characters." | |||
| 8222 | (org-table-fix-formulas "@" (list (cons (number-to-string dline) "INVALID")) | 8508 | (org-table-fix-formulas "@" (list (cons (number-to-string dline) "INVALID")) |
| 8223 | dline -1 dline))) | 8509 | dline -1 dline))) |
| 8224 | 8510 | ||
| 8225 | |||
| 8226 | (defun org-table-sort-lines (with-case &optional sorting-type) | 8511 | (defun org-table-sort-lines (with-case &optional sorting-type) |
| 8227 | "Sort table lines according to the column at point. | 8512 | "Sort table lines according to the column at point. |
| 8228 | 8513 | ||
| @@ -9493,7 +9778,8 @@ With prefix arg ALL, do this for all lines in the table." | |||
| 9493 | 9778 | ||
| 9494 | (defun org-table-formula-substitute-names (f) | 9779 | (defun org-table-formula-substitute-names (f) |
| 9495 | "Replace $const with values in string F." | 9780 | "Replace $const with values in string F." |
| 9496 | (let ((start 0) a (f1 f)) | 9781 | (message "form %s" f) (sit-for 1) |
| 9782 | (let ((start 0) a (f1 f) (pp (/= (string-to-char f) ?'))) | ||
| 9497 | ;; First, check for column names | 9783 | ;; First, check for column names |
| 9498 | (while (setq start (string-match org-table-column-name-regexp f start)) | 9784 | (while (setq start (string-match org-table-column-name-regexp f start)) |
| 9499 | (setq start (1+ start)) | 9785 | (setq start (1+ start)) |
| @@ -9505,7 +9791,8 @@ With prefix arg ALL, do this for all lines in the table." | |||
| 9505 | (setq start (1+ start)) | 9791 | (setq start (1+ start)) |
| 9506 | (if (setq a (save-match-data | 9792 | (if (setq a (save-match-data |
| 9507 | (org-table-get-constant (match-string 1 f)))) | 9793 | (org-table-get-constant (match-string 1 f)))) |
| 9508 | (setq f (replace-match (concat "(" a ")") t t f)))) | 9794 | (setq f (replace-match |
| 9795 | (concat (if pp "(") a (if pp ")")) t t f)))) | ||
| 9509 | (if org-table-formula-debug | 9796 | (if org-table-formula-debug |
| 9510 | (put-text-property 0 (length f) :orig-formula f1 f)) | 9797 | (put-text-property 0 (length f) :orig-formula f1 f)) |
| 9511 | f)) | 9798 | f)) |
| @@ -11010,7 +11297,7 @@ For file links, arg negates `org-context-in-file-links'." | |||
| 11010 | (elmo-msgdb-overview-get-entity | 11297 | (elmo-msgdb-overview-get-entity |
| 11011 | msgnum (wl-summary-buffer-msgdb)))) | 11298 | msgnum (wl-summary-buffer-msgdb)))) |
| 11012 | (from (wl-summary-line-from)) | 11299 | (from (wl-summary-line-from)) |
| 11013 | (to (car (elmo-message-entity-field wl-message-entity 'to))) | 11300 | (to (elmo-message-entity-field wl-message-entity 'to)) |
| 11014 | (subject (let (wl-thr-indent-string wl-parent-message-entity) | 11301 | (subject (let (wl-thr-indent-string wl-parent-message-entity) |
| 11015 | (wl-summary-line-subject)))) | 11302 | (wl-summary-line-subject)))) |
| 11016 | (org-store-link-props :type "wl" :from from :to to | 11303 | (org-store-link-props :type "wl" :from from :to to |
| @@ -11258,12 +11545,12 @@ according to FMT (default from `org-email-link-description-format')." | |||
| 11258 | (if description (concat "[" description "]") "") | 11545 | (if description (concat "[" description "]") "") |
| 11259 | "]")) | 11546 | "]")) |
| 11260 | 11547 | ||
| 11261 | (defconst org-link-escape-chars | 11548 | (defconst org-link-escape-chars |
| 11262 | '((" " . "%20") | 11549 | '((" " . "%20") |
| 11263 | ("[" . "%5B") | 11550 | ("[" . "%5B") |
| 11264 | ("]" . "%5d") | 11551 | ("]" . "%5d") |
| 11265 | ("\340" . "%E0") ; `a | 11552 | ("\340" . "%E0") ; `a |
| 11266 | ("\342" . "%E2") ; ^a | 11553 | ("\342" . "%E2") ; ^a |
| 11267 | ("\347" . "%E7") ; ,c | 11554 | ("\347" . "%E7") ; ,c |
| 11268 | ("\350" . "%E8") ; `e | 11555 | ("\350" . "%E8") ; `e |
| 11269 | ("\351" . "%E9") ; 'e | 11556 | ("\351" . "%E9") ; 'e |
| @@ -11280,7 +11567,7 @@ according to FMT (default from `org-email-link-description-format')." | |||
| 11280 | "Association list of escapes for some characters problematic in links. | 11567 | "Association list of escapes for some characters problematic in links. |
| 11281 | This is the list that is used for internal purposes.") | 11568 | This is the list that is used for internal purposes.") |
| 11282 | 11569 | ||
| 11283 | (defconst org-link-escape-chars-browser | 11570 | (defconst org-link-escape-chars-browser |
| 11284 | '((" " . "%20")) | 11571 | '((" " . "%20")) |
| 11285 | "Association list of escapes for some characters problematic in links. | 11572 | "Association list of escapes for some characters problematic in links. |
| 11286 | This is the list that is used before handing over to the browser.") | 11573 | This is the list that is used before handing over to the browser.") |
| @@ -11459,7 +11746,7 @@ With three \\[universal-argument] prefixes, negate the meaning of | |||
| 11459 | (setq org-stored-links (delq (assoc link org-stored-links) | 11746 | (setq org-stored-links (delq (assoc link org-stored-links) |
| 11460 | org-stored-links))) | 11747 | org-stored-links))) |
| 11461 | (setq desc (or desc (nth 1 entry))))) | 11748 | (setq desc (or desc (nth 1 entry))))) |
| 11462 | 11749 | ||
| 11463 | (if (string-match org-plain-link-re link) | 11750 | (if (string-match org-plain-link-re link) |
| 11464 | ;; URL-like link, normalize the use of angular brackets. | 11751 | ;; URL-like link, normalize the use of angular brackets. |
| 11465 | (setq link (org-make-link (org-remove-angle-brackets link)))) | 11752 | (setq link (org-make-link (org-remove-angle-brackets link)))) |
| @@ -11774,7 +12061,6 @@ optional argument IN-EMACS is non-nil, Emacs will visit the file." | |||
| 11774 | (browse-url-at-point))))) | 12061 | (browse-url-at-point))))) |
| 11775 | (move-marker org-open-link-marker nil)) | 12062 | (move-marker org-open-link-marker nil)) |
| 11776 | 12063 | ||
| 11777 | |||
| 11778 | ;;; File search | 12064 | ;;; File search |
| 11779 | 12065 | ||
| 11780 | (defvar org-create-file-search-functions nil | 12066 | (defvar org-create-file-search-functions nil |
| @@ -12432,23 +12718,38 @@ RET at beg-of-buf -> Append to file as level 2 headline | |||
| 12432 | This function should be placed into `remember-mode-hook' and in fact requires | 12718 | This function should be placed into `remember-mode-hook' and in fact requires |
| 12433 | to be run from that hook to fucntion properly." | 12719 | to be run from that hook to fucntion properly." |
| 12434 | (if org-remember-templates | 12720 | (if org-remember-templates |
| 12435 | 12721 | (let* ((templates (mapcar (lambda (x) | |
| 12436 | (let* ((char (or use-char | 12722 | (if (stringp (car x)) |
| 12723 | (append (list (nth 1 x) (car x)) (cddr x)) | ||
| 12724 | (append (list (car x) "") (cdr x)))) | ||
| 12725 | org-remember-templates)) | ||
| 12726 | (char (or use-char | ||
| 12437 | (cond | 12727 | (cond |
| 12438 | ((= (length org-remember-templates) 1) | 12728 | ((= (length templates) 1) |
| 12439 | (caar org-remember-templates)) | 12729 | (caar templates)) |
| 12440 | ((and (boundp 'org-force-remember-template-char) | 12730 | ((and (boundp 'org-force-remember-template-char) |
| 12441 | org-force-remember-template-char) | 12731 | org-force-remember-template-char) |
| 12442 | (if (string-p org-force-remember-template-char) | 12732 | (if (stringp org-force-remember-template-char) |
| 12443 | (string-to-char org-force-remember-template-char) | 12733 | (string-to-char org-force-remember-template-char) |
| 12444 | org-force-remember-template-char)) | 12734 | org-force-remember-template-char)) |
| 12445 | (t | 12735 | (t |
| 12446 | (message "Select template: %s" | 12736 | (message "Select template: %s" |
| 12447 | (mapconcat | 12737 | (mapconcat |
| 12448 | (lambda (x) (char-to-string (car x))) | 12738 | (lambda (x) |
| 12449 | org-remember-templates " ")) | 12739 | (cond |
| 12450 | (read-char-exclusive))))) | 12740 | ((not (string-match "\\S-" (nth 1 x))) |
| 12451 | (entry (cdr (assoc char org-remember-templates))) | 12741 | (format "[%c]" (car x))) |
| 12742 | ((equal (downcase (car x)) | ||
| 12743 | (downcase (aref (nth 1 x) 0))) | ||
| 12744 | (format "[%c]%s" (car x) (substring (nth 1 x) 1))) | ||
| 12745 | (t (format "[%c]%s" (car x) (nth 1 x))))) | ||
| 12746 | templates " ")) | ||
| 12747 | (let ((inhibit-quit t) (char0 (read-char-exclusive))) | ||
| 12748 | (when (equal char0 ?\C-g) | ||
| 12749 | (jump-to-register remember-register) | ||
| 12750 | (kill-buffer remember-buffer)) | ||
| 12751 | char0))))) | ||
| 12752 | (entry (cddr (assoc char templates))) | ||
| 12452 | (tpl (car entry)) | 12753 | (tpl (car entry)) |
| 12453 | (plist-p (if org-store-link-plist t nil)) | 12754 | (plist-p (if org-store-link-plist t nil)) |
| 12454 | (file (if (and (nth 1 entry) (stringp (nth 1 entry)) | 12755 | (file (if (and (nth 1 entry) (stringp (nth 1 entry)) |
| @@ -12460,8 +12761,11 @@ to be run from that hook to fucntion properly." | |||
| 12460 | (v-T (format-time-string (cdr org-time-stamp-formats) (org-current-time))) | 12761 | (v-T (format-time-string (cdr org-time-stamp-formats) (org-current-time))) |
| 12461 | (v-u (concat "[" (substring v-t 1 -1) "]")) | 12762 | (v-u (concat "[" (substring v-t 1 -1) "]")) |
| 12462 | (v-U (concat "[" (substring v-T 1 -1) "]")) | 12763 | (v-U (concat "[" (substring v-T 1 -1) "]")) |
| 12463 | (v-i initial) ; defined in `remember-mode' | 12764 | ;; `initial' and `annotation' are bound in `remember' |
| 12464 | (v-a (if (equal annotation "[[]]") "" annotation)) ; likewise | 12765 | (v-i (if (boundp 'initial) initial)) |
| 12766 | (v-a (if (and (boundp 'annotation) annotation) | ||
| 12767 | (if (equal annotation "[[]]") "" annotation) | ||
| 12768 | "")) | ||
| 12465 | (v-A (if (and v-a | 12769 | (v-A (if (and v-a |
| 12466 | (string-match "\\[\\(\\[.*?\\]\\)\\(\\[.*?\\]\\)?\\]" v-a)) | 12770 | (string-match "\\[\\(\\[.*?\\]\\)\\(\\[.*?\\]\\)?\\]" v-a)) |
| 12467 | (replace-match "[\\1[%^{Link description}]]" nil nil v-a) | 12771 | (replace-match "[\\1[%^{Link description}]]" nil nil v-a) |
| @@ -12480,7 +12784,7 @@ to be run from that hook to fucntion properly." | |||
| 12480 | ## %s to select file and header location interactively. | 12784 | ## %s to select file and header location interactively. |
| 12481 | ## %s \"%s\" -> \"* %s\" | 12785 | ## %s \"%s\" -> \"* %s\" |
| 12482 | ## C-u C-u C-c C-c \"%s\" -> \"* %s\" | 12786 | ## C-u C-u C-c C-c \"%s\" -> \"* %s\" |
| 12483 | ## To switch templates, use `\\[org-remember]'.\n\n" | 12787 | ## To switch templates, use `\\[org-remember]'. To abort use `C-c C-k'.\n\n" |
| 12484 | (if org-remember-store-without-prompt " C-u C-c C-c" " C-c C-c") | 12788 | (if org-remember-store-without-prompt " C-u C-c C-c" " C-c C-c") |
| 12485 | (if org-remember-store-without-prompt " C-c C-c" " C-u C-c C-c") | 12789 | (if org-remember-store-without-prompt " C-c C-c" " C-u C-c C-c") |
| 12486 | (abbreviate-file-name (or file org-default-notes-file)) | 12790 | (abbreviate-file-name (or file org-default-notes-file)) |
| @@ -12537,7 +12841,7 @@ to be run from that hook to fucntion properly." | |||
| 12537 | (when (string-match "\\S-" ins) | 12841 | (when (string-match "\\S-" ins) |
| 12538 | (or (equal (char-before) ?:) (insert ":")) | 12842 | (or (equal (char-before) ?:) (insert ":")) |
| 12539 | (insert ins) | 12843 | (insert ins) |
| 12540 | (or (equal (char-after) ?:) (insert ":"))))) | 12844 | (or (equal (char-after) ?:) (insert ":"))))) |
| 12541 | (char | 12845 | (char |
| 12542 | (setq org-time-was-given (equal (upcase char) char)) | 12846 | (setq org-time-was-given (equal (upcase char) char)) |
| 12543 | (setq time (org-read-date (equal (upcase char) "U") t nil | 12847 | (setq time (org-read-date (equal (upcase char) "U") t nil |
| @@ -12574,6 +12878,8 @@ of the remember buffer." | |||
| 12574 | (remember (buffer-substring (point) (mark))) | 12878 | (remember (buffer-substring (point) (mark))) |
| 12575 | (call-interactively 'remember)))) | 12879 | (call-interactively 'remember)))) |
| 12576 | 12880 | ||
| 12881 | (defvar org-note-abort nil) ; dynamically scoped | ||
| 12882 | |||
| 12577 | ;;;###autoload | 12883 | ;;;###autoload |
| 12578 | (defun org-remember-handler () | 12884 | (defun org-remember-handler () |
| 12579 | "Store stuff from remember.el into an org file. | 12885 | "Store stuff from remember.el into an org file. |
| @@ -12616,6 +12922,7 @@ See also the variable `org-reverse-note-order'." | |||
| 12616 | (goto-char (point-max)) | 12922 | (goto-char (point-max)) |
| 12617 | (unless (equal (char-before) ?\n) (insert "\n")) | 12923 | (unless (equal (char-before) ?\n) (insert "\n")) |
| 12618 | (catch 'quit | 12924 | (catch 'quit |
| 12925 | (if org-note-abort (throw 'quit nil)) | ||
| 12619 | (let* ((txt (buffer-substring (point-min) (point-max))) | 12926 | (let* ((txt (buffer-substring (point-min) (point-max))) |
| 12620 | (fastp (org-xor (equal current-prefix-arg '(4)) | 12927 | (fastp (org-xor (equal current-prefix-arg '(4)) |
| 12621 | org-remember-store-without-prompt)) | 12928 | org-remember-store-without-prompt)) |
| @@ -12710,7 +13017,7 @@ See also the variable `org-reverse-note-order'." | |||
| 12710 | (org-end-of-subtree t) | 13017 | (org-end-of-subtree t) |
| 12711 | (org-paste-subtree level txt)) | 13018 | (org-paste-subtree level txt)) |
| 12712 | (t (error "This should not happen")))) | 13019 | (t (error "This should not happen")))) |
| 12713 | 13020 | ||
| 12714 | ((and (bobp) (not reversed)) | 13021 | ((and (bobp) (not reversed)) |
| 12715 | ;; Put it at the end, one level below level 1 | 13022 | ;; Put it at the end, one level below level 1 |
| 12716 | (save-restriction | 13023 | (save-restriction |
| @@ -12718,7 +13025,7 @@ See also the variable `org-reverse-note-order'." | |||
| 12718 | (goto-char (point-max)) | 13025 | (goto-char (point-max)) |
| 12719 | (if (not (bolp)) (newline)) | 13026 | (if (not (bolp)) (newline)) |
| 12720 | (org-paste-subtree (org-get-legal-level 1 1) txt))) | 13027 | (org-paste-subtree (org-get-legal-level 1 1) txt))) |
| 12721 | 13028 | ||
| 12722 | ((and (bobp) reversed) | 13029 | ((and (bobp) reversed) |
| 12723 | ;; Put it at the start, as level 1 | 13030 | ;; Put it at the start, as level 1 |
| 12724 | (save-restriction | 13031 | (save-restriction |
| @@ -12877,7 +13184,7 @@ This function can be used in a hook." | |||
| 12877 | 13184 | ||
| 12878 | (defconst org-additional-option-like-keywords | 13185 | (defconst org-additional-option-like-keywords |
| 12879 | '("BEGIN_HTML" "BEGIN_LaTeX" "END_HTML" "END_LaTeX" | 13186 | '("BEGIN_HTML" "BEGIN_LaTeX" "END_HTML" "END_LaTeX" |
| 12880 | "ORGTBL" "HTML:" "LaTeX:")) | 13187 | "ORGTBL" "HTML:" "LaTeX:" "BEGIN:" "END:" "DATE:")) |
| 12881 | 13188 | ||
| 12882 | (defun org-complete (&optional arg) | 13189 | (defun org-complete (&optional arg) |
| 12883 | "Perform completion on word at point. | 13190 | "Perform completion on word at point. |
| @@ -12999,7 +13306,7 @@ At all other locations, this simply calls the value of | |||
| 12999 | (save-excursion | 13306 | (save-excursion |
| 13000 | (org-back-to-heading) | 13307 | (org-back-to-heading) |
| 13001 | (if (looking-at (concat outline-regexp | 13308 | (if (looking-at (concat outline-regexp |
| 13002 | "\\( *\\<" org-comment-string "\\>\\)")) | 13309 | "\\( *\\<" org-comment-string "\\>[ \t]*\\)")) |
| 13003 | (replace-match "" t t nil 1) | 13310 | (replace-match "" t t nil 1) |
| 13004 | (if (looking-at outline-regexp) | 13311 | (if (looking-at outline-regexp) |
| 13005 | (progn | 13312 | (progn |
| @@ -13022,6 +13329,56 @@ If yes, return this value. If not, return the current value of the variable." | |||
| 13022 | (read prop) | 13329 | (read prop) |
| 13023 | (symbol-value var)))) | 13330 | (symbol-value var)))) |
| 13024 | 13331 | ||
| 13332 | (defun org-parse-local-options (string var) | ||
| 13333 | "Parse STRING for startup setting relevant for variable VAR." | ||
| 13334 | (let ((rtn (symbol-value var)) | ||
| 13335 | e opts) | ||
| 13336 | (save-match-data | ||
| 13337 | (if (or (not string) (not (string-match "\\S-" string))) | ||
| 13338 | rtn | ||
| 13339 | (setq opts (delq nil (mapcar (lambda (x) | ||
| 13340 | (setq e (assoc x org-startup-options)) | ||
| 13341 | (if (eq (nth 1 e) var) e nil)) | ||
| 13342 | (org-split-string string "[ \t]+")))) | ||
| 13343 | (if (not opts) | ||
| 13344 | rtn | ||
| 13345 | (setq rtn nil) | ||
| 13346 | (while (setq e (pop opts)) | ||
| 13347 | (if (not (nth 3 e)) | ||
| 13348 | (setq rtn (nth 2 e)) | ||
| 13349 | (if (not (listp rtn)) (setq rtn nil)) | ||
| 13350 | (push (nth 2 e) rtn))) | ||
| 13351 | rtn))))) | ||
| 13352 | |||
| 13353 | (defvar org-blocker-hook nil | ||
| 13354 | "Hook for functions that are allowed to block a state change. | ||
| 13355 | |||
| 13356 | Each function gets as its single argument a property list, see | ||
| 13357 | `org-trigger-hook' for more information about this list. | ||
| 13358 | |||
| 13359 | If any of the functions in this hook returns nil, the state change | ||
| 13360 | is blocked.") | ||
| 13361 | |||
| 13362 | (defvar org-trigger-hook nil | ||
| 13363 | "Hook for functions that are triggered by a state change. | ||
| 13364 | |||
| 13365 | Each function gets as its single argument a property list with at least | ||
| 13366 | the following elements: | ||
| 13367 | |||
| 13368 | (:type type-of-change :position pos-at-entry-start | ||
| 13369 | :from old-state :to new-state) | ||
| 13370 | |||
| 13371 | Depending on the type, more properties may be present. | ||
| 13372 | |||
| 13373 | This mechanism is currently implemented for: | ||
| 13374 | |||
| 13375 | TODO state changes | ||
| 13376 | ------------------ | ||
| 13377 | :type todo-state-change | ||
| 13378 | :from previous state (keyword as a string), or nil | ||
| 13379 | :to new state (keyword as a string), or nil") | ||
| 13380 | |||
| 13381 | |||
| 13025 | (defun org-todo (&optional arg) | 13382 | (defun org-todo (&optional arg) |
| 13026 | "Change the TODO state of an item. | 13383 | "Change the TODO state of an item. |
| 13027 | The state of an item is given by a keyword at the start of the heading, | 13384 | The state of an item is given by a keyword at the start of the heading, |
| @@ -13048,134 +13405,151 @@ For calling through lisp, arg is also interpreted in the following way: | |||
| 13048 | really is a member of `org-todo-keywords'." | 13405 | really is a member of `org-todo-keywords'." |
| 13049 | (interactive "P") | 13406 | (interactive "P") |
| 13050 | (save-excursion | 13407 | (save-excursion |
| 13051 | (org-back-to-heading) | 13408 | (catch 'exit |
| 13052 | (if (looking-at outline-regexp) (goto-char (1- (match-end 0)))) | 13409 | (org-back-to-heading) |
| 13053 | (or (looking-at (concat " +" org-todo-regexp " *")) | 13410 | (if (looking-at outline-regexp) (goto-char (1- (match-end 0)))) |
| 13054 | (looking-at " *")) | 13411 | (or (looking-at (concat " +" org-todo-regexp " *")) |
| 13055 | (let* ((logging (save-match-data (org-entry-get nil "LOGGING" t))) | 13412 | (looking-at " *")) |
| 13056 | (org-log-done (org-parse-local-options logging 'org-log-done)) | 13413 | (let* ((startpos (line-beginning-position)) |
| 13057 | (org-log-repeat (org-parse-local-options logging 'org-log-repeat)) | 13414 | (logging (save-match-data (org-entry-get nil "LOGGING" t))) |
| 13058 | (this (match-string 1)) | 13415 | (org-log-done (org-parse-local-options logging 'org-log-done)) |
| 13059 | (hl-pos (match-beginning 0)) | 13416 | (org-log-repeat (org-parse-local-options logging 'org-log-repeat)) |
| 13060 | (head (org-get-todo-sequence-head this)) | 13417 | (this (match-string 1)) |
| 13061 | (ass (assoc head org-todo-kwd-alist)) | 13418 | (hl-pos (match-beginning 0)) |
| 13062 | (interpret (nth 1 ass)) | 13419 | (head (org-get-todo-sequence-head this)) |
| 13063 | (done-word (nth 3 ass)) | 13420 | (ass (assoc head org-todo-kwd-alist)) |
| 13064 | (final-done-word (nth 4 ass)) | 13421 | (interpret (nth 1 ass)) |
| 13065 | (last-state (or this "")) | 13422 | (done-word (nth 3 ass)) |
| 13066 | (completion-ignore-case t) | 13423 | (final-done-word (nth 4 ass)) |
| 13067 | (member (member this org-todo-keywords-1)) | 13424 | (last-state (or this "")) |
| 13068 | (tail (cdr member)) | 13425 | (completion-ignore-case t) |
| 13069 | (state (cond | 13426 | (member (member this org-todo-keywords-1)) |
| 13070 | ((and org-todo-key-trigger | 13427 | (tail (cdr member)) |
| 13071 | (or (and (equal arg '(4)) (eq org-use-fast-todo-selection 'prefix)) | 13428 | (state (cond |
| 13072 | (and (not arg) org-use-fast-todo-selection | 13429 | ((and org-todo-key-trigger |
| 13073 | (not (eq org-use-fast-todo-selection 'prefix))))) | 13430 | (or (and (equal arg '(4)) (eq org-use-fast-todo-selection 'prefix)) |
| 13074 | ;; Use fast selection | 13431 | (and (not arg) org-use-fast-todo-selection |
| 13075 | (org-fast-todo-selection)) | 13432 | (not (eq org-use-fast-todo-selection 'prefix))))) |
| 13076 | ((and (equal arg '(4)) | 13433 | ;; Use fast selection |
| 13077 | (or (not org-use-fast-todo-selection) | 13434 | (org-fast-todo-selection)) |
| 13078 | (not org-todo-key-trigger))) | 13435 | ((and (equal arg '(4)) |
| 13079 | ;; Read a state with completion | 13436 | (or (not org-use-fast-todo-selection) |
| 13080 | (completing-read "State: " (mapcar (lambda(x) (list x)) | 13437 | (not org-todo-key-trigger))) |
| 13081 | org-todo-keywords-1) | 13438 | ;; Read a state with completion |
| 13082 | nil t)) | 13439 | (completing-read "State: " (mapcar (lambda(x) (list x)) |
| 13083 | ((eq arg 'right) | 13440 | org-todo-keywords-1) |
| 13084 | (if this | 13441 | nil t)) |
| 13085 | (if tail (car tail) nil) | 13442 | ((eq arg 'right) |
| 13086 | (car org-todo-keywords-1))) | ||
| 13087 | ((eq arg 'left) | ||
| 13088 | (if (equal member org-todo-keywords-1) | ||
| 13089 | nil | ||
| 13090 | (if this | 13443 | (if this |
| 13091 | (nth (- (length org-todo-keywords-1) (length tail) 2) | 13444 | (if tail (car tail) nil) |
| 13092 | org-todo-keywords-1) | 13445 | (car org-todo-keywords-1))) |
| 13093 | (org-last org-todo-keywords-1)))) | 13446 | ((eq arg 'left) |
| 13094 | ((and (eq org-use-fast-todo-selection t) (equal arg '(4)) | 13447 | (if (equal member org-todo-keywords-1) |
| 13095 | (setq arg nil))) ; hack to fall back to cycling | 13448 | nil |
| 13096 | (arg | 13449 | (if this |
| 13097 | ;; user or caller requests a specific state | 13450 | (nth (- (length org-todo-keywords-1) (length tail) 2) |
| 13098 | (cond | 13451 | org-todo-keywords-1) |
| 13099 | ((equal arg "") nil) | 13452 | (org-last org-todo-keywords-1)))) |
| 13100 | ((eq arg 'none) nil) | 13453 | ((and (eq org-use-fast-todo-selection t) (equal arg '(4)) |
| 13101 | ((eq arg 'done) (or done-word (car org-done-keywords))) | 13454 | (setq arg nil))) ; hack to fall back to cycling |
| 13102 | ((eq arg 'nextset) | 13455 | (arg |
| 13103 | (or (car (cdr (member head org-todo-heads))) | 13456 | ;; user or caller requests a specific state |
| 13104 | (car org-todo-heads))) | 13457 | (cond |
| 13105 | ((eq arg 'previousset) | 13458 | ((equal arg "") nil) |
| 13106 | (let ((org-todo-heads (reverse org-todo-heads))) | 13459 | ((eq arg 'none) nil) |
| 13460 | ((eq arg 'done) (or done-word (car org-done-keywords))) | ||
| 13461 | ((eq arg 'nextset) | ||
| 13107 | (or (car (cdr (member head org-todo-heads))) | 13462 | (or (car (cdr (member head org-todo-heads))) |
| 13108 | (car org-todo-heads)))) | 13463 | (car org-todo-heads))) |
| 13109 | ((car (member arg org-todo-keywords-1))) | 13464 | ((eq arg 'previousset) |
| 13110 | ((nth (1- (prefix-numeric-value arg)) | 13465 | (let ((org-todo-heads (reverse org-todo-heads))) |
| 13466 | (or (car (cdr (member head org-todo-heads))) | ||
| 13467 | (car org-todo-heads)))) | ||
| 13468 | ((car (member arg org-todo-keywords-1))) | ||
| 13469 | ((nth (1- (prefix-numeric-value arg)) | ||
| 13111 | org-todo-keywords-1)))) | 13470 | org-todo-keywords-1)))) |
| 13112 | ((null member) (or head (car org-todo-keywords-1))) | 13471 | ((null member) (or head (car org-todo-keywords-1))) |
| 13113 | ((equal this final-done-word) nil) ;; -> make empty | 13472 | ((equal this final-done-word) nil) ;; -> make empty |
| 13114 | ((null tail) nil) ;; -> first entry | 13473 | ((null tail) nil) ;; -> first entry |
| 13115 | ((eq interpret 'sequence) | 13474 | ((eq interpret 'sequence) |
| 13116 | (car tail)) | 13475 | (car tail)) |
| 13117 | ((memq interpret '(type priority)) | 13476 | ((memq interpret '(type priority)) |
| 13118 | (if (eq this-command last-command) | 13477 | (if (eq this-command last-command) |
| 13119 | (car tail) | 13478 | (car tail) |
| 13120 | (if (> (length tail) 0) | 13479 | (if (> (length tail) 0) |
| 13121 | (or done-word (car org-done-keywords)) | 13480 | (or done-word (car org-done-keywords)) |
| 13122 | nil))) | 13481 | nil))) |
| 13123 | (t nil))) | 13482 | (t nil))) |
| 13124 | (next (if state (concat " " state " ") " ")) | 13483 | (next (if state (concat " " state " ") " ")) |
| 13125 | dostates) | 13484 | (change-plist (list :type 'todo-state-change :from this :to state |
| 13126 | (replace-match next t t) | 13485 | :position startpos)) |
| 13127 | (unless (pos-visible-in-window-p hl-pos) | 13486 | dostates) |
| 13128 | (message "TODO state changed to %s" (org-trim next))) | 13487 | (when org-blocker-hook |
| 13129 | (unless head | 13488 | (unless (save-excursion |
| 13130 | (setq head (org-get-todo-sequence-head state) | 13489 | (save-match-data |
| 13131 | ass (assoc head org-todo-kwd-alist) | 13490 | (run-hook-with-args-until-failure |
| 13132 | interpret (nth 1 ass) | 13491 | 'org-blocker-hook change-plist))) |
| 13133 | done-word (nth 3 ass) | 13492 | (if (interactive-p) |
| 13134 | final-done-word (nth 4 ass))) | 13493 | (error "TODO state change from %s to %s blocked" this state) |
| 13135 | (when (memq arg '(nextset previousset)) | 13494 | ;; fail silently |
| 13136 | (message "Keyword-Set %d/%d: %s" | 13495 | (message "TODO state change from %s to %s blocked" this state) |
| 13137 | (- (length org-todo-sets) -1 | 13496 | (throw 'exit nil)))) |
| 13138 | (length (memq (assoc state org-todo-sets) org-todo-sets))) | 13497 | (replace-match next t t) |
| 13139 | (length org-todo-sets) | 13498 | (unless (pos-visible-in-window-p hl-pos) |
| 13140 | (mapconcat 'identity (assoc state org-todo-sets) " "))) | 13499 | (message "TODO state changed to %s" (org-trim next))) |
| 13141 | (setq org-last-todo-state-is-todo | 13500 | (unless head |
| 13142 | (not (member state org-done-keywords))) | 13501 | (setq head (org-get-todo-sequence-head state) |
| 13143 | (when (and org-log-done (not (memq arg '(nextset previousset)))) | 13502 | ass (assoc head org-todo-kwd-alist) |
| 13144 | (setq dostates (and (listp org-log-done) (memq 'state org-log-done) | 13503 | interpret (nth 1 ass) |
| 13145 | (or (not org-todo-log-states) | 13504 | done-word (nth 3 ass) |
| 13146 | (member state org-todo-log-states)))) | 13505 | final-done-word (nth 4 ass))) |
| 13147 | 13506 | (when (memq arg '(nextset previousset)) | |
| 13148 | (cond | 13507 | (message "Keyword-Set %d/%d: %s" |
| 13149 | ((and state (member state org-not-done-keywords) | 13508 | (- (length org-todo-sets) -1 |
| 13150 | (not (member this org-not-done-keywords))) | 13509 | (length (memq (assoc state org-todo-sets) org-todo-sets))) |
| 13151 | ;; This is now a todo state and was not one before | 13510 | (length org-todo-sets) |
| 13152 | ;; Remove any CLOSED timestamp, and possibly log the state change | 13511 | (mapconcat 'identity (assoc state org-todo-sets) " "))) |
| 13153 | (org-add-planning-info nil nil 'closed) | 13512 | (setq org-last-todo-state-is-todo |
| 13154 | (and dostates (org-add-log-maybe 'state state 'findpos))) | 13513 | (not (member state org-done-keywords))) |
| 13155 | ((and state dostates) | 13514 | (when (and org-log-done (not (memq arg '(nextset previousset)))) |
| 13156 | ;; This is a non-nil state, and we need to log it | 13515 | (setq dostates (and (listp org-log-done) (memq 'state org-log-done) |
| 13157 | (org-add-log-maybe 'state state 'findpos)) | 13516 | (or (not org-todo-log-states) |
| 13158 | ((and (member state org-done-keywords) | 13517 | (member state org-todo-log-states)))) |
| 13159 | (not (member this org-done-keywords))) | 13518 | |
| 13160 | ;; It is now done, and it was not done before | 13519 | (cond |
| 13161 | (org-add-planning-info 'closed (org-current-time)) | 13520 | ((and state (member state org-not-done-keywords) |
| 13162 | (org-add-log-maybe 'done state 'findpos)))) | 13521 | (not (member this org-not-done-keywords))) |
| 13163 | ;; Fixup tag positioning | 13522 | ;; This is now a todo state and was not one before |
| 13164 | (and org-auto-align-tags (not org-setting-tags) (org-set-tags nil t)) | 13523 | ;; Remove any CLOSED timestamp, and possibly log the state change |
| 13165 | (run-hooks 'org-after-todo-state-change-hook) | 13524 | (org-add-planning-info nil nil 'closed) |
| 13166 | (and (member state org-done-keywords) (org-auto-repeat-maybe)) | 13525 | (and dostates (org-add-log-maybe 'state state 'findpos))) |
| 13167 | (if (and arg (not (member state org-done-keywords))) | 13526 | ((and state dostates) |
| 13168 | (setq head (org-get-todo-sequence-head state))) | 13527 | ;; This is a non-nil state, and we need to log it |
| 13169 | (put-text-property (point-at-bol) (point-at-eol) 'org-todo-head head))) | 13528 | (org-add-log-maybe 'state state 'findpos)) |
| 13170 | ;; Fixup cursor location if close to the keyword | 13529 | ((and (member state org-done-keywords) |
| 13171 | (if (and (outline-on-heading-p) | 13530 | (not (member this org-done-keywords))) |
| 13172 | (not (bolp)) | 13531 | ;; It is now done, and it was not done before |
| 13173 | (save-excursion (beginning-of-line 1) | 13532 | (org-add-planning-info 'closed (org-current-time)) |
| 13174 | (looking-at org-todo-line-regexp)) | 13533 | (org-add-log-maybe 'done state 'findpos)))) |
| 13175 | (< (point) (+ 2 (or (match-end 2) (match-end 1))))) | 13534 | ;; Fixup tag positioning |
| 13176 | (progn | 13535 | (and org-auto-align-tags (not org-setting-tags) (org-set-tags nil t)) |
| 13177 | (goto-char (or (match-end 2) (match-end 1))) | 13536 | (run-hooks 'org-after-todo-state-change-hook) |
| 13178 | (just-one-space)))) | 13537 | (and (member state org-done-keywords) (org-auto-repeat-maybe)) |
| 13538 | (if (and arg (not (member state org-done-keywords))) | ||
| 13539 | (setq head (org-get-todo-sequence-head state))) | ||
| 13540 | (put-text-property (point-at-bol) (point-at-eol) 'org-todo-head head) | ||
| 13541 | ;; Fixup cursor location if close to the keyword | ||
| 13542 | (if (and (outline-on-heading-p) | ||
| 13543 | (not (bolp)) | ||
| 13544 | (save-excursion (beginning-of-line 1) | ||
| 13545 | (looking-at org-todo-line-regexp)) | ||
| 13546 | (< (point) (+ 2 (or (match-end 2) (match-end 1))))) | ||
| 13547 | (progn | ||
| 13548 | (goto-char (or (match-end 2) (match-end 1))) | ||
| 13549 | (just-one-space))) | ||
| 13550 | (when org-trigger-hook | ||
| 13551 | (save-excursion | ||
| 13552 | (run-hook-with-args 'org-trigger-hook change-plist))))))) | ||
| 13179 | 13553 | ||
| 13180 | (defun org-get-todo-sequence-head (kwd) | 13554 | (defun org-get-todo-sequence-head (kwd) |
| 13181 | "Return the head of the TODO sequence to which KWD belongs. | 13555 | "Return the head of the TODO sequence to which KWD belongs. |
| @@ -13202,11 +13576,10 @@ Returns the new TODO keyword, or nil if no state change should occur." | |||
| 13202 | (lambda (x) | 13576 | (lambda (x) |
| 13203 | (if (stringp (car x)) (string-width (car x)) 0)) | 13577 | (if (stringp (car x)) (string-width (car x)) 0)) |
| 13204 | fulltable))) | 13578 | fulltable))) |
| 13205 | (buf (current-buffer)) | ||
| 13206 | (expert nil) | 13579 | (expert nil) |
| 13207 | (fwidth (+ maxlen 3 1 3)) | 13580 | (fwidth (+ maxlen 3 1 3)) |
| 13208 | (ncol (/ (- (window-width) 4) fwidth)) | 13581 | (ncol (/ (- (window-width) 4) fwidth)) |
| 13209 | tg cnt e c char c1 c2 ntable tbl rtn | 13582 | tg cnt e c tbl |
| 13210 | groups ingroup) | 13583 | groups ingroup) |
| 13211 | (save-window-excursion | 13584 | (save-window-excursion |
| 13212 | (if expert | 13585 | (if expert |
| @@ -13216,7 +13589,7 @@ Returns the new TODO keyword, or nil if no state change should occur." | |||
| 13216 | (org-switch-to-buffer-other-window (get-buffer-create " *Org tags*"))) | 13589 | (org-switch-to-buffer-other-window (get-buffer-create " *Org tags*"))) |
| 13217 | (erase-buffer) | 13590 | (erase-buffer) |
| 13218 | (org-set-local 'org-done-keywords done-keywords) | 13591 | (org-set-local 'org-done-keywords done-keywords) |
| 13219 | (setq tbl fulltable char ?a cnt 0) | 13592 | (setq tbl fulltable cnt 0) |
| 13220 | (while (setq e (pop tbl)) | 13593 | (while (setq e (pop tbl)) |
| 13221 | (cond | 13594 | (cond |
| 13222 | ((equal e '(:startgroup)) | 13595 | ((equal e '(:startgroup)) |
| @@ -13469,11 +13842,13 @@ The auto-repeater uses this.") | |||
| 13469 | (org-switch-to-buffer-other-window "*Org Note*") | 13842 | (org-switch-to-buffer-other-window "*Org Note*") |
| 13470 | (erase-buffer) | 13843 | (erase-buffer) |
| 13471 | (let ((org-inhibit-startup t)) (org-mode)) | 13844 | (let ((org-inhibit-startup t)) (org-mode)) |
| 13472 | (insert (format "# Insert note for %s, finish with C-c C-c, or cancel with C-u C-c C-c.\n\n" | 13845 | (insert (format "# Insert note for %s. |
| 13846 | # Finish with C-c C-c, or cancel with C-c C-k.\n\n" | ||
| 13473 | (cond | 13847 | (cond |
| 13474 | ((eq org-log-note-purpose 'clock-out) "stopped clock") | 13848 | ((eq org-log-note-purpose 'clock-out) "stopped clock") |
| 13475 | ((eq org-log-note-purpose 'done) "closed todo item") | 13849 | ((eq org-log-note-purpose 'done) "closed todo item") |
| 13476 | ((eq org-log-note-purpose 'state) "state change") | 13850 | ((eq org-log-note-purpose 'state) |
| 13851 | (format "state change to \"%s\"" org-log-note-state)) | ||
| 13477 | (t (error "This should not happen"))))) | 13852 | (t (error "This should not happen"))))) |
| 13478 | (org-set-local 'org-finish-function 'org-store-log-note)) | 13853 | (org-set-local 'org-finish-function 'org-store-log-note)) |
| 13479 | 13854 | ||
| @@ -13483,8 +13858,8 @@ The auto-repeater uses this.") | |||
| 13483 | (note (cdr (assq org-log-note-purpose org-log-note-headings))) | 13858 | (note (cdr (assq org-log-note-purpose org-log-note-headings))) |
| 13484 | lines ind) | 13859 | lines ind) |
| 13485 | (kill-buffer (current-buffer)) | 13860 | (kill-buffer (current-buffer)) |
| 13486 | (if (string-match "^#.*\n[ \t\n]*" txt) | 13861 | (while (string-match "\\`#.*\n[ \t\n]*" txt) |
| 13487 | (setq txt (replace-match "" t t txt))) | 13862 | (setq txt (replace-match "" t t txt))) |
| 13488 | (if (string-match "\\s-+\\'" txt) | 13863 | (if (string-match "\\s-+\\'" txt) |
| 13489 | (setq txt (replace-match "" t t txt))) | 13864 | (setq txt (replace-match "" t t txt))) |
| 13490 | (setq lines (org-split-string txt "\n")) | 13865 | (setq lines (org-split-string txt "\n")) |
| @@ -13502,7 +13877,7 @@ The auto-repeater uses this.") | |||
| 13502 | ""))))) | 13877 | ""))))) |
| 13503 | (if lines (setq note (concat note " \\\\"))) | 13878 | (if lines (setq note (concat note " \\\\"))) |
| 13504 | (push note lines)) | 13879 | (push note lines)) |
| 13505 | (when current-prefix-arg (setq lines nil)) | 13880 | (when (or current-prefix-arg org-note-abort) (setq lines nil)) |
| 13506 | (when lines | 13881 | (when lines |
| 13507 | (save-excursion | 13882 | (save-excursion |
| 13508 | (set-buffer (marker-buffer org-log-note-marker)) | 13883 | (set-buffer (marker-buffer org-log-note-marker)) |
| @@ -13510,7 +13885,8 @@ The auto-repeater uses this.") | |||
| 13510 | (goto-char org-log-note-marker) | 13885 | (goto-char org-log-note-marker) |
| 13511 | (move-marker org-log-note-marker nil) | 13886 | (move-marker org-log-note-marker nil) |
| 13512 | (end-of-line 1) | 13887 | (end-of-line 1) |
| 13513 | (if (not (bolp)) (insert "\n")) (indent-relative nil) | 13888 | (if (not (bolp)) (let ((inhibit-read-only t)) (insert "\n"))) |
| 13889 | (indent-relative nil) | ||
| 13514 | (insert " - " (pop lines)) | 13890 | (insert " - " (pop lines)) |
| 13515 | (org-indent-line-function) | 13891 | (org-indent-line-function) |
| 13516 | (beginning-of-line 1) | 13892 | (beginning-of-line 1) |
| @@ -13524,6 +13900,41 @@ The auto-repeater uses this.") | |||
| 13524 | (move-marker org-log-note-return-to nil) | 13900 | (move-marker org-log-note-return-to nil) |
| 13525 | (and org-log-post-message (message org-log-post-message))) | 13901 | (and org-log-post-message (message org-log-post-message))) |
| 13526 | 13902 | ||
| 13903 | ;; FIXME: what else would be useful? | ||
| 13904 | ;; - priority | ||
| 13905 | ;; - date | ||
| 13906 | |||
| 13907 | (defun org-sparse-tree (&optional arg) | ||
| 13908 | "Create a sparse tree, prompt for the details. | ||
| 13909 | This command can create sparse trees. You first need to select the type | ||
| 13910 | of match used to create the tree: | ||
| 13911 | |||
| 13912 | t Show entries with a specific TODO keyword. | ||
| 13913 | T Show entries selected by a tags match. | ||
| 13914 | p Enter a property name and its value (both with completion on existing | ||
| 13915 | names/values) and show entries with that property. | ||
| 13916 | r Show entries matching a regular expression" | ||
| 13917 | (interactive "P") | ||
| 13918 | (let (ans kwd value) | ||
| 13919 | (message "Sparse tree: [r]egexp [t]odo-kwd [T]ag [p]roperty") | ||
| 13920 | (setq ans (read-char-exclusive)) | ||
| 13921 | (cond | ||
| 13922 | ((equal ans ?t) | ||
| 13923 | (org-show-todo-tree '(4))) | ||
| 13924 | ((equal ans ?T) | ||
| 13925 | (call-interactively 'org-tags-sparse-tree)) | ||
| 13926 | ((member ans '(?p ?P)) | ||
| 13927 | (setq kwd (completing-read "Property: " | ||
| 13928 | (mapcar 'list (org-buffer-property-keys)))) | ||
| 13929 | (setq value (completing-read "Value: " | ||
| 13930 | (mapcar 'list (org-property-values kwd)))) | ||
| 13931 | (unless (string-match "\\`{.*}\\'" value) | ||
| 13932 | (setq value (concat "\"" value "\""))) | ||
| 13933 | (org-tags-sparse-tree arg (concat kwd "=" value))) | ||
| 13934 | ((member ans '(?r ?R)) | ||
| 13935 | (call-interactively 'org-occur)) | ||
| 13936 | (t (error "No such sparse tree command \"%c\"" ans))))) | ||
| 13937 | |||
| 13527 | (defvar org-occur-highlights nil) | 13938 | (defvar org-occur-highlights nil) |
| 13528 | (make-variable-buffer-local 'org-occur-highlights) | 13939 | (make-variable-buffer-local 'org-occur-highlights) |
| 13529 | 13940 | ||
| @@ -13739,7 +14150,9 @@ are included in the output." | |||
| 13739 | todo marker entry priority) | 14150 | todo marker entry priority) |
| 13740 | (save-excursion | 14151 | (save-excursion |
| 13741 | (goto-char (point-min)) | 14152 | (goto-char (point-min)) |
| 13742 | (when (eq action 'sparse-tree) (org-overview)) | 14153 | (when (eq action 'sparse-tree) |
| 14154 | (org-overview) | ||
| 14155 | (org-remove-occur-highlights)) | ||
| 13743 | (while (re-search-forward re nil t) | 14156 | (while (re-search-forward re nil t) |
| 13744 | (catch :skip | 14157 | (catch :skip |
| 13745 | (setq todo (if (match-end 1) (match-string 2)) | 14158 | (setq todo (if (match-end 1) (match-string 2)) |
| @@ -13769,8 +14182,13 @@ are included in the output." | |||
| 13769 | (not (member org-archive-tag tags-list)))) | 14182 | (not (member org-archive-tag tags-list)))) |
| 13770 | (and (eq action 'agenda) (org-agenda-skip)) | 14183 | (and (eq action 'agenda) (org-agenda-skip)) |
| 13771 | ;; list this headline | 14184 | ;; list this headline |
| 14185 | |||
| 13772 | (if (eq action 'sparse-tree) | 14186 | (if (eq action 'sparse-tree) |
| 13773 | (progn | 14187 | (progn |
| 14188 | (and org-highlight-sparse-tree-matches | ||
| 14189 | (org-get-heading) (match-end 0) | ||
| 14190 | (org-highlight-new-match | ||
| 14191 | (match-beginning 0) (match-beginning 1))) | ||
| 13774 | (org-show-context 'tags-tree)) | 14192 | (org-show-context 'tags-tree)) |
| 13775 | (setq txt (org-format-agenda-item | 14193 | (setq txt (org-format-agenda-item |
| 13776 | "" | 14194 | "" |
| @@ -13806,9 +14224,13 @@ also TODO lines." | |||
| 13806 | 14224 | ||
| 13807 | (defvar org-cached-props nil) | 14225 | (defvar org-cached-props nil) |
| 13808 | (defun org-cached-entry-get (pom property) | 14226 | (defun org-cached-entry-get (pom property) |
| 13809 | (cdr (assoc property (or org-cached-props | 14227 | (if org-use-property-inheritance |
| 13810 | (setq org-cached-props | 14228 | ;; Caching is not possible, check it directly |
| 13811 | (org-entry-properties pom)))))) | 14229 | (org-entry-get pom property 'inherit) |
| 14230 | ;; Get all properties, so that we can do complicated checks easily | ||
| 14231 | (cdr (assoc property (or org-cached-props | ||
| 14232 | (setq org-cached-props | ||
| 14233 | (org-entry-properties pom))))))) | ||
| 13812 | 14234 | ||
| 13813 | (defun org-global-tags-completion-table (&optional files) | 14235 | (defun org-global-tags-completion-table (&optional files) |
| 13814 | "Return the list of all tags in all agenda buffer/files." | 14236 | "Return the list of all tags in all agenda buffer/files." |
| @@ -13834,10 +14256,10 @@ also TODO lines." | |||
| 13834 | (setq match (completing-read | 14256 | (setq match (completing-read |
| 13835 | "Match: " 'org-tags-completion-function nil nil nil | 14257 | "Match: " 'org-tags-completion-function nil nil nil |
| 13836 | 'org-tags-history)))) | 14258 | 'org-tags-history)))) |
| 13837 | 14259 | ||
| 13838 | ;; Parse the string and create a lisp form | 14260 | ;; Parse the string and create a lisp form |
| 13839 | (let ((match0 match) | 14261 | (let ((match0 match) |
| 13840 | (re (org-re "^&?\\([-+:]\\)?\\({[^}]+}\\|LEVEL=\\([0-9]+\\)\\|\\([[:alnum:]]+\\)=\\({[^}]+}\\|\"[^\"]+\"\\)\\|[[:alnum:]_@]+\\)")) | 14262 | (re (org-re "^&?\\([-+:]\\)?\\({[^}]+}\\|LEVEL=\\([0-9]+\\)\\|\\([[:alnum:]_]+\\)=\\({[^}]+}\\|\"[^\"]+\"\\)\\|[[:alnum:]_@]+\\)")) |
| 13841 | minus tag mm | 14263 | minus tag mm |
| 13842 | tagsmatch todomatch tagsmatcher todomatcher kwd matcher | 14264 | tagsmatch todomatch tagsmatcher todomatcher kwd matcher |
| 13843 | orterms term orlist re-p level-p prop-p pn pv) | 14265 | orterms term orlist re-p level-p prop-p pn pv) |
| @@ -13877,7 +14299,7 @@ also TODO lines." | |||
| 13877 | re-p (equal (string-to-char pv) ?{) | 14299 | re-p (equal (string-to-char pv) ?{) |
| 13878 | pv (substring pv 1 -1)) | 14300 | pv (substring pv 1 -1)) |
| 13879 | (if re-p | 14301 | (if re-p |
| 13880 | `(string-match ,pv (org-cached-entry-get nil ,pn)) | 14302 | `(string-match ,pv (or (org-cached-entry-get nil ,pn) "")) |
| 13881 | `(equal ,pv (org-cached-entry-get nil ,pn)))) | 14303 | `(equal ,pv (org-cached-entry-get nil ,pn)))) |
| 13882 | (t `(member ,(downcase tag) tags-list))) | 14304 | (t `(member ,(downcase tag) tags-list))) |
| 13883 | mm (if minus (list 'not mm) mm) | 14305 | mm (if minus (list 'not mm) mm) |
| @@ -13997,12 +14419,12 @@ With prefix ARG, realign all tags in headings in the current buffer." | |||
| 13997 | (while (string-match "[-+&]+" tags) | 14419 | (while (string-match "[-+&]+" tags) |
| 13998 | ;; No boolean logic, just a list | 14420 | ;; No boolean logic, just a list |
| 13999 | (setq tags (replace-match ":" t t tags)))) | 14421 | (setq tags (replace-match ":" t t tags)))) |
| 14000 | 14422 | ||
| 14001 | (if (string-match "\\`[\t ]*\\'" tags) | 14423 | (if (string-match "\\`[\t ]*\\'" tags) |
| 14002 | (setq tags "") | 14424 | (setq tags "") |
| 14003 | (unless (string-match ":$" tags) (setq tags (concat tags ":"))) | 14425 | (unless (string-match ":$" tags) (setq tags (concat tags ":"))) |
| 14004 | (unless (string-match "^:" tags) (setq tags (concat ":" tags)))) | 14426 | (unless (string-match "^:" tags) (setq tags (concat ":" tags)))) |
| 14005 | 14427 | ||
| 14006 | ;; Insert new tags at the correct column | 14428 | ;; Insert new tags at the correct column |
| 14007 | (beginning-of-line 1) | 14429 | (beginning-of-line 1) |
| 14008 | (cond | 14430 | (cond |
| @@ -14269,9 +14691,9 @@ Returns the new tags string, or nil to not change the current settings." | |||
| 14269 | (setq current (delete tg current)) | 14691 | (setq current (delete tg current)) |
| 14270 | (loop for g in groups do | 14692 | (loop for g in groups do |
| 14271 | (if (member tg g) | 14693 | (if (member tg g) |
| 14272 | (mapc (lambda (x) | 14694 | (mapcar (lambda (x) |
| 14273 | (setq current (delete x current))) | 14695 | (setq current (delete x current))) |
| 14274 | g))) | 14696 | g))) |
| 14275 | (push tg current)) | 14697 | (push tg current)) |
| 14276 | (if exit-after-next (setq exit-after-next 'now)))) | 14698 | (if exit-after-next (setq exit-after-next 'now)))) |
| 14277 | 14699 | ||
| @@ -14321,7 +14743,7 @@ Returns the new tags string, or nil to not change the current settings." | |||
| 14321 | (let (tags) | 14743 | (let (tags) |
| 14322 | (save-excursion | 14744 | (save-excursion |
| 14323 | (goto-char (point-min)) | 14745 | (goto-char (point-min)) |
| 14324 | (while (re-search-forward | 14746 | (while (re-search-forward |
| 14325 | (org-re "[ \t]:\\([[:alnum:]_@:]+\\):[ \t\r\n]") nil t) | 14747 | (org-re "[ \t]:\\([[:alnum:]_@:]+\\):[ \t\r\n]") nil t) |
| 14326 | (when (equal (char-after (point-at-bol 0)) ?*) | 14748 | (when (equal (char-after (point-at-bol 0)) ?*) |
| 14327 | (mapc (lambda (x) (add-to-list 'tags x)) | 14749 | (mapc (lambda (x) (add-to-list 'tags x)) |
| @@ -14340,6 +14762,12 @@ Returns the new tags string, or nil to not change the current settings." | |||
| 14340 | These are properties that are not defined in the property drawer, | 14762 | These are properties that are not defined in the property drawer, |
| 14341 | but in some other way.") | 14763 | but in some other way.") |
| 14342 | 14764 | ||
| 14765 | (defconst org-default-properties | ||
| 14766 | '("ARCHIVE" "CATEGORY" "SUMMARY" "DESCRIPTION" | ||
| 14767 | "LOCATION" "LOGGING" "COLUMNS") | ||
| 14768 | "Some properties that are used by Org-mode for various purposes. | ||
| 14769 | Being in this list makes sure that they are offered for completion.") | ||
| 14770 | |||
| 14343 | (defconst org-property-start-re "^[ \t]*:PROPERTIES:[ \t]*$" | 14771 | (defconst org-property-start-re "^[ \t]*:PROPERTIES:[ \t]*$" |
| 14344 | "Regular expression matching the first line of a property drawer.") | 14772 | "Regular expression matching the first line of a property drawer.") |
| 14345 | 14773 | ||
| @@ -14349,9 +14777,8 @@ but in some other way.") | |||
| 14349 | (defun org-property-action () | 14777 | (defun org-property-action () |
| 14350 | "Do an action on properties." | 14778 | "Do an action on properties." |
| 14351 | (interactive) | 14779 | (interactive) |
| 14352 | (let (c prop) | 14780 | (let (c) |
| 14353 | (org-at-property-p) | 14781 | (org-at-property-p) |
| 14354 | (setq prop (match-string 2)) | ||
| 14355 | (message "Property Action: [s]et [d]elete [D]elete globally [c]ompute") | 14782 | (message "Property Action: [s]et [d]elete [D]elete globally [c]ompute") |
| 14356 | (setq c (read-char-exclusive)) | 14783 | (setq c (read-char-exclusive)) |
| 14357 | (cond | 14784 | (cond |
| @@ -14469,7 +14896,7 @@ If WHICH is nil or `all', get all properties. If WHICH is | |||
| 14469 | (unless (member key excluded) | 14896 | (unless (member key excluded) |
| 14470 | (push (cons key (or value "")) props))))) | 14897 | (push (cons key (or value "")) props))))) |
| 14471 | (append sum-props (nreverse props))))))) | 14898 | (append sum-props (nreverse props))))))) |
| 14472 | 14899 | ||
| 14473 | (defun org-entry-get (pom property &optional inherit) | 14900 | (defun org-entry-get (pom property &optional inherit) |
| 14474 | "Get value of PROPERTY for entry at point-or-marker POM. | 14901 | "Get value of PROPERTY for entry at point-or-marker POM. |
| 14475 | If INHERIT is non-nil and the entry does not have the property, | 14902 | If INHERIT is non-nil and the entry does not have the property, |
| @@ -14509,22 +14936,50 @@ If the property is not present at all, nil is returned." | |||
| 14509 | t) | 14936 | t) |
| 14510 | nil))))) | 14937 | nil))))) |
| 14511 | 14938 | ||
| 14939 | ;; Multi-values properties are properties that contain multiple values | ||
| 14940 | ;; These values are assumed to be single words, separated by whitespace. | ||
| 14941 | (defun org-entry-add-to-multivalued-property (pom property value) | ||
| 14942 | "Add VALUE to the words in the PROPERTY in entry at point-or-marker POM." | ||
| 14943 | (let* ((old (org-entry-get pom property)) | ||
| 14944 | (values (and old (org-split-string old "[ \t]")))) | ||
| 14945 | (unless (member value values) | ||
| 14946 | (setq values (cons value values)) | ||
| 14947 | (org-entry-put pom property | ||
| 14948 | (mapconcat 'identity values " "))))) | ||
| 14949 | |||
| 14950 | (defun org-entry-remove-from-multivalued-property (pom property value) | ||
| 14951 | "Remove VALUE from words in the PROPERTY in entry at point-or-marker POM." | ||
| 14952 | (let* ((old (org-entry-get pom property)) | ||
| 14953 | (values (and old (org-split-string old "[ \t]")))) | ||
| 14954 | (when (member value values) | ||
| 14955 | (setq values (delete value values)) | ||
| 14956 | (org-entry-put pom property | ||
| 14957 | (mapconcat 'identity values " "))))) | ||
| 14958 | |||
| 14959 | (defun org-entry-member-in-multivalued-property (pom property value) | ||
| 14960 | "Is VALUE one of the words in the PROPERTY in entry at point-or-marker POM?" | ||
| 14961 | (let* ((old (org-entry-get pom property)) | ||
| 14962 | (values (and old (org-split-string old "[ \t]")))) | ||
| 14963 | (member value values))) | ||
| 14964 | |||
| 14512 | (defvar org-entry-property-inherited-from (make-marker)) | 14965 | (defvar org-entry-property-inherited-from (make-marker)) |
| 14513 | 14966 | ||
| 14514 | (defun org-entry-get-with-inheritance (property) | 14967 | (defun org-entry-get-with-inheritance (property) |
| 14515 | "Get entry property, and search higher levels if not present." | 14968 | "Get entry property, and search higher levels if not present." |
| 14516 | (let (tmp) | 14969 | (let (tmp) |
| 14517 | (save-excursion | 14970 | (save-excursion |
| 14518 | (catch 'ex | 14971 | (save-restriction |
| 14519 | (while t | 14972 | (widen) |
| 14520 | (when (setq tmp (org-entry-get nil property)) | 14973 | (catch 'ex |
| 14521 | (org-back-to-heading t) | 14974 | (while t |
| 14522 | (move-marker org-entry-property-inherited-from (point)) | 14975 | (when (setq tmp (org-entry-get nil property)) |
| 14523 | (throw 'ex tmp)) | 14976 | (org-back-to-heading t) |
| 14524 | (or (org-up-heading-safe) (throw 'ex nil))))) | 14977 | (move-marker org-entry-property-inherited-from (point)) |
| 14525 | (or tmp (cdr (assoc property org-local-properties)) | 14978 | (throw 'ex tmp)) |
| 14526 | (cdr (assoc property org-global-properties))))) | 14979 | (or (org-up-heading-safe) (throw 'ex nil))))) |
| 14527 | 14980 | (or tmp (cdr (assoc property org-local-properties)) | |
| 14981 | (cdr (assoc property org-global-properties)))))) | ||
| 14982 | |||
| 14528 | (defun org-entry-put (pom property value) | 14983 | (defun org-entry-put (pom property value) |
| 14529 | "Set PROPERTY to VALUE for entry at point-or-marker POM." | 14984 | "Set PROPERTY to VALUE for entry at point-or-marker POM." |
| 14530 | (org-with-point-at pom | 14985 | (org-with-point-at pom |
| @@ -14598,18 +15053,34 @@ internally: ARCHIVE, CATEGORY, SUMMARY, DESCRIPTION, LOCATION, and LOGGING." | |||
| 14598 | (cdr range) t) | 15053 | (cdr range) t) |
| 14599 | (add-to-list 'rtn (org-match-string-no-properties 1))) | 15054 | (add-to-list 'rtn (org-match-string-no-properties 1))) |
| 14600 | (outline-next-heading)))) | 15055 | (outline-next-heading)))) |
| 15056 | |||
| 14601 | (when include-specials | 15057 | (when include-specials |
| 14602 | (setq rtn (append org-special-properties rtn))) | 15058 | (setq rtn (append org-special-properties rtn))) |
| 15059 | |||
| 14603 | (when include-defaults | 15060 | (when include-defaults |
| 14604 | (add-to-list rtn "CATEGORY") | 15061 | (mapc (lambda (x) (add-to-list 'rtn x)) org-default-properties)) |
| 14605 | (add-to-list rtn "ARCHIVE")) | 15062 | |
| 14606 | (sort rtn (lambda (a b) (string< (upcase a) (upcase b)))))) | 15063 | (sort rtn (lambda (a b) (string< (upcase a) (upcase b)))))) |
| 14607 | 15064 | ||
| 15065 | (defun org-property-values (key) | ||
| 15066 | "Return a list of all values of property KEY." | ||
| 15067 | (save-excursion | ||
| 15068 | (save-restriction | ||
| 15069 | (widen) | ||
| 15070 | (goto-char (point-min)) | ||
| 15071 | (let ((re (concat "^[ \t]*:" key ":[ \t]*\\(\\S-.*\\)")) | ||
| 15072 | values) | ||
| 15073 | (while (re-search-forward re nil t) | ||
| 15074 | (add-to-list 'values (org-trim (match-string 1)))) | ||
| 15075 | (delete "" values))))) | ||
| 15076 | |||
| 14608 | (defun org-insert-property-drawer () | 15077 | (defun org-insert-property-drawer () |
| 14609 | "Insert a property drawer into the current entry." | 15078 | "Insert a property drawer into the current entry." |
| 14610 | (interactive) | 15079 | (interactive) |
| 14611 | (org-back-to-heading t) | 15080 | (org-back-to-heading t) |
| 14612 | (let ((beg (point)) | 15081 | (looking-at outline-regexp) |
| 15082 | (let ((indent (- (match-end 0)(match-beginning 0))) | ||
| 15083 | (beg (point)) | ||
| 14613 | (re (concat "^[ \t]*" org-keyword-time-regexp)) | 15084 | (re (concat "^[ \t]*" org-keyword-time-regexp)) |
| 14614 | end hiddenp) | 15085 | end hiddenp) |
| 14615 | (outline-next-heading) | 15086 | (outline-next-heading) |
| @@ -14618,14 +15089,14 @@ internally: ARCHIVE, CATEGORY, SUMMARY, DESCRIPTION, LOCATION, and LOGGING." | |||
| 14618 | (while (re-search-forward re end t)) | 15089 | (while (re-search-forward re end t)) |
| 14619 | (setq hiddenp (org-invisible-p)) | 15090 | (setq hiddenp (org-invisible-p)) |
| 14620 | (end-of-line 1) | 15091 | (end-of-line 1) |
| 14621 | (and (= (char-after) ?\n) (forward-char 1)) | 15092 | (and (equal (char-after) ?\n) (forward-char 1)) |
| 14622 | (org-skip-over-state-notes) | 15093 | (org-skip-over-state-notes) |
| 14623 | (end-of-line 0) | 15094 | (skip-chars-backward " \t\n\r") |
| 14624 | (insert "\n:PROPERTIES:\n:END:") | 15095 | (let ((inhibit-read-only t)) (insert "\n:PROPERTIES:\n:END:")) |
| 14625 | (beginning-of-line 0) | 15096 | (beginning-of-line 0) |
| 14626 | (org-indent-line-function) | 15097 | (indent-to-column indent) |
| 14627 | (beginning-of-line 2) | 15098 | (beginning-of-line 2) |
| 14628 | (org-indent-line-function) | 15099 | (indent-to-column indent) |
| 14629 | (beginning-of-line 0) | 15100 | (beginning-of-line 0) |
| 14630 | (if hiddenp | 15101 | (if hiddenp |
| 14631 | (save-excursion | 15102 | (save-excursion |
| @@ -14634,19 +15105,25 @@ internally: ARCHIVE, CATEGORY, SUMMARY, DESCRIPTION, LOCATION, and LOGGING." | |||
| 14634 | (org-flag-drawer t)))) | 15105 | (org-flag-drawer t)))) |
| 14635 | 15106 | ||
| 14636 | (defun org-set-property (property value) | 15107 | (defun org-set-property (property value) |
| 14637 | "In the current entry, set PROPERTY to VALUE." | 15108 | "In the current entry, set PROPERTY to VALUE. |
| 15109 | When called interactively, this will prompt for a property name, offering | ||
| 15110 | completion on existing and default properties. And then it will prompt | ||
| 15111 | for a value, offering competion either on allowed values (via an inherited | ||
| 15112 | xxx_ALL property) or on existing values in other instances of this property | ||
| 15113 | in the current file." | ||
| 14638 | (interactive | 15114 | (interactive |
| 14639 | (let* ((prop (completing-read "Property: " | 15115 | (let* ((prop (completing-read |
| 14640 | (mapcar 'list (org-buffer-property-keys)))) | 15116 | "Property: " (mapcar 'list (org-buffer-property-keys nil t)))) |
| 14641 | (cur (org-entry-get nil prop)) | 15117 | (cur (org-entry-get nil prop)) |
| 14642 | (allowed (org-property-get-allowed-values nil prop 'table)) | 15118 | (allowed (org-property-get-allowed-values nil prop 'table)) |
| 15119 | (existing (mapcar 'list (org-property-values prop))) | ||
| 14643 | (val (if allowed | 15120 | (val (if allowed |
| 14644 | (completing-read "Value: " allowed nil 'req-match) | 15121 | (completing-read "Value: " allowed nil 'req-match) |
| 14645 | (read-string | 15122 | (completing-read |
| 14646 | (concat "Value" (if (and cur (string-match "\\S-" cur)) | 15123 | (concat "Value" (if (and cur (string-match "\\S-" cur)) |
| 14647 | (concat "[" cur "]") "") | 15124 | (concat "[" cur "]") "") |
| 14648 | ": ") | 15125 | ": ") |
| 14649 | "" cur)))) | 15126 | existing nil nil "" nil cur)))) |
| 14650 | (list prop (if (equal val "") cur val)))) | 15127 | (list prop (if (equal val "") cur val)))) |
| 14651 | (unless (equal (org-entry-get nil property) value) | 15128 | (unless (equal (org-entry-get nil property) value) |
| 14652 | (org-entry-put nil property value))) | 15129 | (org-entry-put nil property value))) |
| @@ -14657,7 +15134,7 @@ internally: ARCHIVE, CATEGORY, SUMMARY, DESCRIPTION, LOCATION, and LOGGING." | |||
| 14657 | (let* ((prop (completing-read | 15134 | (let* ((prop (completing-read |
| 14658 | "Property: " (org-entry-properties nil 'standard)))) | 15135 | "Property: " (org-entry-properties nil 'standard)))) |
| 14659 | (list prop))) | 15136 | (list prop))) |
| 14660 | (message (concat "Property " property | 15137 | (message (concat "Property " property |
| 14661 | (if (org-entry-delete nil property) | 15138 | (if (org-entry-delete nil property) |
| 14662 | " deleted" | 15139 | " deleted" |
| 14663 | " was not present in the entry")))) | 15140 | " was not present in the entry")))) |
| @@ -14666,7 +15143,7 @@ internally: ARCHIVE, CATEGORY, SUMMARY, DESCRIPTION, LOCATION, and LOGGING." | |||
| 14666 | "Remove PROPERTY globally, from all entries." | 15143 | "Remove PROPERTY globally, from all entries." |
| 14667 | (interactive | 15144 | (interactive |
| 14668 | (let* ((prop (completing-read | 15145 | (let* ((prop (completing-read |
| 14669 | "Globally remove property: " | 15146 | "Globally remove property: " |
| 14670 | (mapcar 'list (org-buffer-property-keys))))) | 15147 | (mapcar 'list (org-buffer-property-keys))))) |
| 14671 | (list prop))) | 15148 | (list prop))) |
| 14672 | (save-excursion | 15149 | (save-excursion |
| @@ -14703,7 +15180,7 @@ completion." | |||
| 14703 | (let (vals) | 15180 | (let (vals) |
| 14704 | (cond | 15181 | (cond |
| 14705 | ((equal property "TODO") | 15182 | ((equal property "TODO") |
| 14706 | (setq vals (org-with-point-at pom | 15183 | (setq vals (org-with-point-at pom |
| 14707 | (append org-todo-keywords-1 '(""))))) | 15184 | (append org-todo-keywords-1 '(""))))) |
| 14708 | ((equal property "PRIORITY") | 15185 | ((equal property "PRIORITY") |
| 14709 | (let ((n org-lowest-priority)) | 15186 | (let ((n org-lowest-priority)) |
| @@ -14713,7 +15190,7 @@ completion." | |||
| 14713 | ((member property org-special-properties)) | 15190 | ((member property org-special-properties)) |
| 14714 | (t | 15191 | (t |
| 14715 | (setq vals (org-entry-get pom (concat property "_ALL") 'inherit)) | 15192 | (setq vals (org-entry-get pom (concat property "_ALL") 'inherit)) |
| 14716 | 15193 | ||
| 14717 | (when (and vals (string-match "\\S-" vals)) | 15194 | (when (and vals (string-match "\\S-" vals)) |
| 14718 | (setq vals (car (read-from-string (concat "(" vals ")")))) | 15195 | (setq vals (car (read-from-string (concat "(" vals ")")))) |
| 14719 | (setq vals (mapcar (lambda (x) | 15196 | (setq vals (mapcar (lambda (x) |
| @@ -14754,6 +15231,26 @@ completion." | |||
| 14754 | (beginning-of-line 1) | 15231 | (beginning-of-line 1) |
| 14755 | (skip-chars-forward " \t"))) | 15232 | (skip-chars-forward " \t"))) |
| 14756 | 15233 | ||
| 15234 | (defun org-find-entry-with-id (ident) | ||
| 15235 | "Locate the entry that contains the ID property with exact value IDENT. | ||
| 15236 | IDENT can be a string, a symbol or a number, this function will search for | ||
| 15237 | the string representation of it. | ||
| 15238 | Return the position where this entry starts, or nil if there is no such entry." | ||
| 15239 | (let ((id (cond | ||
| 15240 | ((stringp ident) ident) | ||
| 15241 | ((symbol-name ident) (symbol-name ident)) | ||
| 15242 | ((numberp ident) (number-to-string ident)) | ||
| 15243 | (t (error "IDENT %s must be a string, symbol or number" ident)))) | ||
| 15244 | (case-fold-search nil)) | ||
| 15245 | (save-excursion | ||
| 15246 | (save-restriction | ||
| 15247 | (goto-char (point-min)) | ||
| 15248 | (when (re-search-forward | ||
| 15249 | (concat "^[ \t]*:ID:[ \t]+" (regexp-quote id) "[ \t]*$") | ||
| 15250 | nil t) | ||
| 15251 | (org-back-to-heading) | ||
| 15252 | (point)))))) | ||
| 15253 | |||
| 14757 | ;;; Column View | 15254 | ;;; Column View |
| 14758 | 15255 | ||
| 14759 | (defvar org-columns-overlays nil | 15256 | (defvar org-columns-overlays nil |
| @@ -14764,6 +15261,8 @@ completion." | |||
| 14764 | (defvar org-columns-current-fmt-compiled nil | 15261 | (defvar org-columns-current-fmt-compiled nil |
| 14765 | "Local variable, holds the currently active column format. | 15262 | "Local variable, holds the currently active column format. |
| 14766 | This is the compiled version of the format.") | 15263 | This is the compiled version of the format.") |
| 15264 | (defvar org-columns-current-widths nil | ||
| 15265 | "Loval variable, holds the currently widths of fields.") | ||
| 14767 | (defvar org-columns-current-maxwidths nil | 15266 | (defvar org-columns-current-maxwidths nil |
| 14768 | "Loval variable, holds the currently active maximum column widths.") | 15267 | "Loval variable, holds the currently active maximum column widths.") |
| 14769 | (defvar org-columns-begin-marker (make-marker) | 15268 | (defvar org-columns-begin-marker (make-marker) |
| @@ -14783,16 +15282,18 @@ This is the compiled version of the format.") | |||
| 14783 | (org-defkey org-columns-map "c" 'org-columns-content) | 15282 | (org-defkey org-columns-map "c" 'org-columns-content) |
| 14784 | (org-defkey org-columns-map "o" 'org-overview) | 15283 | (org-defkey org-columns-map "o" 'org-overview) |
| 14785 | (org-defkey org-columns-map "e" 'org-columns-edit-value) | 15284 | (org-defkey org-columns-map "e" 'org-columns-edit-value) |
| 15285 | (org-defkey org-columns-map "\C-c\C-t" 'org-columns-todo) | ||
| 15286 | (org-defkey org-columns-map "\C-c\C-c" 'org-columns-set-tags-or-toggle) | ||
| 14786 | (org-defkey org-columns-map "v" 'org-columns-show-value) | 15287 | (org-defkey org-columns-map "v" 'org-columns-show-value) |
| 14787 | (org-defkey org-columns-map "q" 'org-columns-quit) | 15288 | (org-defkey org-columns-map "q" 'org-columns-quit) |
| 14788 | (org-defkey org-columns-map "r" 'org-columns-redo) | 15289 | (org-defkey org-columns-map "r" 'org-columns-redo) |
| 14789 | (org-defkey org-columns-map [left] 'backward-char) | 15290 | (org-defkey org-columns-map [left] 'backward-char) |
| 15291 | (org-defkey org-columns-map "\M-b" 'backward-char) | ||
| 14790 | (org-defkey org-columns-map "a" 'org-columns-edit-allowed) | 15292 | (org-defkey org-columns-map "a" 'org-columns-edit-allowed) |
| 14791 | (org-defkey org-columns-map "s" 'org-columns-edit-attributes) | 15293 | (org-defkey org-columns-map "s" 'org-columns-edit-attributes) |
| 14792 | (org-defkey org-columns-map [right] 'forward-char) | 15294 | (org-defkey org-columns-map "\M-f" (lambda () (interactive) (goto-char (1+ (point))))) |
| 14793 | (org-defkey org-columns-map [right] (lambda () (interactive) (goto-char (1+ (point))))) | 15295 | (org-defkey org-columns-map [right] (lambda () (interactive) (goto-char (1+ (point))))) |
| 14794 | (org-defkey org-columns-map [(shift right)] 'org-columns-next-allowed-value) | 15296 | (org-defkey org-columns-map [(shift right)] 'org-columns-next-allowed-value) |
| 14795 | (org-defkey org-columns-map "\C-c\C-c" 'org-columns-next-allowed-value) | ||
| 14796 | (org-defkey org-columns-map "n" 'org-columns-next-allowed-value) | 15297 | (org-defkey org-columns-map "n" 'org-columns-next-allowed-value) |
| 14797 | (org-defkey org-columns-map [(shift left)] 'org-columns-previous-allowed-value) | 15298 | (org-defkey org-columns-map [(shift left)] 'org-columns-previous-allowed-value) |
| 14798 | (org-defkey org-columns-map "p" 'org-columns-previous-allowed-value) | 15299 | (org-defkey org-columns-map "p" 'org-columns-previous-allowed-value) |
| @@ -14843,9 +15344,9 @@ This is the compiled version of the format.") | |||
| 14843 | (beginning-of-line 1) | 15344 | (beginning-of-line 1) |
| 14844 | (and (looking-at "\\(\\**\\)\\(\\* \\)") | 15345 | (and (looking-at "\\(\\**\\)\\(\\* \\)") |
| 14845 | (org-get-level-face 2)))) | 15346 | (org-get-level-face 2)))) |
| 14846 | (color (list :foreground | 15347 | (color (list :foreground |
| 14847 | (face-attribute (or level-face 'default) :foreground))) | 15348 | (face-attribute (or level-face 'default) :foreground))) |
| 14848 | props pom property ass width f string ov column) | 15349 | props pom property ass width f string ov column val modval) |
| 14849 | ;; Check if the entry is in another buffer. | 15350 | ;; Check if the entry is in another buffer. |
| 14850 | (unless props | 15351 | (unless props |
| 14851 | (if (eq major-mode 'org-agenda-mode) | 15352 | (if (eq major-mode 'org-agenda-mode) |
| @@ -14865,9 +15366,13 @@ This is the compiled version of the format.") | |||
| 14865 | (point-at-bol) (point-at-eol)))))) | 15366 | (point-at-bol) (point-at-eol)))))) |
| 14866 | (assoc property props)) | 15367 | (assoc property props)) |
| 14867 | width (or (cdr (assoc property org-columns-current-maxwidths)) | 15368 | width (or (cdr (assoc property org-columns-current-maxwidths)) |
| 14868 | (nth 2 column)) | 15369 | (nth 2 column) |
| 15370 | (length property)) | ||
| 14869 | f (format "%%-%d.%ds | " width width) | 15371 | f (format "%%-%d.%ds | " width width) |
| 14870 | string (format f (or (cdr ass) ""))) | 15372 | val (or (cdr ass) "") |
| 15373 | modval (if (equal property "ITEM") | ||
| 15374 | (org-columns-cleanup-item val org-columns-current-fmt-compiled)) | ||
| 15375 | string (format f (or modval val))) | ||
| 14871 | ;; Create the overlay | 15376 | ;; Create the overlay |
| 14872 | (org-unmodified | 15377 | (org-unmodified |
| 14873 | (setq ov (org-columns-new-overlay | 15378 | (setq ov (org-columns-new-overlay |
| @@ -14877,6 +15382,7 @@ This is the compiled version of the format.") | |||
| 14877 | (org-overlay-put ov 'keymap org-columns-map) | 15382 | (org-overlay-put ov 'keymap org-columns-map) |
| 14878 | (org-overlay-put ov 'org-columns-key property) | 15383 | (org-overlay-put ov 'org-columns-key property) |
| 14879 | (org-overlay-put ov 'org-columns-value (cdr ass)) | 15384 | (org-overlay-put ov 'org-columns-value (cdr ass)) |
| 15385 | (org-overlay-put ov 'org-columns-value-modified modval) | ||
| 14880 | (org-overlay-put ov 'org-columns-pom pom) | 15386 | (org-overlay-put ov 'org-columns-pom pom) |
| 14881 | (org-overlay-put ov 'org-columns-format f)) | 15387 | (org-overlay-put ov 'org-columns-format f)) |
| 14882 | (if (or (not (char-after beg)) | 15388 | (if (or (not (char-after beg)) |
| @@ -14884,7 +15390,7 @@ This is the compiled version of the format.") | |||
| 14884 | (let ((inhibit-read-only t)) | 15390 | (let ((inhibit-read-only t)) |
| 14885 | (save-excursion | 15391 | (save-excursion |
| 14886 | (goto-char beg) | 15392 | (goto-char beg) |
| 14887 | (insert " "))))) | 15393 | (org-unmodified (insert " ")))))) ;; FIXME: add props and remove later? |
| 14888 | ;; Make the rest of the line disappear. | 15394 | ;; Make the rest of the line disappear. |
| 14889 | (org-unmodified | 15395 | (org-unmodified |
| 14890 | (setq ov (org-columns-new-overlay beg (point-at-eol))) | 15396 | (setq ov (org-columns-new-overlay beg (point-at-eol))) |
| @@ -14905,18 +15411,21 @@ This is the compiled version of the format.") | |||
| 14905 | (defvar org-columns-inhibit-recalculation nil | 15411 | (defvar org-columns-inhibit-recalculation nil |
| 14906 | "Inhibit recomputing of columns on column view startup.") | 15412 | "Inhibit recomputing of columns on column view startup.") |
| 14907 | 15413 | ||
| 15414 | |||
| 14908 | (defvar header-line-format) | 15415 | (defvar header-line-format) |
| 14909 | (defun org-columns-display-here-title () | 15416 | (defun org-columns-display-here-title () |
| 14910 | "Overlay the newline before the current line with the table title." | 15417 | "Overlay the newline before the current line with the table title." |
| 14911 | (interactive) | 15418 | (interactive) |
| 14912 | (let ((fmt org-columns-current-fmt-compiled) | 15419 | (let ((fmt org-columns-current-fmt-compiled) |
| 14913 | string (title "") | 15420 | string (title "") |
| 14914 | property width f column str) | 15421 | property width f column str widths) |
| 14915 | (while (setq column (pop fmt)) | 15422 | (while (setq column (pop fmt)) |
| 14916 | (setq property (car column) | 15423 | (setq property (car column) |
| 14917 | str (or (nth 1 column) property) | 15424 | str (or (nth 1 column) property) |
| 14918 | width (or (cdr (assoc property org-columns-current-maxwidths)) | 15425 | width (or (cdr (assoc property org-columns-current-maxwidths)) |
| 14919 | (nth 2 column)) | 15426 | (nth 2 column) |
| 15427 | (length str)) | ||
| 15428 | widths (push width widths) | ||
| 14920 | f (format "%%-%d.%ds | " width width) | 15429 | f (format "%%-%d.%ds | " width width) |
| 14921 | string (format f str) | 15430 | string (format f str) |
| 14922 | title (concat title string))) | 15431 | title (concat title string))) |
| @@ -14924,6 +15433,7 @@ This is the compiled version of the format.") | |||
| 14924 | (org-add-props " " nil 'display '(space :align-to 0)) | 15433 | (org-add-props " " nil 'display '(space :align-to 0)) |
| 14925 | (org-add-props title nil 'face '(:weight bold :underline t)))) | 15434 | (org-add-props title nil 'face '(:weight bold :underline t)))) |
| 14926 | (org-set-local 'org-previous-header-line-format header-line-format) | 15435 | (org-set-local 'org-previous-header-line-format header-line-format) |
| 15436 | (org-set-local 'org-columns-current-widths (nreverse widths)) | ||
| 14927 | (setq header-line-format title))) | 15437 | (setq header-line-format title))) |
| 14928 | 15438 | ||
| 14929 | (defun org-columns-remove-overlays () | 15439 | (defun org-columns-remove-overlays () |
| @@ -14942,6 +15452,19 @@ This is the compiled version of the format.") | |||
| 14942 | (let ((inhibit-read-only t)) | 15452 | (let ((inhibit-read-only t)) |
| 14943 | (remove-text-properties (point-min) (point-max) '(read-only t))))))) | 15453 | (remove-text-properties (point-min) (point-max) '(read-only t))))))) |
| 14944 | 15454 | ||
| 15455 | (defun org-columns-cleanup-item (item fmt) | ||
| 15456 | "Remove from ITEM what is a column in the format FMT." | ||
| 15457 | (if (not org-complex-heading-regexp) | ||
| 15458 | item | ||
| 15459 | (when (string-match org-complex-heading-regexp item) | ||
| 15460 | (concat | ||
| 15461 | (org-add-props (concat (match-string 1 item) " ") nil | ||
| 15462 | 'org-whitespace (* 2 (1- (org-reduced-level (- (match-end 1) (match-beginning 1)))))) | ||
| 15463 | (and (match-end 2) (not (assoc "TODO" fmt)) (concat " " (match-string 2 item))) | ||
| 15464 | (and (match-end 3) (not (assoc "PRIORITY" fmt)) (concat " " (match-string 3 item))) | ||
| 15465 | " " (match-string 4 item) | ||
| 15466 | (and (match-end 5) (not (assoc "TAGS" fmt)) (concat " " (match-string 5 item))))))) | ||
| 15467 | |||
| 14945 | (defun org-columns-show-value () | 15468 | (defun org-columns-show-value () |
| 14946 | "Show the full value of the property." | 15469 | "Show the full value of the property." |
| 14947 | (interactive) | 15470 | (interactive) |
| @@ -14967,13 +15490,27 @@ If yes, throw an error indicating that changing it does not make sense." | |||
| 14967 | (get-char-property 0 'org-computed val)) | 15490 | (get-char-property 0 'org-computed val)) |
| 14968 | (error "This value is computed from the entry's children")))) | 15491 | (error "This value is computed from the entry's children")))) |
| 14969 | 15492 | ||
| 14970 | (defun org-columns-edit-value () | 15493 | (defun org-columns-todo (&optional arg) |
| 15494 | "Change the TODO state during column view." | ||
| 15495 | (interactive "P") | ||
| 15496 | (org-columns-edit-value "TODO")) | ||
| 15497 | |||
| 15498 | (defun org-columns-set-tags-or-toggle (&optional arg) | ||
| 15499 | "Toggle checkbox at point, or set tags for current headline." | ||
| 15500 | (interactive "P") | ||
| 15501 | (if (string-match "\\`\\[[ xX-]\\]\\'" | ||
| 15502 | (get-char-property (point) 'org-columns-value)) | ||
| 15503 | (org-columns-next-allowed-value) | ||
| 15504 | (org-columns-edit-value "TAGS"))) | ||
| 15505 | |||
| 15506 | (defun org-columns-edit-value (&optional key) | ||
| 14971 | "Edit the value of the property at point in column view. | 15507 | "Edit the value of the property at point in column view. |
| 14972 | Where possible, use the standard interface for changing this line." | 15508 | Where possible, use the standard interface for changing this line." |
| 14973 | (interactive) | 15509 | (interactive) |
| 14974 | (org-columns-check-computed) | 15510 | (org-columns-check-computed) |
| 14975 | (let* ((col (current-column)) | 15511 | (let* ((external-key key) |
| 14976 | (key (get-char-property (point) 'org-columns-key)) | 15512 | (col (current-column)) |
| 15513 | (key (or key (get-char-property (point) 'org-columns-key))) | ||
| 14977 | (value (get-char-property (point) 'org-columns-value)) | 15514 | (value (get-char-property (point) 'org-columns-value)) |
| 14978 | (bol (point-at-bol)) (eol (point-at-eol)) | 15515 | (bol (point-at-bol)) (eol (point-at-eol)) |
| 14979 | (pom (or (get-text-property bol 'org-hd-marker) | 15516 | (pom (or (get-text-property bol 'org-hd-marker) |
| @@ -14986,13 +15523,15 @@ Where possible, use the standard interface for changing this line." | |||
| 14986 | x)) | 15523 | x)) |
| 14987 | org-columns-overlays))) | 15524 | org-columns-overlays))) |
| 14988 | nval eval allowed) | 15525 | nval eval allowed) |
| 14989 | (when (equal key "ITEM") | ||
| 14990 | (error "Cannot edit item headline from here")) | ||
| 14991 | |||
| 14992 | (cond | 15526 | (cond |
| 15527 | ((equal key "ITEM") | ||
| 15528 | (setq eval '(org-with-point-at pom | ||
| 15529 | (org-edit-headline)))) | ||
| 14993 | ((equal key "TODO") | 15530 | ((equal key "TODO") |
| 14994 | (setq eval '(org-with-point-at pom | 15531 | (setq eval '(org-with-point-at pom |
| 14995 | (let ((current-prefix-arg '(4))) (org-todo '(4)))))) | 15532 | (let ((current-prefix-arg |
| 15533 | (if external-key current-prefix-arg '(4)))) | ||
| 15534 | (call-interactively 'org-todo))))) | ||
| 14996 | ((equal key "PRIORITY") | 15535 | ((equal key "PRIORITY") |
| 14997 | (setq eval '(org-with-point-at pom | 15536 | (setq eval '(org-with-point-at pom |
| 14998 | (call-interactively 'org-priority)))) | 15537 | (call-interactively 'org-priority)))) |
| @@ -15018,10 +15557,10 @@ Where possible, use the standard interface for changing this line." | |||
| 15018 | (setq eval '(org-entry-put pom key nval))))) | 15557 | (setq eval '(org-entry-put pom key nval))))) |
| 15019 | (when eval | 15558 | (when eval |
| 15020 | (let ((inhibit-read-only t)) | 15559 | (let ((inhibit-read-only t)) |
| 15021 | (remove-text-properties (1- bol) eol '(read-only t)) | 15560 | (remove-text-properties (max (point-min) (1- bol)) eol '(read-only t)) |
| 15022 | (unwind-protect | 15561 | (unwind-protect |
| 15023 | (progn | 15562 | (progn |
| 15024 | (setq org-columns-overlays | 15563 | (setq org-columns-overlays |
| 15025 | (org-delete-all line-overlays org-columns-overlays)) | 15564 | (org-delete-all line-overlays org-columns-overlays)) |
| 15026 | (mapc 'org-delete-overlay line-overlays) | 15565 | (mapc 'org-delete-overlay line-overlays) |
| 15027 | (org-columns-eval eval)) | 15566 | (org-columns-eval eval)) |
| @@ -15030,17 +15569,33 @@ Where possible, use the standard interface for changing this line." | |||
| 15030 | (if (nth 3 (assoc key org-columns-current-fmt-compiled)) | 15569 | (if (nth 3 (assoc key org-columns-current-fmt-compiled)) |
| 15031 | (org-columns-update key)))) | 15570 | (org-columns-update key)))) |
| 15032 | 15571 | ||
| 15572 | (defun org-edit-headline () ; FIXME: this is not columns specific | ||
| 15573 | "Edit the current headline, the part without TODO keyword, TAGS." | ||
| 15574 | (org-back-to-heading) | ||
| 15575 | (when (looking-at org-todo-line-regexp) | ||
| 15576 | (let ((pre (buffer-substring (match-beginning 0) (match-beginning 3))) | ||
| 15577 | (txt (match-string 3)) | ||
| 15578 | (post "") | ||
| 15579 | txt2) | ||
| 15580 | (if (string-match (org-re "[ \t]+:[[:alnum:]:_@]+:[ \t]*$") txt) | ||
| 15581 | (setq post (match-string 0 txt) | ||
| 15582 | txt (substring txt 0 (match-beginning 0)))) | ||
| 15583 | (setq txt2 (read-string "Edit: " txt)) | ||
| 15584 | (when (not (equal txt txt2)) | ||
| 15585 | (beginning-of-line 1) | ||
| 15586 | (insert pre txt2 post) | ||
| 15587 | (delete-region (point) (point-at-eol)) | ||
| 15588 | (org-set-tags nil t))))) | ||
| 15589 | |||
| 15033 | (defun org-columns-edit-allowed () | 15590 | (defun org-columns-edit-allowed () |
| 15034 | "Edit the list of allowed values for the current property." | 15591 | "Edit the list of allowed values for the current property." |
| 15035 | (interactive) | 15592 | (interactive) |
| 15036 | (let* ((col (current-column)) | 15593 | (let* ((key (get-char-property (point) 'org-columns-key)) |
| 15037 | (key (get-char-property (point) 'org-columns-key)) | ||
| 15038 | (key1 (concat key "_ALL")) | 15594 | (key1 (concat key "_ALL")) |
| 15039 | (value (get-char-property (point) 'org-columns-value)) | ||
| 15040 | (allowed (org-entry-get (point) key1 t)) | 15595 | (allowed (org-entry-get (point) key1 t)) |
| 15041 | nval) | 15596 | nval) |
| 15042 | (setq nval (read-string "Allowed: " allowed)) | 15597 | (setq nval (read-string "Allowed: " allowed)) |
| 15043 | (org-entry-put | 15598 | (org-entry-put |
| 15044 | (cond ((marker-position org-entry-property-inherited-from) | 15599 | (cond ((marker-position org-entry-property-inherited-from) |
| 15045 | org-entry-property-inherited-from) | 15600 | org-entry-property-inherited-from) |
| 15046 | ((marker-position org-columns-top-level-marker) | 15601 | ((marker-position org-columns-top-level-marker) |
| @@ -15050,7 +15605,8 @@ Where possible, use the standard interface for changing this line." | |||
| 15050 | (defun org-columns-eval (form) | 15605 | (defun org-columns-eval (form) |
| 15051 | (let (hidep) | 15606 | (let (hidep) |
| 15052 | (save-excursion | 15607 | (save-excursion |
| 15053 | (forward-line 1) | 15608 | (beginning-of-line 1) |
| 15609 | (condition-case nil (next-line 1) (error nil)) | ||
| 15054 | (setq hidep (org-on-heading-p 1))) | 15610 | (setq hidep (org-on-heading-p 1))) |
| 15055 | (eval form) | 15611 | (eval form) |
| 15056 | (and hidep (hide-entry)))) | 15612 | (and hidep (hide-entry)))) |
| @@ -15098,7 +15654,7 @@ Where possible, use the standard interface for changing this line." | |||
| 15098 | (remove-text-properties (1- bol) eol '(read-only t)) | 15654 | (remove-text-properties (1- bol) eol '(read-only t)) |
| 15099 | (unwind-protect | 15655 | (unwind-protect |
| 15100 | (progn | 15656 | (progn |
| 15101 | (setq org-columns-overlays | 15657 | (setq org-columns-overlays |
| 15102 | (org-delete-all line-overlays org-columns-overlays)) | 15658 | (org-delete-all line-overlays org-columns-overlays)) |
| 15103 | (mapc 'org-delete-overlay line-overlays) | 15659 | (mapc 'org-delete-overlay line-overlays) |
| 15104 | (org-columns-eval '(org-entry-put pom key nval))) | 15660 | (org-columns-eval '(org-entry-put pom key nval))) |
| @@ -15114,6 +15670,16 @@ Where possible, use the standard interface for changing this line." | |||
| 15114 | (< emacs-major-version 22)) | 15670 | (< emacs-major-version 22)) |
| 15115 | (error "Emacs 22 is required for the columns feature"))))) | 15671 | (error "Emacs 22 is required for the columns feature"))))) |
| 15116 | 15672 | ||
| 15673 | ;; FIXME: does not yet work | ||
| 15674 | (defun org-columns-follow-link () | ||
| 15675 | (let ((key (get-char-property (point) 'org-columns-key)) | ||
| 15676 | (value (get-char-property (point) 'org-columns-value))) | ||
| 15677 | (if (or (string-match org-bracket-link-regexp value) | ||
| 15678 | (string-match org-angle-link-re value) | ||
| 15679 | (string-match org-plain-link-re value)) | ||
| 15680 | (org-open-at-point) ; fixme | ||
| 15681 | (error "No link in this value")))) | ||
| 15682 | |||
| 15117 | (defun org-columns-get-format-and-top-level () | 15683 | (defun org-columns-get-format-and-top-level () |
| 15118 | (let (fmt) | 15684 | (let (fmt) |
| 15119 | (when (condition-case nil (org-back-to-heading) (error nil)) | 15685 | (when (condition-case nil (org-back-to-heading) (error nil)) |
| @@ -15249,23 +15815,32 @@ Where possible, use the standard interface for changing this line." | |||
| 15249 | (error "Cannot shift this column further to the left")) | 15815 | (error "Cannot shift this column further to the left")) |
| 15250 | (backward-char 1) | 15816 | (backward-char 1) |
| 15251 | (org-columns-move-right) | 15817 | (org-columns-move-right) |
| 15252 | (backward-char 1))) | 15818 | (backward-char 1))) |
| 15253 | 15819 | ||
| 15254 | (defun org-columns-store-format () | 15820 | (defun org-columns-store-format () |
| 15255 | "Store the text version of the current columns format in appropriate place. | 15821 | "Store the text version of the current columns format in appropriate place. |
| 15256 | This is either in the COLUMNS property of the node starting the current column | 15822 | This is either in the COLUMNS property of the node starting the current column |
| 15257 | display, or in the #+COLUMNS line of the current buffer." | 15823 | display, or in the #+COLUMNS line of the current buffer." |
| 15258 | (let (fmt) | 15824 | (let (fmt (cnt 0)) |
| 15259 | (setq fmt (org-columns-uncompile-format org-columns-current-fmt-compiled)) | 15825 | (setq fmt (org-columns-uncompile-format org-columns-current-fmt-compiled)) |
| 15826 | (org-set-local 'org-columns-current-fmt fmt) | ||
| 15260 | (if (marker-position org-columns-top-level-marker) | 15827 | (if (marker-position org-columns-top-level-marker) |
| 15261 | (save-excursion | 15828 | (save-excursion |
| 15262 | (goto-char org-columns-top-level-marker) | 15829 | (goto-char org-columns-top-level-marker) |
| 15263 | (if (org-entry-get nil "COLUMNS") | 15830 | (if (and (org-at-heading-p) |
| 15831 | (org-entry-get nil "COLUMNS")) | ||
| 15264 | (org-entry-put nil "COLUMNS" fmt) | 15832 | (org-entry-put nil "COLUMNS" fmt) |
| 15265 | (goto-char (point-min)) | 15833 | (goto-char (point-min)) |
| 15834 | ;; Overwrite all #+COLUMNS lines.... | ||
| 15266 | (while (re-search-forward "^#\\+COLUMNS:.*" nil t) | 15835 | (while (re-search-forward "^#\\+COLUMNS:.*" nil t) |
| 15267 | (replace-match (concat "#+COLUMNS: " fmt t t))))) | 15836 | (setq cnt (1+ cnt)) |
| 15268 | (setq org-columns-current-fmt fmt)))) | 15837 | (replace-match (concat "#+COLUMNS: " fmt) t t)) |
| 15838 | (unless (> cnt 0) | ||
| 15839 | (goto-char (point-min)) | ||
| 15840 | (or (org-on-heading-p t) (outline-next-heading)) | ||
| 15841 | (let ((inhibit-read-only t)) | ||
| 15842 | (insert-before-markers "#+COLUMNS: " fmt "\n"))) | ||
| 15843 | (org-set-local 'org-columns-default-format fmt)))))) | ||
| 15269 | 15844 | ||
| 15270 | (defvar org-overriding-columns-format nil | 15845 | (defvar org-overriding-columns-format nil |
| 15271 | "When set, overrides any other definition.") | 15846 | "When set, overrides any other definition.") |
| @@ -15347,7 +15922,7 @@ display, or in the #+COLUMNS line of the current buffer." | |||
| 15347 | (setq pos (org-overlay-start ov)) | 15922 | (setq pos (org-overlay-start ov)) |
| 15348 | (goto-char pos) | 15923 | (goto-char pos) |
| 15349 | (when (setq val (cdr (assoc property | 15924 | (when (setq val (cdr (assoc property |
| 15350 | (get-text-property | 15925 | (get-text-property |
| 15351 | (point-at-bol) 'org-summaries)))) | 15926 | (point-at-bol) 'org-summaries)))) |
| 15352 | (setq fmt (org-overlay-get ov 'org-columns-format)) | 15927 | (setq fmt (org-overlay-get ov 'org-columns-format)) |
| 15353 | (org-overlay-put ov 'org-columns-value val) | 15928 | (org-overlay-put ov 'org-columns-value val) |
| @@ -15403,7 +15978,7 @@ display, or in the #+COLUMNS line of the current buffer." | |||
| 15403 | (if flag str val) format)))) | 15978 | (if flag str val) format)))) |
| 15404 | (aset lflag level t)) | 15979 | (aset lflag level t)) |
| 15405 | ;; clear accumulators for deeper levels | 15980 | ;; clear accumulators for deeper levels |
| 15406 | (loop for l from (1+ level) to (1- lmax) do | 15981 | (loop for l from (1+ level) to (1- lmax) do |
| 15407 | (aset lsum l 0) | 15982 | (aset lsum l 0) |
| 15408 | (aset lflag l nil))) | 15983 | (aset lflag l nil))) |
| 15409 | ((>= level last-level) | 15984 | ((>= level last-level) |
| @@ -15514,6 +16089,114 @@ format the output format for computed results, derived from operator" | |||
| 15514 | (setq org-columns-current-fmt-compiled | 16089 | (setq org-columns-current-fmt-compiled |
| 15515 | (nreverse org-columns-current-fmt-compiled)))) | 16090 | (nreverse org-columns-current-fmt-compiled)))) |
| 15516 | 16091 | ||
| 16092 | |||
| 16093 | ;;; Dynamic block for Column view | ||
| 16094 | |||
| 16095 | (defun org-columns-capture-view () | ||
| 16096 | "Get the column view of the current buffer and return it as a list. | ||
| 16097 | The list will contains the title row and all other rows. Each row is | ||
| 16098 | a list of fields." | ||
| 16099 | (save-excursion | ||
| 16100 | (let* ((title (mapcar 'cadr org-columns-current-fmt-compiled)) | ||
| 16101 | (n (length title)) row tbl) | ||
| 16102 | (goto-char (point-min)) | ||
| 16103 | (while (re-search-forward "^\\*+ " nil t) | ||
| 16104 | (when (get-char-property (match-beginning 0) 'org-columns-key) | ||
| 16105 | (setq row nil) | ||
| 16106 | (loop for i from 0 to (1- n) do | ||
| 16107 | (push (or (get-char-property (+ (match-beginning 0) i) 'org-columns-value-modified) | ||
| 16108 | (get-char-property (+ (match-beginning 0) i) 'org-columns-value) | ||
| 16109 | "") | ||
| 16110 | row)) | ||
| 16111 | (setq row (nreverse row)) | ||
| 16112 | (push row tbl))) | ||
| 16113 | (append (list title 'hline) (nreverse tbl))))) | ||
| 16114 | |||
| 16115 | (defun org-dblock-write:columnview (params) | ||
| 16116 | "Write the column view table. | ||
| 16117 | PARAMS is a property list of parameters: | ||
| 16118 | |||
| 16119 | :width enforce same column widths with <N> specifiers. | ||
| 16120 | :id the :ID: property of the entry where the columns view | ||
| 16121 | should be built, as a string. When `local', call locally. | ||
| 16122 | When `global' call column view with the cursor at the beginning | ||
| 16123 | of the buffer (usually this means that the whole buffer switches | ||
| 16124 | to column view). | ||
| 16125 | :hlines When t, insert a hline before each item. When a number, insert | ||
| 16126 | a hline before each level <= that number. | ||
| 16127 | :vlines When t, make each column a colgroup to enforce vertical lines." | ||
| 16128 | (let ((pos (move-marker (make-marker) (point))) | ||
| 16129 | (hlines (plist-get params :hlines)) | ||
| 16130 | (vlines (plist-get params :vlines)) | ||
| 16131 | tbl id idpos nfields tmp) | ||
| 16132 | (save-excursion | ||
| 16133 | (save-restriction | ||
| 16134 | (when (setq id (plist-get params :id)) | ||
| 16135 | (cond ((not id) nil) | ||
| 16136 | ((eq id 'global) (goto-char (point-min))) | ||
| 16137 | ((eq id 'local) nil) | ||
| 16138 | ((setq idpos (org-find-entry-with-id id)) | ||
| 16139 | (goto-char idpos)) | ||
| 16140 | (t (error "Cannot find entry with :ID: %s" id)))) | ||
| 16141 | (org-columns) | ||
| 16142 | (setq tbl (org-columns-capture-view)) | ||
| 16143 | (setq nfields (length (car tbl))) | ||
| 16144 | (org-columns-quit))) | ||
| 16145 | (goto-char pos) | ||
| 16146 | (move-marker pos nil) | ||
| 16147 | (when tbl | ||
| 16148 | (when (plist-get params :hlines) | ||
| 16149 | (setq tmp nil) | ||
| 16150 | (while tbl | ||
| 16151 | (if (eq (car tbl) 'hline) | ||
| 16152 | (push (pop tbl) tmp) | ||
| 16153 | (if (string-match "\\` *\\(\\*+\\)" (caar tbl)) | ||
| 16154 | (if (and (not (eq (car tmp) 'hline)) | ||
| 16155 | (or (eq hlines t) | ||
| 16156 | (and (numberp hlines) (<= (- (match-end 1) (match-beginning 1)) hlines)))) | ||
| 16157 | (push 'hline tmp))) | ||
| 16158 | (push (pop tbl) tmp))) | ||
| 16159 | (setq tbl (nreverse tmp))) | ||
| 16160 | (when vlines | ||
| 16161 | (setq tbl (mapcar (lambda (x) | ||
| 16162 | (if (eq 'hline x) x (cons "" x))) | ||
| 16163 | tbl)) | ||
| 16164 | (setq tbl (append tbl (list (cons "/" (make-list nfields "<>")))))) | ||
| 16165 | (setq pos (point)) | ||
| 16166 | (insert (org-listtable-to-string tbl)) | ||
| 16167 | (when (plist-get params :width) | ||
| 16168 | (insert "\n|" (mapconcat (lambda (x) (format "<%d>" (max 3 x))) | ||
| 16169 | org-columns-current-widths "|"))) | ||
| 16170 | (goto-char pos) | ||
| 16171 | (org-table-align)))) | ||
| 16172 | |||
| 16173 | (defun org-listtable-to-string (tbl) | ||
| 16174 | "Convert a listtable TBL to a string that contains the Org-mode table. | ||
| 16175 | The table still need to be alligned. The resulting string has no leading | ||
| 16176 | and tailing newline characters." | ||
| 16177 | (mapconcat | ||
| 16178 | (lambda (x) | ||
| 16179 | (cond | ||
| 16180 | ((listp x) | ||
| 16181 | (concat "|" (mapconcat 'identity x "|") "|")) | ||
| 16182 | ((eq x 'hline) "|-|") | ||
| 16183 | (t (error "Garbage in listtable: %s" x)))) | ||
| 16184 | tbl "\n")) | ||
| 16185 | |||
| 16186 | (defun org-insert-columns-dblock () | ||
| 16187 | "Create a dynamic block capturing a column view table." | ||
| 16188 | (interactive) | ||
| 16189 | (let ((defaults '(:name "columnview" :hlines 1)) | ||
| 16190 | (id (completing-read | ||
| 16191 | "Capture columns (local, global, entry with :ID: property) [local]: " | ||
| 16192 | (append '(("global") ("local")) | ||
| 16193 | (mapcar 'list (org-property-values "ID")))))) | ||
| 16194 | (if (equal id "") (setq id 'local)) | ||
| 16195 | (if (equal id "global") (setq id 'global)) | ||
| 16196 | (setq defaults (append defaults (list :id id))) | ||
| 16197 | (org-create-dblock defaults) | ||
| 16198 | (org-update-dblock))) | ||
| 16199 | |||
| 15517 | ;;;; Timestamps | 16200 | ;;;; Timestamps |
| 15518 | 16201 | ||
| 15519 | (defvar org-last-changed-timestamp nil) | 16202 | (defvar org-last-changed-timestamp nil) |
| @@ -15602,8 +16285,18 @@ existing stamp. For example, | |||
| 15602 | 22 sept 0:34 --> currentyear-09-22 0:34 | 16285 | 22 sept 0:34 --> currentyear-09-22 0:34 |
| 15603 | 12 --> currentyear-currentmonth-12 | 16286 | 12 --> currentyear-currentmonth-12 |
| 15604 | Fri --> nearest Friday (today or later) | 16287 | Fri --> nearest Friday (today or later) |
| 15605 | +4 --> four days from today (only if +N is the only thing given) | ||
| 15606 | etc. | 16288 | etc. |
| 16289 | |||
| 16290 | Furthermore you can specify a relative date by giving, as the *first* thing | ||
| 16291 | in the input: a plus/minus sign, a number and a letter [dwmy] to indicate | ||
| 16292 | change in days weeks, months, years. | ||
| 16293 | With a single plus or minus, the date is relative to today. With a double | ||
| 16294 | plus or minus, it is relative to the date in DEFAULT-TIME. E.g. | ||
| 16295 | +4d --> four days from today | ||
| 16296 | +4 --> same as above | ||
| 16297 | +2w --> two weeks from today | ||
| 16298 | ++5 --> five days from default date | ||
| 16299 | |||
| 15607 | The function understands only English month and weekday abbreviations, | 16300 | The function understands only English month and weekday abbreviations, |
| 15608 | but this can be configured with the variables `parse-time-months' and | 16301 | but this can be configured with the variables `parse-time-months' and |
| 15609 | `parse-time-weekdays'. | 16302 | `parse-time-weekdays'. |
| @@ -15637,7 +16330,7 @@ user." | |||
| 15637 | (if with-time "%Y-%m-%d %H:%M" "%Y-%m-%d") def)) | 16330 | (if with-time "%Y-%m-%d %H:%M" "%Y-%m-%d") def)) |
| 15638 | (prompt (concat (if prompt (concat prompt " ") "") | 16331 | (prompt (concat (if prompt (concat prompt " ") "") |
| 15639 | (format "Date and/or time (default [%s]): " timestr))) | 16332 | (format "Date and/or time (default [%s]): " timestr))) |
| 15640 | ans (org-ans0 "") org-ans1 org-ans2 (deltadays 0) | 16333 | ans (org-ans0 "") org-ans1 org-ans2 delta deltan deltaw deltadef |
| 15641 | second minute hour day month year tl wday wday1 pm h2 m2) | 16334 | second minute hour day month year tl wday wday1 pm h2 m2) |
| 15642 | 16335 | ||
| 15643 | (cond | 16336 | (cond |
| @@ -15695,8 +16388,11 @@ user." | |||
| 15695 | (setq ans (read-string prompt "" nil timestr)))) | 16388 | (setq ans (read-string prompt "" nil timestr)))) |
| 15696 | (org-detach-overlay org-date-ovl) | 16389 | (org-detach-overlay org-date-ovl) |
| 15697 | 16390 | ||
| 15698 | (if (string-match "^[ \t]*[-+][0-9]+[ \t]*$" org-ans0) | 16391 | (when (setq delta (org-read-date-get-relative ans (current-time) def)) |
| 15699 | (setq deltadays (string-to-number ans) ans "")) | 16392 | (setq ans (replace-match "" t t ans) |
| 16393 | deltan (car delta) | ||
| 16394 | deltaw (nth 1 delta) | ||
| 16395 | deltadef (nth 2 delta))) | ||
| 15700 | 16396 | ||
| 15701 | ;; Help matching ISO dates with single digit month ot day, like 2006-8-11. | 16397 | ;; Help matching ISO dates with single digit month ot day, like 2006-8-11. |
| 15702 | (when (string-match | 16398 | (when (string-match |
| @@ -15719,7 +16415,7 @@ user." | |||
| 15719 | minute (if (match-end 3) | 16415 | minute (if (match-end 3) |
| 15720 | (string-to-number (match-string 3 ans)) | 16416 | (string-to-number (match-string 3 ans)) |
| 15721 | 0) | 16417 | 0) |
| 15722 | pm (equal ?p | 16418 | pm (equal ?p |
| 15723 | (string-to-char (downcase (match-string 4 ans))))) | 16419 | (string-to-char (downcase (match-string 4 ans))))) |
| 15724 | (if (and (= hour 12) (not pm)) | 16420 | (if (and (= hour 12) (not pm)) |
| 15725 | (setq hour 0) | 16421 | (setq hour 0) |
| @@ -15751,7 +16447,14 @@ user." | |||
| 15751 | minute (or (nth 1 tl) (string-to-number (format-time-string "%M" def))) | 16447 | minute (or (nth 1 tl) (string-to-number (format-time-string "%M" def))) |
| 15752 | second (or (nth 0 tl) 0) | 16448 | second (or (nth 0 tl) 0) |
| 15753 | wday (nth 6 tl)) | 16449 | wday (nth 6 tl)) |
| 15754 | (setq day (+ day deltadays)) | 16450 | (when deltan |
| 16451 | (unless deltadef | ||
| 16452 | (let ((now (decode-time (current-time)))) | ||
| 16453 | (setq day (nth 3 now) month (nth 4 now) year (nth 5 now)))) | ||
| 16454 | (cond ((member deltaw '("d" "")) (setq day (+ day deltan))) | ||
| 16455 | ((equal deltaw "w") (setq day (+ day (* 7 deltan)))) | ||
| 16456 | ((equal deltaw "m") (setq month (+ month deltan))) | ||
| 16457 | ((equal deltaw "y") (setq year (+ year deltan))))) | ||
| 15755 | (when (and wday (not (nth 3 tl))) | 16458 | (when (and wday (not (nth 3 tl))) |
| 15756 | ;; Weekday was given, but no day, so pick that day in the week | 16459 | ;; Weekday was given, but no day, so pick that day in the week |
| 15757 | ;; on or after the derived date. | 16460 | ;; on or after the derived date. |
| @@ -15768,6 +16471,40 @@ user." | |||
| 15768 | (format "%04d-%02d-%02d %02d:%02d" year month day hour minute) | 16471 | (format "%04d-%02d-%02d %02d:%02d" year month day hour minute) |
| 15769 | (format "%04d-%02d-%02d" year month day))))) | 16472 | (format "%04d-%02d-%02d" year month day))))) |
| 15770 | 16473 | ||
| 16474 | (defvar parse-time-weekdays) | ||
| 16475 | |||
| 16476 | (defun org-read-date-get-relative (s today default) | ||
| 16477 | "Check string S for special relative date string. | ||
| 16478 | TODAY and DEFAULT are ionternal times, for today and for a default. | ||
| 16479 | Return shift list (N what def-flag) | ||
| 16480 | WHAT is \"d\", \"w\", \"m\", or \"y\" for day. week, month, year. | ||
| 16481 | N is the number if WHATs to shift | ||
| 16482 | DEF-FLAG is t when a double ++ or -- indicates shift relative to | ||
| 16483 | the DEFAULT date rather than TODAY." | ||
| 16484 | (when (string-match | ||
| 16485 | (concat | ||
| 16486 | "\\`[ \t]*\\([-+]\\{1,2\\}\\)?" | ||
| 16487 | "\\([0-9]+\\)?" | ||
| 16488 | "\\([dwmy]\\|\\(" (mapconcat 'car parse-time-weekdays "\\|") "\\)\\)?" | ||
| 16489 | "\\([ \t]\\|$\\)") s) | ||
| 16490 | (let* ((dir (if (match-end 1) | ||
| 16491 | (string-to-char (substring (match-string 1 s) -1)) | ||
| 16492 | ?+)) | ||
| 16493 | (rel (and (match-end 1) (= 2 (- (match-end 1) (match-beginning 1))))) | ||
| 16494 | (n (if (match-end 2) (string-to-number (match-string 2 s)) 1)) | ||
| 16495 | (what (if (match-end 3) (match-string 3 s) "d")) | ||
| 16496 | (wday1 (cdr (assoc (downcase what) parse-time-weekdays))) | ||
| 16497 | (date (if rel default today)) | ||
| 16498 | (wday (nth 6 (decode-time date))) | ||
| 16499 | delta) | ||
| 16500 | (if wday1 | ||
| 16501 | (progn | ||
| 16502 | (setq delta (mod (+ 7 (- wday1 wday)) 7)) | ||
| 16503 | (if (= dir ?-) (setq delta (- delta 7))) | ||
| 16504 | (if (> n 1) (setq delta (+ delta (* (1- n) (if (= dir ?-) -7 7))))) | ||
| 16505 | (list delta "d" rel)) | ||
| 16506 | (list (* n (if (= dir ?-) -1 1)) what rel))))) | ||
| 16507 | |||
| 15771 | (defun org-eval-in-calendar (form &optional keepdate) | 16508 | (defun org-eval-in-calendar (form &optional keepdate) |
| 15772 | "Eval FORM in the calendar window and return to current window. | 16509 | "Eval FORM in the calendar window and return to current window. |
| 15773 | Also, store the cursor date in variable org-ans2." | 16510 | Also, store the cursor date in variable org-ans2." |
| @@ -15812,8 +16549,8 @@ The command returns the inserted time stamp." | |||
| 15812 | (let ((fmt (funcall (if with-hm 'cdr 'car) org-time-stamp-formats)) | 16549 | (let ((fmt (funcall (if with-hm 'cdr 'car) org-time-stamp-formats)) |
| 15813 | stamp) | 16550 | stamp) |
| 15814 | (if inactive (setq fmt (concat "[" (substring fmt 1 -1) "]"))) | 16551 | (if inactive (setq fmt (concat "[" (substring fmt 1 -1) "]"))) |
| 15815 | (insert (or pre "")) | 16552 | (insert-before-markers (or pre "")) |
| 15816 | (insert (setq stamp (format-time-string fmt time))) | 16553 | (insert-before-markers (setq stamp (format-time-string fmt time))) |
| 15817 | (when (listp extra) | 16554 | (when (listp extra) |
| 15818 | (setq extra (car extra)) | 16555 | (setq extra (car extra)) |
| 15819 | (if (and (stringp extra) | 16556 | (if (and (stringp extra) |
| @@ -15824,9 +16561,9 @@ The command returns the inserted time stamp." | |||
| 15824 | (setq extra nil))) | 16561 | (setq extra nil))) |
| 15825 | (when extra | 16562 | (when extra |
| 15826 | (backward-char 1) | 16563 | (backward-char 1) |
| 15827 | (insert extra) | 16564 | (insert-before-markers extra) |
| 15828 | (forward-char 1)) | 16565 | (forward-char 1)) |
| 15829 | (insert (or post "")) | 16566 | (insert-before-markers (or post "")) |
| 15830 | stamp)) | 16567 | stamp)) |
| 15831 | 16568 | ||
| 15832 | (defun org-toggle-time-stamp-overlays () | 16569 | (defun org-toggle-time-stamp-overlays () |
| @@ -16253,9 +16990,12 @@ With prefix ARG, change that many days." | |||
| 16253 | (if (> (point) (point-min)) (backward-char 1)) | 16990 | (if (> (point) (point-min)) (backward-char 1)) |
| 16254 | (and (looking-at tsr) | 16991 | (and (looking-at tsr) |
| 16255 | (> (- (match-end 0) pos) -1)))))) | 16992 | (> (- (match-end 0) pos) -1)))))) |
| 16256 | (and (boundp 'org-ts-what) | 16993 | (and ans |
| 16994 | (boundp 'org-ts-what) | ||
| 16257 | (setq org-ts-what | 16995 | (setq org-ts-what |
| 16258 | (cond | 16996 | (cond |
| 16997 | ((= pos (match-beginning 0)) 'bracket) | ||
| 16998 | ((= pos (1- (match-end 0))) 'bracket) | ||
| 16259 | ((org-pos-in-match-range pos 2) 'year) | 16999 | ((org-pos-in-match-range pos 2) 'year) |
| 16260 | ((org-pos-in-match-range pos 3) 'month) | 17000 | ((org-pos-in-match-range pos 3) 'month) |
| 16261 | ((org-pos-in-match-range pos 7) 'hour) | 17001 | ((org-pos-in-match-range pos 7) 'hour) |
| @@ -16268,6 +17008,18 @@ With prefix ARG, change that many days." | |||
| 16268 | (t 'day)))) | 17008 | (t 'day)))) |
| 16269 | ans)) | 17009 | ans)) |
| 16270 | 17010 | ||
| 17011 | (defun org-toggle-timestamp-type () | ||
| 17012 | "" | ||
| 17013 | (interactive) | ||
| 17014 | (when (org-at-timestamp-p t) | ||
| 17015 | (save-excursion | ||
| 17016 | (goto-char (match-beginning 0)) | ||
| 17017 | (insert (if (equal (char-after) ?<) "[" "<")) (delete-char 1) | ||
| 17018 | (goto-char (1- (match-end 0))) | ||
| 17019 | (insert (if (equal (char-after) ?>) "]" ">")) (delete-char 1)) | ||
| 17020 | (message "Timestamp is now %sactive" | ||
| 17021 | (if (equal (char-before) ?>) "in" "")))) | ||
| 17022 | |||
| 16271 | (defun org-timestamp-change (n &optional what) | 17023 | (defun org-timestamp-change (n &optional what) |
| 16272 | "Change the date in the time stamp at point. | 17024 | "Change the date in the time stamp at point. |
| 16273 | The date will be changed by N times WHAT. WHAT can be `day', `month', | 17025 | The date will be changed by N times WHAT. WHAT can be `day', `month', |
| @@ -16280,56 +17032,52 @@ in the timestamp determines what will be changed." | |||
| 16280 | ts time time0) | 17032 | ts time time0) |
| 16281 | (if (not (org-at-timestamp-p t)) | 17033 | (if (not (org-at-timestamp-p t)) |
| 16282 | (error "Not at a timestamp")) | 17034 | (error "Not at a timestamp")) |
| 16283 | (if (and (not what) (not (eq org-ts-what 'day)) | 17035 | (if (and (not what) (eq org-ts-what 'bracket)) |
| 16284 | org-display-custom-times | 17036 | (org-toggle-timestamp-type) |
| 16285 | (get-text-property (point) 'display) | 17037 | (if (and (not what) (not (eq org-ts-what 'day)) |
| 16286 | (not (get-text-property (1- (point)) 'display))) | 17038 | org-display-custom-times |
| 16287 | (setq org-ts-what 'day)) | 17039 | (get-text-property (point) 'display) |
| 16288 | (setq org-ts-what (or what org-ts-what) | 17040 | (not (get-text-property (1- (point)) 'display))) |
| 16289 | inactive (= (char-after (match-beginning 0)) ?\[) | 17041 | (setq org-ts-what 'day)) |
| 16290 | ts (match-string 0)) | 17042 | (setq org-ts-what (or what org-ts-what) |
| 16291 | (replace-match "") | 17043 | inactive (= (char-after (match-beginning 0)) ?\[) |
| 16292 | (if (string-match | 17044 | ts (match-string 0)) |
| 16293 | "\\(\\(-[012][0-9]:[0-5][0-9]\\)?\\( [-+][0-9]+[dwmy]\\)*\\)[]>]" | 17045 | (replace-match "") |
| 16294 | ts) | 17046 | (if (string-match |
| 16295 | (setq extra (match-string 1 ts))) | 17047 | "\\(\\(-[012][0-9]:[0-5][0-9]\\)?\\( [-+][0-9]+[dwmy]\\)*\\)[]>]" |
| 16296 | (if (string-match "^.\\{10\\}.*?[0-9]+:[0-9][0-9]" ts) | 17048 | ts) |
| 16297 | (setq with-hm t)) | 17049 | (setq extra (match-string 1 ts))) |
| 16298 | (setq time0 (org-parse-time-string ts)) | 17050 | (if (string-match "^.\\{10\\}.*?[0-9]+:[0-9][0-9]" ts) |
| 16299 | (setq time | 17051 | (setq with-hm t)) |
| 16300 | (apply 'encode-time | 17052 | (setq time0 (org-parse-time-string ts)) |
| 16301 | (append | 17053 | (setq time |
| 16302 | (list (or (car time0) 0)) | 17054 | (encode-time (or (car time0) 0) |
| 16303 | (list (+ (if (eq org-ts-what 'minute) n 0) (nth 1 time0))) | 17055 | (+ (if (eq org-ts-what 'minute) n 0) (nth 1 time0)) |
| 16304 | (list (+ (if (eq org-ts-what 'hour) n 0) (nth 2 time0))) | 17056 | (+ (if (eq org-ts-what 'hour) n 0) (nth 2 time0)) |
| 16305 | (list (+ (if (eq org-ts-what 'day) n 0) (nth 3 time0))) | 17057 | (+ (if (eq org-ts-what 'day) n 0) (nth 3 time0)) |
| 16306 | (list (+ (if (eq org-ts-what 'month) n 0) (nth 4 time0))) | 17058 | (+ (if (eq org-ts-what 'month) n 0) (nth 4 time0)) |
| 16307 | (list (+ (if (eq org-ts-what 'year) n 0) (nth 5 time0))) | 17059 | (+ (if (eq org-ts-what 'year) n 0) (nth 5 time0)) |
| 16308 | (nthcdr 6 time0)))) | 17060 | (nthcdr 6 time0))) |
| 16309 | (when (integerp org-ts-what) | 17061 | (when (integerp org-ts-what) |
| 16310 | (setq extra (org-modify-ts-extra extra org-ts-what n))) | 17062 | (setq extra (org-modify-ts-extra extra org-ts-what n))) |
| 16311 | (if (eq what 'calendar) | 17063 | (if (eq what 'calendar) |
| 16312 | (let ((cal-date | 17064 | (let ((cal-date (org-get-date-from-calendar))) |
| 16313 | (save-excursion | 17065 | (setcar (nthcdr 4 time0) (nth 0 cal-date)) ; month |
| 16314 | (save-match-data | 17066 | (setcar (nthcdr 3 time0) (nth 1 cal-date)) ; day |
| 16315 | (set-buffer "*Calendar*") | 17067 | (setcar (nthcdr 5 time0) (nth 2 cal-date)) ; year |
| 16316 | (calendar-cursor-to-date))))) | 17068 | (setcar time0 (or (car time0) 0)) |
| 16317 | (setcar (nthcdr 4 time0) (nth 0 cal-date)) ; month | 17069 | (setcar (nthcdr 1 time0) (or (nth 1 time0) 0)) |
| 16318 | (setcar (nthcdr 3 time0) (nth 1 cal-date)) ; day | 17070 | (setcar (nthcdr 2 time0) (or (nth 2 time0) 0)) |
| 16319 | (setcar (nthcdr 5 time0) (nth 2 cal-date)) ; year | 17071 | (setq time (apply 'encode-time time0)))) |
| 16320 | (setcar time0 (or (car time0) 0)) | 17072 | (setq org-last-changed-timestamp |
| 16321 | (setcar (nthcdr 1 time0) (or (nth 1 time0) 0)) | 17073 | (org-insert-time-stamp time with-hm inactive nil nil extra)) |
| 16322 | (setcar (nthcdr 2 time0) (or (nth 1 time0) 0)) | 17074 | (org-clock-update-time-maybe) |
| 16323 | (setq time (apply 'encode-time time0)))) | 17075 | (goto-char pos) |
| 16324 | (setq org-last-changed-timestamp | 17076 | ;; Try to recenter the calendar window, if any |
| 16325 | (org-insert-time-stamp time with-hm inactive nil nil extra)) | 17077 | (if (and org-calendar-follow-timestamp-change |
| 16326 | (org-clock-update-time-maybe) | 17078 | (get-buffer-window "*Calendar*" t) |
| 16327 | (goto-char pos) | 17079 | (memq org-ts-what '(day month year))) |
| 16328 | ;; Try to recenter the calendar window, if any | 17080 | (org-recenter-calendar (time-to-days time)))))) |
| 16329 | (if (and org-calendar-follow-timestamp-change | ||
| 16330 | (get-buffer-window "*Calendar*" t) | ||
| 16331 | (memq org-ts-what '(day month year))) | ||
| 16332 | (org-recenter-calendar (time-to-days time))))) | ||
| 16333 | 17081 | ||
| 16334 | ;; FIXME: does not yet work for lead times | 17082 | ;; FIXME: does not yet work for lead times |
| 16335 | (defun org-modify-ts-extra (s pos n) | 17083 | (defun org-modify-ts-extra (s pos n) |
| @@ -16353,7 +17101,7 @@ in the timestamp determines what will be changed." | |||
| 16353 | (setq ng 6 new (car (rassoc (+ n (cdr (assoc (match-string 6 s) idx))) idx)))) | 17101 | (setq ng 6 new (car (rassoc (+ n (cdr (assoc (match-string 6 s) idx))) idx)))) |
| 16354 | ((org-pos-in-match-range pos 5) | 17102 | ((org-pos-in-match-range pos 5) |
| 16355 | (setq ng 5 new (format "%d" (max 1 (+ n (string-to-number (match-string 5 s)))))))) | 17103 | (setq ng 5 new (format "%d" (max 1 (+ n (string-to-number (match-string 5 s)))))))) |
| 16356 | 17104 | ||
| 16357 | (when ng | 17105 | (when ng |
| 16358 | (setq s (concat | 17106 | (setq s (concat |
| 16359 | (substring s 0 (match-beginning ng)) | 17107 | (substring s 0 (match-beginning ng)) |
| @@ -16393,13 +17141,24 @@ A prefix ARG can be used to force the current date." | |||
| 16393 | (calendar-goto-today) | 17141 | (calendar-goto-today) |
| 16394 | (if (and diff (not arg)) (calendar-forward-day diff)))) | 17142 | (if (and diff (not arg)) (calendar-forward-day diff)))) |
| 16395 | 17143 | ||
| 17144 | (defun org-get-date-from-calendar () | ||
| 17145 | "Return a list (month day year) of date at point in calendar." | ||
| 17146 | (with-current-buffer "*Calendar*" | ||
| 17147 | (save-match-data | ||
| 17148 | (calendar-cursor-to-date)))) | ||
| 17149 | |||
| 16396 | (defun org-date-from-calendar () | 17150 | (defun org-date-from-calendar () |
| 16397 | "Insert time stamp corresponding to cursor date in *Calendar* buffer. | 17151 | "Insert time stamp corresponding to cursor date in *Calendar* buffer. |
| 16398 | If there is already a time stamp at the cursor position, update it." | 17152 | If there is already a time stamp at the cursor position, update it." |
| 16399 | (interactive) | 17153 | (interactive) |
| 16400 | (org-timestamp-change 0 'calendar)) | 17154 | (if (org-at-timestamp-p t) |
| 17155 | (org-timestamp-change 0 'calendar) | ||
| 17156 | (let ((cal-date (org-get-date-from-calendar))) | ||
| 17157 | (org-insert-time-stamp | ||
| 17158 | (encode-time 0 0 0 (nth 1 cal-date) (car cal-date) (nth 2 cal-date)))))) | ||
| 16401 | 17159 | ||
| 16402 | ;; Make appt aware of appointments from the agenda | 17160 | ;; Make appt aware of appointments from the agenda |
| 17161 | ;;;###autoload | ||
| 16403 | (defun org-agenda-to-appt (&optional filter) | 17162 | (defun org-agenda-to-appt (&optional filter) |
| 16404 | "Activate appointments found in `org-agenda-files'. | 17163 | "Activate appointments found in `org-agenda-files'. |
| 16405 | When prefixed, prompt for a regular expression and use it as a | 17164 | When prefixed, prompt for a regular expression and use it as a |
| @@ -16417,36 +17176,45 @@ either 'headline or 'category. For example: | |||
| 16417 | will only add headlines containing IMPORTANT or headlines | 17176 | will only add headlines containing IMPORTANT or headlines |
| 16418 | belonging to the category \"Work\"." | 17177 | belonging to the category \"Work\"." |
| 16419 | (interactive "P") | 17178 | (interactive "P") |
| 16420 | (require 'org) | 17179 | (require 'calendar) |
| 16421 | (if (equal filter '(4)) | 17180 | (if (equal filter '(4)) |
| 16422 | (setq filter (read-from-minibuffer "Regexp filter: "))) | 17181 | (setq filter (read-from-minibuffer "Regexp filter: "))) |
| 16423 | (let* ((today (org-date-to-gregorian | 17182 | (let* ((cnt 0) ; count added events |
| 17183 | (today (org-date-to-gregorian | ||
| 16424 | (time-to-days (current-time)))) | 17184 | (time-to-days (current-time)))) |
| 16425 | (files org-agenda-files) entries file) | 17185 | (files (org-agenda-files)) entries file) |
| 17186 | ;; Get all entries which may contain an appt | ||
| 16426 | (while (setq file (pop files)) | 17187 | (while (setq file (pop files)) |
| 16427 | (setq entries (append entries (org-agenda-get-day-entries | 17188 | (setq entries |
| 16428 | file today :timestamp)))) | 17189 | (append entries |
| 17190 | (org-agenda-get-day-entries | ||
| 17191 | file today | ||
| 17192 | :timestamp :scheduled :deadline)))) | ||
| 16429 | (setq entries (delq nil entries)) | 17193 | (setq entries (delq nil entries)) |
| 16430 | (mapc | 17194 | ;; Map thru entries and find if they pass thru the filter |
| 17195 | (mapc | ||
| 16431 | (lambda(x) | 17196 | (lambda(x) |
| 16432 | (let* ((evt (org-trim (get-text-property 1 'txt x))) | 17197 | (let* ((evt (org-trim (get-text-property 1 'txt x))) |
| 16433 | (cat (get-text-property 1 'org-category x)) | 17198 | (cat (get-text-property 1 'org-category x)) |
| 16434 | (tod (get-text-property 1 'time-of-day x)) | 17199 | (tod (get-text-property 1 'time-of-day x)) |
| 16435 | (ok (or (and (stringp filter) (string-match filter evt)) | 17200 | (ok (or (null filter) |
| 16436 | (and (not (null filter)) (listp filter) | 17201 | (and (stringp filter) (string-match filter evt)) |
| 16437 | (or (string-match | 17202 | (and (listp filter) |
| 17203 | (or (string-match | ||
| 16438 | (cadr (assoc 'category filter)) cat) | 17204 | (cadr (assoc 'category filter)) cat) |
| 16439 | (string-match | 17205 | (string-match |
| 16440 | (cadr (assoc 'headline filter)) evt)))))) | 17206 | (cadr (assoc 'headline filter)) evt)))))) |
| 16441 | ;; (setq evt (set-text-properties 0 (length event) nil evt)) | 17207 | ;; FIXME Shall we remove text-properties for the appt text? |
| 17208 | ;; (setq evt (set-text-properties 0 (length evt) nil evt)) | ||
| 16442 | (when (and ok tod) | 17209 | (when (and ok tod) |
| 16443 | (setq tod (number-to-string tod) | 17210 | (setq tod (number-to-string tod) |
| 16444 | tod (when (string-match | 17211 | tod (when (string-match |
| 16445 | "\\([0-9]\\{1,2\\}\\)\\([0-9]\\{2\\}\\)" tod) | 17212 | "\\([0-9]\\{1,2\\}\\)\\([0-9]\\{2\\}\\)" tod) |
| 16446 | (concat (match-string 1 tod) ":" | 17213 | (concat (match-string 1 tod) ":" |
| 16447 | (match-string 2 tod)))) | 17214 | (match-string 2 tod)))) |
| 16448 | (appt-add tod evt)))) entries) | 17215 | (appt-add tod evt) |
| 16449 | nil)) | 17216 | (setq cnt (1+ cnt))))) entries) |
| 17217 | (message "Added %d event%s for today" cnt (if (> cnt 1) "s" "")))) | ||
| 16450 | 17218 | ||
| 16451 | ;;; The clock for measuring work time. | 17219 | ;;; The clock for measuring work time. |
| 16452 | 17220 | ||
| @@ -16922,7 +17690,7 @@ the returned times will be formatted strings." | |||
| 16922 | (setq total-time (+ (or total-time 0) | 17690 | (setq total-time (+ (or total-time 0) |
| 16923 | org-clock-file-total-minutes))))))) | 17691 | org-clock-file-total-minutes))))))) |
| 16924 | (goto-char pos) | 17692 | (goto-char pos) |
| 16925 | 17693 | ||
| 16926 | (unless (eq scope 'agenda) | 17694 | (unless (eq scope 'agenda) |
| 16927 | (org-clock-sum ts te) | 17695 | (org-clock-sum ts te) |
| 16928 | (goto-char (point-min)) | 17696 | (goto-char (point-min)) |
| @@ -16967,7 +17735,7 @@ the returned times will be formatted strings." | |||
| 16967 | (insert-before-markers | 17735 | (insert-before-markers |
| 16968 | "|-\n|" | 17736 | "|-\n|" |
| 16969 | (if (eq scope 'agenda) "|" "") | 17737 | (if (eq scope 'agenda) "|" "") |
| 16970 | "|" | 17738 | "|" |
| 16971 | "*Total time*| " | 17739 | "*Total time*| " |
| 16972 | (format "*%d:%02d*" h m) | 17740 | (format "*%d:%02d*" h m) |
| 16973 | "|\n|-\n") | 17741 | "|\n|-\n") |
| @@ -17356,9 +18124,9 @@ that have been changed along." | |||
| 17356 | (defvar org-agenda-last-dispatch-buffer nil) | 18124 | (defvar org-agenda-last-dispatch-buffer nil) |
| 17357 | 18125 | ||
| 17358 | ;;;###autoload | 18126 | ;;;###autoload |
| 17359 | (defun org-agenda (arg) | 18127 | (defun org-agenda (arg &optional keys restriction) |
| 17360 | "Dispatch agenda commands to collect entries to the agenda buffer. | 18128 | "Dispatch agenda commands to collect entries to the agenda buffer. |
| 17361 | Prompts for a character to select a command. Any prefix arg will be passed | 18129 | Prompts for a command to execute. Any prefix arg will be passed |
| 17362 | on to the selected command. The default selections are: | 18130 | on to the selected command. The default selections are: |
| 17363 | 18131 | ||
| 17364 | a Call `org-agenda-list' to display the agenda for current day or week. | 18132 | a Call `org-agenda-list' to display the agenda for current day or week. |
| @@ -17376,15 +18144,28 @@ More commands can be added by configuring the variable | |||
| 17376 | searches can be pre-defined in this way. | 18144 | searches can be pre-defined in this way. |
| 17377 | 18145 | ||
| 17378 | If the current buffer is in Org-mode and visiting a file, you can also | 18146 | If the current buffer is in Org-mode and visiting a file, you can also |
| 17379 | first press `1' to indicate that the agenda should be temporarily (until the | 18147 | first press `<' once to indicate that the agenda should be temporarily |
| 17380 | next use of \\[org-agenda]) restricted to the current file." | 18148 | \(until the next use of \\[org-agenda]) restricted to the current file. |
| 18149 | Pressing `<' twice means to restrict to the current subtree or region | ||
| 18150 | \(if active)." | ||
| 17381 | (interactive "P") | 18151 | (interactive "P") |
| 17382 | (catch 'exit | 18152 | (catch 'exit |
| 17383 | (let* ((buf (current-buffer)) | 18153 | (let* ((prefix-descriptions nil) |
| 18154 | (org-agenda-custom-commands | ||
| 18155 | ;; normalize different versions | ||
| 18156 | (delq nil | ||
| 18157 | (mapcar | ||
| 18158 | (lambda (x) | ||
| 18159 | (cond ((stringp (cdr x)) | ||
| 18160 | (push x prefix-descriptions) | ||
| 18161 | nil) | ||
| 18162 | ((stringp (nth 1 x)) x) | ||
| 18163 | ((not (nth 1 x)) (cons (car x) (cons "" (cddr x)))) | ||
| 18164 | (t (cons (car x) (cons "" (cdr x)))))) | ||
| 18165 | org-agenda-custom-commands))) | ||
| 18166 | (buf (current-buffer)) | ||
| 17384 | (bfn (buffer-file-name (buffer-base-buffer))) | 18167 | (bfn (buffer-file-name (buffer-base-buffer))) |
| 17385 | (restrict-ok (and bfn (org-mode-p))) | 18168 | entry key type match lprops ans) |
| 17386 | (custom org-agenda-custom-commands) | ||
| 17387 | c entry key type match lprops) | ||
| 17388 | ;; Turn off restriction | 18169 | ;; Turn off restriction |
| 17389 | (put 'org-agenda-files 'org-restrict nil) | 18170 | (put 'org-agenda-files 'org-restrict nil) |
| 17390 | (setq org-agenda-restrict nil) | 18171 | (setq org-agenda-restrict nil) |
| @@ -17394,88 +18175,33 @@ next use of \\[org-agenda]) restricted to the current file." | |||
| 17394 | (put 'org-agenda-redo-command 'org-lprops nil) | 18175 | (put 'org-agenda-redo-command 'org-lprops nil) |
| 17395 | ;; Remember where this call originated | 18176 | ;; Remember where this call originated |
| 17396 | (setq org-agenda-last-dispatch-buffer (current-buffer)) | 18177 | (setq org-agenda-last-dispatch-buffer (current-buffer)) |
| 17397 | (save-window-excursion | 18178 | (unless keys |
| 17398 | (delete-other-windows) | 18179 | (setq ans (org-agenda-get-restriction-and-command prefix-descriptions) |
| 17399 | (org-switch-to-buffer-other-window " *Agenda Commands*") | 18180 | keys (car ans) |
| 17400 | (erase-buffer) | 18181 | restriction (cdr ans))) |
| 17401 | (insert (eval-when-compile | 18182 | ;; Estabish the restriction, if any |
| 17402 | (let ((header | 18183 | (when restriction |
| 17403 | "Press key for an agenda command: | 18184 | (put 'org-agenda-files 'org-restrict (list bfn)) |
| 17404 | -------------------------------- C Configure custom agenda commands | 18185 | (cond |
| 17405 | a Agenda for current week or day e Export agenda views | 18186 | ((eq restriction 'region) |
| 17406 | t List of all TODO entries T Entries with special TODO kwd | 18187 | (setq org-agenda-restrict t) |
| 17407 | m Match a TAGS query M Like m, but only TODO entries | 18188 | (move-marker org-agenda-restrict-begin (region-beginning)) |
| 17408 | L Timeline for current buffer # List stuck projects (!=configure) | 18189 | (move-marker org-agenda-restrict-end (region-end))) |
| 17409 | ") | 18190 | ((eq restriction 'subtree) |
| 17410 | (start 0)) | 18191 | (save-excursion |
| 17411 | (while (string-match "\\(^\\| \\|(\\)\\(\\S-\\)\\( \\|=\\)" header start) | ||
| 17412 | (setq start (match-end 0)) | ||
| 17413 | (add-text-properties (match-beginning 2) (match-end 2) | ||
| 17414 | '(face bold) header)) | ||
| 17415 | header))) | ||
| 17416 | (while (setq entry (pop custom)) | ||
| 17417 | (setq key (car entry) type (nth 1 entry) match (nth 2 entry)) | ||
| 17418 | (insert (format "\n%-4s%-14s: %s" | ||
| 17419 | (org-add-props (copy-sequence key) | ||
| 17420 | '(face bold)) | ||
| 17421 | (cond | ||
| 17422 | ((stringp type) type) | ||
| 17423 | ((eq type 'agenda) "Agenda for current week or day") | ||
| 17424 | ((eq type 'alltodo) "List of all TODO entries") | ||
| 17425 | ((eq type 'stuck) "List of stuck projects") | ||
| 17426 | ((eq type 'todo) "TODO keyword") | ||
| 17427 | ((eq type 'tags) "Tags query") | ||
| 17428 | ((eq type 'tags-todo) "Tags (TODO)") | ||
| 17429 | ((eq type 'tags-tree) "Tags tree") | ||
| 17430 | ((eq type 'todo-tree) "TODO kwd tree") | ||
| 17431 | ((eq type 'occur-tree) "Occur tree") | ||
| 17432 | ((functionp type) (symbol-name type)) | ||
| 17433 | (t "???")) | ||
| 17434 | (if (stringp match) | ||
| 17435 | (org-add-props match nil 'face 'org-warning) | ||
| 17436 | (format "set of %d commands" (length match)))))) | ||
| 17437 | (if restrict-ok | ||
| 17438 | (insert "\n" | ||
| 17439 | (org-add-props "1 Restrict call to current buffer 0 Restrict call to region or subtree" nil 'face 'org-table))) | ||
| 17440 | (goto-char (point-min)) | ||
| 17441 | (if (fboundp 'fit-window-to-buffer) (fit-window-to-buffer)) | ||
| 17442 | (message "Press key for agenda command%s" | ||
| 17443 | (if restrict-ok ", or [1] or [0] to restrict" "")) | ||
| 17444 | (setq c (read-char-exclusive)) | ||
| 17445 | (message "") | ||
| 17446 | (when (memq c '(?L ?1 ?0)) | ||
| 17447 | (if restrict-ok | ||
| 17448 | (put 'org-agenda-files 'org-restrict (list bfn)) | ||
| 17449 | (error "Cannot restrict agenda to current buffer")) | ||
| 17450 | (with-current-buffer " *Agenda Commands*" | ||
| 17451 | (goto-char (point-max)) | ||
| 17452 | (delete-region (point-at-bol) (point)) | ||
| 17453 | (goto-char (point-min))) | ||
| 17454 | (when (eq c ?0) | ||
| 17455 | (setq org-agenda-restrict t) | 18192 | (setq org-agenda-restrict t) |
| 17456 | (with-current-buffer buf | 18193 | (org-back-to-heading t) |
| 17457 | (if (org-region-active-p) | 18194 | (move-marker org-agenda-restrict-begin (point)) |
| 17458 | (progn | 18195 | (move-marker org-agenda-restrict-end |
| 17459 | (move-marker org-agenda-restrict-begin (region-beginning)) | 18196 | (progn (org-end-of-subtree t))))))) |
| 17460 | (move-marker org-agenda-restrict-end (region-end))) | 18197 | |
| 17461 | (save-excursion | ||
| 17462 | (org-back-to-heading t) | ||
| 17463 | (move-marker org-agenda-restrict-begin (point)) | ||
| 17464 | (move-marker org-agenda-restrict-end | ||
| 17465 | (progn (org-end-of-subtree t))))))) | ||
| 17466 | (unless (eq c ?L) | ||
| 17467 | (message "Press key for agenda command%s" | ||
| 17468 | (if restrict-ok " (restricted to current file)" "")) | ||
| 17469 | (setq c (read-char-exclusive))) | ||
| 17470 | (message ""))) | ||
| 17471 | (require 'calendar) ; FIXME: can we avoid this for some commands? | 18198 | (require 'calendar) ; FIXME: can we avoid this for some commands? |
| 17472 | ;; For example the todo list should not need it (but does...) | 18199 | ;; For example the todo list should not need it (but does...) |
| 17473 | (cond | 18200 | (cond |
| 17474 | ((setq entry (assoc (char-to-string c) org-agenda-custom-commands)) | 18201 | ((setq entry (assoc keys org-agenda-custom-commands)) |
| 17475 | (if (symbolp (nth 1 entry)) | 18202 | (if (or (symbolp (nth 2 entry)) (functionp (nth 2 entry))) |
| 17476 | (progn | 18203 | (progn |
| 17477 | (setq type (nth 1 entry) match (nth 2 entry) lprops (nth 3 entry) | 18204 | (setq type (nth 2 entry) match (nth 3 entry) lprops (nth 4 entry)) |
| 17478 | lprops (nth 3 entry)) | ||
| 17479 | (put 'org-agenda-redo-command 'org-lprops lprops) | 18205 | (put 'org-agenda-redo-command 'org-lprops lprops) |
| 17480 | (cond | 18206 | (cond |
| 17481 | ((eq type 'agenda) | 18207 | ((eq type 'agenda) |
| @@ -17502,24 +18228,162 @@ L Timeline for current buffer # List stuck projects (!=configure) | |||
| 17502 | ((eq type 'occur-tree) | 18228 | ((eq type 'occur-tree) |
| 17503 | (org-check-for-org-mode) | 18229 | (org-check-for-org-mode) |
| 17504 | (org-let lprops '(org-occur match))) | 18230 | (org-let lprops '(org-occur match))) |
| 18231 | ((functionp type) | ||
| 18232 | (org-let lprops '(funcall type match))) | ||
| 17505 | ((fboundp type) | 18233 | ((fboundp type) |
| 17506 | (org-let lprops '(funcall type match))) | 18234 | (org-let lprops '(funcall type match))) |
| 17507 | (t (error "Invalid custom agenda command type %s" type)))) | 18235 | (t (error "Invalid custom agenda command type %s" type)))) |
| 17508 | (org-run-agenda-series (nth 1 entry) (cddr entry)))) | 18236 | (org-run-agenda-series (nth 1 entry) (cddr entry)))) |
| 17509 | ((equal c ?C) (customize-variable 'org-agenda-custom-commands)) | 18237 | ((equal keys "C") (customize-variable 'org-agenda-custom-commands)) |
| 17510 | ((equal c ?a) (call-interactively 'org-agenda-list)) | 18238 | ((equal keys "a") (call-interactively 'org-agenda-list)) |
| 17511 | ((equal c ?t) (call-interactively 'org-todo-list)) | 18239 | ((equal keys "t") (call-interactively 'org-todo-list)) |
| 17512 | ((equal c ?T) (org-call-with-arg 'org-todo-list (or arg '(4)))) | 18240 | ((equal keys "T") (org-call-with-arg 'org-todo-list (or arg '(4)))) |
| 17513 | ((equal c ?m) (call-interactively 'org-tags-view)) | 18241 | ((equal keys "m") (call-interactively 'org-tags-view)) |
| 17514 | ((equal c ?M) (org-call-with-arg 'org-tags-view (or arg '(4)))) | 18242 | ((equal keys "M") (org-call-with-arg 'org-tags-view (or arg '(4)))) |
| 17515 | ((equal c ?e) (call-interactively 'org-store-agenda-views)) | 18243 | ((equal keys "e") (call-interactively 'org-store-agenda-views)) |
| 17516 | ((equal c ?L) | 18244 | ((equal keys "L") |
| 17517 | (unless restrict-ok | 18245 | (unless (org-mode-p) |
| 17518 | (error "This is not an Org-mode file")) | 18246 | (error "This is not an Org-mode file")) |
| 17519 | (org-call-with-arg 'org-timeline arg)) | 18247 | (unless restriction |
| 17520 | ((equal c ?#) (call-interactively 'org-agenda-list-stuck-projects)) | 18248 | (put 'org-agenda-files 'org-restrict (list bfn)) |
| 17521 | ((equal c ?!) (customize-variable 'org-stuck-projects)) | 18249 | (org-call-with-arg 'org-timeline arg))) |
| 17522 | (t (error "Invalid key")))))) | 18250 | ((equal keys "#") (call-interactively 'org-agenda-list-stuck-projects)) |
| 18251 | ((equal keys "/") (call-interactively 'org-occur-in-agenda-files)) | ||
| 18252 | ((equal keys "!") (customize-variable 'org-stuck-projects)) | ||
| 18253 | (t (error "Invalid agenda key")))))) | ||
| 18254 | |||
| 18255 | (defun org-agenda-get-restriction-and-command (prefix-descriptions) | ||
| 18256 | "The user interface for selecting an agenda command." | ||
| 18257 | (catch 'exit | ||
| 18258 | (let* ((bfn (buffer-file-name (buffer-base-buffer))) | ||
| 18259 | (restrict-ok (and bfn (org-mode-p))) | ||
| 18260 | (region-p (org-region-active-p)) | ||
| 18261 | (custom org-agenda-custom-commands) | ||
| 18262 | (selstring "") | ||
| 18263 | restriction | ||
| 18264 | c entry key type match prefixes rmheader header-end custom1 desc) | ||
| 18265 | (save-window-excursion | ||
| 18266 | (delete-other-windows) | ||
| 18267 | (org-switch-to-buffer-other-window " *Agenda Commands*") | ||
| 18268 | (erase-buffer) | ||
| 18269 | (insert (eval-when-compile | ||
| 18270 | (let ((header | ||
| 18271 | "Press key for an agenda command: < Buffer,subtree/region restriction | ||
| 18272 | -------------------------------- C Configure custom agenda commands | ||
| 18273 | a Agenda for current week or day e Export agenda views | ||
| 18274 | t List of all TODO entries T Entries with special TODO kwd | ||
| 18275 | m Match a TAGS query M Like m, but only TODO entries | ||
| 18276 | L Timeline for current buffer # List stuck projects (!=configure) | ||
| 18277 | / Multi-occur | ||
| 18278 | ") | ||
| 18279 | (start 0)) | ||
| 18280 | (while (string-match | ||
| 18281 | "\\(^\\| \\|(\\)\\(\\S-\\)\\( \\|=\\)" | ||
| 18282 | header start) | ||
| 18283 | (setq start (match-end 0)) | ||
| 18284 | (add-text-properties (match-beginning 2) (match-end 2) | ||
| 18285 | '(face bold) header)) | ||
| 18286 | header))) | ||
| 18287 | (setq header-end (move-marker (make-marker) (point))) | ||
| 18288 | (while t | ||
| 18289 | (setq custom1 custom) | ||
| 18290 | (when (eq rmheader t) | ||
| 18291 | (goto-line 1) | ||
| 18292 | (re-search-forward ":" nil t) | ||
| 18293 | (delete-region (match-end 0) (line-end-position)) | ||
| 18294 | (forward-char 1) | ||
| 18295 | (looking-at "-+") | ||
| 18296 | (delete-region (match-end 0) (line-end-position)) | ||
| 18297 | (move-marker header-end (match-end 0))) | ||
| 18298 | (goto-char header-end) | ||
| 18299 | (delete-region (point) (point-max)) | ||
| 18300 | (while (setq entry (pop custom1)) | ||
| 18301 | (setq key (car entry) desc (nth 1 entry) | ||
| 18302 | type (nth 2 entry) match (nth 3 entry)) | ||
| 18303 | (if (> (length key) 1) | ||
| 18304 | (add-to-list 'prefixes (string-to-char key)) | ||
| 18305 | (insert | ||
| 18306 | (format | ||
| 18307 | "\n%-4s%-14s: %s" | ||
| 18308 | (org-add-props (copy-sequence key) | ||
| 18309 | '(face bold)) | ||
| 18310 | (cond | ||
| 18311 | ((string-match "\\S-" desc) desc) | ||
| 18312 | ((eq type 'agenda) "Agenda for current week or day") | ||
| 18313 | ((eq type 'alltodo) "List of all TODO entries") | ||
| 18314 | ((eq type 'stuck) "List of stuck projects") | ||
| 18315 | ((eq type 'todo) "TODO keyword") | ||
| 18316 | ((eq type 'tags) "Tags query") | ||
| 18317 | ((eq type 'tags-todo) "Tags (TODO)") | ||
| 18318 | ((eq type 'tags-tree) "Tags tree") | ||
| 18319 | ((eq type 'todo-tree) "TODO kwd tree") | ||
| 18320 | ((eq type 'occur-tree) "Occur tree") | ||
| 18321 | ((functionp type) (if (symbolp type) | ||
| 18322 | (symbol-name type) | ||
| 18323 | "Lambda expression")) | ||
| 18324 | (t "???")) | ||
| 18325 | (cond | ||
| 18326 | ((stringp match) | ||
| 18327 | (org-add-props match nil 'face 'org-warning)) | ||
| 18328 | (match | ||
| 18329 | (format "set of %d commands" (length match))) | ||
| 18330 | (t "")))))) | ||
| 18331 | (when prefixes | ||
| 18332 | (mapcar (lambda (x) | ||
| 18333 | (insert | ||
| 18334 | (format "\n%s %s" | ||
| 18335 | (org-add-props (char-to-string x) | ||
| 18336 | nil 'face 'bold) | ||
| 18337 | (or (cdr (assoc (concat selstring (char-to-string x)) | ||
| 18338 | prefix-descriptions)) | ||
| 18339 | "Prefix key")))) | ||
| 18340 | prefixes)) | ||
| 18341 | (goto-char (point-min)) | ||
| 18342 | (if (and (fboundp 'fit-window-to-buffer) | ||
| 18343 | (not (pos-visible-in-window-p (point-max)))) | ||
| 18344 | (fit-window-to-buffer)) | ||
| 18345 | (message "Press key for agenda command%s:" | ||
| 18346 | (if restrict-ok | ||
| 18347 | (if restriction | ||
| 18348 | (format " (restricted to %s)" restriction) | ||
| 18349 | " (unrestricted)") | ||
| 18350 | "")) | ||
| 18351 | (setq c (read-char-exclusive)) | ||
| 18352 | (message "") | ||
| 18353 | (cond | ||
| 18354 | ((assoc (char-to-string c) custom) | ||
| 18355 | (setq selstring (concat selstring (char-to-string c))) | ||
| 18356 | (throw 'exit (cons selstring restriction))) | ||
| 18357 | ((memq c prefixes) | ||
| 18358 | (setq selstring (concat selstring (char-to-string c)) | ||
| 18359 | prefixes nil | ||
| 18360 | rmheader (or rmheader t) | ||
| 18361 | custom (delq nil (mapcar | ||
| 18362 | (lambda (x) | ||
| 18363 | (if (or (= (length (car x)) 1) | ||
| 18364 | (/= (string-to-char (car x)) c)) | ||
| 18365 | nil | ||
| 18366 | (cons (substring (car x) 1) (cdr x)))) | ||
| 18367 | custom)))) | ||
| 18368 | ((and (not restrict-ok) (memq c '(?1 ?0 ?<))) | ||
| 18369 | (message "Restriction is only possible in Org-mode buffers") | ||
| 18370 | (ding) (sit-for 1)) | ||
| 18371 | ((eq c ?1) | ||
| 18372 | (setq restriction 'buffer)) | ||
| 18373 | ((eq c ?0) | ||
| 18374 | (setq restriction (if region-p 'region 'subtree))) | ||
| 18375 | ((eq c ?<) | ||
| 18376 | (setq restriction | ||
| 18377 | (cond | ||
| 18378 | ((eq restriction 'buffer) | ||
| 18379 | (if region-p 'region 'subtree)) | ||
| 18380 | ((memq restriction '(subtree region)) | ||
| 18381 | nil) | ||
| 18382 | (t 'buffer)))) | ||
| 18383 | ((and (equal selstring "") (memq c '(?a ?t ?m ?L ?C ?e ?T ?M ?# ?/))) | ||
| 18384 | (throw 'exit (cons (setq selstring (char-to-string c)) restriction))) | ||
| 18385 | ((equal c ?q) (error "Abort")) | ||
| 18386 | (t (error "Invalid key %c" c)))))))) | ||
| 17523 | 18387 | ||
| 17524 | (defun org-run-agenda-series (name series) | 18388 | (defun org-run-agenda-series (name series) |
| 17525 | (org-prepare-agenda name) | 18389 | (org-prepare-agenda name) |
| @@ -17570,11 +18434,10 @@ before running the agenda command." | |||
| 17570 | (let (pars) | 18434 | (let (pars) |
| 17571 | (while parameters | 18435 | (while parameters |
| 17572 | (push (list (pop parameters) (if parameters (pop parameters))) pars)) | 18436 | (push (list (pop parameters) (if parameters (pop parameters))) pars)) |
| 17573 | (if (> (length cmd-key) 1) | 18437 | (if (> (length cmd-key) 2) |
| 17574 | (eval (list 'let (nreverse pars) | 18438 | (eval (list 'let (nreverse pars) |
| 17575 | (list 'org-tags-view nil cmd-key))) | 18439 | (list 'org-tags-view nil cmd-key))) |
| 17576 | (flet ((read-char-exclusive () (string-to-char cmd-key))) | 18440 | (eval (list 'let (nreverse pars) (list 'org-agenda nil cmd-key)))) |
| 17577 | (eval (list 'let (nreverse pars) '(org-agenda nil))))) | ||
| 17578 | (set-buffer org-agenda-buffer-name) | 18441 | (set-buffer org-agenda-buffer-name) |
| 17579 | (princ (org-encode-for-stdout (buffer-string))))) | 18442 | (princ (org-encode-for-stdout (buffer-string))))) |
| 17580 | 18443 | ||
| @@ -17625,11 +18488,10 @@ agenda-day The day in the agenda where this is listed" | |||
| 17625 | (while parameters | 18488 | (while parameters |
| 17626 | (push (list (pop parameters) (if parameters (pop parameters))) pars)) | 18489 | (push (list (pop parameters) (if parameters (pop parameters))) pars)) |
| 17627 | (push (list 'org-agenda-remove-tags t) pars) | 18490 | (push (list 'org-agenda-remove-tags t) pars) |
| 17628 | (if (> (length cmd-key) 1) | 18491 | (if (> (length cmd-key) 2) |
| 17629 | (eval (list 'let (nreverse pars) | 18492 | (eval (list 'let (nreverse pars) |
| 17630 | (list 'org-tags-view nil cmd-key))) | 18493 | (list 'org-tags-view nil cmd-key))) |
| 17631 | (flet ((read-char-exclusive () (string-to-char cmd-key))) | 18494 | (eval (list 'let (nreverse pars) (list 'org-agenda nil cmd-key)))) |
| 17632 | (eval (list 'let (nreverse pars) '(org-agenda nil))))) | ||
| 17633 | (set-buffer org-agenda-buffer-name) | 18495 | (set-buffer org-agenda-buffer-name) |
| 17634 | (let* ((lines (org-split-string (buffer-string) "\n")) | 18496 | (let* ((lines (org-split-string (buffer-string) "\n")) |
| 17635 | line) | 18497 | line) |
| @@ -17713,9 +18575,8 @@ so the the export commands caneasily use it." | |||
| 17713 | files (nth 4 cmd)) | 18575 | files (nth 4 cmd)) |
| 17714 | (if (stringp files) (setq files (list files))) | 18576 | (if (stringp files) (setq files (list files))) |
| 17715 | (when files | 18577 | (when files |
| 17716 | (flet ((read-char-exclusive () (string-to-char thiscmdkey))) | 18578 | (eval (list 'let (append org-agenda-exporter-settings opts pars) |
| 17717 | (eval (list 'let (append org-agenda-exporter-settings opts pars) | 18579 | (list 'org-agenda nil thiscmdkey))) |
| 17718 | '(org-agenda nil)))) | ||
| 17719 | (set-buffer org-agenda-buffer-name) | 18580 | (set-buffer org-agenda-buffer-name) |
| 17720 | (while files | 18581 | (while files |
| 17721 | (eval (list 'let (append org-agenda-exporter-settings opts pars) | 18582 | (eval (list 'let (append org-agenda-exporter-settings opts pars) |
| @@ -17781,8 +18642,10 @@ higher priority settings." | |||
| 17781 | "Fit the window to the buffer size." | 18642 | "Fit the window to the buffer size." |
| 17782 | (and (memq org-agenda-window-setup '(reorganize-frame)) | 18643 | (and (memq org-agenda-window-setup '(reorganize-frame)) |
| 17783 | (fboundp 'fit-window-to-buffer) | 18644 | (fboundp 'fit-window-to-buffer) |
| 17784 | (fit-window-to-buffer nil (/ (* (frame-height) 3) 4) | 18645 | (fit-window-to-buffer |
| 17785 | (/ (frame-height) 2)))) | 18646 | nil |
| 18647 | (floor (* (frame-height) (cdr org-agenda-window-frame-fractions))) | ||
| 18648 | (floor (* (frame-height) (car org-agenda-window-frame-fractions)))))) | ||
| 17786 | 18649 | ||
| 17787 | ;;; Agenda file list | 18650 | ;;; Agenda file list |
| 17788 | 18651 | ||
| @@ -17796,6 +18659,12 @@ is currently in place." | |||
| 17796 | ((stringp org-agenda-files) (org-read-agenda-file-list)) | 18659 | ((stringp org-agenda-files) (org-read-agenda-file-list)) |
| 17797 | ((listp org-agenda-files) org-agenda-files) | 18660 | ((listp org-agenda-files) org-agenda-files) |
| 17798 | (t (error "Invalid value of `org-agenda-files'"))))) | 18661 | (t (error "Invalid value of `org-agenda-files'"))))) |
| 18662 | (setq files (apply 'append | ||
| 18663 | (mapcar (lambda (f) | ||
| 18664 | (if (file-directory-p f) | ||
| 18665 | (directory-files f t "\\.org\\'") | ||
| 18666 | (list f))) | ||
| 18667 | files))) | ||
| 17799 | (if org-agenda-skip-unavailable-files | 18668 | (if org-agenda-skip-unavailable-files |
| 17800 | (delq nil | 18669 | (delq nil |
| 17801 | (mapcar (function | 18670 | (mapcar (function |
| @@ -17989,8 +18858,37 @@ Optional argument FILE means, use this file instead of the current." | |||
| 17989 | (if (and (boundp 'org-agenda-view-columns-initially) | 18858 | (if (and (boundp 'org-agenda-view-columns-initially) |
| 17990 | org-agenda-view-columns-initially) | 18859 | org-agenda-view-columns-initially) |
| 17991 | (org-agenda-columns)) | 18860 | (org-agenda-columns)) |
| 18861 | (when org-agenda-fontify-priorities | ||
| 18862 | (org-fontify-priorities)) | ||
| 17992 | (run-hooks 'org-finalize-agenda-hook)))) | 18863 | (run-hooks 'org-finalize-agenda-hook)))) |
| 17993 | 18864 | ||
| 18865 | (defun org-fontify-priorities () | ||
| 18866 | "Make highest priority lines bold, and lowest italic." | ||
| 18867 | (interactive) | ||
| 18868 | (mapc (lambda (o) (if (eq (org-overlay-get o 'org-type) 'org-priority) | ||
| 18869 | (org-delete-overlay o))) | ||
| 18870 | (overlays-in (point-min) (point-max))) | ||
| 18871 | (save-excursion | ||
| 18872 | (let ((ovs (org-overlays-in (point-min) (point-max))) | ||
| 18873 | (inhibit-read-only t) | ||
| 18874 | b e p ov h l) | ||
| 18875 | (goto-char (point-min)) | ||
| 18876 | (while (re-search-forward "\\[#\\(.\\)\\]" nil t) | ||
| 18877 | (setq h (or (get-char-property (point) 'org-highest-priority) | ||
| 18878 | org-highest-priority) | ||
| 18879 | l (or (get-char-property (point) 'org-lowest-priority) | ||
| 18880 | org-lowest-priority) | ||
| 18881 | p (string-to-char (match-string 1)) | ||
| 18882 | b (match-beginning 0) e (line-end-position) | ||
| 18883 | ov (org-make-overlay b e)) | ||
| 18884 | (org-overlay-put | ||
| 18885 | ov 'face | ||
| 18886 | (cond ((listp org-agenda-fontify-priorities) | ||
| 18887 | (cdr (assoc p org-agenda-fontify-priorities))) | ||
| 18888 | ((equal p l) 'italic) | ||
| 18889 | ((equal p h) 'bold))) | ||
| 18890 | (org-overlay-put ov 'org-type 'org-priority))))) | ||
| 18891 | |||
| 17994 | (defun org-prepare-agenda-buffers (files) | 18892 | (defun org-prepare-agenda-buffers (files) |
| 17995 | "Create buffers for all agenda files, protect archived trees and comments." | 18893 | "Create buffers for all agenda files, protect archived trees and comments." |
| 17996 | (interactive) | 18894 | (interactive) |
| @@ -18116,6 +19014,8 @@ When a buffer is unmodified, it is just killed. When modified, it is saved | |||
| 18116 | 19014 | ||
| 18117 | ;;; Agenda timeline | 19015 | ;;; Agenda timeline |
| 18118 | 19016 | ||
| 19017 | (defvar org-agenda-only-exact-dates nil) ; dynamically scoped | ||
| 19018 | |||
| 18119 | (defun org-timeline (&optional include-all) | 19019 | (defun org-timeline (&optional include-all) |
| 18120 | "Show a time-sorted view of the entries in the current org file. | 19020 | "Show a time-sorted view of the entries in the current org file. |
| 18121 | Only entries with a time stamp of today or later will be listed. With | 19021 | Only entries with a time stamp of today or later will be listed. With |
| @@ -18137,6 +19037,8 @@ dates." | |||
| 18137 | (day-numbers (org-get-all-dates beg end 'no-ranges | 19037 | (day-numbers (org-get-all-dates beg end 'no-ranges |
| 18138 | t doclosed ; always include today | 19038 | t doclosed ; always include today |
| 18139 | org-timeline-show-empty-dates)) | 19039 | org-timeline-show-empty-dates)) |
| 19040 | (org-deadline-warning-days 0) | ||
| 19041 | (org-agenda-only-exact-dates t) | ||
| 18140 | (today (time-to-days (current-time))) | 19042 | (today (time-to-days (current-time))) |
| 18141 | (past t) | 19043 | (past t) |
| 18142 | args | 19044 | args |
| @@ -18154,6 +19056,8 @@ dates." | |||
| 18154 | (file-name-nondirectory buffer-file-name))) | 19056 | (file-name-nondirectory buffer-file-name))) |
| 18155 | (if doclosed (push :closed args)) | 19057 | (if doclosed (push :closed args)) |
| 18156 | (push :timestamp args) | 19058 | (push :timestamp args) |
| 19059 | (push :deadline args) | ||
| 19060 | (push :scheduled args) | ||
| 18157 | (push :sexp args) | 19061 | (push :sexp args) |
| 18158 | (if dotodo (push :todo args)) | 19062 | (if dotodo (push :todo args)) |
| 18159 | (while (setq d (pop day-numbers)) | 19063 | (while (setq d (pop day-numbers)) |
| @@ -18289,6 +19193,7 @@ NDAYS defaults to `org-agenda-ndays'." | |||
| 18289 | (d (- nt n1))) | 19193 | (d (- nt n1))) |
| 18290 | (- sd (+ (if (< d 0) 7 0) d))))) | 19194 | (- sd (+ (if (< d 0) 7 0) d))))) |
| 18291 | (day-numbers (list start)) | 19195 | (day-numbers (list start)) |
| 19196 | (day-cnt 0) | ||
| 18292 | (inhibit-redisplay (not debug-on-error)) | 19197 | (inhibit-redisplay (not debug-on-error)) |
| 18293 | s e rtn rtnall file date d start-pos end-pos todayp nd) | 19198 | s e rtn rtnall file date d start-pos end-pos todayp nd) |
| 18294 | (setq org-agenda-redo-command | 19199 | (setq org-agenda-redo-command |
| @@ -18355,6 +19260,7 @@ NDAYS defaults to `org-agenda-ndays'." | |||
| 18355 | (setq rtnall (append rtnall rtn)))) | 19260 | (setq rtnall (append rtnall rtn)))) |
| 18356 | (if (or rtnall org-agenda-show-all-dates) | 19261 | (if (or rtnall org-agenda-show-all-dates) |
| 18357 | (progn | 19262 | (progn |
| 19263 | (setq day-cnt (1+ day-cnt)) | ||
| 18358 | (insert | 19264 | (insert |
| 18359 | (if (stringp org-agenda-format-date) | 19265 | (if (stringp org-agenda-format-date) |
| 18360 | (format-time-string org-agenda-format-date | 19266 | (format-time-string org-agenda-format-date |
| @@ -18363,13 +19269,15 @@ NDAYS defaults to `org-agenda-ndays'." | |||
| 18363 | "\n") | 19269 | "\n") |
| 18364 | (put-text-property s (1- (point)) 'face 'org-agenda-structure) | 19270 | (put-text-property s (1- (point)) 'face 'org-agenda-structure) |
| 18365 | (put-text-property s (1- (point)) 'org-date-line t) | 19271 | (put-text-property s (1- (point)) 'org-date-line t) |
| 19272 | (put-text-property s (1- (point)) 'org-day-cnt day-cnt) | ||
| 18366 | (if todayp (put-text-property s (1- (point)) 'org-today t)) | 19273 | (if todayp (put-text-property s (1- (point)) 'org-today t)) |
| 18367 | (if rtnall (insert | 19274 | (if rtnall (insert |
| 18368 | (org-finalize-agenda-entries | 19275 | (org-finalize-agenda-entries |
| 18369 | (org-agenda-add-time-grid-maybe | 19276 | (org-agenda-add-time-grid-maybe |
| 18370 | rtnall nd todayp)) | 19277 | rtnall nd todayp)) |
| 18371 | "\n")) | 19278 | "\n")) |
| 18372 | (put-text-property s (1- (point)) 'day d)))) | 19279 | (put-text-property s (1- (point)) 'day d) |
| 19280 | (put-text-property s (1- (point)) 'org-day-cnt day-cnt)))) | ||
| 18373 | (goto-char (point-min)) | 19281 | (goto-char (point-min)) |
| 18374 | (org-fit-agenda-window) | 19282 | (org-fit-agenda-window) |
| 18375 | (unless (and (pos-visible-in-window-p (point-min)) | 19283 | (unless (and (pos-visible-in-window-p (point-min)) |
| @@ -18868,11 +19776,24 @@ the documentation of `org-diary'." | |||
| 18868 | 19776 | ||
| 18869 | ;; FIXME: this works only if the cursor is *not* at the | 19777 | ;; FIXME: this works only if the cursor is *not* at the |
| 18870 | ;; beginning of the entry | 19778 | ;; beginning of the entry |
| 19779 | ;(defun org-entry-is-done-p () | ||
| 19780 | ; "Is the current entry marked DONE?" | ||
| 19781 | ; (save-excursion | ||
| 19782 | ; (and (re-search-backward "[\r\n]\\*+ " nil t) | ||
| 19783 | ; (looking-at org-nl-done-regexp)))) | ||
| 19784 | |||
| 19785 | (defun org-entry-is-todo-p () | ||
| 19786 | (member (org-get-todo-state) org-not-done-keywords)) | ||
| 19787 | |||
| 18871 | (defun org-entry-is-done-p () | 19788 | (defun org-entry-is-done-p () |
| 18872 | "Is the current entry marked DONE?" | 19789 | (member (org-get-todo-state) org-done-keywords)) |
| 19790 | |||
| 19791 | (defun org-get-todo-state () | ||
| 18873 | (save-excursion | 19792 | (save-excursion |
| 18874 | (and (re-search-backward "[\r\n]\\*+ " nil t) | 19793 | (org-back-to-heading t) |
| 18875 | (looking-at org-nl-done-regexp)))) | 19794 | (and (looking-at org-todo-line-regexp) |
| 19795 | (match-end 2) | ||
| 19796 | (match-string 2)))) | ||
| 18876 | 19797 | ||
| 18877 | (defun org-at-date-range-p (&optional inactive-ok) | 19798 | (defun org-at-date-range-p (&optional inactive-ok) |
| 18878 | "Is the cursor inside a date range?" | 19799 | "Is the cursor inside a date range?" |
| @@ -18921,7 +19842,9 @@ the documentation of `org-diary'." | |||
| 18921 | (save-match-data | 19842 | (save-match-data |
| 18922 | (beginning-of-line) | 19843 | (beginning-of-line) |
| 18923 | (setq beg (point) end (progn (outline-next-heading) (point))) | 19844 | (setq beg (point) end (progn (outline-next-heading) (point))) |
| 18924 | (when (or (and org-agenda-todo-ignore-scheduled (goto-char beg) | 19845 | (when (or (and org-agenda-todo-ignore-with-date (goto-char beg) |
| 19846 | (re-search-forward org-ts-regexp end t)) | ||
| 19847 | (and org-agenda-todo-ignore-scheduled (goto-char beg) | ||
| 18925 | (re-search-forward org-scheduled-time-regexp end t)) | 19848 | (re-search-forward org-scheduled-time-regexp end t)) |
| 18926 | (and org-agenda-todo-ignore-deadlines (goto-char beg) | 19849 | (and org-agenda-todo-ignore-deadlines (goto-char beg) |
| 18927 | (re-search-forward org-deadline-time-regexp end t) | 19850 | (re-search-forward org-deadline-time-regexp end t) |
| @@ -19151,7 +20074,8 @@ the documentation of `org-diary'." | |||
| 19151 | ;; When to show a deadline in the calendar: | 20074 | ;; When to show a deadline in the calendar: |
| 19152 | ;; If the expiration is within wdays warning time. | 20075 | ;; If the expiration is within wdays warning time. |
| 19153 | ;; Past-due deadlines are only shown on the current date | 20076 | ;; Past-due deadlines are only shown on the current date |
| 19154 | (if (or (and (<= diff wdays) todayp) | 20077 | (if (or (and (<= diff wdays) |
| 20078 | (and todayp (not org-agenda-only-exact-dates))) | ||
| 19155 | (= diff 0)) | 20079 | (= diff 0)) |
| 19156 | (save-excursion | 20080 | (save-excursion |
| 19157 | (setq category (org-get-category)) | 20081 | (setq category (org-get-category)) |
| @@ -19175,8 +20099,9 @@ the documentation of `org-diary'." | |||
| 19175 | (setq txt nil) | 20099 | (setq txt nil) |
| 19176 | (setq txt (org-format-agenda-item | 20100 | (setq txt (org-format-agenda-item |
| 19177 | (if (= diff 0) | 20101 | (if (= diff 0) |
| 19178 | "Deadline: " | 20102 | (car org-agenda-deadline-leaders) |
| 19179 | (format "In %3d d.: " diff)) | 20103 | (format (nth 1 org-agenda-deadline-leaders) |
| 20104 | diff)) | ||
| 19180 | head category tags timestr)))) | 20105 | head category tags timestr)))) |
| 19181 | (setq txt org-agenda-no-heading-message)) | 20106 | (setq txt org-agenda-no-heading-message)) |
| 19182 | (when txt | 20107 | (when txt |
| @@ -19228,7 +20153,8 @@ FRACTION is what fraction of the head-warning time has passed." | |||
| 19228 | (setq pastschedp (and todayp (< diff 0))) | 20153 | (setq pastschedp (and todayp (< diff 0))) |
| 19229 | ;; When to show a scheduled item in the calendar: | 20154 | ;; When to show a scheduled item in the calendar: |
| 19230 | ;; If it is on or past the date. | 20155 | ;; If it is on or past the date. |
| 19231 | (if (or (and (< diff 0) todayp) | 20156 | (if (or (and (< diff 0) |
| 20157 | (and todayp (not org-agenda-only-exact-dates))) | ||
| 19232 | (= diff 0)) | 20158 | (= diff 0)) |
| 19233 | (save-excursion | 20159 | (save-excursion |
| 19234 | (setq category (org-get-category)) | 20160 | (setq category (org-get-category)) |
| @@ -19251,8 +20177,9 @@ FRACTION is what fraction of the head-warning time has passed." | |||
| 19251 | (setq txt nil) | 20177 | (setq txt nil) |
| 19252 | (setq txt (org-format-agenda-item | 20178 | (setq txt (org-format-agenda-item |
| 19253 | (if (= diff 0) | 20179 | (if (= diff 0) |
| 19254 | "Scheduled: " | 20180 | (car org-agenda-scheduled-leaders) |
| 19255 | (format "Sched.%2dx: " (- 1 diff))) | 20181 | (format (nth 1 org-agenda-scheduled-leaders) |
| 20182 | (- 1 diff))) | ||
| 19256 | head category tags timestr)))) | 20183 | head category tags timestr)))) |
| 19257 | (setq txt org-agenda-no-heading-message)) | 20184 | (setq txt org-agenda-no-heading-message)) |
| 19258 | (when txt | 20185 | (when txt |
| @@ -19412,6 +20339,7 @@ Any match of REMOVE-RE will be removed from TXT." | |||
| 19412 | ;; The user can turn this off with a variable. | 20339 | ;; The user can turn this off with a variable. |
| 19413 | (if (and org-agenda-remove-times-when-in-prefix (or stamp plain) | 20340 | (if (and org-agenda-remove-times-when-in-prefix (or stamp plain) |
| 19414 | (string-match (concat (regexp-quote s0) " *") txt) | 20341 | (string-match (concat (regexp-quote s0) " *") txt) |
| 20342 | (not (equal ?\] (string-to-char (substring txt (match-end 0))))) | ||
| 19415 | (if (eq org-agenda-remove-times-when-in-prefix 'beg) | 20343 | (if (eq org-agenda-remove-times-when-in-prefix 'beg) |
| 19416 | (= (match-beginning 0) 0) | 20344 | (= (match-beginning 0) 0) |
| 19417 | t)) | 20345 | t)) |
| @@ -19460,6 +20388,8 @@ Any match of REMOVE-RE will be removed from TXT." | |||
| 19460 | ;; And finally add the text properties | 20388 | ;; And finally add the text properties |
| 19461 | (org-add-props rtn nil | 20389 | (org-add-props rtn nil |
| 19462 | 'org-category (downcase category) 'tags tags | 20390 | 'org-category (downcase category) 'tags tags |
| 20391 | 'org-highest-priority org-highest-priority | ||
| 20392 | 'org-lowest-priority org-lowest-priority | ||
| 19463 | 'prefix-length (- (length rtn) (length txt)) | 20393 | 'prefix-length (- (length rtn) (length txt)) |
| 19464 | 'time-of-day time-of-day | 20394 | 'time-of-day time-of-day |
| 19465 | 'txt txt | 20395 | 'txt txt |
| @@ -19553,11 +20483,8 @@ The optional STRING argument forces conversion into a 5 character wide string | |||
| 19553 | HH:MM." | 20483 | HH:MM." |
| 19554 | (save-match-data | 20484 | (save-match-data |
| 19555 | (when | 20485 | (when |
| 19556 | (or | 20486 | (or (string-match "\\<\\([012]?[0-9]\\)\\(:\\([0-5][0-9]\\)\\)\\([AaPp][Mm]\\)?\\> *" s) |
| 19557 | (string-match | 20487 | (string-match "\\<\\([012]?[0-9]\\)\\(:\\([0-5][0-9]\\)\\)?\\([AaPp][Mm]\\)\\> *" s)) |
| 19558 | "\\<\\([012]?[0-9]\\)\\(:\\([0-5][0-9]\\)\\)\\([AaPp][Mm]\\)?\\> *" s) | ||
| 19559 | (string-match | ||
| 19560 | "\\<\\([012]?[0-9]\\)\\(:\\([0-5][0-9]\\)\\)?\\([AaPp][Mm]\\)\\> *" s)) | ||
| 19561 | (let* ((h (string-to-number (match-string 1 s))) | 20488 | (let* ((h (string-to-number (match-string 1 s))) |
| 19562 | (m (if (match-end 3) (string-to-number (match-string 3 s)) 0)) | 20489 | (m (if (match-end 3) (string-to-number (match-string 3 s)) 0)) |
| 19563 | (ampm (if (match-end 4) (downcase (match-string 4 s)))) | 20490 | (ampm (if (match-end 4) (downcase (match-string 4 s)))) |
| @@ -19728,12 +20655,13 @@ When this is the global TODO list, a prefix argument will be interpreted." | |||
| 19728 | (setf (nth 1 org-agenda-overriding-arguments) (car comp)) | 20655 | (setf (nth 1 org-agenda-overriding-arguments) (car comp)) |
| 19729 | (setf (nth 2 org-agenda-overriding-arguments) (cdr comp)) | 20656 | (setf (nth 2 org-agenda-overriding-arguments) (cdr comp)) |
| 19730 | (org-agenda-redo) | 20657 | (org-agenda-redo) |
| 19731 | (org-agenda-find-today-or-agenda))) | 20658 | (org-agenda-find-same-or-today-or-agenda))) |
| 19732 | (t (error "Cannot find today"))))) | 20659 | (t (error "Cannot find today"))))) |
| 19733 | 20660 | ||
| 19734 | (defun org-agenda-find-today-or-agenda () | 20661 | (defun org-agenda-find-same-or-today-or-agenda (&optional cnt) |
| 19735 | (goto-char | 20662 | (goto-char |
| 19736 | (or (text-property-any (point-min) (point-max) 'org-today t) | 20663 | (or (and cnt (text-property-any (point-min) (point-max) 'org-day-cnt cnt)) |
| 20664 | (text-property-any (point-min) (point-max) 'org-today t) | ||
| 19737 | (text-property-any (point-min) (point-max) 'org-agenda-type 'agenda) | 20665 | (text-property-any (point-min) (point-max) 'org-agenda-type 'agenda) |
| 19738 | (point-min)))) | 20666 | (point-min)))) |
| 19739 | 20667 | ||
| @@ -19745,6 +20673,7 @@ With prefix ARG, go forward that many times the current span." | |||
| 19745 | (let* ((span org-agenda-span) | 20673 | (let* ((span org-agenda-span) |
| 19746 | (sd org-starting-day) | 20674 | (sd org-starting-day) |
| 19747 | (greg (calendar-gregorian-from-absolute sd)) | 20675 | (greg (calendar-gregorian-from-absolute sd)) |
| 20676 | (cnt (get-text-property (point) 'org-day-cnt)) | ||
| 19748 | greg2 nd) | 20677 | greg2 nd) |
| 19749 | (cond | 20678 | (cond |
| 19750 | ((eq span 'day) | 20679 | ((eq span 'day) |
| @@ -19763,9 +20692,9 @@ With prefix ARG, go forward that many times the current span." | |||
| 19763 | (setq nd (- (calendar-absolute-from-gregorian greg2) sd)))) | 20692 | (setq nd (- (calendar-absolute-from-gregorian greg2) sd)))) |
| 19764 | (let ((org-agenda-overriding-arguments | 20693 | (let ((org-agenda-overriding-arguments |
| 19765 | (list (car org-agenda-last-arguments) sd nd t))) | 20694 | (list (car org-agenda-last-arguments) sd nd t))) |
| 19766 | (org-agenda-redo) | 20695 | (org-agenda-redo) |
| 19767 | (org-agenda-find-today-or-agenda)))) | 20696 | (org-agenda-find-same-or-today-or-agenda cnt)))) |
| 19768 | 20697 | ||
| 19769 | (defun org-agenda-earlier (arg) | 20698 | (defun org-agenda-earlier (arg) |
| 19770 | "Go backward in time by the current span. | 20699 | "Go backward in time by the current span. |
| 19771 | With prefix ARG, go backward that many times the current span." | 20700 | With prefix ARG, go backward that many times the current span." |
| @@ -19806,7 +20735,7 @@ SPAN may be `day', `week', `month', `year'." | |||
| 19806 | (list (car org-agenda-last-arguments) | 20735 | (list (car org-agenda-last-arguments) |
| 19807 | (car computed) (cdr computed) t))) | 20736 | (car computed) (cdr computed) t))) |
| 19808 | (org-agenda-redo) | 20737 | (org-agenda-redo) |
| 19809 | (org-agenda-find-today-or-agenda)) | 20738 | (org-agenda-find-same-or-today-or-agenda)) |
| 19810 | (org-agenda-set-mode-name) | 20739 | (org-agenda-set-mode-name) |
| 19811 | (message "Switched to %s view" span)) | 20740 | (message "Switched to %s view" span)) |
| 19812 | 20741 | ||
| @@ -20059,13 +20988,10 @@ If this information is not given, the function uses the tree at point." | |||
| 20059 | (defun org-agenda-open-link () | 20988 | (defun org-agenda-open-link () |
| 20060 | "Follow the link in the current line, if any." | 20989 | "Follow the link in the current line, if any." |
| 20061 | (interactive) | 20990 | (interactive) |
| 20062 | (let ((eol (point-at-eol))) | 20991 | (save-excursion |
| 20063 | (save-excursion | 20992 | (save-restriction |
| 20064 | (if (or (re-search-forward org-bracket-link-regexp eol t) | 20993 | (narrow-to-region (point-at-bol) (point-at-eol)) |
| 20065 | (re-search-forward org-angle-link-re eol t) | 20994 | (org-open-at-point)))) |
| 20066 | (re-search-forward org-plain-link-re eol t)) | ||
| 20067 | (call-interactively 'org-open-at-point) | ||
| 20068 | (error "No link in current line"))))) | ||
| 20069 | 20995 | ||
| 20070 | (defun org-agenda-switch-to (&optional delete-other-windows) | 20996 | (defun org-agenda-switch-to (&optional delete-other-windows) |
| 20071 | "Go to the Org-mode file which contains the item at point." | 20997 | "Go to the Org-mode file which contains the item at point." |
| @@ -20479,7 +21405,7 @@ be used to request time specification in the time stamp." | |||
| 20479 | (save-excursion | 21405 | (save-excursion |
| 20480 | (org-back-to-heading t) | 21406 | (org-back-to-heading t) |
| 20481 | (if (looking-at | 21407 | (if (looking-at |
| 20482 | (if no-tags | 21408 | (if no-tags |
| 20483 | (org-re "\\*+[ \t]+\\([^\n\r]*?\\)\\([ \t]+:[[:alnum:]:_@]+:[ \t]*\\)?$") | 21409 | (org-re "\\*+[ \t]+\\([^\n\r]*?\\)\\([ \t]+:[[:alnum:]:_@]+:[ \t]*\\)?$") |
| 20484 | "\\*+[ \t]+\\([^\r\n]*\\)")) | 21410 | "\\*+[ \t]+\\([^\r\n]*\\)")) |
| 20485 | (match-string 1) ""))) | 21411 | (match-string 1) ""))) |
| @@ -20980,7 +21906,8 @@ The images can be removed again with \\[org-ctrl-c-ctrl-c]." | |||
| 20980 | (:emphasize . org-export-with-emphasize) | 21906 | (:emphasize . org-export-with-emphasize) |
| 20981 | (:sub-superscript . org-export-with-sub-superscripts) | 21907 | (:sub-superscript . org-export-with-sub-superscripts) |
| 20982 | (:footnotes . org-export-with-footnotes) | 21908 | (:footnotes . org-export-with-footnotes) |
| 20983 | (:property-drawer . org-export-with-property-drawer) | 21909 | (:drawers . org-export-with-drawers) |
| 21910 | (:tags . org-export-with-tags) | ||
| 20984 | (:TeX-macros . org-export-with-TeX-macros) | 21911 | (:TeX-macros . org-export-with-TeX-macros) |
| 20985 | (:LaTeX-fragments . org-export-with-LaTeX-fragments) | 21912 | (:LaTeX-fragments . org-export-with-LaTeX-fragments) |
| 20986 | (:skip-before-1st-heading . org-export-skip-text-before-1st-heading) | 21913 | (:skip-before-1st-heading . org-export-skip-text-before-1st-heading) |
| @@ -21042,7 +21969,8 @@ The images can be removed again with \\[org-ctrl-c-ctrl-c]." | |||
| 21042 | ("|" . :tables) | 21969 | ("|" . :tables) |
| 21043 | ("^" . :sub-superscript) | 21970 | ("^" . :sub-superscript) |
| 21044 | ("f" . :footnotes) | 21971 | ("f" . :footnotes) |
| 21045 | ("p" . :property-drawer) | 21972 | ("d" . :drawers) |
| 21973 | ("tags" . :tags) | ||
| 21046 | ("*" . :emphasize) | 21974 | ("*" . :emphasize) |
| 21047 | ("TeX" . :TeX-macros) | 21975 | ("TeX" . :TeX-macros) |
| 21048 | ("LaTeX" . :LaTeX-fragments) | 21976 | ("LaTeX" . :LaTeX-fragments) |
| @@ -21503,11 +22431,18 @@ translations. There is currently no way for users to extend this.") | |||
| 21503 | b (org-end-of-subtree t)) | 22431 | b (org-end-of-subtree t)) |
| 21504 | (if (> b a) (delete-region a b))))) | 22432 | (if (> b a) (delete-region a b))))) |
| 21505 | 22433 | ||
| 21506 | ;; Get rid of property drawers | 22434 | ;; Get rid of drawers |
| 21507 | (unless org-export-with-property-drawer | 22435 | (unless (eq t org-export-with-drawers) |
| 21508 | (goto-char (point-min)) | 22436 | (goto-char (point-min)) |
| 21509 | (while (re-search-forward "^[ \t]*:PROPERTIES:[ \t]*\n\\([^@]*?\n\\)?[ \t]*:END:[ \t]*\n" nil t) | 22437 | (let ((re (concat "^[ \t]*:\\(" |
| 21510 | (replace-match ""))) | 22438 | (mapconcat 'identity |
| 22439 | (if (listp org-export-with-drawers) | ||
| 22440 | org-export-with-drawers | ||
| 22441 | org-drawers) | ||
| 22442 | "\\|") | ||
| 22443 | "\\):[ \t]*\n\\([^@]*?\n\\)?[ \t]*:END:[ \t]*\n"))) | ||
| 22444 | (while (re-search-forward re nil t) | ||
| 22445 | (replace-match "")))) | ||
| 21511 | 22446 | ||
| 21512 | ;; Find targets in comments and move them out of comments, | 22447 | ;; Find targets in comments and move them out of comments, |
| 21513 | ;; but mark them as targets that should be invisible | 22448 | ;; but mark them as targets that should be invisible |
| @@ -21529,7 +22464,7 @@ translations. There is currently no way for users to extend this.") | |||
| 21529 | (setq fmt (pop formatters)) | 22464 | (setq fmt (pop formatters)) |
| 21530 | (when (car fmt) | 22465 | (when (car fmt) |
| 21531 | (goto-char (point-min)) | 22466 | (goto-char (point-min)) |
| 21532 | (while (re-search-forward (concat "^#\\+" (cadr fmt) | 22467 | (while (re-search-forward (concat "^#\\+" (cadr fmt) |
| 21533 | ":[ \t]*\\(.*\\)") nil t) | 22468 | ":[ \t]*\\(.*\\)") nil t) |
| 21534 | (replace-match "\\1" t) | 22469 | (replace-match "\\1" t) |
| 21535 | (add-text-properties | 22470 | (add-text-properties |
| @@ -21537,7 +22472,7 @@ translations. There is currently no way for users to extend this.") | |||
| 21537 | '(org-protected t)))) | 22472 | '(org-protected t)))) |
| 21538 | (goto-char (point-min)) | 22473 | (goto-char (point-min)) |
| 21539 | (while (re-search-forward | 22474 | (while (re-search-forward |
| 21540 | (concat "^#\\+" | 22475 | (concat "^#\\+" |
| 21541 | (caddr fmt) "\\>.*\\(\\(\n.*\\)*?\n\\)#\\+" | 22476 | (caddr fmt) "\\>.*\\(\\(\n.*\\)*?\n\\)#\\+" |
| 21542 | (cadddr fmt) "\\>.*\n?") nil t) | 22477 | (cadddr fmt) "\\>.*\n?") nil t) |
| 21543 | (if (car fmt) | 22478 | (if (car fmt) |
| @@ -21688,7 +22623,7 @@ translations. There is currently no way for users to extend this.") | |||
| 21688 | (add-text-properties (point) (1+ (point-at-eol)) | 22623 | (add-text-properties (point) (1+ (point-at-eol)) |
| 21689 | (list :org-license-to-kill t))))) | 22624 | (list :org-license-to-kill t))))) |
| 21690 | title)) | 22625 | title)) |
| 21691 | 22626 | ||
| 21692 | (defun org-solidify-link-text (s &optional alist) | 22627 | (defun org-solidify-link-text (s &optional alist) |
| 21693 | "Take link text and make a safe target out of it." | 22628 | "Take link text and make a safe target out of it." |
| 21694 | (save-match-data | 22629 | (save-match-data |
| @@ -21848,10 +22783,10 @@ underlined headlines. The default is 3." | |||
| 21848 | (fundamental-mode) | 22783 | (fundamental-mode) |
| 21849 | ;; create local variables for all options, to make sure all called | 22784 | ;; create local variables for all options, to make sure all called |
| 21850 | ;; functions get the correct information | 22785 | ;; functions get the correct information |
| 21851 | (mapc (lambda (x) | 22786 | (mapcar (lambda (x) |
| 21852 | (set (make-local-variable (cdr x)) | 22787 | (set (make-local-variable (cdr x)) |
| 21853 | (plist-get opt-plist (car x)))) | 22788 | (plist-get opt-plist (car x)))) |
| 21854 | org-export-plist-vars) | 22789 | org-export-plist-vars) |
| 21855 | (org-set-local 'org-odd-levels-only odd) | 22790 | (org-set-local 'org-odd-levels-only odd) |
| 21856 | (setq umax (if arg (prefix-numeric-value arg) | 22791 | (setq umax (if arg (prefix-numeric-value arg) |
| 21857 | org-export-headline-levels)) | 22792 | org-export-headline-levels)) |
| @@ -21883,49 +22818,55 @@ underlined headlines. The default is 3." | |||
| 21883 | (progn | 22818 | (progn |
| 21884 | (push (concat (nth 3 lang-words) "\n") thetoc) | 22819 | (push (concat (nth 3 lang-words) "\n") thetoc) |
| 21885 | (push (concat (make-string (length (nth 3 lang-words)) ?=) "\n") thetoc) | 22820 | (push (concat (make-string (length (nth 3 lang-words)) ?=) "\n") thetoc) |
| 21886 | (mapc '(lambda (line) | 22821 | (mapcar '(lambda (line) |
| 21887 | (if (string-match org-todo-line-regexp | 22822 | (if (string-match org-todo-line-regexp |
| 21888 | line) | 22823 | line) |
| 21889 | ;; This is a headline | 22824 | ;; This is a headline |
| 21890 | (progn | 22825 | (progn |
| 21891 | (setq have-headings t) | 22826 | (setq have-headings t) |
| 21892 | (setq level (- (match-end 1) (match-beginning 1)) | 22827 | (setq level (- (match-end 1) (match-beginning 1)) |
| 21893 | level (org-tr-level level) | 22828 | level (org-tr-level level) |
| 21894 | txt (match-string 3 line) | 22829 | txt (match-string 3 line) |
| 21895 | todo | 22830 | todo |
| 21896 | (or (and org-export-mark-todo-in-toc | 22831 | (or (and org-export-mark-todo-in-toc |
| 21897 | (match-beginning 2) | 22832 | (match-beginning 2) |
| 21898 | (not (member (match-string 2 line) | 22833 | (not (member (match-string 2 line) |
| 21899 | org-done-keywords))) | 22834 | org-done-keywords))) |
| 21900 | ; TODO, not DONE | 22835 | ; TODO, not DONE |
| 21901 | (and org-export-mark-todo-in-toc | 22836 | (and org-export-mark-todo-in-toc |
| 21902 | (= level umax-toc) | 22837 | (= level umax-toc) |
| 21903 | (org-search-todo-below | 22838 | (org-search-todo-below |
| 21904 | line lines level)))) | 22839 | line lines level)))) |
| 21905 | (setq txt (org-html-expand-for-ascii txt)) | 22840 | (setq txt (org-html-expand-for-ascii txt)) |
| 21906 | 22841 | ||
| 21907 | (if (and (memq org-export-with-tags '(not-in-toc nil)) | 22842 | (while (string-match org-bracket-link-regexp txt) |
| 21908 | (string-match | 22843 | (setq txt |
| 21909 | (org-re "[ \t]+:[[:alnum:]_@:]+:[ \t]*$") | 22844 | (replace-match |
| 21910 | txt)) | 22845 | (match-string (if (match-end 2) 3 1) txt) |
| 21911 | (setq txt (replace-match "" t t txt))) | 22846 | t t txt))) |
| 21912 | (if (string-match quote-re0 txt) | 22847 | |
| 21913 | (setq txt (replace-match "" t t txt))) | 22848 | (if (and (memq org-export-with-tags '(not-in-toc nil)) |
| 21914 | 22849 | (string-match | |
| 21915 | (if org-export-with-section-numbers | 22850 | (org-re "[ \t]+:[[:alnum:]_@:]+:[ \t]*$") |
| 21916 | (setq txt (concat (org-section-number level) | 22851 | txt)) |
| 21917 | " " txt))) | 22852 | (setq txt (replace-match "" t t txt))) |
| 21918 | (if (<= level umax-toc) | 22853 | (if (string-match quote-re0 txt) |
| 21919 | (progn | 22854 | (setq txt (replace-match "" t t txt))) |
| 21920 | (push | 22855 | |
| 21921 | (concat | 22856 | (if org-export-with-section-numbers |
| 21922 | (make-string | 22857 | (setq txt (concat (org-section-number level) |
| 21923 | (* (max 0 (- level org-min-level)) 4) ?\ ) | 22858 | " " txt))) |
| 21924 | (format (if todo "%s (*)\n" "%s\n") txt)) | 22859 | (if (<= level umax-toc) |
| 21925 | thetoc) | 22860 | (progn |
| 21926 | (setq org-last-level level)) | 22861 | (push |
| 21927 | )))) | 22862 | (concat |
| 21928 | lines) | 22863 | (make-string |
| 22864 | (* (max 0 (- level org-min-level)) 4) ?\ ) | ||
| 22865 | (format (if todo "%s (*)\n" "%s\n") txt)) | ||
| 22866 | thetoc) | ||
| 22867 | (setq org-last-level level)) | ||
| 22868 | )))) | ||
| 22869 | lines) | ||
| 21929 | (setq thetoc (if have-headings (nreverse thetoc) nil)))) | 22870 | (setq thetoc (if have-headings (nreverse thetoc) nil)))) |
| 21930 | 22871 | ||
| 21931 | (org-init-section-numbers) | 22872 | (org-init-section-numbers) |
| @@ -21988,6 +22929,15 @@ underlined headlines. The default is 3." | |||
| 21988 | (or (looking-at "[ \t]*\n[ \t]*\n") | 22929 | (or (looking-at "[ \t]*\n[ \t]*\n") |
| 21989 | (insert "\n\n"))) | 22930 | (insert "\n\n"))) |
| 21990 | 22931 | ||
| 22932 | ;; Convert whitespace place holders | ||
| 22933 | (goto-char (point-min)) | ||
| 22934 | (let (beg end) | ||
| 22935 | (while (setq beg (next-single-property-change (point) 'org-whitespace)) | ||
| 22936 | (setq end (next-single-property-change beg 'org-whitespace)) | ||
| 22937 | (goto-char beg) | ||
| 22938 | (delete-region beg end) | ||
| 22939 | (insert (make-string (- end beg) ?\ )))) | ||
| 22940 | |||
| 21991 | (save-buffer) | 22941 | (save-buffer) |
| 21992 | ;; remove display and invisible chars | 22942 | ;; remove display and invisible chars |
| 21993 | (let (beg end) | 22943 | (let (beg end) |
| @@ -22153,11 +23103,12 @@ Does include HTML export options as well as TODO and CATEGORY stuff." | |||
| 22153 | #+EMAIL: %s | 23103 | #+EMAIL: %s |
| 22154 | #+LANGUAGE: %s | 23104 | #+LANGUAGE: %s |
| 22155 | #+TEXT: Some descriptive text to be emitted. Several lines OK. | 23105 | #+TEXT: Some descriptive text to be emitted. Several lines OK. |
| 22156 | #+OPTIONS: H:%d num:%s toc:%s \\n:%s @:%s ::%s |:%s ^:%s f:%s *:%s TeX:%s LaTeX:%s skip:%s p:%s | 23106 | #+OPTIONS: H:%d num:%s toc:%s \\n:%s @:%s ::%s |:%s ^:%s f:%s *:%s TeX:%s LaTeX:%s skip:%s d:%s tags:%s |
| 22157 | #+CATEGORY: %s | 23107 | #+CATEGORY: %s |
| 22158 | #+SEQ_TODO: %s | 23108 | #+SEQ_TODO: %s |
| 22159 | #+TYP_TODO: %s | 23109 | #+TYP_TODO: %s |
| 22160 | #+PRIORITIES: %c %c %c | 23110 | #+PRIORITIES: %c %c %c |
| 23111 | #+DRAWERS: %s | ||
| 22161 | #+STARTUP: %s %s %s %s %s | 23112 | #+STARTUP: %s %s %s %s %s |
| 22162 | #+TAGS: %s | 23113 | #+TAGS: %s |
| 22163 | #+ARCHIVE: %s | 23114 | #+ARCHIVE: %s |
| @@ -22177,11 +23128,13 @@ Does include HTML export options as well as TODO and CATEGORY stuff." | |||
| 22177 | org-export-with-TeX-macros | 23128 | org-export-with-TeX-macros |
| 22178 | org-export-with-LaTeX-fragments | 23129 | org-export-with-LaTeX-fragments |
| 22179 | org-export-skip-text-before-1st-heading | 23130 | org-export-skip-text-before-1st-heading |
| 22180 | org-export-with-property-drawer | 23131 | org-export-with-drawers |
| 23132 | org-export-with-tags | ||
| 22181 | (file-name-nondirectory buffer-file-name) | 23133 | (file-name-nondirectory buffer-file-name) |
| 22182 | "TODO FEEDBACK VERIFY DONE" | 23134 | "TODO FEEDBACK VERIFY DONE" |
| 22183 | "Me Jason Marie DONE" | 23135 | "Me Jason Marie DONE" |
| 22184 | org-highest-priority org-lowest-priority org-default-priority | 23136 | org-highest-priority org-lowest-priority org-default-priority |
| 23137 | (mapconcat 'identity org-drawers " ") | ||
| 22185 | (cdr (assoc org-startup-folded | 23138 | (cdr (assoc org-startup-folded |
| 22186 | '((nil . "showall") (t . "overview") (content . "content")))) | 23139 | '((nil . "showall") (t . "overview") (content . "content")))) |
| 22187 | (if org-odd-levels-only "odd" "oddeven") | 23140 | (if org-odd-levels-only "odd" "oddeven") |
| @@ -22249,7 +23202,7 @@ this line is also exported in fixed-width font." | |||
| 22249 | (save-excursion | 23202 | (save-excursion |
| 22250 | (org-back-to-heading) | 23203 | (org-back-to-heading) |
| 22251 | (if (looking-at (concat outline-regexp | 23204 | (if (looking-at (concat outline-regexp |
| 22252 | "\\( *\\<" org-quote-string "\\>\\)")) | 23205 | "\\( *\\<" org-quote-string "\\>[ \t]*\\)")) |
| 22253 | (replace-match "" t t nil 1) | 23206 | (replace-match "" t t nil 1) |
| 22254 | (if (looking-at outline-regexp) | 23207 | (if (looking-at outline-regexp) |
| 22255 | (progn | 23208 | (progn |
| @@ -22497,10 +23450,10 @@ the body tags themselves." | |||
| 22497 | (org-odd-levels-only odd)) | 23450 | (org-odd-levels-only odd)) |
| 22498 | ;; create local variables for all options, to make sure all called | 23451 | ;; create local variables for all options, to make sure all called |
| 22499 | ;; functions get the correct information | 23452 | ;; functions get the correct information |
| 22500 | (mapc (lambda (x) | 23453 | (mapcar (lambda (x) |
| 22501 | (set (make-local-variable (cdr x)) | 23454 | (set (make-local-variable (cdr x)) |
| 22502 | (plist-get opt-plist (car x)))) | 23455 | (plist-get opt-plist (car x)))) |
| 22503 | org-export-plist-vars) | 23456 | org-export-plist-vars) |
| 22504 | (setq umax (if arg (prefix-numeric-value arg) | 23457 | (setq umax (if arg (prefix-numeric-value arg) |
| 22505 | org-export-headline-levels)) | 23458 | org-export-headline-levels)) |
| 22506 | (setq umax-toc (if (integerp org-export-with-toc) | 23459 | (setq umax-toc (if (integerp org-export-with-toc) |
| @@ -22561,11 +23514,9 @@ lang=\"%s\" xml:lang=\"%s\"> | |||
| 22561 | (= level umax-toc) | 23514 | (= level umax-toc) |
| 22562 | (org-search-todo-below | 23515 | (org-search-todo-below |
| 22563 | line lines level)))) | 23516 | line lines level)))) |
| 22564 | (if (and (memq org-export-with-tags '(not-in-toc nil)) | 23517 | (if (string-match |
| 22565 | (string-match | 23518 | (org-re "[ \t]+:\\([[:alnum:]_@:]+\\):[ \t]*$") txt) |
| 22566 | (org-re "[ \t]+:[[:alnum:]_@:]+:[ \t]*$") | 23519 | (setq txt (replace-match " <span class=\"tag\"> \\1</span>" t nil txt))) |
| 22567 | txt)) | ||
| 22568 | (setq txt (replace-match "" t t txt))) | ||
| 22569 | (if (string-match quote-re0 txt) | 23520 | (if (string-match quote-re0 txt) |
| 22570 | (setq txt (replace-match "" t t txt))) | 23521 | (setq txt (replace-match "" t t txt))) |
| 22571 | (if org-export-with-section-numbers | 23522 | (if org-export-with-section-numbers |
| @@ -22777,7 +23728,7 @@ lang=\"%s\" xml:lang=\"%s\"> | |||
| 22777 | (if (and (string-match org-todo-line-regexp line) | 23728 | (if (and (string-match org-todo-line-regexp line) |
| 22778 | (match-beginning 2)) | 23729 | (match-beginning 2)) |
| 22779 | 23730 | ||
| 22780 | (setq line | 23731 | (setq line |
| 22781 | (concat (substring line 0 (match-beginning 2)) | 23732 | (concat (substring line 0 (match-beginning 2)) |
| 22782 | "<span class=\"" | 23733 | "<span class=\"" |
| 22783 | (if (member (match-string 2 line) | 23734 | (if (member (match-string 2 line) |
| @@ -22925,12 +23876,13 @@ lang=\"%s\" xml:lang=\"%s\"> | |||
| 22925 | (pop local-list-num)) | 23876 | (pop local-list-num)) |
| 22926 | (setq local-list-indent nil | 23877 | (setq local-list-indent nil |
| 22927 | in-local-list nil)) | 23878 | in-local-list nil)) |
| 22928 | (org-html-level-start 1 nil umax | 23879 | (org-html-level-start 0 nil umax |
| 22929 | (and org-export-with-toc (<= level umax)) | 23880 | (and org-export-with-toc (<= level umax)) |
| 22930 | head-count) | 23881 | head-count) |
| 22931 | 23882 | ||
| 22932 | (unless body-only | 23883 | (unless body-only |
| 22933 | (when (plist-get opt-plist :auto-postamble) | 23884 | (when (plist-get opt-plist :auto-postamble) |
| 23885 | (insert "<div id=\"postamble\">") | ||
| 22934 | (when (and org-export-author-info author) | 23886 | (when (and org-export-author-info author) |
| 22935 | (insert "<p class=\"author\"> " | 23887 | (insert "<p class=\"author\"> " |
| 22936 | (nth 1 lang-words) ": " author "\n") | 23888 | (nth 1 lang-words) ": " author "\n") |
| @@ -22941,7 +23893,8 @@ lang=\"%s\" xml:lang=\"%s\"> | |||
| 22941 | (when (and date org-export-time-stamp-file) | 23893 | (when (and date org-export-time-stamp-file) |
| 22942 | (insert "<p class=\"date\"> " | 23894 | (insert "<p class=\"date\"> " |
| 22943 | (nth 2 lang-words) ": " | 23895 | (nth 2 lang-words) ": " |
| 22944 | date "</p>\n"))) | 23896 | date "</p>\n")) |
| 23897 | (insert "</div>")) | ||
| 22945 | 23898 | ||
| 22946 | (if org-export-html-with-timestamp | 23899 | (if org-export-html-with-timestamp |
| 22947 | (insert org-export-html-html-helper-timestamp)) | 23900 | (insert org-export-html-html-helper-timestamp)) |
| @@ -22965,7 +23918,9 @@ lang=\"%s\" xml:lang=\"%s\"> | |||
| 22965 | (when (looking-at "\\s-*</p>") | 23918 | (when (looking-at "\\s-*</p>") |
| 22966 | (goto-char (match-end 0)) | 23919 | (goto-char (match-end 0)) |
| 22967 | (insert "\n"))) | 23920 | (insert "\n"))) |
| 22968 | (mapc 'insert thetoc)) | 23921 | (insert "<div id=\"table-of-contents\">\n") |
| 23922 | (mapc 'insert thetoc) | ||
| 23923 | (insert "</div>\n")) | ||
| 22969 | ;; remove empty paragraphs and lists | 23924 | ;; remove empty paragraphs and lists |
| 22970 | (goto-char (point-min)) | 23925 | (goto-char (point-min)) |
| 22971 | (while (re-search-forward "<p>[ \r\n\t]*</p>" nil t) | 23926 | (while (re-search-forward "<p>[ \r\n\t]*</p>" nil t) |
| @@ -22973,6 +23928,17 @@ lang=\"%s\" xml:lang=\"%s\"> | |||
| 22973 | (goto-char (point-min)) | 23928 | (goto-char (point-min)) |
| 22974 | (while (re-search-forward "<li>[ \r\n\t]*</li>\n?" nil t) | 23929 | (while (re-search-forward "<li>[ \r\n\t]*</li>\n?" nil t) |
| 22975 | (replace-match "")) | 23930 | (replace-match "")) |
| 23931 | ;; Convert whitespace place holders | ||
| 23932 | (goto-char (point-min)) | ||
| 23933 | (let (beg end n) | ||
| 23934 | (while (setq beg (next-single-property-change (point) 'org-whitespace)) | ||
| 23935 | (setq n (get-text-property beg 'org-whitespace) | ||
| 23936 | end (next-single-property-change beg 'org-whitespace)) | ||
| 23937 | (goto-char beg) | ||
| 23938 | (delete-region beg end) | ||
| 23939 | (insert (format "<span style=\"visibility:hidden;\">%s</span>" | ||
| 23940 | (make-string n ?x))))) | ||
| 23941 | |||
| 22976 | (or to-buffer (save-buffer)) | 23942 | (or to-buffer (save-buffer)) |
| 22977 | (goto-char (point-min)) | 23943 | (goto-char (point-min)) |
| 22978 | (message "Exporting... done") | 23944 | (message "Exporting... done") |
| @@ -23111,14 +24077,14 @@ lang=\"%s\" xml:lang=\"%s\"> | |||
| 23111 | (lambda (x) | 24077 | (lambda (x) |
| 23112 | (setq gr (pop org-table-colgroup-info)) | 24078 | (setq gr (pop org-table-colgroup-info)) |
| 23113 | (format "%s<COL align=\"%s\"></COL>%s" | 24079 | (format "%s<COL align=\"%s\"></COL>%s" |
| 23114 | (if (memq gr '(:start :startend)) | 24080 | (if (memq gr '(:start :startend)) |
| 23115 | (prog1 | 24081 | (prog1 |
| 23116 | (if colgropen "</colgroup>\n<colgroup>" "<colgroup>") | 24082 | (if colgropen "</colgroup>\n<colgroup>" "<colgroup>") |
| 23117 | (setq colgropen t)) | 24083 | (setq colgropen t)) |
| 23118 | "") | 24084 | "") |
| 23119 | (if (> (/ (float x) nlines) org-table-number-fraction) | 24085 | (if (> (/ (float x) nlines) org-table-number-fraction) |
| 23120 | "right" "left") | 24086 | "right" "left") |
| 23121 | (if (memq gr '(:end :startend)) | 24087 | (if (memq gr '(:end :startend)) |
| 23122 | (progn (setq colgropen nil) "</colgroup>") | 24088 | (progn (setq colgropen nil) "</colgroup>") |
| 23123 | ""))) | 24089 | ""))) |
| 23124 | fnum "") | 24090 | fnum "") |
| @@ -23282,8 +24248,9 @@ But it has the disadvantage, that Org-mode's HTML conversions cannot be used." | |||
| 23282 | 24248 | ||
| 23283 | (defun org-export-cleanup-toc-line (s) | 24249 | (defun org-export-cleanup-toc-line (s) |
| 23284 | "Remove tags and time staps from lines going into the toc." | 24250 | "Remove tags and time staps from lines going into the toc." |
| 23285 | (if (string-match (org-re " +:[[:alnum:]_@:]+: *$") s) | 24251 | (when (memq org-export-with-tags '(not-in-toc nil)) |
| 23286 | (setq s (replace-match "" t t s))) | 24252 | (if (string-match (org-re " +:[[:alnum:]_@:]+: *$") s) |
| 24253 | (setq s (replace-match "" t t s)))) | ||
| 23287 | (when org-export-remove-timestamps-from-toc | 24254 | (when org-export-remove-timestamps-from-toc |
| 23288 | (while (string-match org-maybe-keyword-time-regexp s) | 24255 | (while (string-match org-maybe-keyword-time-regexp s) |
| 23289 | (setq s (replace-match "" t t s)))) | 24256 | (setq s (replace-match "" t t s)))) |
| @@ -23295,8 +24262,10 @@ But it has the disadvantage, that Org-mode's HTML conversions cannot be used." | |||
| 23295 | (defun org-html-expand (string) | 24262 | (defun org-html-expand (string) |
| 23296 | "Prepare STRING for HTML export. Applies all active conversions. | 24263 | "Prepare STRING for HTML export. Applies all active conversions. |
| 23297 | If there are links in the string, don't modify these." | 24264 | If there are links in the string, don't modify these." |
| 23298 | (let* (m s l res) | 24265 | (let* ((re (concat org-bracket-link-regexp "\\|" |
| 23299 | (while (setq m (string-match org-bracket-link-regexp string)) | 24266 | (org-re "[ \t]+\\(:[[:alnum:]_@:]+:\\)[ \t]*$"))) |
| 24267 | m s l res) | ||
| 24268 | (while (setq m (string-match re string)) | ||
| 23300 | (setq s (substring string 0 m) | 24269 | (setq s (substring string 0 m) |
| 23301 | l (match-string 0 string) | 24270 | l (match-string 0 string) |
| 23302 | string (substring string (match-end 0))) | 24271 | string (substring string (match-end 0))) |
| @@ -23412,13 +24381,13 @@ stacked delimiters is N. Escaping delimiters is not possible." | |||
| 23412 | "Insert a new level in HTML export. | 24381 | "Insert a new level in HTML export. |
| 23413 | When TITLE is nil, just close all open levels." | 24382 | When TITLE is nil, just close all open levels." |
| 23414 | (org-close-par-maybe) | 24383 | (org-close-par-maybe) |
| 23415 | (let ((l (1+ (max level umax)))) | 24384 | (let ((l org-level-max)) |
| 23416 | (while (<= l org-level-max) | 24385 | (while (>= l (1+ level)) |
| 23417 | (if (aref org-levels-open (1- l)) | 24386 | (if (aref org-levels-open (1- l)) |
| 23418 | (progn | 24387 | (progn |
| 23419 | (org-html-level-close l) | 24388 | (org-html-level-close l umax) |
| 23420 | (aset org-levels-open (1- l) nil))) | 24389 | (aset org-levels-open (1- l) nil))) |
| 23421 | (setq l (1+ l))) | 24390 | (setq l (1- l))) |
| 23422 | (when title | 24391 | (when title |
| 23423 | ;; If title is nil, this means this function is called to close | 24392 | ;; If title is nil, this means this function is called to close |
| 23424 | ;; all levels, so the rest is done only if title is given | 24393 | ;; all levels, so the rest is done only if title is given |
| @@ -23443,19 +24412,22 @@ When TITLE is nil, just close all open levels." | |||
| 23443 | (aset org-levels-open (1- level) t) | 24412 | (aset org-levels-open (1- level) t) |
| 23444 | (org-close-par-maybe) | 24413 | (org-close-par-maybe) |
| 23445 | (insert "<ul>\n<li>" title "<br/>\n"))) | 24414 | (insert "<ul>\n<li>" title "<br/>\n"))) |
| 24415 | (aset org-levels-open (1- level) t) | ||
| 23446 | (if (and org-export-with-section-numbers (not body-only)) | 24416 | (if (and org-export-with-section-numbers (not body-only)) |
| 23447 | (setq title (concat (org-section-number level) " " title))) | 24417 | (setq title (concat (org-section-number level) " " title))) |
| 23448 | (setq level (+ level org-export-html-toplevel-hlevel -1)) | 24418 | (setq level (+ level org-export-html-toplevel-hlevel -1)) |
| 23449 | (if with-toc | 24419 | (if with-toc |
| 23450 | (insert (format "\n<h%d id=\"sec-%d\">%s</h%d>\n" | 24420 | (insert (format "\n<div class=\"outline-%d\">\n<h%d id=\"sec-%d\">%s</h%d>\n" |
| 23451 | level head-count title level)) | 24421 | level level head-count title level)) |
| 23452 | (insert (format "\n<h%d>%s</h%d>\n" level title level))) | 24422 | (insert (format "\n<div class=\"outline-%d\">\n<h%d>%s</h%d>\n" level level title level))) |
| 23453 | (org-open-par))))) | 24423 | (org-open-par))))) |
| 23454 | 24424 | ||
| 23455 | (defun org-html-level-close (&rest args) | 24425 | (defun org-html-level-close (level max-outline-level) |
| 23456 | "Terminate one level in HTML export." | 24426 | "Terminate one level in HTML export." |
| 23457 | (org-close-li) | 24427 | (if (<= level max-outline-level) |
| 23458 | (insert "</ul>\n")) | 24428 | (insert "</div>\n") |
| 24429 | (org-close-li) | ||
| 24430 | (insert "</ul>\n"))) | ||
| 23459 | 24431 | ||
| 23460 | ;;; iCalendar export | 24432 | ;;; iCalendar export |
| 23461 | 24433 | ||
| @@ -23839,7 +24811,7 @@ The XOXO buffer is named *xoxo-<source buffer name>*" | |||
| 23839 | (unless (featurep 'xemacs) | 24811 | (unless (featurep 'xemacs) |
| 23840 | (org-defkey org-mode-map [S-iso-lefttab] 'org-shifttab)) | 24812 | (org-defkey org-mode-map [S-iso-lefttab] 'org-shifttab)) |
| 23841 | (org-defkey org-mode-map [(shift tab)] 'org-shifttab) | 24813 | (org-defkey org-mode-map [(shift tab)] 'org-shifttab) |
| 23842 | (define-key org-mode-map (kbd "<backtab>") 'org-shifttab) | 24814 | (define-key org-mode-map [backtab] 'org-shifttab) |
| 23843 | 24815 | ||
| 23844 | (org-defkey org-mode-map [(shift return)] 'org-table-copy-down) | 24816 | (org-defkey org-mode-map [(shift return)] 'org-table-copy-down) |
| 23845 | (org-defkey org-mode-map [(meta shift return)] 'org-insert-todo-heading) | 24817 | (org-defkey org-mode-map [(meta shift return)] 'org-insert-todo-heading) |
| @@ -23909,8 +24881,7 @@ The XOXO buffer is named *xoxo-<source buffer name>*" | |||
| 23909 | (org-defkey org-mode-map "\C-c;" 'org-toggle-comment) | 24881 | (org-defkey org-mode-map "\C-c;" 'org-toggle-comment) |
| 23910 | (org-defkey org-mode-map "\C-c\C-v" 'org-show-todo-tree) | 24882 | (org-defkey org-mode-map "\C-c\C-v" 'org-show-todo-tree) |
| 23911 | (org-defkey org-mode-map "\C-c\C-w" 'org-check-deadlines) | 24883 | (org-defkey org-mode-map "\C-c\C-w" 'org-check-deadlines) |
| 23912 | (org-defkey org-mode-map "\C-c/" 'org-occur) ; Minor-mode reserved | 24884 | (org-defkey org-mode-map "\C-c/" 'org-sparse-tree) ; Minor-mode reserved |
| 23913 | (org-defkey org-mode-map "\C-c\C-x/" 'org-occur-in-agenda-files) | ||
| 23914 | (org-defkey org-mode-map "\C-c\\" 'org-tags-sparse-tree) ; Minor-mode res. | 24885 | (org-defkey org-mode-map "\C-c\\" 'org-tags-sparse-tree) ; Minor-mode res. |
| 23915 | (org-defkey org-mode-map "\C-c\C-m" 'org-ctrl-c-ret) | 24886 | (org-defkey org-mode-map "\C-c\C-m" 'org-ctrl-c-ret) |
| 23916 | (org-defkey org-mode-map "\M-\C-m" 'org-insert-heading) | 24887 | (org-defkey org-mode-map "\M-\C-m" 'org-insert-heading) |
| @@ -23935,6 +24906,7 @@ The XOXO buffer is named *xoxo-<source buffer name>*" | |||
| 23935 | (org-defkey org-mode-map "\C-c-" 'org-ctrl-c-minus) | 24906 | (org-defkey org-mode-map "\C-c-" 'org-ctrl-c-minus) |
| 23936 | (org-defkey org-mode-map "\C-c^" 'org-sort) | 24907 | (org-defkey org-mode-map "\C-c^" 'org-sort) |
| 23937 | (org-defkey org-mode-map "\C-c\C-c" 'org-ctrl-c-ctrl-c) | 24908 | (org-defkey org-mode-map "\C-c\C-c" 'org-ctrl-c-ctrl-c) |
| 24909 | (org-defkey org-mode-map "\C-c\C-k" 'org-kill-note-or-show-branches) | ||
| 23938 | (org-defkey org-mode-map "\C-c#" 'org-update-checkbox-count) | 24910 | (org-defkey org-mode-map "\C-c#" 'org-update-checkbox-count) |
| 23939 | (org-defkey org-mode-map "\C-m" 'org-return) | 24911 | (org-defkey org-mode-map "\C-m" 'org-return) |
| 23940 | (org-defkey org-mode-map "\C-c?" 'org-table-field-info) | 24912 | (org-defkey org-mode-map "\C-c?" 'org-table-field-info) |
| @@ -23969,6 +24941,8 @@ The XOXO buffer is named *xoxo-<source buffer name>*" | |||
| 23969 | (org-defkey org-mode-map "\C-c\C-x\C-u" 'org-dblock-update) | 24941 | (org-defkey org-mode-map "\C-c\C-x\C-u" 'org-dblock-update) |
| 23970 | (org-defkey org-mode-map "\C-c\C-x\C-l" 'org-preview-latex-fragment) | 24942 | (org-defkey org-mode-map "\C-c\C-x\C-l" 'org-preview-latex-fragment) |
| 23971 | (org-defkey org-mode-map "\C-c\C-x\C-b" 'org-toggle-checkbox) | 24943 | (org-defkey org-mode-map "\C-c\C-x\C-b" 'org-toggle-checkbox) |
| 24944 | (org-defkey org-mode-map "\C-c\C-xp" 'org-set-property) | ||
| 24945 | (org-defkey org-mode-map "\C-c\C-xr" 'org-insert-columns-dblock) | ||
| 23972 | 24946 | ||
| 23973 | (define-key org-mode-map "\C-c\C-x\C-c" 'org-columns) | 24947 | (define-key org-mode-map "\C-c\C-x\C-c" 'org-columns) |
| 23974 | 24948 | ||
| @@ -24201,7 +25175,7 @@ for more information." | |||
| 24201 | ((org-at-table-p) (org-call-with-arg 'org-table-move-row 'up)) | 25175 | ((org-at-table-p) (org-call-with-arg 'org-table-move-row 'up)) |
| 24202 | ((org-on-heading-p) (call-interactively 'org-move-subtree-up)) | 25176 | ((org-on-heading-p) (call-interactively 'org-move-subtree-up)) |
| 24203 | ((org-at-item-p) (call-interactively 'org-move-item-up)) | 25177 | ((org-at-item-p) (call-interactively 'org-move-item-up)) |
| 24204 | (t (org-shiftcursor-error)))) | 25178 | (t (transpose-lines 1) (beginning-of-line -1)))) |
| 24205 | 25179 | ||
| 24206 | (defun org-metadown (&optional arg) | 25180 | (defun org-metadown (&optional arg) |
| 24207 | "Move subtree down or move table row down. | 25181 | "Move subtree down or move table row down. |
| @@ -24213,7 +25187,7 @@ commands for more information." | |||
| 24213 | ((org-at-table-p) (call-interactively 'org-table-move-row)) | 25187 | ((org-at-table-p) (call-interactively 'org-table-move-row)) |
| 24214 | ((org-on-heading-p) (call-interactively 'org-move-subtree-down)) | 25188 | ((org-on-heading-p) (call-interactively 'org-move-subtree-down)) |
| 24215 | ((org-at-item-p) (call-interactively 'org-move-item-down)) | 25189 | ((org-at-item-p) (call-interactively 'org-move-item-down)) |
| 24216 | (t (org-shiftcursor-error)))) | 25190 | (t (beginning-of-line 2) (transpose-lines 1) (beginning-of-line 0)))) |
| 24217 | 25191 | ||
| 24218 | (defun org-shiftup (&optional arg) | 25192 | (defun org-shiftup (&optional arg) |
| 24219 | "Increase item in timestamp or increase priority of current headline. | 25193 | "Increase item in timestamp or increase priority of current headline. |
| @@ -24246,6 +25220,7 @@ depending on context. See the individual commands for more information." | |||
| 24246 | (cond | 25220 | (cond |
| 24247 | ((org-at-timestamp-p t) (call-interactively 'org-timestamp-up-day)) | 25221 | ((org-at-timestamp-p t) (call-interactively 'org-timestamp-up-day)) |
| 24248 | ((org-on-heading-p) (org-call-with-arg 'org-todo 'right)) | 25222 | ((org-on-heading-p) (org-call-with-arg 'org-todo 'right)) |
| 25223 | ((org-at-item-p) (org-call-with-arg 'org-cycle-list-bullet nil)) | ||
| 24249 | ((org-at-property-p) (call-interactively 'org-property-next-allowed-value)) | 25224 | ((org-at-property-p) (call-interactively 'org-property-next-allowed-value)) |
| 24250 | (t (org-shiftcursor-error)))) | 25225 | (t (org-shiftcursor-error)))) |
| 24251 | 25226 | ||
| @@ -24255,6 +25230,7 @@ depending on context. See the individual commands for more information." | |||
| 24255 | (cond | 25230 | (cond |
| 24256 | ((org-at-timestamp-p t) (call-interactively 'org-timestamp-down-day)) | 25231 | ((org-at-timestamp-p t) (call-interactively 'org-timestamp-down-day)) |
| 24257 | ((org-on-heading-p) (org-call-with-arg 'org-todo 'left)) | 25232 | ((org-on-heading-p) (org-call-with-arg 'org-todo 'left)) |
| 25233 | ((org-at-item-p) (org-call-with-arg 'org-cycle-list-bullet 'previous)) | ||
| 24258 | ((org-at-property-p) | 25234 | ((org-at-property-p) |
| 24259 | (call-interactively 'org-property-previous-allowed-value)) | 25235 | (call-interactively 'org-property-previous-allowed-value)) |
| 24260 | (t (org-shiftcursor-error)))) | 25236 | (t (org-shiftcursor-error)))) |
| @@ -24394,6 +25370,14 @@ Also updates the keyword regular expressions." | |||
| 24394 | (let ((org-inhibit-startup t)) (org-mode)) | 25370 | (let ((org-inhibit-startup t)) (org-mode)) |
| 24395 | (message "Org-mode restarted to refresh keyword and special line setup")) | 25371 | (message "Org-mode restarted to refresh keyword and special line setup")) |
| 24396 | 25372 | ||
| 25373 | (defun org-kill-note-or-show-branches () | ||
| 25374 | "If this is a Note buffer, abort storing the note. Else call `show-branches'." | ||
| 25375 | (interactive) | ||
| 25376 | (if (not org-finish-function) | ||
| 25377 | (call-interactively 'show-branches) | ||
| 25378 | (let ((org-note-abort t)) | ||
| 25379 | (funcall org-finish-function)))) | ||
| 25380 | |||
| 24397 | (defun org-return () | 25381 | (defun org-return () |
| 24398 | "Goto next table row or insert a newline. | 25382 | "Goto next table row or insert a newline. |
| 24399 | Calls `org-table-next-row' or `newline', depending on context. | 25383 | Calls `org-table-next-row' or `newline', depending on context. |
| @@ -24406,6 +25390,7 @@ See the individual commands for more information." | |||
| 24406 | (call-interactively 'org-table-next-row)) | 25390 | (call-interactively 'org-table-next-row)) |
| 24407 | (t (newline)))) | 25391 | (t (newline)))) |
| 24408 | 25392 | ||
| 25393 | |||
| 24409 | (defun org-ctrl-c-minus () | 25394 | (defun org-ctrl-c-minus () |
| 24410 | "Insert separator line in table or modify bullet type in list. | 25395 | "Insert separator line in table or modify bullet type in list. |
| 24411 | Calls `org-table-insert-hline' or `org-cycle-list-bullet', | 25396 | Calls `org-table-insert-hline' or `org-cycle-list-bullet', |
| @@ -24414,6 +25399,12 @@ depending on context." | |||
| 24414 | (cond | 25399 | (cond |
| 24415 | ((org-at-table-p) | 25400 | ((org-at-table-p) |
| 24416 | (call-interactively 'org-table-insert-hline)) | 25401 | (call-interactively 'org-table-insert-hline)) |
| 25402 | ((org-on-heading-p) | ||
| 25403 | ;; Convert to item | ||
| 25404 | (save-excursion | ||
| 25405 | (beginning-of-line 1) | ||
| 25406 | (if (looking-at "\\*+ ") | ||
| 25407 | (replace-match (concat (make-string (- (match-end 0) (point)) ?\ ) "- "))))) | ||
| 24417 | ((org-in-item-p) | 25408 | ((org-in-item-p) |
| 24418 | (call-interactively 'org-cycle-list-bullet)) | 25409 | (call-interactively 'org-cycle-list-bullet)) |
| 24419 | (t (error "`C-c -' does have no function here.")))) | 25410 | (t (error "`C-c -' does have no function here.")))) |
| @@ -24566,7 +25557,10 @@ See the individual commands for more information." | |||
| 24566 | ("TAGS and Properties" | 25557 | ("TAGS and Properties" |
| 24567 | ["Set Tags" 'org-ctrl-c-ctrl-c (org-at-heading-p)] | 25558 | ["Set Tags" 'org-ctrl-c-ctrl-c (org-at-heading-p)] |
| 24568 | ["Change tag in region" 'org-change-tag-in-region (org-region-active-p)] | 25559 | ["Change tag in region" 'org-change-tag-in-region (org-region-active-p)] |
| 24569 | ["Column view of properties" org-columns t]) | 25560 | "--" |
| 25561 | ["Set property" 'org-set-property t] | ||
| 25562 | ["Column view of properties" org-columns t] | ||
| 25563 | ["Insert Column View DBlock" org-insert-columns-dblock t]) | ||
| 24570 | ("Dates and Scheduling" | 25564 | ("Dates and Scheduling" |
| 24571 | ["Timestamp" org-time-stamp t] | 25565 | ["Timestamp" org-time-stamp t] |
| 24572 | ["Timestamp (inactive)" org-time-stamp-inactive t] | 25566 | ["Timestamp (inactive)" org-time-stamp-inactive t] |
| @@ -24831,14 +25825,20 @@ really on, so that the block visually is on the match." | |||
| 24831 | (throw 'exit t))) | 25825 | (throw 'exit t))) |
| 24832 | nil)))) | 25826 | nil)))) |
| 24833 | 25827 | ||
| 24834 | (defun org-occur-in-agenda-files (regexp) | 25828 | (defun org-occur-in-agenda-files (regexp &optional nlines) |
| 24835 | "Call `multi-occur' with buffers for all agenda files." | 25829 | "Call `multi-occur' with buffers for all agenda files." |
| 24836 | (interactive "sList all lines matching: ") | 25830 | (interactive "sOrg-files matching: \np") |
| 24837 | (multi-occur | 25831 | (let* ((files (org-agenda-files)) |
| 24838 | (mapcar | 25832 | (tnames (mapcar 'file-truename files)) |
| 24839 | (lambda (x) (or (get-file-buffer x) (find-file-noselect x))) | 25833 | (extra org-agenda-multi-occur-extra-files) |
| 24840 | (org-agenda-files)) | 25834 | f) |
| 24841 | regexp)) | 25835 | (while (setq f (pop extra)) |
| 25836 | (unless (member (file-truename f) tnames) | ||
| 25837 | (add-to-list 'files f 'append) | ||
| 25838 | (add-to-list 'tnames (file-truename f) 'append))) | ||
| 25839 | (multi-occur | ||
| 25840 | (mapcar (lambda (x) (or (get-file-buffer x) (find-file-noselect x))) files) | ||
| 25841 | regexp))) | ||
| 24842 | 25842 | ||
| 24843 | (defun org-uniquify (list) | 25843 | (defun org-uniquify (list) |
| 24844 | "Remove duplicate elements from LIST." | 25844 | "Remove duplicate elements from LIST." |
| @@ -25348,7 +26348,6 @@ Show the heading too, if it is currently invisible." | |||
| 25348 | 26348 | ||
| 25349 | ;;;; Experimental code | 26349 | ;;;; Experimental code |
| 25350 | 26350 | ||
| 25351 | |||
| 25352 | (defun org-closed-in-range () | 26351 | (defun org-closed-in-range () |
| 25353 | "Sparse tree of items closed in a certain time range. | 26352 | "Sparse tree of items closed in a certain time range. |
| 25354 | Still experimental, may disappear in the furture." | 26353 | Still experimental, may disappear in the furture." |
| @@ -25413,27 +26412,6 @@ Respect keys that are already there." | |||
| 25413 | (push (cons k c) new)))) | 26412 | (push (cons k c) new)))) |
| 25414 | (nreverse new))) | 26413 | (nreverse new))) |
| 25415 | 26414 | ||
| 25416 | (defun org-parse-local-options (string var) | ||
| 25417 | "Parse STRING for startup setting relevant for variable VAR." | ||
| 25418 | (let ((rtn (symbol-value var)) | ||
| 25419 | e opts) | ||
| 25420 | (save-match-data | ||
| 25421 | (if (or (not string) (not (string-match "\\S-" string))) | ||
| 25422 | rtn | ||
| 25423 | (setq opts (delq nil (mapcar (lambda (x) | ||
| 25424 | (setq e (assoc x org-startup-options)) | ||
| 25425 | (if (eq (nth 1 e) var) e nil)) | ||
| 25426 | (org-split-string string "[ \t]+")))) | ||
| 25427 | (if (not opts) | ||
| 25428 | rtn | ||
| 25429 | (setq rtn nil) | ||
| 25430 | (while (setq e (pop opts)) | ||
| 25431 | (if (not (nth 3 e)) | ||
| 25432 | (setq rtn (nth 2 e)) | ||
| 25433 | (if (not (listp rtn)) (setq rtn nil)) | ||
| 25434 | (push (nth 2 e) rtn))) | ||
| 25435 | rtn))))) | ||
| 25436 | |||
| 25437 | ;;;; Finish up | 26415 | ;;;; Finish up |
| 25438 | 26416 | ||
| 25439 | (provide 'org) | 26417 | (provide 'org) |