comparison lisp/org/org-agenda.el @ 104810:86b7fe7d1d8f

2009-09-02 Carsten Dominik <carsten.dominik@gmail.com> * org-protocol.el (org-protocol-store-link) (org-protocol-remember, org-protocol-open-source): Add autoloads. * org-compat.el (org-float-time): New function. * org.el (org-clock-update-time-maybe) (org-sort-entries-or-items, org-do-sort) (org-evaluate-time-range, org-time-string-to-seconds) (org-closed-in-range): Use `org-float-time'. * org-timer.el (org-timer-start, org-timer-pause-or-continue) (org-timer-seconds): Use `org-float-time'. * org-clock.el (org-clock-get-clocked-time, org-clock-out) (org-clock-sum, org-dblock-write:clocktable) (org-clocktable-steps): Use `org-float-time'. * org-agenda.el (org-agenda-last-marker-time) (org-agenda-new-marker, org-diary): Use `org-float-time'. * org-compat.el (w32-focus-frame): Declare the w32-focus-frame function. * org-exp.el (org-get-file-contents): Only protect lines that really need it. * org-html.el (require): Require cl for compilation. * org.el: Avoid using `default-major-mode'. * org-plot.el (require): Require CL only at compile time. * org-exp.el (require): Require CL only at compile time. * org-agenda.el (org-agenda-quit): When the agenda window is dedicated, remove other windows before exiting, so that the frame really will be killed. * org-exp.el (org-export-handle-include-files): Reset START and END for each loop cycle. 2009-09-02 Carsten Dominik <carsten.dominik@gmail.com> * org.el (org-eval-in-calendar): Use `org-select-frame-set-input-focus'. * org-compat.el (org-select-frame-set-input-focus): New function. * org.el (org-update-statistics-cookies): New function. (org-mode-map): Bind `C-c #' to `org-update-statistics-cookies'. 2009-09-02 Carsten Dominik <carsten.dominik@gmail.com> * org-src.el (org-edit-fixed-width-region): Set org-src-mode only after the local variables are set. * org-latex.el (org-export-latex-protect-amp): New function. (org-export-latex-links): Protect link ampersands in tables. * org-exp.el (org-export-select-backend-specific-text): Match in two steps, to avoid regexp problems. * org.el (org-offer-links-in-entry): Improve working with many and duplicate links. * org-agenda.el (org-agenda-show-1): Make more consistent with normal cycling. (org-agenda-cycle-show): Make more consistent with normal cycling. * org-gnus.el (org-gnus-store-link): Restore the linking to a website. 2009-09-02 Bastien Guerry <bzg@altern.org> * org-latex.el (org-export-latex-first-lines): Bugfix. 2009-09-02 Carsten Dominik <carsten.dominik@gmail.com> * org-clock.el (org-clock-modify-effort-estimate): Emit message about new effort. * org.el (org-set-effort): New function. (org-mode-map): New key for effort setting command. * org-agenda.el (org-agenda): Keep window setup when calling agenda from within agenda window. (org-agenda-mode-map): New keys for effort setting commands. (org-agenda-menu): Add effort setting commands to menu. (org-agenda-set-property, org-agenda-set-effort): New functions. * org-latex.el (org-export-latex-tables): Fix `org-table-last-alignment' and `org-table-last-column-widths' if the first column has been removed. 2009-09-02 Carsten Dominik <carsten.dominik@gmail.com> * org.el (org-remove-timestamp-with-keyword): Only remove in entry, not in subtree. * org-src.el (org-src-lang-modes): Add abbreviation elisp for emacs lisp. * org.el (org-open-at-point): When on headline, offer all strings in entry. * org-remember.el (org-remember-templates): Documentation fix. * org.el (org-move-subtree-down): Use `org-get-next-sibling' and `org-get-last-sibling' instead of the outline versions of these functions. (org-get-last-sibling): New function. (org-refile): Use `org-get-next-sibling' instead of the outline version of this function. (org-clean-visibility-after-subtree-move): Use `org-get-next-sibling' and `org-get-last-sibling' instead of the outline versions of these functions. 2009-09-02 Carsten Dominik <carsten.dominik@gmail.com> * org-agenda.el (org-prepare-agenda): When creating a new frame for the agenda, make the window dedicated. * org-agenda.el (org-agenda-mode-map): New keys for time motion. * org-table.el (org-table-align): Change the order of reinsertion and deletion, to avoid problems with overlays following the table. * org.el (org-parse-time-string): Better error message. (org-show-subtree): Use org-end-of-subtree. * org-macs.el (org-goto-line): New defsubst. * org.el (org-open-file, org-change-tag-in-region) (org-fast-tag-show-exit): Don't use `goto-line'. * org-table.el (org-table-align, org-table-insert-column) (org-table-delete-column, org-table-move-column) (org-table-sort-lines, org-table-copy-region) (org-table-paste-rectangle, org-table-wrap-region) (org-table-get-specials, org-table-rotate-recalc-marks) (org-table-get-range, org-table-recalculate) (org-table-edit-formulas, org-table-fedit-convert-buffer) (org-table-show-reference, org-table-highlight-rectangle): Don't use `goto-line'. * org-src.el (org-edit-src-code, org-edit-fixed-width-region) (org-edit-src-exit): Don't use `goto-line'. * org-macs.el (org-preserve-lc): Don't use `goto-line'. * org-list.el (org-renumber-ordered-list, org-fix-bullet-type): Don't use `goto-line'. * org-exp.el (org-export-number-lines): Don't use `goto-line'. * org-colview.el (org-columns, org-columns-redo) (org-agenda-columns): Don't use `goto-line'. * org-colview-xemacs.el (org-columns, org-agenda-columns): Don't use `goto-line'. * org-agenda.el (org-agenda-mode): Force visual line motion off. (org-agenda-add-entry-text-maxlines): Improve docstring. (org-agenda-start-with-entry-text-mode): New option. (org-agenda-entry-text-maxlines): New option. (org-agenda-entry-text-mode): New variable. (org-agenda-mode): Set initial value of `org-agenda-entry-text-mode'. (org-agenda-mode-map): Add the `E' key. (org-agenda-menu): Add entry text mode to the menu. (org-agenda-get-some-entry-text): Fix line count bug. (org-finalize-agenda): Apply entry text mode if appropriate. (org-agenda-entry-text-show-here): New function. (org-agenda-entry-text-show): New function. (org-agenda-entry-text-hide): New function. (org-agenda-view-mode-dispatch): Add entry text mode to the view key menu. (org-agenda-entry-text-mode): New command. (org-agenda-set-mode-name): Add entry text mode to the mode line string. (org-agenda-undo, org-agenda-get-restriction-and-command) (org-agenda-get-some-entry-text, org-agenda-redo): Don't use `goto-line'. 2009-09-02 Bernt Hansen <bernt@norang.ca> * org-clock.el (org-notify): Bugfix. 2009-09-02 Carsten Dominik <carsten.dominik@gmail.com> * org-agenda.el (org-agenda-open-link): Handle multiple links and check for after-string. * org-gnus.el (org-gnus-store-link): Simplify. * org.el (org-latex-regexps): Don't add extra empty lines for display formulas. 2009-09-02 Carsten Dominik <carsten.dominik@gmail.com> * org-agenda.el (org-agenda-get-some-entry-text): New function. (org-agenda-add-entry-text): Use `org-agenda-get-some-entry-text'. * org.el (org-cycle-separator-lines): Update docstring. (org-cycle-show-empty-lines): Handle negative values for `org-cycle-show-empty-lines'. * org-exp.el (org-export-protect-sub-super): New function. (org-export-normalize-links): Protect the url of plain links from supscript and superscript processing. * org-remember.el (org-remember-escaped-%): New function. (org-remember-apply-template): Use `org-remember-escaped-%' to detect escaped % signs. 2009-09-02 Bastien Guerry <bzg@altern.org> * org-timer.el (org-timer-set-timer): Use `org-notify' and play a sound when showing the notification. * org-clock.el (org-notify): New function. (org-clock-notify-once-if-expired): Use `org-notify'. * org-gnus.el (org-gnus-store-link): Handle `gnus-summary-mode' and `gnus-article-mode' separately. (gnus-summary-article-header): Fix the declare-function. 2009-09-02 Carsten Dominik <carsten.dominik@gmail.com> * org-exp.el (org-export-format-source-code-or-example): Translate language. * org-src.el (org-src-lang-modes): New variable (org-edit-src-code): Translate language. * org-exp.el (org-export-format-source-code-or-example): Deal wit the new structure of the `org-export-latex-listings-langs' variable. * org-latex.el (org-export-latex-listings-langs): Change structure of the variable from plist to alist. 2009-09-02 Carsten Dominik <carsten.dominik@gmail.com> * org.el (org-in-commented-line): New function. 2009-09-02 Carsten Dominik <carsten.dominik@gmail.com> * org.el (org-hide-block-toggle): Make folded blocks searchable. 2009-09-02 Friedrich Delgado Friedrichs <friedel@nomaden.org> (tiny change) * org.el (org-flag-drawer): More useful error. 2009-09-02 Carsten Dominik <carsten.dominik@gmail.com> * org-remember.el (org-remember-apply-template): Use org-icompleting-read. * org-publish.el (org-publish): Use org-icompleting-read. * org-colview.el (org-columns-edit-value, org-columns-new) (org-insert-columns-dblock): Use org-icompleting-read. * org-colview-xemacs.el (org-columns-edit-value) (org-columns-new, org-insert-columns-dblock): Use org-icompleting-read. * org-attach.el (org-attach-delete-one, org-attach-open): Use org-icompleting-read. 2009-09-02 Carsten Dominik <carsten.dominik@gmail.com> * org.el (org-hierarchical-todo-statistics): Improve docstring. (org-version): Return the version text. (org-org-menu): Add a menu entry for the new bug reporter. (org-submit-bug-report): New command. * org-list.el (org-hierarchical-checkbox-statistics): Improve docstring. * org.el (org-emphasis-regexp-components): Add "`" to set of pre-emphasis characters. * org-latex.el (org-export-latex-classes): Always include the soul package. (org-export-latex-emphasis-alist): Use \st for strikethough. * org-exp-blocks.el (org-export-blocks-preprocess): Use `indent-code-rigidly' to indent. * org-agenda.el (org-agenda-get-restriction-and-command): Remove properties only if MATCH really is a string. 2009-09-02 Carsten Dominik <carsten.dominik@gmail.com> * org-latex.el (org-export-latex-packages-alist): Fix customization type. * org.el (org-create-formula-image): Also use `org-export-latex-packages-alist'. * org-html.el (org-export-as-html): Fix bug in footnote regexp. (org-export-as-html): Format footnotes correctly. 2009-09-02 Carsten Dominik <carsten.dominik@gmail.com> * org.el (org-fast-tag-selection): Avoid text properties on tags in the alist. * org-agenda.el (org-agenda-get-restriction-and-command): Avoid text properties on the match element. 2009-09-02 Carsten Dominik <carsten.dominik@gmail.com> * org.el (org-set-regexps-and-options): Make sure the list of done keywords is not invalid. * org-exp.el (org-export-interpolate-newlines): New function. 2009-09-02 Carsten Dominik <carsten.dominik@gmail.com> * org.el (org-format-latex): Avoid nested overlays. * org-latex.el (org-export-latex-listings-langs): Add a few more languages. * org-exp.el (org-export-preprocess-apply-macros): Make sure to ignore newlines and space before the first macro argument. * org-latex.el (org-export-latex-tables): Remove save-excursion around `org-table-align'. 2009-09-02 Carsten Dominik <carsten.dominik@gmail.com> * org.el (org-export-html-special-string-regexps): Definition moved into org.el * org-exp.el (org-export-preprocess-apply-macros): Allow newlines in macro calls. 2009-09-02 Carsten Dominik <carsten.dominik@gmail.com> * org-latex.el (org-export-latex-listings) (org-export-latex-listings-langs): New options. * org-exp.el (org-export-format-source-code-or-example): Use listing package if requested by the user. 2009-09-02 Bastien Guerry <bzg@altern.org> * org.el (org-iswitchb): Fix bug when aborting the `org-iswitchb' command before actually switching to a buffer. 2009-09-02 Carsten Dominik <carsten.dominik@gmail.com> * org-exp.el (org-get-file-contents): Only quote org lines when the markup is src or example. * org-agenda.el (org-agenda-skip-scheduled-if-deadline-is-shown): New option (org-agenda-get-day-entries): Remember deadline results and pass them on into the function getting the scheduling information. (org-agenda-get-scheduled): Accept deadline results as parameters and maybe skip some entries. (org-agenda-skip-scheduled-if-deadline-is-shown): New option. * org.el (org-insert-heading): When respecting content, do not convert current line to headline. * org-clock.el (org-clock-save-markers-for-cut-and-paste): Also cheeeeeck the hd marker (org-clock-in): Also set the hd marker. (org-clock-out): Also set the hd marker. (org-clock-cancel): Reset markers. * org.el (org-clock-hd-marker): New marker. * org-faces.el (org-agenda-clocking): New face. * org-agenda.el (org-agenda-mark-clocking-task): New function. (org-finalize-agenda): call `org-agenda-mark-clocking-task'. * org.el (org-modules): Add org-track.el. * org-agenda.el (org-agenda-bulk-marked-p): New function. (org-agenda-bulk-mark, org-agenda-bulk-unmark): Use `org-agenda-bulk-marked-p'. (org-agenda-bulk-toggle): New command. 2009-09-02 Carsten Dominik <carsten.dominik@gmail.com> * org.el (org-move-subtree-down): Hide subtree if it was folded, not just the body. * org-remember.el (org-remember-finalize): Avoid buffer-modified messages.
author Carsten Dominik <dominik@science.uva.nl>
date Wed, 02 Sep 2009 12:59:52 +0000
parents ac1a55cc2c38
children dc1e0326ee77
comparison
equal deleted inserted replaced
104809:23afd425bd15 104810:86b7fe7d1d8f
4 ;; Free Software Foundation, Inc. 4 ;; Free Software Foundation, Inc.
5 5
6 ;; Author: Carsten Dominik <carsten at orgmode dot org> 6 ;; Author: Carsten Dominik <carsten at orgmode dot org>
7 ;; Keywords: outlines, hypermedia, calendar, wp 7 ;; Keywords: outlines, hypermedia, calendar, wp
8 ;; Homepage: http://orgmode.org 8 ;; Homepage: http://orgmode.org
9 ;; Version: 6.29c 9 ;; Version: 6.30c
10 ;; 10 ;;
11 ;; This file is part of GNU Emacs. 11 ;; This file is part of GNU Emacs.
12 ;; 12 ;;
13 ;; GNU Emacs is free software: you can redistribute it and/or modify 13 ;; GNU Emacs is free software: you can redistribute it and/or modify
14 ;; it under the terms of the GNU General Public License as published by 14 ;; it under the terms of the GNU General Public License as published by
126 "Maximum number of entry text lines to be added to agenda. 126 "Maximum number of entry text lines to be added to agenda.
127 This is only relevant when `org-agenda-add-entry-text' is part of 127 This is only relevant when `org-agenda-add-entry-text' is part of
128 `org-agenda-before-write-hook', which it is by default. 128 `org-agenda-before-write-hook', which it is by default.
129 When this is 0, nothing will happen. When it is greater than 0, it 129 When this is 0, nothing will happen. When it is greater than 0, it
130 specifies the maximum number of lines that will be added for each entry 130 specifies the maximum number of lines that will be added for each entry
131 that is listed in the agenda view." 131 that is listed in the agenda view.
132
133 Note that this variable is not used during display, only when exporting
134 the agenda. For agenda display, see org-agenda-entry-text-mode and the
135 variable `org-agenda-entry-text-maxlines'."
132 :group 'org-agenda 136 :group 'org-agenda
133 :type 'integer) 137 :type 'integer)
134 138
135 (defcustom org-agenda-add-entry-text-descriptive-links t 139 (defcustom org-agenda-add-entry-text-descriptive-links t
136 "Non-nil means, export org-links as descriptive links in agenda added text. 140 "Non-nil means, export org-links as descriptive links in agenda added text.
553 is DONE." 557 is DONE."
554 :group 'org-agenda-skip 558 :group 'org-agenda-skip
555 :group 'org-agenda-daily/weekly 559 :group 'org-agenda-daily/weekly
556 :type 'boolean) 560 :type 'boolean)
557 561
562 (defcustom org-agenda-skip-scheduled-if-deadline-is-shown nil
563 "Non-nil means skip scheduling line if same entry shows because of deadline.
564 In the agenda of today, an entry can show up multiple times because
565 it is both scheduled and has a nearby deadline, and maybe a plain time
566 stamp as well.
567 When this variable is t, then only the deadline is shown and the fact that
568 the entry is scheduled today or was scheduled previously is not shown.
569 When this variable is nil, the entry will be shown several times. When
570 the variable is the symbol `not-today', then skip scheduled previously,
571 but not scheduled today."
572 :group 'org-agenda-skip
573 :group 'org-agenda-daily/weekly
574 :type '(choice
575 (const :tag "Never" nil)
576 (const :tag "Always" t)
577 (const :tag "Not when scheduled today" not-today)))
578
558 (defcustom org-agenda-skip-deadline-if-done nil 579 (defcustom org-agenda-skip-deadline-if-done nil
559 "Non-nil means don't show deadlines when the corresponding item is done. 580 "Non-nil means don't show deadlines when the corresponding item is done.
560 When nil, the deadline is still shown and should give you a happy feeling. 581 When nil, the deadline is still shown and should give you a happy feeling.
561 This is relevant for the daily/weekly agenda. And it applied only to the 582 This is relevant for the daily/weekly agenda. And it applied only to the
562 actually date of the deadline. Warnings about approaching and past-due 583 actually date of the deadline. Warnings about approaching and past-due
631 652
632 (defcustom org-agenda-start-with-follow-mode nil 653 (defcustom org-agenda-start-with-follow-mode nil
633 "The initial value of follow-mode in a newly created agenda window." 654 "The initial value of follow-mode in a newly created agenda window."
634 :group 'org-agenda-startup 655 :group 'org-agenda-startup
635 :type 'boolean) 656 :type 'boolean)
657
658 (defcustom org-agenda-start-with-entry-text-mode nil
659 "The initial value of entry-text-mode in a newly created agenda window."
660 :group 'org-agenda-startup
661 :type 'boolean)
662
663 (defcustom org-agenda-entry-text-maxlines 5
664 "Number of text lines to be added when `E' is presed in the agenda.
665
666 Note that this variable only used during agenda display. Add add entry text
667 when exporting the agenda, configure the variable
668 `org-agenda-add-entry-ext-maxlines'."
669 :group 'org-agenda
670 :type 'integer)
636 671
637 (defvar org-agenda-include-inactive-timestamps nil 672 (defvar org-agenda-include-inactive-timestamps nil
638 "Non-nil means, include inactive time stamps in agenda and timeline.") 673 "Non-nil means, include inactive time stamps in agenda and timeline.")
639 674
640 (defgroup org-agenda-windows nil 675 (defgroup org-agenda-windows nil
1226 "Keymap for `org-agenda-mode'.") 1261 "Keymap for `org-agenda-mode'.")
1227 1262
1228 (defvar org-agenda-menu) ; defined later in this file. 1263 (defvar org-agenda-menu) ; defined later in this file.
1229 (defvar org-agenda-restrict) ; defined later in this file. 1264 (defvar org-agenda-restrict) ; defined later in this file.
1230 (defvar org-agenda-follow-mode nil) 1265 (defvar org-agenda-follow-mode nil)
1266 (defvar org-agenda-entry-text-mode nil)
1231 (defvar org-agenda-clockreport-mode nil) 1267 (defvar org-agenda-clockreport-mode nil)
1232 (defvar org-agenda-show-log nil) 1268 (defvar org-agenda-show-log nil)
1233 (defvar org-agenda-redo-command nil) 1269 (defvar org-agenda-redo-command nil)
1234 (defvar org-agenda-query-string nil) 1270 (defvar org-agenda-query-string nil)
1235 (defvar org-agenda-mode-hook nil 1271 (defvar org-agenda-mode-hook nil
1254 (org-set-local 'font-lock-global-modes (list 'not major-mode)) 1290 (org-set-local 'font-lock-global-modes (list 'not major-mode))
1255 (setq mode-name "Org-Agenda") 1291 (setq mode-name "Org-Agenda")
1256 (use-local-map org-agenda-mode-map) 1292 (use-local-map org-agenda-mode-map)
1257 (easy-menu-add org-agenda-menu) 1293 (easy-menu-add org-agenda-menu)
1258 (if org-startup-truncated (setq truncate-lines t)) 1294 (if org-startup-truncated (setq truncate-lines t))
1295 (org-set-local 'line-move-visual nil)
1259 (org-add-hook 'post-command-hook 'org-agenda-post-command-hook nil 'local) 1296 (org-add-hook 'post-command-hook 'org-agenda-post-command-hook nil 'local)
1260 (org-add-hook 'pre-command-hook 'org-unhighlight nil 'local) 1297 (org-add-hook 'pre-command-hook 'org-unhighlight nil 'local)
1261 ;; Make sure properties are removed when copying text 1298 ;; Make sure properties are removed when copying text
1262 (when (boundp 'buffer-substring-filters) 1299 (when (boundp 'buffer-substring-filters)
1263 (org-set-local 'buffer-substring-filters 1300 (org-set-local 'buffer-substring-filters
1264 (cons (lambda (x) 1301 (cons (lambda (x)
1265 (set-text-properties 0 (length x) nil x) x) 1302 (set-text-properties 0 (length x) nil x) x)
1266 buffer-substring-filters))) 1303 buffer-substring-filters)))
1267 (unless org-agenda-keep-modes 1304 (unless org-agenda-keep-modes
1268 (setq org-agenda-follow-mode org-agenda-start-with-follow-mode 1305 (setq org-agenda-follow-mode org-agenda-start-with-follow-mode
1306 org-agenda-entry-text-mode org-agenda-start-with-entry-text-mode
1269 org-agenda-clockreport-mode org-agenda-start-with-clockreport-mode 1307 org-agenda-clockreport-mode org-agenda-start-with-clockreport-mode
1270 org-agenda-show-log org-agenda-start-with-log-mode)) 1308 org-agenda-show-log org-agenda-start-with-log-mode))
1271 1309
1272 (easy-menu-change 1310 (easy-menu-change
1273 '("Agenda") "Agenda Files" 1311 '("Agenda") "Agenda Files"
1290 org-agenda-mode-map global-map) 1328 org-agenda-mode-map global-map)
1291 (org-defkey org-agenda-mode-map "\C-i" 'org-agenda-goto) 1329 (org-defkey org-agenda-mode-map "\C-i" 'org-agenda-goto)
1292 (org-defkey org-agenda-mode-map [(tab)] 'org-agenda-goto) 1330 (org-defkey org-agenda-mode-map [(tab)] 'org-agenda-goto)
1293 (org-defkey org-agenda-mode-map "\C-m" 'org-agenda-switch-to) 1331 (org-defkey org-agenda-mode-map "\C-m" 'org-agenda-switch-to)
1294 (org-defkey org-agenda-mode-map "\C-k" 'org-agenda-kill) 1332 (org-defkey org-agenda-mode-map "\C-k" 'org-agenda-kill)
1295 (org-defkey org-agenda-mode-map "\C-c$" 'org-agenda-archive)
1296 (org-defkey org-agenda-mode-map "\C-c\C-x\C-s" 'org-agenda-archive)
1297 (org-defkey org-agenda-mode-map "\C-c\C-w" 'org-agenda-refile) 1333 (org-defkey org-agenda-mode-map "\C-c\C-w" 'org-agenda-refile)
1298 (org-defkey org-agenda-mode-map "m" 'org-agenda-bulk-mark) 1334 (org-defkey org-agenda-mode-map "m" 'org-agenda-bulk-mark)
1299 (org-defkey org-agenda-mode-map "u" 'org-agenda-bulk-unmark) 1335 (org-defkey org-agenda-mode-map "u" 'org-agenda-bulk-unmark)
1300 (org-defkey org-agenda-mode-map "U" 'org-agenda-bulk-remove-all-marks) 1336 (org-defkey org-agenda-mode-map "U" 'org-agenda-bulk-remove-all-marks)
1301 (org-defkey org-agenda-mode-map "B" 'org-agenda-bulk-action) 1337 (org-defkey org-agenda-mode-map "B" 'org-agenda-bulk-action)
1302 (org-defkey org-agenda-mode-map "\C-c\C-x!" 'org-reload) 1338 (org-defkey org-agenda-mode-map "\C-c\C-x!" 'org-reload)
1339 (org-defkey org-agenda-mode-map "\C-c$" 'org-agenda-archive)
1340 (org-defkey org-agenda-mode-map "\C-c\C-x\C-s" 'org-agenda-archive)
1303 (org-defkey org-agenda-mode-map "$" 'org-agenda-archive) 1341 (org-defkey org-agenda-mode-map "$" 'org-agenda-archive)
1304 (org-defkey org-agenda-mode-map "A" 'org-agenda-archive-to-archive-sibling) 1342 (org-defkey org-agenda-mode-map "A" 'org-agenda-archive-to-archive-sibling)
1305 (org-defkey org-agenda-mode-map "\C-c\C-o" 'org-agenda-open-link) 1343 (org-defkey org-agenda-mode-map "\C-c\C-o" 'org-agenda-open-link)
1306 (org-defkey org-agenda-mode-map " " 'org-agenda-show) 1344 (org-defkey org-agenda-mode-map " " 'org-agenda-show)
1307 (org-defkey org-agenda-mode-map "\C-c\C-t" 'org-agenda-todo)
1308 (org-defkey org-agenda-mode-map [(control shift right)] 'org-agenda-todo-nextset) 1345 (org-defkey org-agenda-mode-map [(control shift right)] 'org-agenda-todo-nextset)
1309 (org-defkey org-agenda-mode-map [(control shift left)] 'org-agenda-todo-previousset) 1346 (org-defkey org-agenda-mode-map [(control shift left)] 'org-agenda-todo-previousset)
1310 (org-defkey org-agenda-mode-map "\C-c\C-xb" 'org-agenda-tree-to-indirect-buffer) 1347 (org-defkey org-agenda-mode-map "\C-c\C-xb" 'org-agenda-tree-to-indirect-buffer)
1311 (org-defkey org-agenda-mode-map "b" 'org-agenda-tree-to-indirect-buffer)
1312 (org-defkey org-agenda-mode-map "o" 'delete-other-windows) 1348 (org-defkey org-agenda-mode-map "o" 'delete-other-windows)
1313 (org-defkey org-agenda-mode-map "L" 'org-agenda-recenter) 1349 (org-defkey org-agenda-mode-map "L" 'org-agenda-recenter)
1350 (org-defkey org-agenda-mode-map "\C-c\C-t" 'org-agenda-todo)
1314 (org-defkey org-agenda-mode-map "t" 'org-agenda-todo) 1351 (org-defkey org-agenda-mode-map "t" 'org-agenda-todo)
1315 (org-defkey org-agenda-mode-map "a" 'org-agenda-toggle-archive-tag) 1352 (org-defkey org-agenda-mode-map "a" 'org-agenda-toggle-archive-tag)
1316 (org-defkey org-agenda-mode-map ":" 'org-agenda-set-tags) 1353 (org-defkey org-agenda-mode-map ":" 'org-agenda-set-tags)
1317 (org-defkey org-agenda-mode-map "\C-c\C-q" 'org-agenda-set-tags) 1354 (org-defkey org-agenda-mode-map "\C-c\C-q" 'org-agenda-set-tags)
1318 (org-defkey org-agenda-mode-map "." 'org-agenda-goto-today) 1355 (org-defkey org-agenda-mode-map "." 'org-agenda-goto-today)
1334 (org-defkey org-agenda-mode-map "\C-c\C-d" 'org-agenda-deadline) 1371 (org-defkey org-agenda-mode-map "\C-c\C-d" 'org-agenda-deadline)
1335 (let ((l '(1 2 3 4 5 6 7 8 9 0))) 1372 (let ((l '(1 2 3 4 5 6 7 8 9 0)))
1336 (while l (org-defkey org-agenda-mode-map 1373 (while l (org-defkey org-agenda-mode-map
1337 (int-to-string (pop l)) 'digit-argument))) 1374 (int-to-string (pop l)) 'digit-argument)))
1338 1375
1339 (org-defkey org-agenda-mode-map "f" 'org-agenda-follow-mode) 1376 (org-defkey org-agenda-mode-map "F" 'org-agenda-follow-mode)
1340 (org-defkey org-agenda-mode-map "R" 'org-agenda-clockreport-mode) 1377 (org-defkey org-agenda-mode-map "R" 'org-agenda-clockreport-mode)
1378 (org-defkey org-agenda-mode-map "E" 'org-agenda-entry-text-mode)
1341 (org-defkey org-agenda-mode-map "l" 'org-agenda-log-mode) 1379 (org-defkey org-agenda-mode-map "l" 'org-agenda-log-mode)
1342 (org-defkey org-agenda-mode-map "v" 'org-agenda-view-mode-dispatch) 1380 (org-defkey org-agenda-mode-map "v" 'org-agenda-view-mode-dispatch)
1343 (org-defkey org-agenda-mode-map "D" 'org-agenda-toggle-diary) 1381 (org-defkey org-agenda-mode-map "D" 'org-agenda-toggle-diary)
1344 (org-defkey org-agenda-mode-map "G" 'org-agenda-toggle-time-grid) 1382 (org-defkey org-agenda-mode-map "G" 'org-agenda-toggle-time-grid)
1345 (org-defkey org-agenda-mode-map "r" 'org-agenda-redo) 1383 (org-defkey org-agenda-mode-map "r" 'org-agenda-redo)
1346 (org-defkey org-agenda-mode-map "g" 'org-agenda-redo) 1384 (org-defkey org-agenda-mode-map "g" 'org-agenda-redo)
1347 (org-defkey org-agenda-mode-map "e" 'org-agenda-execute) 1385 (org-defkey org-agenda-mode-map "e" 'org-agenda-set-effort)
1386 (org-defkey org-agenda-mode-map "\C-c\C-xe" 'org-agenda-set-effort)
1387 (org-defkey org-agenda-mode-map "\C-c\C-x\C-e"
1388 'org-clock-modify-effort-estimate)
1389 (org-defkey org-agenda-mode-map "\C-c\C-xp" 'org-agenda-set-property)
1348 (org-defkey org-agenda-mode-map "q" 'org-agenda-quit) 1390 (org-defkey org-agenda-mode-map "q" 'org-agenda-quit)
1349 (org-defkey org-agenda-mode-map "x" 'org-agenda-exit) 1391 (org-defkey org-agenda-mode-map "x" 'org-agenda-exit)
1350 (org-defkey org-agenda-mode-map "\C-x\C-w" 'org-write-agenda) 1392 (org-defkey org-agenda-mode-map "\C-x\C-w" 'org-write-agenda)
1351 (org-defkey org-agenda-mode-map "\C-x\C-s" 'org-save-all-org-buffers) 1393 (org-defkey org-agenda-mode-map "\C-x\C-s" 'org-save-all-org-buffers)
1352 (org-defkey org-agenda-mode-map "s" 'org-save-all-org-buffers) 1394 (org-defkey org-agenda-mode-map "s" 'org-save-all-org-buffers)
1378 (org-defkey org-agenda-mode-map "-" 'org-agenda-priority-down) 1420 (org-defkey org-agenda-mode-map "-" 'org-agenda-priority-down)
1379 (org-defkey org-agenda-mode-map [(shift up)] 'org-agenda-priority-up) 1421 (org-defkey org-agenda-mode-map [(shift up)] 'org-agenda-priority-up)
1380 (org-defkey org-agenda-mode-map [(shift down)] 'org-agenda-priority-down) 1422 (org-defkey org-agenda-mode-map [(shift down)] 'org-agenda-priority-down)
1381 (org-defkey org-agenda-mode-map [?\C-c ?\C-x (up)] 'org-agenda-priority-up) 1423 (org-defkey org-agenda-mode-map [?\C-c ?\C-x (up)] 'org-agenda-priority-up)
1382 (org-defkey org-agenda-mode-map [?\C-c ?\C-x (down)] 'org-agenda-priority-down) 1424 (org-defkey org-agenda-mode-map [?\C-c ?\C-x (down)] 'org-agenda-priority-down)
1383 (org-defkey org-agenda-mode-map [(right)] 'org-agenda-later) 1425 (org-defkey org-agenda-mode-map "f" 'org-agenda-later)
1384 (org-defkey org-agenda-mode-map [(left)] 'org-agenda-earlier) 1426 (org-defkey org-agenda-mode-map "b" 'org-agenda-earlier)
1385 (org-defkey org-agenda-mode-map "\C-c\C-x\C-c" 'org-agenda-columns) 1427 (org-defkey org-agenda-mode-map "\C-c\C-x\C-c" 'org-agenda-columns)
1386 (org-defkey org-agenda-mode-map "\C-c\C-x>" 'org-agenda-remove-restriction-lock) 1428 (org-defkey org-agenda-mode-map "\C-c\C-x>" 'org-agenda-remove-restriction-lock)
1387 1429
1388 (org-defkey org-agenda-mode-map "[" 'org-agenda-manipulate-query-add) 1430 (org-defkey org-agenda-mode-map "[" 'org-agenda-manipulate-query-add)
1389 (org-defkey org-agenda-mode-map "]" 'org-agenda-manipulate-query-subtract) 1431 (org-defkey org-agenda-mode-map "]" 'org-agenda-manipulate-query-subtract)
1452 ["Change Time +1 hour" org-agenda-do-date-later :active (org-agenda-check-type nil 'agenda 'timeline) :keys "C-u S-right"] 1494 ["Change Time +1 hour" org-agenda-do-date-later :active (org-agenda-check-type nil 'agenda 'timeline) :keys "C-u S-right"]
1453 ["Change Time -1 hour" org-agenda-do-date-earlier :active (org-agenda-check-type nil 'agenda 'timeline) :keys "C-u S-left"] 1495 ["Change Time -1 hour" org-agenda-do-date-earlier :active (org-agenda-check-type nil 'agenda 'timeline) :keys "C-u S-left"]
1454 ["Change Time + min" org-agenda-date-later :active (org-agenda-check-type nil 'agenda 'timeline) :keys "C-u C-u S-right"] 1496 ["Change Time + min" org-agenda-date-later :active (org-agenda-check-type nil 'agenda 'timeline) :keys "C-u C-u S-right"]
1455 ["Change Time - min" org-agenda-date-earlier :active (org-agenda-check-type nil 'agenda 'timeline) :keys "C-u C-u S-left"] 1497 ["Change Time - min" org-agenda-date-earlier :active (org-agenda-check-type nil 'agenda 'timeline) :keys "C-u C-u S-left"]
1456 ["Change Date to ..." org-agenda-date-prompt (org-agenda-check-type nil 'agenda 'timeline)]) 1498 ["Change Date to ..." org-agenda-date-prompt (org-agenda-check-type nil 'agenda 'timeline)])
1457 ("Clock" 1499 ("Clock and Effort"
1458 ["Clock in" org-agenda-clock-in t] 1500 ["Clock in" org-agenda-clock-in t]
1459 ["Clock out" org-agenda-clock-out t] 1501 ["Clock out" org-agenda-clock-out t]
1460 ["Clock cancel" org-agenda-clock-cancel t] 1502 ["Clock cancel" org-agenda-clock-cancel t]
1461 ["Goto running clock" org-clock-goto t]) 1503 ["Goto running clock" org-clock-goto t]
1504 "--"
1505 ["Set Effort" org-agenda-set-effort t]
1506 ["Change clocked effort" org-clock-modify-effort-estimate
1507 (org-clock-is-active)])
1462 ("Priority" 1508 ("Priority"
1463 ["Set Priority" org-agenda-priority t] 1509 ["Set Priority" org-agenda-priority t]
1464 ["Increase Priority" org-agenda-priority-up t] 1510 ["Increase Priority" org-agenda-priority-up t]
1465 ["Decrease Priority" org-agenda-priority-down t] 1511 ["Decrease Priority" org-agenda-priority-down t]
1466 ["Show Priority" org-agenda-show-priority t]) 1512 ["Show Priority" org-agenda-show-priority t])
1500 :active (org-agenda-check-type nil 'agenda)] 1546 :active (org-agenda-check-type nil 'agenda)]
1501 "--" 1547 "--"
1502 ["Show clock report" org-agenda-clockreport-mode 1548 ["Show clock report" org-agenda-clockreport-mode
1503 :style toggle :selected org-agenda-clockreport-mode 1549 :style toggle :selected org-agenda-clockreport-mode
1504 :active (org-agenda-check-type nil 'agenda)] 1550 :active (org-agenda-check-type nil 'agenda)]
1551 ["Show some entry text" org-agenda-entry-text-mode
1552 :style toggle :selected org-agenda-entry-text-mode
1553 :active t]
1505 "--" 1554 "--"
1506 ["Show Logbook entries" org-agenda-log-mode 1555 ["Show Logbook entries" org-agenda-log-mode
1507 :style toggle :selected org-agenda-show-log 1556 :style toggle :selected org-agenda-show-log
1508 :active (org-agenda-check-type nil 'agenda 'timeline) 1557 :active (org-agenda-check-type nil 'agenda 'timeline)
1509 :keys "v l (or just l)"] 1558 :keys "v l (or just l)"]
1566 (while (and pending-undo-list 1615 (while (and pending-undo-list
1567 (listp pending-undo-list) 1616 (listp pending-undo-list)
1568 (not (car pending-undo-list))) 1617 (not (car pending-undo-list)))
1569 (pop pending-undo-list)) 1618 (pop pending-undo-list))
1570 (undo-more 1)))))) 1619 (undo-more 1))))))
1571 (goto-line line) 1620 (org-goto-line line)
1572 (message "`%s' undone (buffer %s)" cmd (buffer-name rembuf)))) 1621 (message "`%s' undone (buffer %s)" cmd (buffer-name rembuf))))
1573 1622
1574 (defun org-verify-change-for-undo (l1 l2) 1623 (defun org-verify-change-for-undo (l1 l2)
1575 "Verify that a real change occurred between the undo lists L1 and L2." 1624 "Verify that a real change occurred between the undo lists L1 and L2."
1576 (while (and l1 (listp l1) (null (car l1))) (pop l1)) 1625 (while (and l1 (listp l1) (null (car l1))) (pop l1))
1620 Pressing `<' twice means to restrict to the current subtree or region 1669 Pressing `<' twice means to restrict to the current subtree or region
1621 \(if active)." 1670 \(if active)."
1622 (interactive "P") 1671 (interactive "P")
1623 (catch 'exit 1672 (catch 'exit
1624 (let* ((prefix-descriptions nil) 1673 (let* ((prefix-descriptions nil)
1674 (org-agenda-window-setup (if (equal (buffer-name)
1675 org-agenda-buffer-name)
1676 'current-window
1677 org-agenda-window-setup))
1625 (org-agenda-custom-commands-orig org-agenda-custom-commands) 1678 (org-agenda-custom-commands-orig org-agenda-custom-commands)
1626 (org-agenda-custom-commands 1679 (org-agenda-custom-commands
1627 ;; normalize different versions 1680 ;; normalize different versions
1628 (delq nil 1681 (delq nil
1629 (mapcar 1682 (mapcar
1776 header))) 1829 header)))
1777 (setq header-end (move-marker (make-marker) (point))) 1830 (setq header-end (move-marker (make-marker) (point)))
1778 (while t 1831 (while t
1779 (setq custom1 custom) 1832 (setq custom1 custom)
1780 (when (eq rmheader t) 1833 (when (eq rmheader t)
1781 (goto-line 1) 1834 (org-goto-line 1)
1782 (re-search-forward ":" nil t) 1835 (re-search-forward ":" nil t)
1783 (delete-region (match-end 0) (point-at-eol)) 1836 (delete-region (match-end 0) (point-at-eol))
1784 (forward-char 1) 1837 (forward-char 1)
1785 (looking-at "-+") 1838 (looking-at "-+")
1786 (delete-region (match-end 0) (point-at-eol)) 1839 (delete-region (match-end 0) (point-at-eol))
1787 (move-marker header-end (match-end 0))) 1840 (move-marker header-end (match-end 0)))
1788 (goto-char header-end) 1841 (goto-char header-end)
1789 (delete-region (point) (point-max)) 1842 (delete-region (point) (point-max))
1790 (while (setq entry (pop custom1)) 1843 (while (setq entry (pop custom1))
1791 (setq key (car entry) desc (nth 1 entry) 1844 (setq key (car entry) desc (nth 1 entry)
1792 type (nth 2 entry) match (nth 3 entry)) 1845 type (nth 2 entry)
1846 match (nth 3 entry))
1793 (if (> (length key) 1) 1847 (if (> (length key) 1)
1794 (add-to-list 'prefixes (string-to-char key)) 1848 (add-to-list 'prefixes (string-to-char key))
1795 (insert 1849 (insert
1796 (format 1850 (format
1797 "\n%-4s%-14s: %s" 1851 "\n%-4s%-14s: %s"
1813 (symbol-name type) 1867 (symbol-name type)
1814 "Lambda expression")) 1868 "Lambda expression"))
1815 (t "???")) 1869 (t "???"))
1816 (cond 1870 (cond
1817 ((stringp match) 1871 ((stringp match)
1872 (setq match (copy-sequence match))
1818 (org-add-props match nil 'face 'org-warning)) 1873 (org-add-props match nil 'face 'org-warning))
1819 (match 1874 (match
1820 (format "set of %d commands" (length match))) 1875 (format "set of %d commands" (length match)))
1821 (t "")))))) 1876 (t ""))))))
1822 (when prefixes 1877 (when prefixes
2210 "Add entry text to agenda lines. 2265 "Add entry text to agenda lines.
2211 This will add a maximum of `org-agenda-add-entry-text-maxlines' lines of the 2266 This will add a maximum of `org-agenda-add-entry-text-maxlines' lines of the
2212 entry text following headings shown in the agenda. 2267 entry text following headings shown in the agenda.
2213 Drawers will be excluded, also the line with scheduling/deadline info." 2268 Drawers will be excluded, also the line with scheduling/deadline info."
2214 (when (> org-agenda-add-entry-text-maxlines 0) 2269 (when (> org-agenda-add-entry-text-maxlines 0)
2215 (let (m txt drawer-re kwd-time-re ind) 2270 (let (m txt)
2216 (goto-char (point-min)) 2271 (goto-char (point-min))
2217 (while (not (eobp)) 2272 (while (not (eobp))
2218 (if (not (setq m (get-text-property (point) 'org-hd-marker))) 2273 (if (not (setq m (get-text-property (point) 'org-hd-marker)))
2219 (beginning-of-line 2) 2274 (beginning-of-line 2)
2220 (save-excursion 2275 (setq txt (org-agenda-get-some-entry-text
2221 (with-current-buffer (marker-buffer m) 2276 m org-agenda-add-entry-text-maxlines))
2222 (if (not (org-mode-p))
2223 (setq txt "")
2224 (save-excursion
2225 (save-restriction
2226 (widen)
2227 (goto-char m)
2228 (beginning-of-line 2)
2229 (setq txt (buffer-substring
2230 (point)
2231 (progn (outline-next-heading) (point)))
2232 drawer-re org-drawer-regexp
2233 kwd-time-re (concat "^[ \t]*" org-keyword-time-regexp
2234 ".*\n?"))
2235 (with-temp-buffer
2236 (insert txt)
2237 (when org-agenda-add-entry-text-descriptive-links
2238 (goto-char (point-min))
2239 (while (org-activate-bracket-links (point-max))
2240 (add-text-properties (match-beginning 0) (match-end 0)
2241 '(face org-link))))
2242 (goto-char (point-min))
2243 (while (re-search-forward org-bracket-link-regexp (point-max) t)
2244 (set-text-properties (match-beginning 0) (match-end 0)
2245 nil))
2246 (goto-char (point-min))
2247 (while (re-search-forward drawer-re nil t)
2248 (delete-region
2249 (match-beginning 0)
2250 (progn (re-search-forward
2251 "^[ \t]*:END:.*\n?" nil 'move)
2252 (point))))
2253 (goto-char (point-min))
2254 (while (re-search-forward kwd-time-re nil t)
2255 (replace-match ""))
2256 (if (re-search-forward "[ \t\n]+\\'" nil t)
2257 (replace-match ""))
2258 (goto-char (point-min))
2259 ;; find min indentation
2260 (goto-char (point-min))
2261 (untabify (point-min) (point-max))
2262 (setq ind (org-get-indentation))
2263 (while (not (eobp))
2264 (unless (looking-at "[ \t]*$")
2265 (setq ind (min ind (org-get-indentation))))
2266 (beginning-of-line 2))
2267 (goto-char (point-min))
2268 (while (not (eobp))
2269 (unless (looking-at "[ \t]*$")
2270 (move-to-column ind)
2271 (delete-region (point-at-bol) (point)))
2272 (beginning-of-line 2))
2273 (goto-char (point-min))
2274 (while (and (not (eobp)) (re-search-forward "^" nil t))
2275 (replace-match " > "))
2276 (goto-char (point-min))
2277 (while (looking-at "[ \t]*\n") (replace-match ""))
2278 (goto-char (point-max))
2279 (when (> (org-current-line)
2280 (1+ org-agenda-add-entry-text-maxlines))
2281 (goto-line (1+ org-agenda-add-entry-text-maxlines))
2282 (backward-char 1))
2283 (setq txt (buffer-substring (point-min) (point)))))))))
2284 (end-of-line 1) 2277 (end-of-line 1)
2285 (if (string-match "\\S-" txt) (insert "\n" txt))))))) 2278 (if (string-match "\\S-" txt) (insert "\n" txt)))))))
2279
2280 (defun org-agenda-get-some-entry-text (marker n-lines)
2281 "Extract entry text from MARKER, at most N-LINES lines.
2282 This will ignore drawers etc, just get the text."
2283 (let (txt drawer-re kwd-time-re ind)
2284 (save-excursion
2285 (with-current-buffer (marker-buffer marker)
2286 (if (not (org-mode-p))
2287 (setq txt "")
2288 (save-excursion
2289 (save-restriction
2290 (widen)
2291 (goto-char marker)
2292 (beginning-of-line 2)
2293 (setq txt (buffer-substring
2294 (point)
2295 (progn (outline-next-heading) (point)))
2296 drawer-re org-drawer-regexp
2297 kwd-time-re (concat "^[ \t]*" org-keyword-time-regexp
2298 ".*\n?"))
2299 (with-temp-buffer
2300 (insert txt)
2301 (when org-agenda-add-entry-text-descriptive-links
2302 (goto-char (point-min))
2303 (while (org-activate-bracket-links (point-max))
2304 (add-text-properties (match-beginning 0) (match-end 0)
2305 '(face org-link))))
2306 (goto-char (point-min))
2307 (while (re-search-forward org-bracket-link-regexp (point-max) t)
2308 (set-text-properties (match-beginning 0) (match-end 0)
2309 nil))
2310 (goto-char (point-min))
2311 (while (re-search-forward drawer-re nil t)
2312 (delete-region
2313 (match-beginning 0)
2314 (progn (re-search-forward
2315 "^[ \t]*:END:.*\n?" nil 'move)
2316 (point))))
2317 (goto-char (point-min))
2318 (while (re-search-forward kwd-time-re nil t)
2319 (replace-match ""))
2320 (if (re-search-forward "[ \t\n]+\\'" nil t)
2321 (replace-match ""))
2322 (goto-char (point-min))
2323 ;; find min indentation
2324 (goto-char (point-min))
2325 (untabify (point-min) (point-max))
2326 (setq ind (org-get-indentation))
2327 (while (not (eobp))
2328 (unless (looking-at "[ \t]*$")
2329 (setq ind (min ind (org-get-indentation))))
2330 (beginning-of-line 2))
2331 (goto-char (point-min))
2332 (while (not (eobp))
2333 (unless (looking-at "[ \t]*$")
2334 (move-to-column ind)
2335 (delete-region (point-at-bol) (point)))
2336 (beginning-of-line 2))
2337 (goto-char (point-min))
2338 (while (and (not (eobp)) (re-search-forward "^" nil t))
2339 (replace-match " > "))
2340 (goto-char (point-min))
2341 (while (looking-at "[ \t]*\n") (replace-match ""))
2342 (goto-char (point-max))
2343 (when (> (org-current-line)
2344 n-lines)
2345 (org-goto-line (1+ n-lines))
2346 (backward-char 1))
2347 (setq txt (buffer-substring (point-min) (point)))))))))
2348 txt))
2286 2349
2287 (defun org-agenda-collect-markers () 2350 (defun org-agenda-collect-markers ()
2288 "Collect the markers pointing to entries in the agenda buffer." 2351 "Collect the markers pointing to entries in the agenda buffer."
2289 (let (m markers) 2352 (let (m markers)
2290 (save-excursion 2353 (save-excursion
2384 ((equal org-agenda-window-setup 'current-window) 2447 ((equal org-agenda-window-setup 'current-window)
2385 (switch-to-buffer abuf)) 2448 (switch-to-buffer abuf))
2386 ((equal org-agenda-window-setup 'other-window) 2449 ((equal org-agenda-window-setup 'other-window)
2387 (org-switch-to-buffer-other-window abuf)) 2450 (org-switch-to-buffer-other-window abuf))
2388 ((equal org-agenda-window-setup 'other-frame) 2451 ((equal org-agenda-window-setup 'other-frame)
2389 (switch-to-buffer-other-frame abuf)) 2452 (switch-to-buffer-other-frame abuf)
2453 (set-window-dedicated-p (selected-window) t))
2390 ((equal org-agenda-window-setup 'reorganize-frame) 2454 ((equal org-agenda-window-setup 'reorganize-frame)
2391 (delete-other-windows) 2455 (delete-other-windows)
2392 (org-switch-to-buffer-other-window abuf)))) 2456 (org-switch-to-buffer-other-window abuf))))
2393 (setq buffer-read-only nil) 2457 (setq buffer-read-only nil)
2394 (let ((inhibit-read-only t)) (erase-buffer)) 2458 (let ((inhibit-read-only t)) (erase-buffer))
2418 (org-agenda-columns)) 2482 (org-agenda-columns))
2419 (when org-agenda-fontify-priorities 2483 (when org-agenda-fontify-priorities
2420 (org-agenda-fontify-priorities)) 2484 (org-agenda-fontify-priorities))
2421 (when (and org-agenda-dim-blocked-tasks org-blocker-hook) 2485 (when (and org-agenda-dim-blocked-tasks org-blocker-hook)
2422 (org-agenda-dim-blocked-tasks)) 2486 (org-agenda-dim-blocked-tasks))
2487 (org-agenda-mark-clocking-task)
2488 (when org-agenda-entry-text-mode
2489 (org-agenda-entry-text-hide)
2490 (org-agenda-entry-text-show))
2423 (run-hooks 'org-finalize-agenda-hook) 2491 (run-hooks 'org-finalize-agenda-hook)
2424 (setq org-agenda-type (get-text-property (point) 'org-agenda-type)) 2492 (setq org-agenda-type (get-text-property (point) 'org-agenda-type))
2425 (when (get 'org-agenda-filter :preset-filter) 2493 (when (get 'org-agenda-filter :preset-filter)
2426 (org-agenda-filter-apply org-agenda-filter)) 2494 (org-agenda-filter-apply org-agenda-filter))
2427 ))) 2495 )))
2496
2497 (defun org-agenda-mark-clocking-task ()
2498 "Mark the current clock entry in the agenda if it is present."
2499 (mapc (lambda (o)
2500 (if (eq (org-overlay-get o 'type) 'org-agenda-clocking)
2501 (org-delete-overlay o)))
2502 (org-overlays-in (point-min) (point-max)))
2503 (when (marker-buffer org-clock-hd-marker)
2504 (save-excursion
2505 (goto-char (point-min))
2506 (let (s ov)
2507 (while (setq s (next-single-property-change (point) 'org-hd-marker))
2508 (goto-char s)
2509 (when (equal (get-text-property (point) 'org-hd-marker)
2510 org-clock-hd-marker)
2511 (setq ov (org-make-overlay (point-at-bol) (1+ (point-at-eol))))
2512 (org-overlay-put ov 'type 'org-agenda-clocking)
2513 (org-overlay-put ov 'face 'org-agenda-clocking)
2514 (org-overlay-put ov 'help-echo
2515 "The clock is running in this item")))))))
2428 2516
2429 (defun org-agenda-fontify-priorities () 2517 (defun org-agenda-fontify-priorities ()
2430 "Make highest priority lines bold, and lowest italic." 2518 "Make highest priority lines bold, and lowest italic."
2431 (interactive) 2519 (interactive)
2432 (mapc (lambda (o) (if (eq (org-overlay-get o 'org-type) 'org-priority) 2520 (mapc (lambda (o) (if (eq (org-overlay-get o 'org-type) 'org-priority)
2528 (goto-char to) 2616 (goto-char to)
2529 (throw :skip t)))) 2617 (throw :skip t))))
2530 2618
2531 (defvar org-agenda-markers nil 2619 (defvar org-agenda-markers nil
2532 "List of all currently active markers created by `org-agenda'.") 2620 "List of all currently active markers created by `org-agenda'.")
2533 (defvar org-agenda-last-marker-time (time-to-seconds (current-time)) 2621 (defvar org-agenda-last-marker-time (org-float-time)
2534 "Creation time of the last agenda marker.") 2622 "Creation time of the last agenda marker.")
2535 2623
2536 (defun org-agenda-new-marker (&optional pos) 2624 (defun org-agenda-new-marker (&optional pos)
2537 "Return a new agenda marker. 2625 "Return a new agenda marker.
2538 Org-mode keeps a list of these markers and resets them when they are 2626 Org-mode keeps a list of these markers and resets them when they are
2539 no longer in use." 2627 no longer in use."
2540 (let ((m (copy-marker (or pos (point))))) 2628 (let ((m (copy-marker (or pos (point)))))
2541 (setq org-agenda-last-marker-time (time-to-seconds (current-time))) 2629 (setq org-agenda-last-marker-time (org-float-time))
2542 (push m org-agenda-markers) 2630 (push m org-agenda-markers)
2543 m)) 2631 m))
2544 2632
2545 (defun org-agenda-reset-markers () 2633 (defun org-agenda-reset-markers ()
2546 "Reset markers created by `org-agenda'." 2634 "Reset markers created by `org-agenda'."
2549 2637
2550 (defun org-agenda-save-markers-for-cut-and-paste (beg end) 2638 (defun org-agenda-save-markers-for-cut-and-paste (beg end)
2551 "Save relative positions of markers in region." 2639 "Save relative positions of markers in region."
2552 (mapc (lambda (m) (org-check-and-save-marker m beg end)) 2640 (mapc (lambda (m) (org-check-and-save-marker m beg end))
2553 org-agenda-markers)) 2641 org-agenda-markers))
2642
2643 ;;; Entry text mode
2644
2645 (defun org-agenda-entry-text-show-here ()
2646 "Add some text from te entry as context to the current line."
2647 (let (m txt o)
2648 (setq m (get-text-property (point) 'org-hd-marker))
2649 (unless (marker-buffer m)
2650 (error "No marker points to an entry here"))
2651 (setq txt (concat "\n" (org-no-properties
2652 (org-agenda-get-some-entry-text
2653 m org-agenda-entry-text-maxlines))))
2654 (when (string-match "\\S-" txt)
2655 (setq o (org-make-overlay (point-at-bol) (point-at-eol)))
2656 (org-overlay-put o 'evaporate t)
2657 (org-overlay-put o 'org-overlay-type 'agenda-entry-content)
2658 (org-overlay-put o 'after-string txt))))
2659
2660 (defun org-agenda-entry-text-show ()
2661 "Add entry context for all agenda lines."
2662 (interactive)
2663 (save-excursion
2664 (goto-char (point-max))
2665 (beginning-of-line 1)
2666 (while (not (bobp))
2667 (when (get-text-property (point) 'org-hd-marker)
2668 (org-agenda-entry-text-show-here))
2669 (beginning-of-line 0))))
2670
2671 (defun org-agenda-entry-text-hide ()
2672 "Remove any shown entry context."
2673 (delq nil
2674 (mapcar (lambda (o)
2675 (if (eq (org-overlay-get o 'org-overlay-type)
2676 'agenda-entry-content)
2677 (progn (org-delete-overlay o) t)))
2678 (org-overlays-in (point-min) (point-max)))))
2554 2679
2555 ;;; Agenda timeline 2680 ;;; Agenda timeline
2556 2681
2557 (defvar org-agenda-only-exact-dates nil) ; dynamically scoped 2682 (defvar org-agenda-only-exact-dates nil) ; dynamically scoped
2558 2683
3113 (and arg (integerp arg) (> arg 0) 3238 (and arg (integerp arg) (> arg 0)
3114 (nth (1- arg) kwds)))) 3239 (nth (1- arg) kwds))))
3115 rtn rtnall files file pos) 3240 rtn rtnall files file pos)
3116 (when (equal arg '(4)) 3241 (when (equal arg '(4))
3117 (setq org-select-this-todo-keyword 3242 (setq org-select-this-todo-keyword
3118 (org-ido-completing-read "Keyword (or KWD1|K2D2|...): " 3243 (org-icompleting-read "Keyword (or KWD1|K2D2|...): "
3119 (mapcar 'list kwds) nil nil))) 3244 (mapcar 'list kwds) nil nil)))
3120 (and (equal 0 arg) (setq org-select-this-todo-keyword nil)) 3245 (and (equal 0 arg) (setq org-select-this-todo-keyword nil))
3121 (org-set-local 'org-last-arg arg) 3246 (org-set-local 'org-last-arg arg)
3122 (setq org-agenda-redo-command 3247 (setq org-agenda-redo-command
3123 '(org-todo-list (or current-prefix-arg org-last-arg))) 3248 '(org-todo-list (or current-prefix-arg org-last-arg)))
3545 &%%(org-diary :deadline :timestamp :sexp :scheduled) 3670 &%%(org-diary :deadline :timestamp :sexp :scheduled)
3546 3671
3547 The function expects the lisp variables `entry' and `date' to be provided 3672 The function expects the lisp variables `entry' and `date' to be provided
3548 by the caller, because this is how the calendar works. Don't use this 3673 by the caller, because this is how the calendar works. Don't use this
3549 function from a program - use `org-agenda-get-day-entries' instead." 3674 function from a program - use `org-agenda-get-day-entries' instead."
3550 (when (> (- (time-to-seconds (current-time)) 3675 (when (> (- (org-float-time)
3551 org-agenda-last-marker-time) 3676 org-agenda-last-marker-time)
3552 5) 3677 5)
3553 (org-agenda-reset-markers)) 3678 (org-agenda-reset-markers))
3554 (org-compile-prefix-format 'agenda) 3679 (org-compile-prefix-format 'agenda)
3555 (org-set-sorting-strategy 'agenda) 3680 (org-set-sorting-strategy 'agenda)
3580 (let* ((org-startup-folded nil) 3705 (let* ((org-startup-folded nil)
3581 (org-startup-align-all-tables nil) 3706 (org-startup-align-all-tables nil)
3582 (buffer (if (file-exists-p file) 3707 (buffer (if (file-exists-p file)
3583 (org-get-agenda-file-buffer file) 3708 (org-get-agenda-file-buffer file)
3584 (error "No such file %s" file))) 3709 (error "No such file %s" file)))
3585 arg results rtn) 3710 arg results rtn deadline-results)
3586 (if (not buffer) 3711 (if (not buffer)
3587 ;; If file does not exist, make sure an error message ends up in diary 3712 ;; If file does not exist, make sure an error message ends up in diary
3588 (list (format "ORG-AGENDA-ERROR: No such org-file %s" file)) 3713 (list (format "ORG-AGENDA-ERROR: No such org-file %s" file))
3589 (with-current-buffer buffer 3714 (with-current-buffer buffer
3590 (unless (org-mode-p) 3715 (unless (org-mode-p)
3610 (setq results (append results rtn))) 3735 (setq results (append results rtn)))
3611 ((eq arg :sexp) 3736 ((eq arg :sexp)
3612 (setq rtn (org-agenda-get-sexps)) 3737 (setq rtn (org-agenda-get-sexps))
3613 (setq results (append results rtn))) 3738 (setq results (append results rtn)))
3614 ((eq arg :scheduled) 3739 ((eq arg :scheduled)
3615 (setq rtn (org-agenda-get-scheduled)) 3740 (setq rtn (org-agenda-get-scheduled deadline-results))
3616 (setq results (append results rtn))) 3741 (setq results (append results rtn)))
3617 ((eq arg :closed) 3742 ((eq arg :closed)
3618 (setq rtn (org-agenda-get-progress)) 3743 (setq rtn (org-agenda-get-progress))
3619 (setq results (append results rtn))) 3744 (setq results (append results rtn)))
3620 ((eq arg :deadline) 3745 ((eq arg :deadline)
3621 (setq rtn (org-agenda-get-deadlines)) 3746 (setq rtn (org-agenda-get-deadlines))
3747 (setq deadline-results (copy-sequence rtn))
3622 (setq results (append results rtn)))))))) 3748 (setq results (append results rtn))))))))
3623 results)))) 3749 results))))
3624 3750
3625 (defun org-agenda-get-todos () 3751 (defun org-agenda-get-todos ()
3626 "Return the TODO information for agenda display." 3752 "Return the TODO information for agenda display."
4019 (let ((faces org-agenda-deadline-faces) f) 4145 (let ((faces org-agenda-deadline-faces) f)
4020 (catch 'exit 4146 (catch 'exit
4021 (while (setq f (pop faces)) 4147 (while (setq f (pop faces))
4022 (if (>= fraction (car f)) (throw 'exit (cdr f))))))) 4148 (if (>= fraction (car f)) (throw 'exit (cdr f)))))))
4023 4149
4024 (defun org-agenda-get-scheduled () 4150 (defun org-agenda-get-scheduled (&optional deadline-results)
4025 "Return the scheduled information for agenda display." 4151 "Return the scheduled information for agenda display."
4026 (let* ((props (list 'org-not-done-regexp org-not-done-regexp 4152 (let* ((props (list 'org-not-done-regexp org-not-done-regexp
4027 'org-todo-regexp org-todo-regexp 4153 'org-todo-regexp org-todo-regexp
4028 'org-complex-heading-regexp org-complex-heading-regexp 4154 'org-complex-heading-regexp org-complex-heading-regexp
4029 'done-face 'org-agenda-done 4155 'done-face 'org-agenda-done
4033 (format "mouse-2 or RET jump to org file %s" 4159 (format "mouse-2 or RET jump to org file %s"
4034 (abbreviate-file-name buffer-file-name)))) 4160 (abbreviate-file-name buffer-file-name))))
4035 (regexp org-scheduled-time-regexp) 4161 (regexp org-scheduled-time-regexp)
4036 (todayp (org-agenda-todayp date)) ; DATE bound by calendar 4162 (todayp (org-agenda-todayp date)) ; DATE bound by calendar
4037 (d1 (calendar-absolute-from-gregorian date)) ; DATE bound by calendar 4163 (d1 (calendar-absolute-from-gregorian date)) ; DATE bound by calendar
4164 mm
4165 (deadline-position-alist
4166 (mapcar (lambda (a) (and (setq mm (get-text-property
4167 0 'org-hd-marker a))
4168 (cons (marker-position mm) a)))
4169 deadline-results))
4038 d2 diff pos pos1 category tags donep 4170 d2 diff pos pos1 category tags donep
4039 ee txt head pastschedp todo-state face timestr s) 4171 ee txt head pastschedp todo-state face timestr s)
4040 (goto-char (point-min)) 4172 (goto-char (point-min))
4041 (while (re-search-forward regexp nil t) 4173 (while (re-search-forward regexp nil t)
4042 (catch :skip 4174 (catch :skip
4065 (setq category (org-get-category)) 4197 (setq category (org-get-category))
4066 (if (not (re-search-backward "^\\*+[ \t]+" nil t)) 4198 (if (not (re-search-backward "^\\*+[ \t]+" nil t))
4067 (setq txt org-agenda-no-heading-message) 4199 (setq txt org-agenda-no-heading-message)
4068 (goto-char (match-end 0)) 4200 (goto-char (match-end 0))
4069 (setq pos1 (match-beginning 0)) 4201 (setq pos1 (match-beginning 0))
4202 (if (and
4203 (or (eq t org-agenda-skip-scheduled-if-deadline-is-shown)
4204 (and org-agenda-skip-scheduled-if-deadline-is-shown
4205 pastschedp))
4206 (setq mm (assoc pos1 deadline-position-alist)))
4207 (throw :skip nil))
4070 (setq tags (org-get-tags-at)) 4208 (setq tags (org-get-tags-at))
4071 (setq head (buffer-substring-no-properties 4209 (setq head (buffer-substring-no-properties
4072 (point) 4210 (point)
4073 (progn (skip-chars-forward "^\r\n") (point)))) 4211 (progn (skip-chars-forward "^\r\n") (point))))
4074 (if (string-match " \\([012]?[0-9]:[0-9][0-9]\\)" s) 4212 (if (string-match " \\([012]?[0-9]:[0-9][0-9]\\)" s)
4271 (or (get-text-property 0 'org-hd-marker txt) 4409 (or (get-text-property 0 'org-hd-marker txt)
4272 (get-text-property 0 'org-marker txt))) 4410 (get-text-property 0 'org-marker txt)))
4273 (error nil))) 4411 (error nil)))
4274 (when effort 4412 (when effort
4275 (setq neffort (org-hh:mm-string-to-minutes effort) 4413 (setq neffort (org-hh:mm-string-to-minutes effort)
4276 effort (setq effort (concat "[" effort"]" ))))) 4414 effort (setq effort (concat "[" effort "]" )))))
4277 4415
4278 (when remove-re 4416 (when remove-re
4279 (while (string-match remove-re txt) 4417 (while (string-match remove-re txt)
4280 (setq txt (replace-match "" t t txt)))) 4418 (setq txt (replace-match "" t t txt))))
4281 4419
4660 (defun org-agenda-quit () 4798 (defun org-agenda-quit ()
4661 "Exit agenda by removing the window or the buffer." 4799 "Exit agenda by removing the window or the buffer."
4662 (interactive) 4800 (interactive)
4663 (if org-agenda-columns-active 4801 (if org-agenda-columns-active
4664 (org-columns-quit) 4802 (org-columns-quit)
4803 (if (window-dedicated-p) (delete-other-windows))
4665 (let ((buf (current-buffer))) 4804 (let ((buf (current-buffer)))
4666 (and (not (eq org-agenda-window-setup 'current-window)) 4805 (and (not (eq org-agenda-window-setup 'current-window))
4667 (not (one-window-p)) 4806 (not (one-window-p))
4668 (delete-window)) 4807 (delete-window))
4669 (kill-buffer buf) 4808 (kill-buffer buf)
4711 org-agenda-pending-undo-list nil) 4850 org-agenda-pending-undo-list nil)
4712 (message "Rebuilding agenda buffer...done") 4851 (message "Rebuilding agenda buffer...done")
4713 (put 'org-agenda-filter :preset-filter preset) 4852 (put 'org-agenda-filter :preset-filter preset)
4714 (and (or filter preset) (org-agenda-filter-apply filter)) 4853 (and (or filter preset) (org-agenda-filter-apply filter))
4715 (and cols (interactive-p) (org-agenda-columns)) 4854 (and cols (interactive-p) (org-agenda-columns))
4716 (goto-line line) 4855 (org-goto-line line)
4717 (recenter window-line))) 4856 (recenter window-line)))
4718 4857
4719 4858
4720 (defvar org-global-tags-completion-table nil) 4859 (defvar org-global-tags-completion-table nil)
4721 (defvar org-agenda-filter-form nil) 4860 (defvar org-agenda-filter-form nil)
4770 (when (equal char ?\t) 4909 (when (equal char ?\t)
4771 (unless (local-variable-p 'org-global-tags-completion-table (current-buffer)) 4910 (unless (local-variable-p 'org-global-tags-completion-table (current-buffer))
4772 (org-set-local 'org-global-tags-completion-table 4911 (org-set-local 'org-global-tags-completion-table
4773 (org-global-tags-completion-table))) 4912 (org-global-tags-completion-table)))
4774 (let ((completion-ignore-case t)) 4913 (let ((completion-ignore-case t))
4775 (setq tag (org-ido-completing-read 4914 (setq tag (org-icompleting-read
4776 "Tag: " org-global-tags-completion-table)))) 4915 "Tag: " org-global-tags-completion-table))))
4777 (cond 4916 (cond
4778 ((equal char ?/) 4917 ((equal char ?/)
4779 (org-agenda-filter-by-tag-show-all) 4918 (org-agenda-filter-by-tag-show-all)
4780 (when (get 'org-agenda-filter :preset-filter) 4919 (when (get 'org-agenda-filter :preset-filter)
4903 (interactive) 5042 (interactive)
4904 (org-agenda-manipulate-query ?\})) 5043 (org-agenda-manipulate-query ?\}))
4905 (defun org-agenda-manipulate-query (char) 5044 (defun org-agenda-manipulate-query (char)
4906 (cond 5045 (cond
4907 ((memq org-agenda-type '(timeline agenda)) 5046 ((memq org-agenda-type '(timeline agenda))
4908 (if (y-or-n-p "Re-display with inactive time stamps included? ") 5047 (let ((org-agenda-include-inactive-timestamps t))
4909 (let ((org-agenda-include-inactive-timestamps t)) 5048 (org-agenda-redo))
4910 (org-agenda-redo)) 5049 (message "Display now includes inactive timestamps as well"))
4911 (error "Abort")))
4912 ((eq org-agenda-type 'search) 5050 ((eq org-agenda-type 'search)
4913 (org-add-to-string 5051 (org-add-to-string
4914 'org-agenda-query-string 5052 'org-agenda-query-string
4915 (cdr (assoc char '((?\[ . " +") (?\] . " -") 5053 (cdr (assoc char '((?\[ . " +") (?\] . " -")
4916 (?\{ . " +{}") (?\} . " -{}"))))) 5054 (?\{ . " +{}") (?\} . " -{}")))))
4997 5135
4998 (defun org-agenda-view-mode-dispatch () 5136 (defun org-agenda-view-mode-dispatch ()
4999 "Call one of the view mode commands." 5137 "Call one of the view mode commands."
5000 (interactive) 5138 (interactive)
5001 (message "View: [d]ay [w]eek [m]onth [y]ear [l]og [L]og-all [a]rch-trees [A]rch-files 5139 (message "View: [d]ay [w]eek [m]onth [y]ear [l]og [L]og-all [a]rch-trees [A]rch-files
5002 clock[R]eport time[G]rid include[D]iary") 5140 clock[R]eport time[G]rid [[]inactive [E]ntryText include[D]iary")
5003 (let ((a (read-char-exclusive))) 5141 (let ((a (read-char-exclusive)))
5004 (case a 5142 (case a
5005 (?d (call-interactively 'org-agenda-day-view)) 5143 (?d (call-interactively 'org-agenda-day-view))
5006 (?w (call-interactively 'org-agenda-week-view)) 5144 (?w (call-interactively 'org-agenda-week-view))
5007 (?m (call-interactively 'org-agenda-month-view)) 5145 (?m (call-interactively 'org-agenda-month-view))
5008 (?y (call-interactively 'org-agenda-year-view)) 5146 (?y (call-interactively 'org-agenda-year-view))
5009 (?l (call-interactively 'org-agenda-log-mode)) 5147 (?l (call-interactively 'org-agenda-log-mode))
5148 ((?F ?f) (call-interactively 'org-agenda-follow-mode))
5010 (?a (call-interactively 'org-agenda-archives-mode)) 5149 (?a (call-interactively 'org-agenda-archives-mode))
5011 (?A (org-agenda-archives-mode 'files)) 5150 (?A (org-agenda-archives-mode 'files))
5012 (?R (call-interactively 'org-agenda-clockreport-mode)) 5151 ((?R ?r) (call-interactively 'org-agenda-clockreport-mode))
5152 ((?E ?e) (call-interactively 'org-agenda-entry-text-mode))
5013 (?G (call-interactively 'org-agenda-toggle-time-grid)) 5153 (?G (call-interactively 'org-agenda-toggle-time-grid))
5014 (?D (call-interactively 'org-agenda-toggle-diary)) 5154 (?D (call-interactively 'org-agenda-toggle-diary))
5155 (?\[ (let ((org-agenda-include-inactive-timestamps t))
5156 (org-agenda-check-type t 'timeline 'agenda)
5157 (org-agenda-redo))
5158 (message "Display now includes inactive timestamps as well"))
5015 (?q (message "Abort")) 5159 (?q (message "Abort"))
5016 (otherwise (error "Invalid key" ))))) 5160 (otherwise (error "Invalid key" )))))
5017 5161
5018 (defun org-agenda-day-view (&optional day-of-year) 5162 (defun org-agenda-day-view (&optional day-of-year)
5019 "Switch to daily view for agenda. 5163 "Switch to daily view for agenda.
5169 (setq org-agenda-follow-mode (not org-agenda-follow-mode)) 5313 (setq org-agenda-follow-mode (not org-agenda-follow-mode))
5170 (org-agenda-set-mode-name) 5314 (org-agenda-set-mode-name)
5171 (message "Follow mode is %s" 5315 (message "Follow mode is %s"
5172 (if org-agenda-follow-mode "on" "off"))) 5316 (if org-agenda-follow-mode "on" "off")))
5173 5317
5318 (defun org-agenda-entry-text-mode (&optional arg)
5319 "Toggle entry text mode in an agenda buffer."
5320 (interactive "P")
5321 (if (integerp arg)
5322 (setq org-agenda-entry-text-mode t)
5323 (setq org-agenda-entry-text-mode (not org-agenda-entry-text-mode)))
5324 (org-agenda-entry-text-hide)
5325 (and org-agenda-entry-text-mode
5326 (let ((org-agenda-entry-text-maxlines
5327 (if (integerp arg) arg org-agenda-entry-text-maxlines)))
5328 (org-agenda-entry-text-show)))
5329 (org-agenda-set-mode-name)
5330 (message "Entry text mode is %s. Maximum number of lines is %d"
5331 (if org-agenda-entry-text-mode "on" "off")
5332 (if (integerp arg) arg org-agenda-entry-text-maxlines)))
5333
5174 (defun org-agenda-clockreport-mode () 5334 (defun org-agenda-clockreport-mode ()
5175 "Toggle clocktable mode in an agenda buffer." 5335 "Toggle clocktable mode in an agenda buffer."
5176 (interactive) 5336 (interactive)
5177 (org-agenda-check-type t 'agenda) 5337 (org-agenda-check-type t 'agenda)
5178 (setq org-agenda-clockreport-mode (not org-agenda-clockreport-mode)) 5338 (setq org-agenda-clockreport-mode (not org-agenda-clockreport-mode))
5242 (setq mode-name 5402 (setq mode-name
5243 (concat "Org-Agenda" 5403 (concat "Org-Agenda"
5244 (if (equal org-agenda-ndays 1) " Day" "") 5404 (if (equal org-agenda-ndays 1) " Day" "")
5245 (if (equal org-agenda-ndays 7) " Week" "") 5405 (if (equal org-agenda-ndays 7) " Week" "")
5246 (if org-agenda-follow-mode " Follow" "") 5406 (if org-agenda-follow-mode " Follow" "")
5407 (if org-agenda-entry-text-mode " ETxt" "")
5247 (if org-agenda-include-diary " Diary" "") 5408 (if org-agenda-include-diary " Diary" "")
5248 (if org-agenda-use-time-grid " Grid" "") 5409 (if org-agenda-use-time-grid " Grid" "")
5249 (if (consp org-agenda-show-log) " LogAll" 5410 (if (consp org-agenda-show-log) " LogAll"
5250 (if org-agenda-show-log " Log" "")) 5411 (if org-agenda-show-log " Log" ""))
5251 (if (or org-agenda-filter (get 'org-agenda-filter 5412 (if (or org-agenda-filter (get 'org-agenda-filter
5409 (beginning-of-line 0)))))) 5570 (beginning-of-line 0))))))
5410 5571
5411 (defun org-agenda-refile (&optional goto rfloc) 5572 (defun org-agenda-refile (&optional goto rfloc)
5412 "Refile the item at point." 5573 "Refile the item at point."
5413 (interactive "P") 5574 (interactive "P")
5575 (if (equal goto '(16))
5576 (org-refile-goto-last-stored)
5577 (let* ((marker (or (get-text-property (point) 'org-hd-marker)
5578 (org-agenda-error)))
5579 (buffer (marker-buffer marker))
5580 (pos (marker-position marker))
5581 (rfloc (or rfloc
5582 (org-refile-get-location
5583 (if goto "Goto: " "Refile to: ") buffer
5584 org-refile-allow-creating-parent-nodes))))
5585 (with-current-buffer buffer
5586 (save-excursion
5587 (save-restriction
5588 (widen)
5589 (goto-char marker)
5590 (org-remove-subtree-entries-from-agenda)
5591 (org-refile goto buffer rfloc)))))))
5592
5593 (defun org-agenda-open-link (&optional arg)
5594 "Follow the link in the current line, if any.
5595 This looks for a link in the displayed lin in the agenda. It also looks
5596 at the text of the entry itself."
5597 (interactive "P")
5414 (let* ((marker (or (get-text-property (point) 'org-hd-marker) 5598 (let* ((marker (or (get-text-property (point) 'org-hd-marker)
5415 (org-agenda-error))) 5599 (get-text-property (point) 'org-marker)))
5416 (buffer (marker-buffer marker)) 5600 (buffer (and marker (marker-buffer marker))))
5417 (pos (marker-position marker)) 5601 (unless buffer (error "Don't know where to look for links"))
5418 (rfloc (or rfloc
5419 (org-refile-get-location
5420 (if goto "Goto: " "Refile to: ") buffer
5421 org-refile-allow-creating-parent-nodes))))
5422 (with-current-buffer buffer 5602 (with-current-buffer buffer
5423 (save-excursion 5603 (save-excursion
5424 (save-restriction 5604 (save-restriction
5425 (widen) 5605 (widen)
5426 (goto-char marker) 5606 (goto-char marker)
5427 (org-remove-subtree-entries-from-agenda) 5607 (org-offer-links-in-entry arg))))))
5428 (org-refile goto buffer rfloc))))))
5429
5430
5431
5432
5433 (defun org-agenda-open-link ()
5434 "Follow the link in the current line, if any."
5435 (interactive)
5436 (org-agenda-copy-local-variable 'org-link-abbrev-alist-local)
5437 (save-excursion
5438 (save-restriction
5439 (narrow-to-region (point-at-bol) (point-at-eol))
5440 (org-open-at-point))))
5441 5608
5442 (defun org-agenda-copy-local-variable (var) 5609 (defun org-agenda-copy-local-variable (var)
5443 "Get a variable from a referenced buffer and install it here." 5610 "Get a variable from a referenced buffer and install it here."
5444 (let ((m (get-text-property (point) 'org-marker))) 5611 (let ((m (get-text-property (point) 'org-marker)))
5445 (when (and m (buffer-live-p (marker-buffer m))) 5612 (when (and m (buffer-live-p (marker-buffer m)))
5485 "Display the Org-mode file which contains the item at point. 5652 "Display the Org-mode file which contains the item at point.
5486 The prefix arg causes further revieling: 5653 The prefix arg causes further revieling:
5487 5654
5488 0 hide the subtree 5655 0 hide the subtree
5489 1 just show the entry according to defaults. 5656 1 just show the entry according to defaults.
5490 2 show the text below the heading 5657 2 show the children view
5491 3 show the entire subtree 5658 3 show the subtree view
5492 4 show the entire subtree and any LOGBOOK drawers 5659 4 show the entire subtree and any LOGBOOK drawers
5493 5 show the entire subtree and any drawers 5660 5 show the entire subtree and any drawers
5494 With prefix argument FULL-ENTRY, make the entire entry visible 5661 With prefix argument FULL-ENTRY, make the entire entry visible
5495 if it was hidden in the outline." 5662 if it was hidden in the outline."
5496 (interactive "p") 5663 (interactive "p")
5498 (org-agenda-goto t) 5665 (org-agenda-goto t)
5499 (org-recenter-heading 1) 5666 (org-recenter-heading 1)
5500 (cond 5667 (cond
5501 ((= more 0) 5668 ((= more 0)
5502 (hide-subtree) 5669 (hide-subtree)
5503 (message "Remote: hide subtree")) 5670 (save-excursion
5671 (org-back-to-heading)
5672 (run-hook-with-args 'org-cycle-hook 'folded))
5673 (message "Remote: FOLDED"))
5504 ((and (interactive-p) (= more 1)) 5674 ((and (interactive-p) (= more 1))
5505 (message "Remote: show with default settings")) 5675 (message "Remote: show with default settings"))
5506 ((= more 2) 5676 ((= more 2)
5507 (show-entry) 5677 (show-entry)
5678 (show-children)
5508 (save-excursion 5679 (save-excursion
5509 (org-back-to-heading) 5680 (org-back-to-heading)
5510 (org-cycle-hide-drawers 'children)) 5681 (run-hook-with-args 'org-cycle-hook 'children))
5511 (message "Remote: show entry")) 5682 (message "Remote: CHILDREN"))
5512 ((= more 3) 5683 ((= more 3)
5513 (show-subtree) 5684 (show-subtree)
5514 (save-excursion 5685 (save-excursion
5515 (org-back-to-heading) 5686 (org-back-to-heading)
5516 (org-cycle-hide-drawers 'subtree)) 5687 (run-hook-with-args 'org-cycle-hook 'subtree))
5517 (message "Remote: show subtree")) 5688 (message "Remote: SUBTREE"))
5518 ((= more 4) 5689 ((= more 4)
5519 (let* ((org-drawers (delete "LOGBOOK" (copy-sequence org-drawers))) 5690 (let* ((org-drawers (delete "LOGBOOK" (copy-sequence org-drawers)))
5520 (org-drawer-regexp 5691 (org-drawer-regexp
5521 (concat "^[ \t]*:\\(" 5692 (concat "^[ \t]*:\\("
5522 (mapconcat 'regexp-quote org-drawers "\\|") 5693 (mapconcat 'regexp-quote org-drawers "\\|")
5523 "\\):[ \t]*$"))) 5694 "\\):[ \t]*$")))
5524 (show-subtree) 5695 (show-subtree)
5525 (save-excursion 5696 (save-excursion
5526 (org-back-to-heading) 5697 (org-back-to-heading)
5527 (org-cycle-hide-drawers 'subtree))) 5698 (org-cycle-hide-drawers 'subtree)))
5528 (message "Remote: show subtree and LOGBOOK")) 5699 (message "Remote: SUBTREE AND LOGBOOK"))
5529 ((> more 4) 5700 ((> more 4)
5530 (show-subtree) 5701 (show-subtree)
5531 (message "Remote: show subtree and LOGBOOK"))) 5702 (message "Remote: SUBTREE AND ALL DRAWERS")))
5532 (select-window win))) 5703 (select-window win)))
5533 5704
5534 (defun org-recenter-heading (n) 5705 (defun org-recenter-heading (n)
5535 (save-excursion 5706 (save-excursion
5536 (org-back-to-heading) 5707 (org-back-to-heading)
5537 (recenter n))) 5708 (recenter n)))
5538 5709
5539 (defvar org-agenda-cycle-counter nil) 5710 (defvar org-agenda-cycle-counter nil)
5540 (defun org-agenda-cycle-show (n) 5711 (defun org-agenda-cycle-show (&optional n)
5541 "Show the current entry in another window, with default settings. 5712 "Show the current entry in another window, with default settings.
5542 Default settings are taken from `org-show-hierarchy-above' and siblings. 5713 Default settings are taken from `org-show-hierarchy-above' and siblings.
5543 When use repeadedly in immediate succession, the remote entry will cycle 5714 When use repeatedly in immediate succession, the remote entry will cycle
5544 through visibility 5715 through visibility
5545 5716
5546 entry -> subtree -> subtree with logbook" 5717 children -> subtree -> folded
5547 (interactive "p") 5718
5548 (when (and (= n 1) 5719 When called with a numeric prefix arg, that arg will be passed through to
5549 (not (eq last-command this-command))) 5720 `org-agenda-show-1'. For the interpretation of that argument, see the
5550 (setq org-agenda-cycle-counter 0)) 5721 docstring of `org-agenda-show-1'."
5551 (setq org-agenda-cycle-counter (1+ org-agenda-cycle-counter)) 5722 (interactive "P")
5552 (if (> org-agenda-cycle-counter 4) 5723 (if (integerp n)
5553 (setq org-agenda-cycle-counter 0)) 5724 (setq org-agenda-cycle-counter n)
5725 (if (not (eq last-command this-command))
5726 (setq org-agenda-cycle-counter 1)
5727 (if (equal org-agenda-cycle-counter 0)
5728 (setq org-agenda-cycle-counter 2)
5729 (setq org-agenda-cycle-counter (1+ org-agenda-cycle-counter))
5730 (if (> org-agenda-cycle-counter 3)
5731 (setq org-agenda-cycle-counter 0)))))
5554 (org-agenda-show-1 org-agenda-cycle-counter)) 5732 (org-agenda-show-1 org-agenda-cycle-counter))
5555 5733
5556 (defun org-agenda-recenter (arg) 5734 (defun org-agenda-recenter (arg)
5557 "Display the Org-mode file which contains the item at point and recenter." 5735 "Display the Org-mode file which contains the item at point and recenter."
5558 (interactive "P") 5736 (interactive "P")
5819 (end-of-line 1) 5997 (end-of-line 1)
5820 (setq newhead (org-get-heading))) 5998 (setq newhead (org-get-heading)))
5821 (org-agenda-change-all-lines newhead hdmarker) 5999 (org-agenda-change-all-lines newhead hdmarker)
5822 (beginning-of-line 1))))) 6000 (beginning-of-line 1)))))
5823 6001
6002 (defun org-agenda-set-property ()
6003 "Set a property for the current headline."
6004 (interactive)
6005 (org-agenda-check-no-diary)
6006 (org-agenda-show) ;;; FIXME This is a stupid hack and should not be needed
6007 (let* ((hdmarker (or (get-text-property (point) 'org-hd-marker)
6008 (org-agenda-error)))
6009 (buffer (marker-buffer hdmarker))
6010 (pos (marker-position hdmarker))
6011 (inhibit-read-only t)
6012 newhead)
6013 (org-with-remote-undo buffer
6014 (with-current-buffer buffer
6015 (widen)
6016 (goto-char pos)
6017 (save-excursion
6018 (org-show-context 'agenda))
6019 (save-excursion
6020 (and (outline-next-heading)
6021 (org-flag-heading nil))) ; show the next heading
6022 (goto-char pos)
6023 (call-interactively 'org-set-property)))))
6024
6025 (defun org-agenda-set-effort ()
6026 "Set the effort property for the current headline."
6027 (interactive)
6028 (org-agenda-check-no-diary)
6029 (org-agenda-show) ;;; FIXME This is a stupid hack and should not be needed
6030 (let* ((hdmarker (or (get-text-property (point) 'org-hd-marker)
6031 (org-agenda-error)))
6032 (buffer (marker-buffer hdmarker))
6033 (pos (marker-position hdmarker))
6034 (inhibit-read-only t)
6035 newhead)
6036 (org-with-remote-undo buffer
6037 (with-current-buffer buffer
6038 (widen)
6039 (goto-char pos)
6040 (save-excursion
6041 (org-show-context 'agenda))
6042 (save-excursion
6043 (and (outline-next-heading)
6044 (org-flag-heading nil))) ; show the next heading
6045 (goto-char pos)
6046 (call-interactively 'org-set-effort)
6047 (end-of-line 1)))))
6048
5824 (defun org-agenda-toggle-archive-tag () 6049 (defun org-agenda-toggle-archive-tag ()
5825 "Toggle the archive tag for the current entry." 6050 "Toggle the archive tag for the current entry."
5826 (interactive) 6051 (interactive)
5827 (org-agenda-check-no-diary) 6052 (org-agenda-check-no-diary)
5828 (org-agenda-show) ;;; FIXME This is a stupid hack and should not be needed 6053 (org-agenda-show) ;;; FIXME This is a stupid hack and should not be needed
6271 ;;; Bulk commands 6496 ;;; Bulk commands
6272 6497
6273 (defvar org-agenda-bulk-marked-entries nil 6498 (defvar org-agenda-bulk-marked-entries nil
6274 "List of markers that refer to marked entries in the agenda.") 6499 "List of markers that refer to marked entries in the agenda.")
6275 6500
6501 (defun org-agenda-bulk-marked-p ()
6502 (eq (get-char-property (point-at-bol) 'type)
6503 'org-marked-entry-overlay))
6504
6276 (defun org-agenda-bulk-mark () 6505 (defun org-agenda-bulk-mark ()
6277 "Mark the entry at point for future bulk action." 6506 "Mark the entry at point for future bulk action."
6278 (interactive) 6507 (interactive)
6279 (org-agenda-check-no-diary) 6508 (org-agenda-check-no-diary)
6280 (let* ((m (get-text-property (point) 'org-hd-marker)) 6509 (let* ((m (get-text-property (point) 'org-hd-marker))
6281 ov) 6510 ov)
6282 (unless (eq (get-char-property (point-at-bol) 'type) 6511 (unless (org-agenda-bulk-marked-p)
6283 'org-marked-entry-overlay)
6284 (unless m (error "Nothing to mark at point")) 6512 (unless m (error "Nothing to mark at point"))
6285 (push m org-agenda-bulk-marked-entries) 6513 (push m org-agenda-bulk-marked-entries)
6286 (setq ov (org-make-overlay (point-at-bol) (+ 2 (point-at-bol)))) 6514 (setq ov (org-make-overlay (point-at-bol) (+ 2 (point-at-bol))))
6287 (org-overlay-display ov ">>" 6515 (org-overlay-display ov ">>"
6288 (org-get-todo-face "TODO") 6516 (org-get-todo-face "TODO")
6293 (length org-agenda-bulk-marked-entries)))) 6521 (length org-agenda-bulk-marked-entries))))
6294 6522
6295 (defun org-agenda-bulk-unmark () 6523 (defun org-agenda-bulk-unmark ()
6296 "Unmark the entry at point for future bulk action." 6524 "Unmark the entry at point for future bulk action."
6297 (interactive) 6525 (interactive)
6298 (when (eq (get-char-property (point-at-bol) 'type) 6526 (when (org-agenda-bulk-marked-p)
6299 'org-marked-entry-overlay)
6300 (org-agenda-bulk-remove-overlays 6527 (org-agenda-bulk-remove-overlays
6301 (point-at-bol) (+ 2 (point-at-bol))) 6528 (point-at-bol) (+ 2 (point-at-bol)))
6302 (setq org-agenda-bulk-marked-entries 6529 (setq org-agenda-bulk-marked-entries
6303 (delete (get-text-property (point-at-bol) 'org-hd-marker) 6530 (delete (get-text-property (point-at-bol) 'org-hd-marker)
6304 org-agenda-bulk-marked-entries))) 6531 org-agenda-bulk-marked-entries)))
6305 (beginning-of-line 2) 6532 (beginning-of-line 2)
6306 (message "%d entries marked for bulk action" 6533 (message "%d entries marked for bulk action"
6307 (length org-agenda-bulk-marked-entries))) 6534 (length org-agenda-bulk-marked-entries)))
6308 6535
6536 (defun org-agenda-bulk-toggle ()
6537 "Toggle marking the entry at point for bulk action."
6538 (interactive)
6539 (if (org-agenda-bulk-marked-p)
6540 (org-agenda-bulk-unmark)
6541 (org-agenda-bulk-mark)))
6309 6542
6310 (defun org-agenda-bulk-remove-overlays (&optional beg end) 6543 (defun org-agenda-bulk-remove-overlays (&optional beg end)
6311 "Remove the mark overlays between BEG and END in the agenda buffer. 6544 "Remove the mark overlays between BEG and END in the agenda buffer.
6312 BEG and END default to the buffer limits. 6545 BEG and END default to the buffer limits.
6313 6546
6355 (error "This should not happen")))) 6588 (error "This should not happen"))))
6356 6589
6357 (setq cmd (list 'org-agenda-refile nil (list 'quote rfloc)))) 6590 (setq cmd (list 'org-agenda-refile nil (list 'quote rfloc))))
6358 6591
6359 ((equal action ?t) 6592 ((equal action ?t)
6360 (setq state (org-ido-completing-read 6593 (setq state (org-icompleting-read
6361 "Todo state: " 6594 "Todo state: "
6362 (with-current-buffer (marker-buffer (car entries)) 6595 (with-current-buffer (marker-buffer (car entries))
6363 (mapcar 'list org-todo-keywords-1)))) 6596 (mapcar 'list org-todo-keywords-1))))
6364 (setq cmd `(let ((org-inhibit-blocking t) 6597 (setq cmd `(let ((org-inhibit-blocking t)
6365 (org-inhibit-logging 'note)) 6598 (org-inhibit-logging 'note))
6366 (org-agenda-todo ,state)))) 6599 (org-agenda-todo ,state))))
6367 6600
6368 ((memq action '(?- ?+)) 6601 ((memq action '(?- ?+))
6369 (setq tag (org-ido-completing-read 6602 (setq tag (org-icompleting-read
6370 (format "Tag to %s: " (if (eq action ?+) "add" "remove")) 6603 (format "Tag to %s: " (if (eq action ?+) "add" "remove"))
6371 (with-current-buffer (marker-buffer (car entries)) 6604 (with-current-buffer (marker-buffer (car entries))
6372 (delq nil 6605 (delq nil
6373 (mapcar (lambda (x) 6606 (mapcar (lambda (x)
6374 (if (stringp (car x)) x)) org-tag-alist))))) 6607 (if (stringp (car x)) x)) org-tag-alist)))))