emacs-orgmode
[Top][All Lists]
Advanced

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

Re: [Orgmode] Fix for org-agenda-cleanup-fancy-diary


From: Erik Hetzner
Subject: Re: [Orgmode] Fix for org-agenda-cleanup-fancy-diary
Date: Wed, 01 Apr 2009 10:26:41 -0700
User-agent: Wanderlust/2.15.6 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (Gojō) APEL/10.7 Emacs/22.2 (i486-pc-linux-gnu) MULE/5.0 (SAKAKI)

At Wed, 1 Apr 2009 13:18:09 +0200,
Carsten Dominik wrote:
>
> Hi Erik,
>
> can you show
>
> - an example entry
> - how it shows up in the agenda without your patch
> - how it shows up with your patch
>
> so that I am better able to understand what you are trying
> to achieve with this patch?

Hi Carsten -

Of course, my apologies.

I have a set of functions that download from remote ical files, then
convert to diary entries. (attached, if anybody is interested).

This results in some diary entries which look like, for example:

x x x x x x x x 
1/4/2009 All day event
 Description of all day event

1/4/2009 14:00-15:00 meeting
 A pretty
 long meeting description
x x x x x x x x 

This creates fancy diary pages that look like:

x x x x x x x x 
Wednesday, 1 April 2009:  April Fools' Day
==========================================
All day event
 Description of all day event
14:00-15:00 meeting
 A pretty
 long meeting description
x x x x x x x x 

Without the patch, I get agendas that look like:

x x x x x x x x 
Wednesday   1 April 2009
  Diary:      14:00-15:00 meeting
  Diary:      April Fools' Day
  Diary:      All day event
  Diary:      Description of all day event
  Diary:      A pretty
  Diary:      long meeting description
x x x x x x x x 

As you can see, the descriptions of the events are all mixed up.
With the patch, it removes any line from the fancy diary page that
starts with a space, resulting in a more compact agenda:

x x x x x x x x 
Wednesday   1 April 2009
  Diary:      14:00-15:00 meeting
  Diary:      April Fools' Day
  Diary:      All day event
x x x x x x x x 

I can then get full event descriptions by clicking on the agenda items.

One problem that I noticed with this solution is that diary entries
that begin with a space (Note the two spaces before ‘Do something
every month’):

x x x x x x x x 
%%(and (diary-date 1 t t) (diary-block 1 9 2006 1 1 9999))  Do something every 
month
x x x x x x x x 

get displayed with a leading space in the diary display and thus get
lost when transforming to an agenda. The icalendar library seems to
create diary entries like this, a problem that I will have to track
down.

I hope that explains what I am trying to do.

best,
Erik Hetzner

;; icalendar -> diary code

(require 'icalendar)
(require 'url)

(defcustom egh:ical-diary-url-list
  '()
  "List of ICS urls and the diary files to convert them to. DIARY FILES WILL BE 
OVERWRITTEN!"
  :type '(repeat (cons string string)))

(defun egh:remote-ics-to-diary (url diary)
  (let* ((ics-temp (make-temp-file "ical"))
         (curl-args
          (append (list "-o" ics-temp)
                  (list url))))
    (apply 'call-process "curl" nil nil nil curl-args)
    (with-temp-buffer
      (insert-file-contents ics-temp)
      (icalendar-import-buffer diary t))
    (delete-file ics-temp)
    (save-excursion
      (find-file diary)
      (save-buffer)
      (kill-buffer nil))))

(defun egh:ical-import-all ()
  (interactive)
  (let ((fetch-and-process-ical-url
        (lambda (entry)
          (let* ((url (car entry))
                 (file (expand-file-name (cdr entry)))
                 (buff (get-file-buffer file)))
            (if buff
                (kill-buffer buff))
            (if (file-exists-p file)
                (delete-file file))
            (egh:remote-ics-to-diary url file)))))
    (mapc fetch-and-process-ical-url
          egh:ical-diary-url-list)))

(add-hook 'diary-display-hook 'fancy-diary-display)
(add-hook 'list-diary-entries-hook 'include-other-diary-files)
(add-hook 'mark-diary-entries-hook 'mark-included-diary-files)

(setq midnight-mode t)
(add-hook 'midnight-hook 'egh:remote-ics-to-diary)

Attachment: pgpCu3UDKSCNm.pgp
Description: PGP signature


reply via email to

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