;;Copyright 2008 Timothy Hobbs, tim.thelion@gmail.com ;; ;; This program is free software: you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by ;; the Free Software Foundation, either version 3 of the License, or ;; (at your option) any later version. ;; ;; This program is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; GNU General Public License for more details. ;; ;; You should have received a copy of the GNU General Public License ;; along with this program. If not, see . (defvar planner-overview-period nil "The period of the current overview.") (make-variable-buffer-local 'planner-overview-period) (defun planner-cycle ( ) "Cycle through different planner modes: Today. Today+insinuated calendar. Next 7 days todo list overview. Todo list overview up until next month." (interactive) (let ((day (nth 3 (decode-time (current-time)))) (month (nth 4 (decode-time (current-time)))) (year (nth 5 (decode-time (current-time))))) (if (eq planner-overview-period 'month) (progn (setq planner-overview-period nil) (planner-goto-today)) (if (eq planner-overview-period 'week) (progn (planner-tasks-overview (concat (int-to-string year) "." (substring (int-to-string (/ (float month) 100)) 2) "." (substring (int-to-string (/ (float day) 100)) 2)) (concat (int-to-string year) "." (substring (int-to-string (/ (float (1+ month)) 100)) 2) "." (substring (int-to-string (/ (float day) 100)) 2))) (switch-to-buffer "*planner tasks overview*") (setq planner-overview-period 'month) (delete-other-windows)) (if (eq major-mode 'calendar-mode) (progn (planner-tasks-overview (concat (int-to-string year) "." (substring (int-to-string (/ (float month) 100)) 2) "." (substring (int-to-string (/ (float day) 100)) 2)) (concat (int-to-string year) "." (substring (int-to-string (/ (float month) 100)) 2) "." (substring (int-to-string (/ (float (+ day 7)) 100)) 2))) (switch-to-buffer "*planner tasks overview*") (setq planner-overview-period 'week) (delete-other-windows)) (if (eq major-mode 'planner-mode) (progn (delete-other-windows) (planner-goto-today) (calendar) (planner-calendar-insinuate)) (planner-goto-today))))))) (provide 'planner-cycle)