update to work with latest planner-publish.el
[planner-el.git] / planner-schedule.el
blob2a38133a2c7a220290734e2f05356435cc647606
1 ;;; planner-schedule.el --- Schedule integration for the Emacs Planner
3 ;; Copyright (C) 2001, 2004 Free Software Foundation, Inc.
5 ;; Author: John Wiegley <johnw@gnu.org>
6 ;; Keywords: planner, timeclock
7 ;; URL: http://www.plannerlove.com/
9 ;; This file is free software; you can redistribute it and/or modify
10 ;; it under the terms of the GNU General Public License as published by
11 ;; the Free Software Foundation; either version 2, or (at your option)
12 ;; any later version.
14 ;; This file is distributed in the hope that it will be useful,
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ;; GNU General Public License for more details.
19 ;; You should have received a copy of the GNU General Public License
20 ;; along with GNU Emacs; see the file COPYING. If not, write to the
21 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
22 ;; Boston, MA 02110-1301, USA.
24 ;;; Commentary:
26 ;; This module allows you to project task completion time.
27 ;; Tasks should be of the form
29 ;; #A0 _ 2h Do something
30 ;; #B0 _ 1h30m Do something
31 ;; #B0 _ 2d Do something
32 ;; #B0 _ 2w Do something
33 ;; #B0 _ 10s Do something
35 ;; s: seconds, m: minutes, h: hours, d: days, w: weeks
37 ;; You can find schedule.el in the contrib directory of Planner.
39 ;;; Code:
41 (require 'planner)
42 (require 'schedule)
44 (defun planner-schedule-task-estimate (info)
45 "Return a time estimate for task (INFO) completion, in seconds."
46 (when (string-match "\\`\\s-*\\([0-9]+[smhdw]\\)"
47 (planner-task-description info))
48 (schedule-duration-to-seconds
49 (match-string 1 (planner-task-description info)))))
51 (defun planner-schedule-end-projection ()
52 "Show when today's task load will be finished, according to estimates."
53 (require 'schedule)
54 (schedule-initialize)
55 (save-excursion
56 (let ((now (schedule-completion-time (current-time) 0))
57 spent remaining slippage finish)
58 (goto-char (point-min))
59 (while (re-search-forward "^#[A-C]" nil t)
60 (let* ((task (planner-current-task-info))
61 (estimate (planner-schedule-task-estimate task)))
62 (when estimate
63 (setq now (schedule-completion-time now estimate)))))
64 now)))
66 ;;;###autoload
67 (defun planner-schedule-show-end-project ()
68 "Display the estimated project completion time."
69 (interactive)
70 (message (format-time-string "%c" (planner-schedule-end-projection))))
72 (condition-case nil
73 (let ((map planner-mode-map))
74 (define-key map (kbd "C-c RET") 'planner-schedule-show-end-project)
75 (define-key map "\C-c\C-m" 'planner-schedule-show-end-project)
76 (if (featurep 'xemacs)
77 (define-key map (kbd "C-c C-T C-e")
78 'planner-schedule-show-end-project)
79 (define-key map (kbd "C-c C-S-t C-e")
80 'planner-schedule-show-end-project)))
81 (error (message "Could not bind schedule keys in planner mode")))
83 (provide 'planner-schedule)
85 ;;; planner-schedule.el ends here