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

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

[emacs-wiki-discuss] Re: weekly-view, cyclic tasks and planner-appts


From: Edgar Gonçalves
Subject: [emacs-wiki-discuss] Re: weekly-view, cyclic tasks and planner-appts
Date: Thu, 16 Mar 2006 11:48:17 +0000
User-agent: Gnus/5.110004 (No Gnus v0.4)

On Tuesday, Edgar Gonçalves wrote:
[snip-snip-snip]
>
> So now I have a weekly-view by adding the appts only to the diary entries with
> this advice:
>
> (defadvice week-graph-view-diary-entries (around show-planner-appts activate)
>   (let ((list-diary-entries-hook '(planner-include-appt-entries)))
>     ad-do-it))
>
>
> And the "magic" function is:
>
> (defun planner-include-appt-entries ()
>   "Add diary entries with todays planner appointments."
>   (declare (special original-date))
>   (let ((start-day (planner-beginning-of-week
>                   (planner-date-to-filename original-date))))
>     ;; Cycle through forthcoming appts for all the week days:
>     (dolist (appt (planner-appt-forthcoming-get-appts 4 start-day))
>       (let ((date (car appt)) ;; date       : YYYY.MM.DD
>           (text (cadr appt))) ;; description: @START-TIME | END-TIME | TEXT
>       (add-to-diary-list (planner-filename-to-calendar-date date)
>                          text
>                          "")))))
>
> Don't forget you have to change cal-desk's regexp recognition (unfortunately
> they're hard coded, it'd be better to have some variable regexp list!), and 
> add
> the regexps I've mentioned in a previous post in this thread to
> `diary-time-regexp-list'.

After a few days trying I discovered a major hassle with my code. Somehow,
regular diary entries fetching was messing with the planner forthcoming
appointments fetching (which looks into diary entries, creating some kind of
recursion in that process). So I dropped the advice-way of changing the weekly
view display, and created a separate function. This way, both should work, with
different results (although I'll probably never use the old one again!). So
I'll give you the working functions. They work on current, past and future
days of the calendar, now!


(defun planner-include-appt-entries ()
  "Add diary entries with todays planner appointments."
  (declare (special date))
  (let ((start-day (planner-date-to-filename date))
        (number-of-days (if week-graph-work-week 4 6)))
    ;; Cycle through forthcoming appts for all the week days:
    (dolist (appt (planner-appt-forthcoming-get-appts number-of-days
                                                      start-day))
      (let ((date (car appt))   ;; date       : YYYY.MM.DD
            (text (cadr appt))) ;; description: @START-TIME | END-TIME | TEXT
        (add-to-diary-list (planner-filename-to-calendar-date date)
                           text
                           "")))))

(defun week-graph-view-planner-appt-entries (around show-planner-appts activate)
  "Redefinition of `week-graph-view-diary-entries', to work only with planner."
  (interactive)
  (save-excursion
    (calendar-cursor-to-nearest-date)
    (let ((diary-display-hook 'fancy-diary-display-week-graph)
          (day (calendar-day-of-week (calendar-cursor-to-date))))
      (unless (= day calendar-week-start-day)
        (calendar-beginning-of-week 1))
      (diary-check-diary-file)
      (let* ((date (calendar-cursor-to-date t))
            (diary-entries-list nil)
            (date-string (calendar-date-string date)))
        (planner-include-appt-entries)
        (fancy-diary-display-week-graph)))))

;; Switch key definition to work the way I want normally:
(define-key calendar-mode-map "w" 'week-graph-view-planner-appt-entries)
(define-key calendar-mode-map "W" 'week-graph-view-diary-entries)


>
>
> On my TODO list are the following interesting (at least for me) issues:
> - Make tooltips to weekly-view entries, with start and end times and
>   description
Check!
> - Make buttons with links in weekly-view entries
I just found out how easy it is to make buttons, but I haven't thought about
where I'm going to point them to (should cyclic entries point to the cyclic
file, or to the right day page?)
> - Give different colors to weekly-view entries (e.g., tasks priorities)
> - Make entries editable. This could be tricky, because I'd have to detect
>   cyclic entries (changing the diary file) and task entries (and I'd use
>   `planner-edit-task-description').
These will be postponed for a while, I'm short of time, right now...


These last changes are not fully tested, but when I'm comfortable with the
results I'll publish them here!


-- 
Edgar Gonçalves
Software Engineering Group @ INESC-ID
IST/Technical University of Lisbon
Rua Alves Redol, 9, Room 635              
1000-029 Lisboa, Portugal                 
mailto:edgar[DOT]goncalves[AT]inesc[DASH]id[DOT]pt
http://www.esw.inesc-id.pt/~eemg





reply via email to

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