Gnus development mailing list
 help / color / mirror / Atom feed
From: "Damon Haley" <dkh@member.fsf.org>
To: asjo@koldfront.dk (Adam Sjøgren)
Cc: ding@gnus.org
Subject: Re: text/calendar attachments invisible in gnus
Date: Tue, 08 Jan 2013 09:36:23 -0700	[thread overview]
Message-ID: <vsxbik1udvws1k.fsf@member.fsf.org> (raw)
In-Reply-To: <87sj6tycd1.fsf@topper.koldfront.dk> ("Adam =?utf-8?Q?Sj?= =?utf-8?Q?=C3=B8gren=22's?= message of "Tue, 25 Dec 2012 23:51:22 +0100")

>>>>> Adam Sjøgren <asjo@koldfront.dk> writes:

> I hacked a little on your recipe recently (my colleagues got a new version
> of Outlook and now the HTML parts have no information, none what so ever).

> I grabbed some of the time zone stuff from one the the .el-files that can
> import into org-mode (I think it was), and fiddled with various other things
> (charset and some formatting).

> I haven't figured the reply-bit out either, because my colleagues look at my
> calender on the Exchange-server, and I'll bet (but I'll be happy to lose the
> bet) that you need to use Outlook for that to work.

Adam, thanks for this.  Now I can finally see these calendar events I get in
gnus.  It would be great to eventually be able to accept the Exchange invites in gnus,
but this is good enough for now.

Damon

> Anyway, here is my butchering of your recipe:

> (add-to-list 'mm-inlined-types "text/calendar")
> (add-to-list 'mm-automatic-display "text/calendar")
> (add-to-list 'mm-inline-media-tests '("text/calendar" mm-inline-text-calendar identity))

> (require 'icalendar)
> (require 'boxquote)

> (defun mm-inline-text-calendar (handle)
>   (let ((text ""))
>     (with-temp-buffer
>       (mm-insert-part handle)
>       (save-window-excursion
>         (setq info (mapcar (lambda (s) (mm-decode-string s "utf-8"))
>                            (format-text-calendar-for-display (icalendar--read-element nil nil))))))
>     (let ((start (point)))
>       (mm-insert-inline handle "\n")
>       (mm-insert-inline handle (car info))
>       (mm-insert-inline handle "\n")
>       (goto-char start)
>       (when (search-forward "DESCRIPTION " nil t)
>         (replace-match "" nil t)
>         (beginning-of-line)
>         (fill-region (point) (point-max)))
>       (boxquote-region start (point-max)))
>     (boxquote-title (car (cdr info)))
>     (mm-insert-inline handle "\n")))

> (defun format-text-calendar-for-display (element)
>   "Format a text/calendar element parsed by icalendar--read-element into text"
>   (let ((fields '(LOCATION ORGANIZER DESCRIPTION))
>         (fieldformat "%-11s %s\n")
>         (content "")
>         (first-date "")
>         (last-date "")
>         (title ""))
>     (dolist (event (icalendar--all-events element))
>       (let* ((zone-map (icalendar--convert-all-timezones element))
>              (dtstart-zone (icalendar--find-time-zone (icalendar--get-event-property-attributes event 'DTSTART) zone-map))
>              (dtstart (icalendar--decode-isodatetime (icalendar--get-event-property event 'DTSTART) nil dtstart-zone))
>              (dtend-zone (icalendar--find-time-zone (icalendar--get-event-property-attributes event 'DTEND) zone-map))
>              (dtend   (icalendar--decode-isodatetime (icalendar--get-event-property event 'DTEND) nil dtend-zone))
>              (datestring (concat (icalendar--datetime-to-iso-date dtstart "-") " "
>                                  (icalendar--datetime-to-colontime dtstart) "-"
>                                  (icalendar--datetime-to-colontime dtend))))
>         (when (string-equal first-date "")
>           (setq first-date datestring))
>         (setq last-date datestring)
>         (dolist (field fields)
>           (let ((propertyvalue (mapconcat (lambda (property)
>                                             (icalendar--convert-string-for-import property)
>                                             (replace-regexp-in-string "\\\\n" "\n"
>                                                                       (replace-regexp-in-string "^MAILTO:" "" property)))
>                                           (icalendar--get-event-properties event field) " ")))
>             (when (not (string-equal propertyvalue ""))
>               (setq content (concat content (format fieldformat field (replace-regexp-in-string "\\\\ " "" propertyvalue)))))))))
>     (setq content (replace-regexp-in-string "\n\n$" "" content))
>     (setq title (if (string-equal first-date last-date) first-date (concat first-date " ... " last-date)))
>     (list content title)))

> I hope some of it is useful.

>   Best regards,

>     Adam

-- 
app: https://alpha.app.net/haleyscomet
net: https://identi.ca/vinylisl
git: https://github.com/dhaley
irc: dkh on #drupal-colorado/irc/freenode.net




  reply	other threads:[~2013-01-08 16:36 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-30 21:46 Uwe Brauer
2012-11-30 23:42 ` Steinar Bang
2012-12-24  5:01 ` Leonidas Tsampros
2012-12-25 22:51   ` Adam Sjøgren
2013-01-08 16:36     ` Damon Haley [this message]
2013-01-09 18:57       ` Adam Sjøgren
2013-01-08 20:54     ` Uwe Brauer
2013-01-09 19:01       ` Adam Sjøgren
2013-01-10 18:10         ` Uwe Brauer
2013-01-11  0:01           ` Adam Sjøgren
2013-05-02  7:39   ` Deus Max

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=vsxbik1udvws1k.fsf@member.fsf.org \
    --to=dkh@member.fsf.org \
    --cc=asjo@koldfront.dk \
    --cc=ding@gnus.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).