emacs-wiki-discuss
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[emacs-wiki-discuss] Graphical week view of tasks Re: Thinking about pla


From: Sacha Chua
Subject: [emacs-wiki-discuss] Graphical week view of tasks Re: Thinking about planning
Date: Sun, 02 Oct 2005 02:22:33 -0400
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/21.3.50 (gnu/linux)

Sacha Chua <address@hidden> writes:

> *** Weekly planning
> The main reason I have a paper planner (8.5" x 11": weekly calendar +
> todo list + notes) is have that week-at-a-glance view. I like iCal's
> interface for planning tasks on a weekly basis, but I'm not entirely
> sure how to map that onto Emacs, and I like my daily notes and my
> day-view task list.

I am pleased to announce that in the process of procrastinating my
weekly reflection, I've managed to come up with a weekly view of
tasks. Check out the bottom of
http://sacha.free.net.ph/notebook/wiki/2005.10.02.php .

Warning! Probably only works on my browser - Mozilla Firefox. Anyway,
it's a cute little weekly calendar that shows my tasks. There's
probably a much better way to do that, involving perhaps routing it
through diary and deskcal and a few other things. Suggestions would be
very much appreciated, as I'm no expert on CSS.

;; Totally idiosyncratic way to display scheduled tasks on a weekly calendar
;; Example: http://sacha.free.net.ph/notebook/wiki/2005.10.02.php

;; Assembles weekly calendar through clever use of CSS and absolute
;; positioning inside relative-positioned blocks. Tasks should look like
;; #A _ @0800-1300 Something with time
;; #A _ @0800-1300 Q1 Something with Covey quadrants, too!

;; Code quirks: Calls planner-backend-output-file, which is something
;; like muse-output-file in planner-muse and emacs-wiki-published-file
;; in emacs-wiki. If you're not using planner--duo or planner--merge,
;; tweak this...

;; Add this to your CSS:
;; .week_calendar TD A { display: block; position: absolute; width: 100%; 
overflow: hidden }
;; .week_calendar .timed TD { position: relative; height: 375px; width: 100px }
;; .week_calendar TD { width: 100px; }
;; .week_calendar TD DIV { position: relative }
;; .week_calendar LI { overflow: hidden; }
;; .q1 { background-color: red }
;; .q2 { background-color: yellow }
;; .unknown { background-color: gray }

;; Add this to a planner page:
;; <planner-tasks-table from="." to="+7">

(defun sacha/planner-tasks-table-tag (tag-beg tag-end attrs)
  "Mark up tasks for this week.
Tags are of the form <planner-tasks-table from=\".\" to=\"+7\">."
  (insert "<nowiki>" (sacha/planner-weekly-table (cdr (assoc "from" attrs))
                                                 (cdr (assoc "to" attrs))) 
"</nowiki>"))

(add-to-list 'planner-markup-tags '("planner-tasks-table" nil t nil 
sacha/planner-tasks-table-tag))

;; Everything else is bubblegum and duct tape

(defun sacha/planner-weekly-class (task-info)
  "Stylesheet class for TASK-INFO.
A Q1 task is urgent and important - red tasks.
A Q2 task is not urgent but is important - yellow tasks.
Everything else is colored gray."
  (cond
   ((string-match "Q1" (planner-task-description task-info)) "q1")
   ((string-match "Q2" (planner-task-description task-info)) "q2")
   (t "unknown")))

(defun sacha/planner-weekly-timed-task-line (info target)
  "Turn INFO into a block describing the timed task, linking to TARGET."
 (let ((info (or info (planner-current-task-info)))
       start-time end-time
       (pixels-per-hour 20)
       (day-start (* 7 60)))
   (when (string-match "@\\([0-9][0-9][0-9][0-9]\\)-\\([0-9][0-9][0-9][0-9]\\)" 
(planner-task-description info))
     (setq start-time (string-to-number (match-string 1 
(planner-task-description info))))
     (setq end-time (string-to-number (match-string 2 (planner-task-description 
info))))
     (setq start-time (+ (% start-time 100) (* (/ start-time 100) 60)))
     (setq end-time (+ (% end-time 100) (* (/ end-time 100) 60))))
   (when (and start-time end-time)
     (format "<a href=\"%s\" title=\"%s\" class=\"%s\" style=\"top: %spx; 
height: %spx\">%s</a>\n"
             target
             (planner-task-description info)
             (sacha/planner-weekly-class info)
             (number-to-string (round (* (/ (- start-time day-start) 60.0) 
pixels-per-hour)))
             (number-to-string (round (* (/ (- end-time start-time) 60.0) 
pixels-per-hour)))
             (planner-task-description info)))))

(defun sacha/planner-weekly-timed-tasks-for-day (target)
  "Return a list of all the timed tasks in the current buffer, linked to 
TARGET."
  (goto-char (point-min))
  (let (lines)
    (while (re-search-forward planner-task-regexp nil t)
      (setq lines (concat lines (or (sacha/planner-weekly-timed-task-line 
(planner-current-task-info) target) ""))))
    (concat "<div>" lines "</div>")))

;; I thought about using this, but then I dropped it.
(defun sacha/planner-weekly-untimed-tasks-for-day (target)
  "Return a list of all the untimed tasks in the current buffer, linked to 
TARGET."
  (goto-char (point-min))
  (let (lines)
    (while (re-search-forward planner-task-regexp nil t)
      (let ((info (planner-current-task-info)))
        (unless (string-match 
"@\\([0-9][0-9][0-9][0-9]\\)-\\([0-9][0-9][0-9][0-9]\\)"
                              (planner-task-description info))
          (setq lines (concat lines
                              (format "<li><a href=\"%s\" title=\"%s\" 
class=\"%s\">%s</a></li>"
                                      target
                                      (planner-task-description info)
                                      class
                                      (planner-task-description info)))))))
    (concat "<ul>" lines "</ul>")))

(defun sacha/planner-weekly-table (from to)
  "Create a table with timed task entries defined by FROM and TO."
  (let ((pages (planner-get-day-pages (planner-expand-name from) 
(planner-expand-name to)))
        result-timed
        result-untimed
        header
        date)
    (with-temp-buffer
      (with-planner
        (while pages
          (erase-buffer)
          (insert-file-contents (planner-page-file (car pages)))
          (setq date (planner-filename-to-calendar-date (car pages)))
          (setq header (concat (format "<th><a href=\"%s\">%s %d</a></th>"
                                       (planner-backend-output-file (car pages))
                                       (calendar-day-name date t)
                                       (extract-calendar-day date)) header))
          (setq result-timed
                (concat "<td>" (sacha/planner-weekly-timed-tasks-for-day
                                (planner-backend-output-file (car pages))) 
"</td>"
                        result-timed))
          (setq pages (cdr pages))))
      (setq result (concat "<table class=\"week_calendar\"><tr>" header
                           "</tr><tr class=\"timed\">" result-timed
                           "</tr></table>")))
    result))


-- 
Sacha Chua <address@hidden> - open source geekette
http://sacha.free.net.ph/ - PGP Key ID: 0xE7FDF77C
interests: emacs, gnu/linux, personal information management, juggling
sachac on irc.freenode.net#emacs . YM: sachachua83




reply via email to

[Prev in Thread] Current Thread [Next in Thread]