From: Jan Tatarik Date: Thu, 21 Nov 2013 22:55:59 +0000 (+0000) Subject: lisp/gnus/gnus-icalendar.el: Fix org-timestamp for events ending at midnight; RSVP... X-Git-Tag: emacs-24.3.90~173^2^2~42^2~45^2~387^2~753 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=680f4ae6ba858da2e078a7f9c2f2d3eb4b6f325d;p=emacs.git lisp/gnus/gnus-icalendar.el: Fix org-timestamp for events ending at midnight; RSVP handling --- diff --git a/lisp/gnus/ChangeLog b/lisp/gnus/ChangeLog index 11f9e59c478..b44cca022ee 100644 --- a/lisp/gnus/ChangeLog +++ b/lisp/gnus/ChangeLog @@ -1,3 +1,13 @@ +2013-11-21 Jan Tatarik + + * gnus-icalendar.el (gnus-icalendar-additional-identities): New. + (gnus-icalendar-identities): Support additional-identities. + +2013-11-21 Jan Tatarik + + * gnus-icalendar.el (gnus-icalendar-event:org-timestamp): Fix + org-timestamp for events ending at midnight. + 2013-11-21 Ivan Shmakov (tiny change) * nndoc.el (nndoc-type-alist, nndoc-debbugs-db-type-p): Support debbugs diff --git a/lisp/gnus/gnus-icalendar.el b/lisp/gnus/gnus-icalendar.el index a8277635f3e..56c56f3dd46 100644 --- a/lisp/gnus/gnus-icalendar.el +++ b/lisp/gnus/gnus-icalendar.el @@ -387,14 +387,46 @@ Return nil for non-recurring EVENT." (end (gnus-icalendar-event:end-time event)) (start-date (format-time-string "%Y-%m-%d %a" start)) (start-time (format-time-string "%H:%M" start)) + (start-at-midnight (string= start-time "00:00")) (end-date (format-time-string "%Y-%m-%d %a" end)) (end-time (format-time-string "%H:%M" end)) + (end-at-midnight (string= end-time "00:00")) + (start-end-date-diff (/ (float-time (time-subtract + (date-to-time end-date) + (date-to-time start-date))) + 86400)) (org-repeat (gnus-icalendar-event:org-repeat event)) - (repeat (if org-repeat (concat " " org-repeat) ""))) - - (if (equal start-date end-date) - (format "<%s %s-%s%s>" start-date start-time end-time repeat) - (format "<%s %s>--<%s %s>" start-date start-time end-date end-time)))) + (repeat (if org-repeat (concat " " org-repeat) "")) + (time-1-day '(0 86400))) + + ;; NOTE: special care is needed with appointments ending at midnight + ;; (typically all-day events): the end time has to be changed to 23:59 to + ;; prevent org agenda showing the event on one additional day + (cond + ;; start/end midnight + ;; A 0:0 - A+1 0:0 -> A + ;; A 0:0 - A+n 0:0 -> A - A+n-1 + ((and start-at-midnight end-at-midnight) (if (> start-end-date-diff 1) + (let ((end-ts (format-time-string "%Y-%m-%d %a" (time-subtract end time-1-day)))) + (format "<%s>--<%s>" start-date end-ts)) + (format "<%s%s>" start-date repeat))) + ;; end midnight + ;; A .:. - A+1 0:0 -> A .:.-23:59 + ;; A .:. - A+n 0:0 -> A .:. - A_n-1 + (end-at-midnight (if (= start-end-date-diff 1) + (format "<%s %s-23:59%s>" start-date start-time repeat) + (let ((end-ts (format-time-string "%Y-%m-%d %a" (time-subtract end time-1-day)))) + (format "<%s %s>--<%s>" start-date start-time end-ts)))) + ;; start midnight + ;; A 0:0 - A .:. -> A 0:0-.:. (default 1) + ;; A 0:0 - A+n .:. -> A - A+n .:. + ((and start-at-midnight + (plusp start-end-date-diff)) (format "<%s>--<%s %s>" start-date end-date end-time)) + ;; default + ;; A .:. - A .:. -> A .:.-.:. + ;; A .:. - B .:. + ((zerop start-end-date-diff) (format "<%s %s-%s%s>" start-date start-time end-time repeat)) + (t (format "<%s %s>--<%s %s>" start-date start-time end-date end-time))))) (defun gnus-icalendar--format-summary-line (summary &optional location) (if location @@ -617,6 +649,22 @@ is searched." :type '(string) :group 'gnus-icalendar) +(defcustom gnus-icalendar-additional-identities nil + "We need to know your identity to make replies to calendar requests work. + +Gnus will only offer you the Accept/Tentative/Decline buttons for +calendar events if any of your identities matches at least one +RSVP participant. + +Your identity is guessed automatically from the variables `user-full-name', +`user-mail-address', and `gnus-ignored-from-addresses'. + +If you need even more aliases you can define them here. It really +only makes sense to define names or email addresses." + + :type '(repeat string) + :group 'gnus-icalendar) + (make-variable-buffer-local (defvar gnus-icalendar-reply-status nil)) @@ -630,8 +678,9 @@ is searched." (apply #'append (mapcar (lambda (x) (if (listp x) x (list x))) (list user-full-name (regexp-quote user-mail-address) - ; NOTE: this one can be a list - gnus-ignored-from-addresses)))) + ; NOTE: these can be lists + gnus-ignored-from-addresses ; already regexp-quoted + (mapcar #'regexp-quote gnus-icalendar-additional-identities))))) ;; TODO: make the template customizable (defmethod gnus-icalendar-event->gnus-calendar ((event gnus-icalendar-event) &optional reply-status)