aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarsten Dominik2005-12-12 11:47:09 +0000
committerCarsten Dominik2005-12-12 11:47:09 +0000
commit7ac93e3c01ae66d903451cda434bc4c30a76dd19 (patch)
treeca4830f78b4e0b372649cd53e29d6bfecb2250aa
parent7c14546c334fbf613e74e454e1a4ed0b7828a150 (diff)
downloademacs-7ac93e3c01ae66d903451cda434bc4c30a76dd19.tar.gz
emacs-7ac93e3c01ae66d903451cda434bc4c30a76dd19.zip
*** empty log message ***
-rw-r--r--lisp/textmodes/org.el261
1 files changed, 218 insertions, 43 deletions
diff --git a/lisp/textmodes/org.el b/lisp/textmodes/org.el
index 47d6464da19..13a19fab18c 100644
--- a/lisp/textmodes/org.el
+++ b/lisp/textmodes/org.el
@@ -5,7 +5,7 @@
5;; Author: Carsten Dominik <dominik at science dot uva dot nl> 5;; Author: Carsten Dominik <dominik at science dot uva dot nl>
6;; Keywords: outlines, hypermedia, calendar 6;; Keywords: outlines, hypermedia, calendar
7;; Homepage: http://www.astro.uva.nl/~dominik/Tools/org/ 7;; Homepage: http://www.astro.uva.nl/~dominik/Tools/org/
8;; Version: 3.23 8;; Version: 3.24
9;; 9;;
10;; This file is part of GNU Emacs. 10;; This file is part of GNU Emacs.
11;; 11;;
@@ -82,6 +82,10 @@
82;; 82;;
83;; Changes: 83;; Changes:
84;; ------- 84;; -------
85;; Version 3.24
86;; - Switching and item to DONE records a time stamp when the variable
87;; `org-log-done' is turned on. Default is off.
88;;
85;; Version 3.23 89;; Version 3.23
86;; - M-RET makes new items as well as new headings. 90;; - M-RET makes new items as well as new headings.
87;; - Various small bug fixes 91;; - Various small bug fixes
@@ -257,7 +261,7 @@
257 261
258;;; Customization variables 262;;; Customization variables
259 263
260(defvar org-version "3.23" 264(defvar org-version "3.24"
261 "The version number of the file org.el.") 265 "The version number of the file org.el.")
262(defun org-version () 266(defun org-version ()
263 (interactive) 267 (interactive)
@@ -448,6 +452,11 @@ Changes become only effective after restarting Emacs."
448 :group 'org-keywords 452 :group 'org-keywords
449 :type 'string) 453 :type 'string)
450 454
455(defcustom org-closed-string "CLOSED:"
456 "String ued as the prefix for timestamps logging closing a TODO entry."
457 :group 'org-keywords
458 :type 'string)
459
451(defcustom org-comment-string "COMMENT" 460(defcustom org-comment-string "COMMENT"
452 "Entries starting with this keyword will never be exported. 461 "Entries starting with this keyword will never be exported.
453An entry can be toggled between COMMENT and normal with 462An entry can be toggled between COMMENT and normal with
@@ -528,6 +537,7 @@ or contain a special line
528 537
529If the file does not specify a category, then file's base name 538If the file does not specify a category, then file's base name
530is used instead.") 539is used instead.")
540(make-variable-buffer-local 'org-category)
531 541
532(defgroup org-time nil 542(defgroup org-time nil
533 "Options concerning time stamps and deadlines in Org-mode." 543 "Options concerning time stamps and deadlines in Org-mode."
@@ -560,6 +570,13 @@ moved to the new date."
560 :group 'org-time 570 :group 'org-time
561 :type 'boolean) 571 :type 'boolean)
562 572
573(defcustom org-log-done nil
574 "When set, insert a (non-active) time stamp when TODO entry is marked DONE.
575When the state of an entry is changed from nothing to TODO, remove a previous
576closing date."
577 :group 'org-time
578 :type 'boolean)
579
563(defgroup org-agenda nil 580(defgroup org-agenda nil
564 "Options concerning agenda display Org-mode." 581 "Options concerning agenda display Org-mode."
565 :tag "Org Agenda" 582 :tag "Org Agenda"
@@ -1997,6 +2014,7 @@ This variable is set by `org-before-change-function'. `org-table-align'
1997sets it back to nil.") 2014sets it back to nil.")
1998(defvar org-mode-hook nil) 2015(defvar org-mode-hook nil)
1999(defvar org-inhibit-startup nil) ; Dynamically-scoped param. 2016(defvar org-inhibit-startup nil) ; Dynamically-scoped param.
2017(defvar org-agenda-keep-modes nil) ; Dynamically-scoped param.
2000 2018
2001 2019
2002;;;###autoload 2020;;;###autoload
@@ -2022,6 +2040,7 @@ The following commands are available:
2022 (easy-menu-add org-tbl-menu) 2040 (easy-menu-add org-tbl-menu)
2023 (org-install-agenda-files-menu) 2041 (org-install-agenda-files-menu)
2024 (setq outline-regexp "\\*+") 2042 (setq outline-regexp "\\*+")
2043; (setq outline-regexp "\\(?:\\*+\\|[ \t]*\\(?:[-+*]\\|[0-9]+[.)]\\) \\)")
2025 (setq outline-level 'org-outline-level) 2044 (setq outline-level 'org-outline-level)
2026 (if org-startup-truncated (setq truncate-lines t)) 2045 (if org-startup-truncated (setq truncate-lines t))
2027 (org-set-regexps-and-options) 2046 (org-set-regexps-and-options)
@@ -2098,7 +2117,9 @@ The following commands are available:
2098 (cons (length (format-time-string (car org-time-stamp-formats))) 2117 (cons (length (format-time-string (car org-time-stamp-formats)))
2099 (length (format-time-string (cdr org-time-stamp-formats)))) 2118 (length (format-time-string (cdr org-time-stamp-formats))))
2100 "This holds the lengths of the two different time formats.") 2119 "This holds the lengths of the two different time formats.")
2101(defconst org-ts-regexp "<\\([0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\}[^\r\n>]*\\)>" 2120(defconst org-ts-regexp "<\\([0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\}[^\r\n>]*?\\)>"
2121 "Regular expression for fast time stamp matching.")
2122(defconst org-ts-regexp-both "[[<]\\([0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\}[^\r\n>]*?\\)[]>]"
2102 "Regular expression for fast time stamp matching.") 2123 "Regular expression for fast time stamp matching.")
2103(defconst org-ts-regexp1 "\\(\\([0-9]\\{4\\}\\)-\\([0-9]\\{2\\}\\)-\\([0-9]\\{2\\}\\)\\([^0-9>\r\n]*\\)\\(\\([0-9]\\{2\\}\\):\\([0-9]\\{2\\}\\)\\)?\\)" 2124(defconst org-ts-regexp1 "\\(\\([0-9]\\{4\\}\\)-\\([0-9]\\{2\\}\\)-\\([0-9]\\{2\\}\\)\\([^0-9>\r\n]*\\)\\(\\([0-9]\\{2\\}\\):\\([0-9]\\{2\\}\\)\\)?\\)"
2104 "Regular expression matching time strings for analysis.") 2125 "Regular expression matching time strings for analysis.")
@@ -2128,7 +2149,8 @@ The following commands are available:
2128 'keymap org-mouse-map)) 2149 'keymap org-mouse-map))
2129 t))) 2150 t)))
2130 2151
2131(defvar org-camel-regexp "\\*?\\<[A-Z]+[a-z]+[A-Z][a-zA-Z]*\\>") 2152(defvar org-camel-regexp "\\*?\\<[A-Z]+[a-z]+[A-Z][a-zA-Z]*\\>"
2153 "Matches CamelCase words, possibly with a star before it.")
2132(defun org-activate-camels (limit) 2154(defun org-activate-camels (limit)
2133 "Run through the buffer and add overlays to dates." 2155 "Run through the buffer and add overlays to dates."
2134 (if (re-search-forward org-camel-regexp limit t) 2156 (if (re-search-forward org-camel-regexp limit t)
@@ -2165,6 +2187,7 @@ The following commands are available:
2165; (list (concat "\\<" org-scheduled-string) '(0 'org-warning t)) 2187; (list (concat "\\<" org-scheduled-string) '(0 'org-warning t))
2166 (list (concat "\\<" org-deadline-string) '(0 'org-special-keyword t)) 2188 (list (concat "\\<" org-deadline-string) '(0 'org-special-keyword t))
2167 (list (concat "\\<" org-scheduled-string) '(0 'org-special-keyword t)) 2189 (list (concat "\\<" org-scheduled-string) '(0 'org-special-keyword t))
2190 (list (concat "\\<" org-closed-string) '(0 'org-special-keyword t))
2168 ;; '("\\(\\s-\\|^\\)\\(\\*\\([a-zA-Z]+\\)\\*\\)\\([^a-zA-Z*]\\|$\\)" 2191 ;; '("\\(\\s-\\|^\\)\\(\\*\\([a-zA-Z]+\\)\\*\\)\\([^a-zA-Z*]\\|$\\)"
2169 ;; (3 'bold)) 2192 ;; (3 'bold))
2170 ;; '("\\(\\s-\\|^\\)\\(/\\([a-zA-Z]+\\)/\\)\\([^a-zA-Z*]\\|$\\)" 2193 ;; '("\\(\\s-\\|^\\)\\(/\\([a-zA-Z]+\\)/\\)\\([^a-zA-Z*]\\|$\\)"
@@ -3370,6 +3393,11 @@ prefix arg, switch to that state."
3370 (replace-match next t t) 3393 (replace-match next t t)
3371 (setq org-last-todo-state-is-todo 3394 (setq org-last-todo-state-is-todo
3372 (not (equal state org-done-string))) 3395 (not (equal state org-done-string)))
3396 (when org-log-done
3397 (if (equal state org-done-string)
3398 (org-log-done)
3399 (if (not this)
3400 (org-log-done t))))
3373 (run-hooks 'org-after-todo-state-change-hook))) 3401 (run-hooks 'org-after-todo-state-change-hook)))
3374 ;; Fixup cursor location if close to the keyword 3402 ;; Fixup cursor location if close to the keyword
3375 (if (and (outline-on-heading-p) 3403 (if (and (outline-on-heading-p)
@@ -3381,6 +3409,38 @@ prefix arg, switch to that state."
3381 (goto-char (or (match-end 2) (match-end 1))) 3409 (goto-char (or (match-end 2) (match-end 1)))
3382 (just-one-space)))) 3410 (just-one-space))))
3383 3411
3412(defun org-log-done (&optional undone)
3413 "Add a time stamp logging that a TODO entry has been closed.
3414When UNDONE is non-nil, remove such a time stamg again."
3415 (interactive)
3416 (let (beg end col)
3417 (save-excursion
3418 (org-back-to-heading t)
3419 (setq beg (point))
3420 (looking-at (concat outline-regexp " *"))
3421 (goto-char (match-end 0))
3422 (setq col (current-column))
3423 (outline-next-heading)
3424 (setq end (point))
3425 (goto-char beg)
3426 (when (re-search-forward (concat
3427 "[\r\n]\\([ \t]*"
3428 (regexp-quote org-closed-string)
3429 " *\\[.*?\\][^\n\r]*[\n\r]?\\)") end t)
3430 (delete-region (match-beginning 1) (match-end 1)))
3431 (unless undone
3432 (org-back-to-heading t)
3433 (skip-chars-forward "^\n\r")
3434 (goto-char (min (1+ (point)) (point-max)))
3435 (when (not (member (char-before) '(?\r ?\n)))
3436 (insert "\n"))
3437 (indent-to col)
3438 (insert org-closed-string " "
3439 (format-time-string
3440 (concat "[" (substring (cdr org-time-stamp-formats) 1 -1) "]")
3441 (current-time))
3442 "\n")))))
3443
3384(defun org-show-todo-tree (arg) 3444(defun org-show-todo-tree (arg)
3385 "Make a compact tree which shows all headlines marked with TODO. 3445 "Make a compact tree which shows all headlines marked with TODO.
3386The tree will show the lines where the regexp matches, and all higher 3446The tree will show the lines where the regexp matches, and all higher
@@ -3602,7 +3662,9 @@ at the cursor, it will be modified."
3602 "Insert an inactive time stamp. 3662 "Insert an inactive time stamp.
3603An inactive time stamp is enclosed in square brackets instead of angle 3663An inactive time stamp is enclosed in square brackets instead of angle
3604brackets. It is inactive in the sense that it does not trigger agenda entries, 3664brackets. It is inactive in the sense that it does not trigger agenda entries,
3605does not link to the calendar and cannot be changed with the S-cursor keys." 3665does not link to the calendar and cannot be changed with the S-cursor keys.
3666So these are more for recording a certain time/date."
3667 ;; FIXME: Would it be better not to ask for a date/time here?
3606 (interactive "P") 3668 (interactive "P")
3607 (let ((fmt (if arg (cdr org-time-stamp-formats) 3669 (let ((fmt (if arg (cdr org-time-stamp-formats)
3608 (car org-time-stamp-formats))) 3670 (car org-time-stamp-formats)))
@@ -4041,6 +4103,7 @@ If there is already a time stamp at the cursor position, update it."
4041 4103
4042(defvar org-agenda-menu) 4104(defvar org-agenda-menu)
4043(defvar org-agenda-follow-mode nil) 4105(defvar org-agenda-follow-mode nil)
4106(defvar org-agenda-show-log nil)
4044(defvar org-agenda-buffer-name "*Org Agenda*") 4107(defvar org-agenda-buffer-name "*Org Agenda*")
4045(defvar org-agenda-redo-command nil) 4108(defvar org-agenda-redo-command nil)
4046(defvar org-agenda-mode-hook nil) 4109(defvar org-agenda-mode-hook nil)
@@ -4063,7 +4126,9 @@ The following commands are available:
4063 (add-hook 'post-command-hook 'org-agenda-post-command-hook nil 'local) 4126 (add-hook 'post-command-hook 'org-agenda-post-command-hook nil 'local)
4064 (make-local-hook 'pre-command-hook) ; Needed for XEmacs 4127 (make-local-hook 'pre-command-hook) ; Needed for XEmacs
4065 (add-hook 'pre-command-hook 'org-unhighlight nil 'local) 4128 (add-hook 'pre-command-hook 'org-unhighlight nil 'local)
4066 (setq org-agenda-follow-mode nil) 4129 (unless org-agenda-keep-modes
4130 (setq org-agenda-follow-mode nil
4131 org-agenda-show-log nil))
4067 (easy-menu-change 4132 (easy-menu-change
4068 '("Agenda") "Agenda Files" 4133 '("Agenda") "Agenda Files"
4069 (append 4134 (append
@@ -4097,6 +4162,7 @@ The following commands are available:
4097 (int-to-string (pop l)) 'digit-argument))) 4162 (int-to-string (pop l)) 'digit-argument)))
4098 4163
4099(define-key org-agenda-mode-map "f" 'org-agenda-follow-mode) 4164(define-key org-agenda-mode-map "f" 'org-agenda-follow-mode)
4165(define-key org-agenda-mode-map "L" 'org-agenda-log-mode)
4100(define-key org-agenda-mode-map "D" 'org-agenda-toggle-diary) 4166(define-key org-agenda-mode-map "D" 'org-agenda-toggle-diary)
4101(define-key org-agenda-mode-map "g" 'org-agenda-toggle-time-grid) 4167(define-key org-agenda-mode-map "g" 'org-agenda-toggle-time-grid)
4102(define-key org-agenda-mode-map "r" 'org-agenda-redo) 4168(define-key org-agenda-mode-map "r" 'org-agenda-redo)
@@ -4170,6 +4236,8 @@ The following commands are available:
4170 ["Week View" org-agenda-week-view :active (local-variable-p 'starting-day) 4236 ["Week View" org-agenda-week-view :active (local-variable-p 'starting-day)
4171 :style radio :selected (equal org-agenda-ndays 7)] 4237 :style radio :selected (equal org-agenda-ndays 7)]
4172 "--" 4238 "--"
4239 ["Show Logbook entries" org-agenda-log-mode
4240 :style toggle :selected org-agenda-show-log :active t]
4173 ["Include Diary" org-agenda-toggle-diary 4241 ["Include Diary" org-agenda-toggle-diary
4174 :style toggle :selected org-agenda-include-diary :active t] 4242 :style toggle :selected org-agenda-include-diary :active t]
4175 ["Use Time Grid" org-agenda-toggle-time-grid 4243 ["Use Time Grid" org-agenda-toggle-time-grid
@@ -4240,7 +4308,7 @@ When a buffer is unmodified, it is just killed. When modified, it is saved
4240 4308
4241(defvar org-respect-restriction nil) ; Dynamically-scoped param. 4309(defvar org-respect-restriction nil) ; Dynamically-scoped param.
4242 4310
4243(defun org-timeline (&optional include-all) 4311(defun org-timeline (&optional include-all keep-modes)
4244 "Show a time-sorted view of the entries in the current org file. 4312 "Show a time-sorted view of the entries in the current org file.
4245Only entries with a time stamp of today or later will be listed. With 4313Only entries with a time stamp of today or later will be listed. With
4246one \\[universal-argument] prefix argument, past entries will also be listed. 4314one \\[universal-argument] prefix argument, past entries will also be listed.
@@ -4252,8 +4320,10 @@ dates."
4252 (require 'calendar) 4320 (require 'calendar)
4253 (org-agenda-maybe-reset-markers 'force) 4321 (org-agenda-maybe-reset-markers 'force)
4254 (org-compile-prefix-format org-timeline-prefix-format) 4322 (org-compile-prefix-format org-timeline-prefix-format)
4255 (let* ((dopast include-all) 4323 (let* ((dopast (or include-all org-agenda-show-log))
4256 (dotodo (equal include-all '(16))) 4324 (dotodo (member include-all '((16))))
4325 (doclosed org-agenda-show-log)
4326 (org-agenda-keep-modes keep-modes)
4257 (entry (buffer-file-name)) 4327 (entry (buffer-file-name))
4258 (org-agenda-files (list (buffer-file-name))) 4328 (org-agenda-files (list (buffer-file-name)))
4259 (date (calendar-current-date)) 4329 (date (calendar-current-date))
@@ -4262,15 +4332,16 @@ dates."
4262 (beg (if (org-region-active-p) (region-beginning) (point-min))) 4332 (beg (if (org-region-active-p) (region-beginning) (point-min)))
4263 (end (if (org-region-active-p) (region-end) (point-max))) 4333 (end (if (org-region-active-p) (region-end) (point-max)))
4264 (day-numbers (org-get-all-dates beg end 'no-ranges 4334 (day-numbers (org-get-all-dates beg end 'no-ranges
4265 t)) ; always include today 4335 t doclosed)) ; always include today
4266 (today (time-to-days (current-time))) 4336 (today (time-to-days (current-time)))
4267 (org-respect-restriction t) 4337 (org-respect-restriction t)
4268 (past t) 4338 (past t)
4339 args
4269 s e rtn d) 4340 s e rtn d)
4270 (setq org-agenda-redo-command 4341 (setq org-agenda-redo-command
4271 (list 'progn 4342 (list 'progn
4272 (list 'switch-to-buffer-other-window (current-buffer)) 4343 (list 'switch-to-buffer-other-window (current-buffer))
4273 (list 'org-timeline (list 'quote include-all)))) 4344 (list 'org-timeline (list 'quote include-all) t)))
4274 (if (not dopast) 4345 (if (not dopast)
4275 ;; Remove past dates from the list of dates. 4346 ;; Remove past dates from the list of dates.
4276 (setq day-numbers (delq nil (mapcar (lambda(x) 4347 (setq day-numbers (delq nil (mapcar (lambda(x)
@@ -4281,6 +4352,9 @@ dates."
4281 (setq buffer-read-only nil) 4352 (setq buffer-read-only nil)
4282 (erase-buffer) 4353 (erase-buffer)
4283 (org-agenda-mode) (setq buffer-read-only nil) 4354 (org-agenda-mode) (setq buffer-read-only nil)
4355 (if doclosed (push :closed args))
4356 (push :timestamp args)
4357 (if dotodo (push :todo args))
4284 (while (setq d (pop day-numbers)) 4358 (while (setq d (pop day-numbers))
4285 (if (and (>= d today) 4359 (if (and (>= d today)
4286 dopast 4360 dopast
@@ -4290,10 +4364,8 @@ dates."
4290 (insert (make-string 79 ?-) "\n"))) 4364 (insert (make-string 79 ?-) "\n")))
4291 (setq date (calendar-gregorian-from-absolute d)) 4365 (setq date (calendar-gregorian-from-absolute d))
4292 (setq s (point)) 4366 (setq s (point))
4293 (if dotodo 4367 (setq rtn (apply 'org-agenda-get-day-entries
4294 (setq rtn (org-agenda-get-day-entries 4368 entry date args))
4295 entry date :todo :timestamp))
4296 (setq rtn (org-agenda-get-day-entries entry date :timestamp)))
4297 (if (or rtn (equal d today)) 4369 (if (or rtn (equal d today))
4298 (progn 4370 (progn
4299 (insert (calendar-day-name date) " " 4371 (insert (calendar-day-name date) " "
@@ -4315,12 +4387,15 @@ dates."
4315 (goto-char pos1)))) 4387 (goto-char pos1))))
4316 4388
4317;;;###autoload 4389;;;###autoload
4318(defun org-agenda (&optional include-all start-day ndays) 4390(defun org-agenda (&optional include-all start-day ndays keep-modes)
4319 "Produce a weekly view from all files in variable `org-agenda-files'. 4391 "Produce a weekly view from all files in variable `org-agenda-files'.
4320The view will be for the current week, but from the overview buffer you 4392The view will be for the current week, but from the overview buffer you
4321will be able to go to other weeks. 4393will be able to go to other weeks.
4322With one \\[universal-argument] prefix argument INCLUDE-ALL, all unfinished TODO items will 4394With one \\[universal-argument] prefix argument INCLUDE-ALL, all unfinished TODO items will
4323also be shown, under the current date. 4395also be shown, under the current date.
4396With two \\[universal-argument] prefix argument INCLUDE-ALL, all TODO entries marked DONE
4397on the days are also shown. See the variable `org-log-done' for how
4398to turn on logging.
4324START-DAY defaults to TODAY, or to the most recent match for the weekday 4399START-DAY defaults to TODAY, or to the most recent match for the weekday
4325given in `org-agenda-start-on-weekday'. 4400given in `org-agenda-start-on-weekday'.
4326NDAYS defaults to `org-agenda-ndays'." 4401NDAYS defaults to `org-agenda-ndays'."
@@ -4332,6 +4407,7 @@ NDAYS defaults to `org-agenda-ndays'."
4332 (if (or (equal ndays 1) 4407 (if (or (equal ndays 1)
4333 (and (null ndays) (equal 1 org-agenda-ndays))) 4408 (and (null ndays) (equal 1 org-agenda-ndays)))
4334 nil org-agenda-start-on-weekday)) 4409 nil org-agenda-start-on-weekday))
4410 (org-agenda-keep-modes keep-modes)
4335 (files (copy-sequence org-agenda-files)) 4411 (files (copy-sequence org-agenda-files))
4336 (win (selected-window)) 4412 (win (selected-window))
4337 (today (time-to-days (current-time))) 4413 (today (time-to-days (current-time)))
@@ -4348,7 +4424,7 @@ NDAYS defaults to `org-agenda-ndays'."
4348 (inhibit-redisplay t) 4424 (inhibit-redisplay t)
4349 s e rtn rtnall file date d start-pos end-pos todayp nd) 4425 s e rtn rtnall file date d start-pos end-pos todayp nd)
4350 (setq org-agenda-redo-command 4426 (setq org-agenda-redo-command
4351 (list 'org-agenda (list 'quote include-all) start-day ndays)) 4427 (list 'org-agenda (list 'quote include-all) start-day ndays t))
4352 ;; Make the list of days 4428 ;; Make the list of days
4353 (setq ndays (or ndays org-agenda-ndays) 4429 (setq ndays (or ndays org-agenda-ndays)
4354 nd ndays) 4430 nd ndays)
@@ -4395,7 +4471,13 @@ NDAYS defaults to `org-agenda-ndays'."
4395 (while (setq file (pop files)) 4471 (while (setq file (pop files))
4396 (catch 'nextfile 4472 (catch 'nextfile
4397 (org-check-agenda-file file) 4473 (org-check-agenda-file file)
4398 (setq rtn (org-agenda-get-day-entries file date)) 4474 (if org-agenda-show-log
4475 (setq rtn (org-agenda-get-day-entries
4476 file date
4477 :deadline :scheduled :timestamp :closed))
4478 (setq rtn (org-agenda-get-day-entries
4479 file date
4480 :deadline :scheduled :timestamp)))
4399 (setq rtnall (append rtnall rtn)))) 4481 (setq rtnall (append rtnall rtn))))
4400 (if org-agenda-include-diary 4482 (if org-agenda-include-diary
4401 (progn 4483 (progn
@@ -4437,7 +4519,7 @@ NDAYS defaults to `org-agenda-ndays'."
4437(defvar org-select-this-todo-keyword nil) 4519(defvar org-select-this-todo-keyword nil)
4438 4520
4439;;;###autoload 4521;;;###autoload
4440(defun org-todo-list (arg) 4522(defun org-todo-list (arg &optional keep-modes)
4441 "Show all TODO entries from all agenda file in a single list. 4523 "Show all TODO entries from all agenda file in a single list.
4442The prefix arg can be used to select a specific TODO keyword and limit 4524The prefix arg can be used to select a specific TODO keyword and limit
4443the list to these. When using \\[universal-argument], you will be prompted 4525the list to these. When using \\[universal-argument], you will be prompted
@@ -4446,7 +4528,8 @@ for a keyword. A numeric prefix directly selects the Nth keyword in
4446 (interactive "P") 4528 (interactive "P")
4447 (org-agenda-maybe-reset-markers 'force) 4529 (org-agenda-maybe-reset-markers 'force)
4448 (org-compile-prefix-format org-agenda-prefix-format) 4530 (org-compile-prefix-format org-agenda-prefix-format)
4449 (let* ((today (time-to-days (current-time))) 4531 (let* ((org-agenda-keep-modes keep-modes)
4532 (today (time-to-days (current-time)))
4450 (date (calendar-gregorian-from-absolute today)) 4533 (date (calendar-gregorian-from-absolute today))
4451 (win (selected-window)) 4534 (win (selected-window))
4452 (kwds org-todo-keywords) 4535 (kwds org-todo-keywords)
@@ -4470,7 +4553,7 @@ for a keyword. A numeric prefix directly selects the Nth keyword in
4470 (set (make-local-variable 'last-arg) arg) 4553 (set (make-local-variable 'last-arg) arg)
4471 (set (make-local-variable 'org-todo-keywords) kwds) 4554 (set (make-local-variable 'org-todo-keywords) kwds)
4472 (set (make-local-variable 'org-agenda-redo-command) 4555 (set (make-local-variable 'org-agenda-redo-command)
4473 '(org-todo-list (or current-prefix-arg last-arg))) 4556 '(org-todo-list (or current-prefix-arg last-arg) t))
4474 (setq files org-agenda-files 4557 (setq files org-agenda-files
4475 rtnall nil) 4558 rtnall nil)
4476 (while (setq file (pop files)) 4559 (while (setq file (pop files))
@@ -4484,6 +4567,15 @@ for a keyword. A numeric prefix directly selects the Nth keyword in
4484 (setq pos (point)) 4567 (setq pos (point))
4485 (insert (or org-select-this-todo-keyword "ALL") "\n") 4568 (insert (or org-select-this-todo-keyword "ALL") "\n")
4486 (add-text-properties pos (1- (point)) (list 'face 'org-warning)) 4569 (add-text-properties pos (1- (point)) (list 'face 'org-warning))
4570 (setq pos (point))
4571 (insert
4572 "Available with `N r': (0)ALL "
4573 (let ((n 0))
4574 (mapconcat (lambda (x)
4575 (format "(%d)%s" (setq n (1+ n)) x))
4576 org-todo-keywords " "))
4577 "\n")
4578 (add-text-properties pos (1- (point)) (list 'face 'org-link))
4487 (when rtnall 4579 (when rtnall
4488 (insert (org-finalize-agenda-entries rtnall) "\n")) 4580 (insert (org-finalize-agenda-entries rtnall) "\n"))
4489 (goto-char (point-min)) 4581 (goto-char (point-min))
@@ -4536,8 +4628,9 @@ When this is the global TODO list, a prefix argument will be interpreted."
4536 (if (boundp 'starting-day) 4628 (if (boundp 'starting-day)
4537 (let ((cmd (car org-agenda-redo-command)) 4629 (let ((cmd (car org-agenda-redo-command))
4538 (iall (nth 1 org-agenda-redo-command)) 4630 (iall (nth 1 org-agenda-redo-command))
4539 (nday (nth 3 org-agenda-redo-command))) 4631 (nday (nth 3 org-agenda-redo-command))
4540 (eval (list cmd iall nil nday))) 4632 (keep (nth 4 org-agenda-redo-command)))
4633 (eval (list cmd iall nil nday keep)))
4541 (goto-char (or (text-property-any (point-min) (point-max) 'org-today t) 4634 (goto-char (or (text-property-any (point-min) (point-max) 'org-today t)
4542 (point-min))))) 4635 (point-min)))))
4543 4636
@@ -4548,7 +4641,7 @@ With prefix ARG, go forward that many times `org-agenda-ndays'."
4548 (unless (boundp 'starting-day) 4641 (unless (boundp 'starting-day)
4549 (error "Not allowed")) 4642 (error "Not allowed"))
4550 (org-agenda (if (boundp 'include-all-loc) include-all-loc nil) 4643 (org-agenda (if (boundp 'include-all-loc) include-all-loc nil)
4551 (+ starting-day (* arg org-agenda-ndays)))) 4644 (+ starting-day (* arg org-agenda-ndays)) nil t))
4552 4645
4553(defun org-agenda-earlier (arg) 4646(defun org-agenda-earlier (arg)
4554 "Go back in time by `org-agenda-ndays' days. 4647 "Go back in time by `org-agenda-ndays' days.
@@ -4557,7 +4650,7 @@ With prefix ARG, go back that many times `org-agenda-ndays'."
4557 (unless (boundp 'starting-day) 4650 (unless (boundp 'starting-day)
4558 (error "Not allowed")) 4651 (error "Not allowed"))
4559 (org-agenda (if (boundp 'include-all-loc) include-all-loc nil) 4652 (org-agenda (if (boundp 'include-all-loc) include-all-loc nil)
4560 (- starting-day (* arg org-agenda-ndays)))) 4653 (- starting-day (* arg org-agenda-ndays)) nil t))
4561 4654
4562(defun org-agenda-week-view () 4655(defun org-agenda-week-view ()
4563 "Switch to weekly view for agenda." 4656 "Switch to weekly view for agenda."
@@ -4567,7 +4660,8 @@ With prefix ARG, go back that many times `org-agenda-ndays'."
4567 (setq org-agenda-ndays 7) 4660 (setq org-agenda-ndays 7)
4568 (org-agenda include-all-loc 4661 (org-agenda include-all-loc
4569 (or (get-text-property (point) 'day) 4662 (or (get-text-property (point) 'day)
4570 starting-day)) 4663 starting-day)
4664 nil t)
4571 (org-agenda-set-mode-name) 4665 (org-agenda-set-mode-name)
4572 (message "Switched to week view")) 4666 (message "Switched to week view"))
4573 4667
@@ -4579,7 +4673,8 @@ With prefix ARG, go back that many times `org-agenda-ndays'."
4579 (setq org-agenda-ndays 1) 4673 (setq org-agenda-ndays 1)
4580 (org-agenda include-all-loc 4674 (org-agenda include-all-loc
4581 (or (get-text-property (point) 'day) 4675 (or (get-text-property (point) 'day)
4582 starting-day)) 4676 starting-day)
4677 nil t)
4583 (org-agenda-set-mode-name) 4678 (org-agenda-set-mode-name)
4584 (message "Switched to day view")) 4679 (message "Switched to day view"))
4585 4680
@@ -4624,6 +4719,15 @@ With prefix ARG, go back that many times `org-agenda-ndays'."
4624 (message "Follow mode is %s" 4719 (message "Follow mode is %s"
4625 (if org-agenda-follow-mode "on" "off"))) 4720 (if org-agenda-follow-mode "on" "off")))
4626 4721
4722(defun org-agenda-log-mode ()
4723 "Toggle follow mode in an agenda buffer."
4724 (interactive)
4725 (setq org-agenda-show-log (not org-agenda-show-log))
4726 (org-agenda-set-mode-name)
4727 (org-agenda-redo)
4728 (message "Log mode is %s"
4729 (if org-agenda-show-log "on" "off")))
4730
4627(defun org-agenda-toggle-diary () 4731(defun org-agenda-toggle-diary ()
4628 "Toggle follow mode in an agenda buffer." 4732 "Toggle follow mode in an agenda buffer."
4629 (interactive) 4733 (interactive)
@@ -4650,7 +4754,8 @@ With prefix ARG, go back that many times `org-agenda-ndays'."
4650 (if (equal org-agenda-ndays 7) " Week" "") 4754 (if (equal org-agenda-ndays 7) " Week" "")
4651 (if org-agenda-follow-mode " Follow" "") 4755 (if org-agenda-follow-mode " Follow" "")
4652 (if org-agenda-include-diary " Diary" "") 4756 (if org-agenda-include-diary " Diary" "")
4653 (if org-agenda-use-time-grid " Grid" ""))) 4757 (if org-agenda-use-time-grid " Grid" "")
4758 (if org-agenda-show-log " Log" "")))
4654 (force-mode-line-update)) 4759 (force-mode-line-update))
4655 4760
4656(defun org-agenda-post-command-hook () 4761(defun org-agenda-post-command-hook ()
@@ -4838,17 +4943,19 @@ Optional argument FILE means, use this file instead of the current."
4838;; org-agenda-new-buffers, so that the buffer will not be removed 4943;; org-agenda-new-buffers, so that the buffer will not be removed
4839;; when exiting the agenda???? 4944;; when exiting the agenda????
4840 4945
4841(defun org-get-all-dates (beg end &optional no-ranges force-today) 4946(defun org-get-all-dates (beg end &optional no-ranges force-today inactive)
4842 "Return a list of all relevant day numbers from BEG to END buffer positions. 4947 "Return a list of all relevant day numbers from BEG to END buffer positions.
4843If NO-RANGES is non-nil, include only the start and end dates of a range, 4948If NO-RANGES is non-nil, include only the start and end dates of a range,
4844not every single day in the range. If FORCE-TODAY is non-nil, make 4949not every single day in the range. If FORCE-TODAY is non-nil, make
4845sure that TODAY is included in the list." 4950sure that TODAY is included in the list. If INACTIVE is non-nil, also
4846 (let (dates date day day1 day2 ts1 ts2) 4951inactive time stamps (those in square brackets) are included."
4952 (let ((re (if inactive org-ts-regexp-both org-ts-regexp))
4953 dates date day day1 day2 ts1 ts2)
4847 (if force-today 4954 (if force-today
4848 (setq dates (list (time-to-days (current-time))))) 4955 (setq dates (list (time-to-days (current-time)))))
4849 (save-excursion 4956 (save-excursion
4850 (goto-char beg) 4957 (goto-char beg)
4851 (while (re-search-forward org-ts-regexp end t) 4958 (while (re-search-forward re end t)
4852 (setq day (time-to-days (org-time-string-to-time 4959 (setq day (time-to-days (org-time-string-to-time
4853 (substring (match-string 1) 0 10)))) 4960 (substring (match-string 1) 0 10))))
4854 (or (memq day dates) (push day dates))) 4961 (or (memq day dates) (push day dates)))
@@ -4931,16 +5038,24 @@ function from a program - use `org-agenda-get-day-entries' instead."
4931 (while (re-search-forward "\\(^\\|\r\\)#\\+CATEGORY:[ \t]*\\(.*\\)" nil t) 5038 (while (re-search-forward "\\(^\\|\r\\)#\\+CATEGORY:[ \t]*\\(.*\\)" nil t)
4932 (push (cons (point) (org-trim (match-string 2))) tbl))) 5039 (push (cons (point) (org-trim (match-string 2))) tbl)))
4933 tbl)) 5040 tbl))
4934 (defun org-get-category (&optional pos) 5041(defun org-get-category (&optional pos)
4935 "Get the category applying to position POS." 5042 "Get the category applying to position POS."
4936 (if (not org-category-table) 5043 (if (not org-category-table)
4937 org-category 5044 (cond
4938 (let ((tbl org-category-table) 5045 ((null org-category)
4939 (pos (or pos (point)))) 5046 (setq org-category
4940 (while (and tbl (> (caar tbl) pos)) 5047 (if (buffer-file-name)
4941 (pop tbl)) 5048 (file-name-sans-extension
4942 (or (cdar tbl) (cdr (nth (1- (length org-category-table)) 5049 (file-name-nondirectory (buffer-file-name)))
4943 org-category-table)))))) 5050 "???")))
5051 ((symbolp org-category) (symbol-name org-category))
5052 (t org-category))
5053 (let ((tbl org-category-table)
5054 (pos (or pos (point))))
5055 (while (and tbl (> (caar tbl) pos))
5056 (pop tbl))
5057 (or (cdar tbl) (cdr (nth (1- (length org-category-table))
5058 org-category-table))))))
4944 5059
4945(defun org-agenda-get-day-entries (file date &rest args) 5060(defun org-agenda-get-day-entries (file date &rest args)
4946 "Does the work for `org-diary' and `org-agenda'. 5061 "Does the work for `org-diary' and `org-agenda'.
@@ -4987,6 +5102,9 @@ the documentation of `org-diary'."
4987 ((eq arg :scheduled) 5102 ((eq arg :scheduled)
4988 (setq rtn (org-agenda-get-scheduled)) 5103 (setq rtn (org-agenda-get-scheduled))
4989 (setq results (append results rtn))) 5104 (setq results (append results rtn)))
5105 ((eq arg :closed)
5106 (setq rtn (org-agenda-get-closed))
5107 (setq results (append results rtn)))
4990 ((and (eq arg :deadline) 5108 ((and (eq arg :deadline)
4991 (equal date (calendar-current-date))) 5109 (equal date (calendar-current-date)))
4992 (setq rtn (org-agenda-get-deadlines)) 5110 (setq rtn (org-agenda-get-deadlines))
@@ -5117,6 +5235,7 @@ the documentation of `org-diary'."
5117 (if donep 'org-done 'org-warning) 5235 (if donep 'org-done 'org-warning)
5118 'undone-face 'org-warning 5236 'undone-face 'org-warning
5119 'done-face 'org-done 5237 'done-face 'org-done
5238 'category category
5120 'priority (+ 100 priority)) 5239 'priority (+ 100 priority))
5121 txt) 5240 txt)
5122 (if scheduledp 5241 (if scheduledp
@@ -5125,6 +5244,7 @@ the documentation of `org-diary'."
5125 (list 'face 'org-scheduled-today 5244 (list 'face 'org-scheduled-today
5126 'undone-face 'org-scheduled-today 5245 'undone-face 'org-scheduled-today
5127 'done-face 'org-done 5246 'done-face 'org-done
5247 'category category
5128 priority (+ 99 priority)) 5248 priority (+ 99 priority))
5129 txt) 5249 txt)
5130 (add-text-properties 5250 (add-text-properties
@@ -5134,6 +5254,59 @@ the documentation of `org-diary'."
5134 (outline-next-heading)))) 5254 (outline-next-heading))))
5135 (nreverse ee))) 5255 (nreverse ee)))
5136 5256
5257(defun org-agenda-get-closed ()
5258 "Return the loggedd TODO entries for agenda display."
5259 (let* ((props (list 'mouse-face 'highlight
5260 'keymap org-agenda-keymap
5261 'help-echo
5262 (format "mouse-2 or RET jump to org file %s"
5263 (abbreviate-file-name (buffer-file-name)))))
5264 (regexp (concat
5265 "\\<" org-closed-string " *\\["
5266 (regexp-quote
5267 (substring
5268 (format-time-string
5269 (car org-time-stamp-formats)
5270 (apply 'encode-time ; DATE bound by calendar
5271 (list 0 0 0 (nth 1 date) (car date) (nth 2 date))))
5272 1 11))))
5273 marker hdmarker deadlinep scheduledp donep tmp priority category
5274 ee txt timestr)
5275 (goto-char (point-min))
5276 (while (re-search-forward regexp nil t)
5277 (if (not (save-match-data (org-at-date-range-p)))
5278 (progn
5279 (setq marker (org-agenda-new-marker (match-beginning 0))
5280 category (org-get-category (match-beginning 0))
5281 timestr (buffer-substring (match-beginning 0) (point-at-eol))
5282 donep (org-entry-is-done-p))
5283 (if (string-match "\\]" timestr)
5284 ;; substring should only run to end of time stamp
5285 (setq timestr (substring timestr 0 (match-end 0))))
5286 (save-excursion
5287 (if (re-search-backward "\\(^\\|\r\\)\\*+" nil t)
5288 (progn
5289 (goto-char (match-end 1))
5290 (setq hdmarker (org-agenda-new-marker))
5291 (looking-at "\\*+[ \t]*\\([^\r\n]+\\)")
5292 (setq txt (org-format-agenda-item
5293 "Closed: "
5294 (match-string 1) category timestr)))
5295 (setq txt org-agenda-no-heading-message))
5296 (setq priority 100000)
5297 (add-text-properties
5298 0 (length txt) (append (list 'org-marker marker
5299 'org-hd-marker hdmarker
5300 'face 'org-done
5301 'priority priority
5302 'category category
5303 'undone-face 'org-warning
5304 'done-face 'org-done) props)
5305 txt)
5306 (push txt ee))
5307 (outline-next-heading))))
5308 (nreverse ee)))
5309
5137(defun org-agenda-get-deadlines () 5310(defun org-agenda-get-deadlines ()
5138 "Return the deadline information for agenda display." 5311 "Return the deadline information for agenda display."
5139 (let* ((wdays org-deadline-warning-days) 5312 (let* ((wdays org-deadline-warning-days)
@@ -5850,7 +6023,8 @@ argument, latitude and longitude will be prompted for."
5850This is a command that has to be installed in `calendar-mode-map'." 6023This is a command that has to be installed in `calendar-mode-map'."
5851 (interactive) 6024 (interactive)
5852 (org-agenda nil (calendar-absolute-from-gregorian 6025 (org-agenda nil (calendar-absolute-from-gregorian
5853 (calendar-cursor-to-date)))) 6026 (calendar-cursor-to-date))
6027 nil t))
5854 6028
5855(defun org-agenda-convert-date () 6029(defun org-agenda-convert-date ()
5856 (interactive) 6030 (interactive)
@@ -11435,3 +11609,4 @@ Show the heading too, if it is currently invisible."
11435;; arch-tag: e77da1a7-acc7-4336-b19e-efa25af3f9fd 11609;; arch-tag: e77da1a7-acc7-4336-b19e-efa25af3f9fd
11436;;; org.el ends here 11610;;; org.el ends here
11437 11611
11612