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

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

Re: [emacs-wiki-discuss] planner-appt or diary question


From: Seth Falcon
Subject: Re: [emacs-wiki-discuss] planner-appt or diary question
Date: Tue, 13 Dec 2005 22:24:20 -0800
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (darwin)

On 13 Dec 2005, address@hidden wrote:
>> Maybe I want something like this [other suggestions for similar
>> solutions welcome]:
>
>> * Today's Appointments (2005.12.10)
>
>> @14:00 |       | # Some task
>> @15:00 |       | # Some task
>
>> * Upcoming Appointments
>
>> 2005.12.11 | @14:00 |       | # Some task
>> 2005.12.15 | @9:00  |       | # Some task
>
> That looks good.  The @s in the forthcoming appointments section
> would get highlighted as planner-appt's highlighting currently
> stands, so perhaps they should be @-less for now?

Some preliminary code to display upcoming appointments is below.  For
lack of a better name, planner-headsup-generate prompts for a number N
and displays in a temp buffer all appointments scheduled between today
and today+N.

Here's a sample output:

  * Upcoming Appointments
  
  2005.12.14 9:10 | ''''      | # A task for doing
  2005.12.20 16:00 | 17:00 | # another item to take care of

I'd like to do better:
  - with the dates in a separate "column"
  - handling 9:00 vs 09:00 
  - handling empty end times

Aside from the formatting improvements, I would like to set this up so
that it updates my current day page.  One option would be to find a
way to plug it into planner-appt so that when the schedule is updated,
this bit is inserted as well.  I would welcome suggestions on how to
go about that.

Best,

+ seth




(defvar planner-headsup-buffer "*planner-headsup buffer*" "Temp buffer name for 
planner-headsup")

(defun planner-headsup-generate (n)
  "Generate a headsup report spanning a period from today to N
days into the future."
  (interactive
   (list (read-string "Number of days: ")))

  (save-some-buffers nil (lambda () (planner-derived-mode-p 'planner-mode)))
  (set-buffer (get-buffer-create planner-headsup-buffer))
  (setq muse-current-project (muse-project planner-project))
  (planner-mode)
  (erase-buffer)
  (cd (planner-directory)) ;; why?
  (let* ((begin (planner-today))
         (end (planner-expand-name (concat "+" n)))
         (pages (planner-get-day-pages begin end))
        tasks)
    (while pages
      (when (caar pages)
        (with-temp-buffer
          (with-planner
            (insert-file-contents-literally (cdar pages))
            (setq tasks (planner-headsup-get-tasks (caar pages)))))
        (goto-char (point-min))
        (if tasks
            (insert "\n" tasks)))
      (setq pages (cdr pages))))
  (insert "* Upcoming Appointments\n")
  (display-buffer (get-buffer-create planner-headsup-buffer) t))


(defun planner-headsup-get-tasks (date)
  (goto-char (point-min))
  (let (result)
    (while (re-search-forward planner-task-regexp nil t)
      (let* ((info (planner-current-task-info))
             (task (planner-task-description info)))
        (when info
            (and 
             (and (not (equal (planner-task-status info) "C"))
                  (not (equal (planner-task-status info) "X")))
             (string-match "^@" task)
             (progn
               (setq task (planner-appt-format-appt-section-line task))
               (string-match "\\(@\\)[0-9]" task)
               (setq task (substring task (match-end 1)))
               (setq task (concat date " " task))
               (setq result
                     (if result (concat result "\n" task) task)))))))
    result))







reply via email to

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