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