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

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

[emacs-wiki-discuss] Re: Newbie question


From: Sacha Chua
Subject: [emacs-wiki-discuss] Re: Newbie question
Date: Thu, 09 Mar 2006 00:23:58 -0500
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/21.3.50 (gnu/linux)

Rohan Nicholls <address@hidden> writes:

> At the moment I am using the priority of a, b, or c to signal urgency,
> and it would be nice to use a similar system in a second column to
> indicate importance.  This would allow me to see how many non-urgent

You'll probably love planner-rank.el, which not only allows you to do
importance/urgency but will even automatically calculate urgency for
you based on the deadline. =)

> but important tasks I am getting done, and how much of my time is
> being spent in "crisis management" (important and urgent, and urgent
> but unimportant tasks), the idea being to shift to be doing more of
> the former and less of the latter.

As for crisis management tracking: I have a totally small-time
schedule visualizer that works off tasks with times like @1000-1400
and Q1, Q2, Q3, or Q4 somewhere in the task description.

If you can actually get this to work on your system, totally cool. =)

;; 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.

;; 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-publish-markup-tags '("planner-tasks-table" nil t 
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)))
   (unless (string= (planner-task-status info) "C")
     (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* ((planner-dates-relative-to-today-flag nil)
         (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>"
                                       (concat (car pages) ".php")
                                       (calendar-day-name date t)
                                       (extract-calendar-day date)) header))
          (setq result-timed
                (concat "<td>" (sacha/planner-weekly-timed-tasks-for-day
                                (concat (car pages) ".php")) "</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, free software geekette
http://sacha.free.net.ph/ - PGP Key ID: 0xE7FDF77C
interests: emacs, gnu/linux, personal information management, public speaking
sachac on irc.freenode.net#emacs . YM: sachachua83




reply via email to

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