From mboxrd@z Thu Jan 1 00:00:00 1970 From: Carsten Dominik Subject: Re: Fix for org-agenda-cleanup-fancy-diary Date: Thu, 2 Apr 2009 09:29:46 +0200 Message-ID: <94189A4C-6EFF-4D4B-A67D-0937092E809E@gmail.com> References: <49d27cda.1f538c0a.3e43.0351@mx.google.com> <1ACBF12E-6592-4A9C-A487-330DDA9FFB6F@gmail.com> <49d3a3ad.0e538c0a.623d.ffff9e16@mx.google.com> Mime-Version: 1.0 (Apple Message framework v930.3) Content-Type: text/plain; charset=WINDOWS-1252; format=flowed; delsp=yes Content-Transfer-Encoding: quoted-printable Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LpHii-0004fI-TY for emacs-orgmode@gnu.org; Thu, 02 Apr 2009 03:52:17 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LpHic-0004d2-2P for emacs-orgmode@gnu.org; Thu, 02 Apr 2009 03:52:15 -0400 Received: from [199.232.76.173] (port=37215 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LpHib-0004cw-N6 for emacs-orgmode@gnu.org; Thu, 02 Apr 2009 03:52:09 -0400 Received: from mail-ew0-f160.google.com ([209.85.219.160]:61184) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1LpHib-00059v-8w for emacs-orgmode@gnu.org; Thu, 02 Apr 2009 03:52:09 -0400 Received: by mail-ew0-f160.google.com with SMTP id 4so426602ewy.42 for ; Thu, 02 Apr 2009 00:52:08 -0700 (PDT) In-Reply-To: <49d3a3ad.0e538c0a.623d.ffff9e16@mx.google.com> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Erik Hetzner Cc: emacs-orgmode@gnu.org Hi Erik, I see your point. The trouble is that it is a traditional syntax to write things in the diary like this: 1/4/2009 some event 8:30 another event 10:00 meet with Sam for coffee etc etc. You patch will remove all those secondary lines. I think the right solution fr your case is that I will give you a hook in the cleanup routine, so that you can do your own cleanup. Or a variable, OK, we could do that too. - Carsten On Apr 1, 2009, at 7:26 PM, Erik Hetzner wrote: > 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 > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > 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 =20 > items. > > One problem that I noticed with this solution is that diary entries > that begin with a space (Note the two spaces before =91Do something > every month=92): > > x x x x x x x x > %%(and (diary-date 1 t t) (diary-block 1 9 2006 1 1 9999)) Do =20 > 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 =20 > 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)