mirror of https://github.com/djcb/mu.git
mu4e (ical): Optionally save ical events to a diary file upon reply
This commit is contained in:
parent
0f38dd4b1a
commit
834582b7bd
|
@ -8,6 +8,7 @@
|
|||
|
||||
;; To enable optional iCalendar->Org sync functionality
|
||||
;; NOTE: both the capture file and the headline(s) inside must already exist
|
||||
;; (require 'org-agenda)
|
||||
;; (setq gnus-icalendar-org-capture-file "~/org/notes.org")
|
||||
;; (setq gnus-icalendar-org-capture-headline '("Calendar"))
|
||||
;; (gnus-icalendar-org-setup)
|
||||
|
@ -58,13 +59,15 @@
|
|||
(fold-icalendar-buffer)
|
||||
(mu4e-icalendar-reply-ical msg event status (buffer-name)))
|
||||
|
||||
;; Back in article buffer
|
||||
(setq-local gnus-icalendar-reply-status status)
|
||||
(when gnus-icalendar-org-enabled-p
|
||||
(gnus-icalendar--update-org-event event status)
|
||||
;; refresh article buffer to update the reply status
|
||||
(with-current-buffer mu4e~headers-buffer-name
|
||||
(mu4e-headers-rerun-search)))))))
|
||||
;; Back in article buffer
|
||||
(setq-local gnus-icalendar-reply-status status)
|
||||
(when gnus-icalendar-org-enabled-p
|
||||
(gnus-icalendar--update-org-event event status))
|
||||
(when mu4e-icalendar-diary-file
|
||||
(mu4e~icalendar-insert-diary event status mu4e-icalendar-diary-file))
|
||||
;; refresh article buffer to update the reply status
|
||||
(with-current-buffer mu4e~headers-buffer-name
|
||||
(mu4e-headers-rerun-search))))))
|
||||
|
||||
(defun mu4e~icalendar-delete-citation ()
|
||||
(delete-region (point-min) (point-max)))
|
||||
|
@ -98,6 +101,28 @@
|
|||
))
|
||||
|
||||
|
||||
(defun mu4e~icalendar-insert-diary (event reply-status filename)
|
||||
"Insert a diary entry for the EVENT with reply STATUS in FILE."
|
||||
;; FIXME: handle recurring events
|
||||
(let* ((beg (gnus-icalendar-event:start-time event))
|
||||
(beg-date (format-time-string "%d/%m/%Y" beg))
|
||||
(beg-time (format-time-string "%H:%M" beg))
|
||||
(end (gnus-icalendar-event:end-time event))
|
||||
(end-date (format-time-string "%d/%m/%Y" end))
|
||||
(end-time (format-time-string "%H:%M" end))
|
||||
(summary (gnus-icalendar-event:summary event))
|
||||
(location (gnus-icalendar-event:location event))
|
||||
(status (capitalize (symbol-name reply-status)))
|
||||
(txt (if location
|
||||
(format "%s (%s)\n %s " summary status location)
|
||||
(format "%s (%s)" summary status))))
|
||||
(with-temp-buffer
|
||||
(if (string= beg-date end-date)
|
||||
(insert beg-date " " beg-time "-" end-time " " txt "\n")
|
||||
(insert beg-date " " beg-time " Start of: " txt "\n")
|
||||
(insert beg-date " " end-time " End of: " txt "\n"))
|
||||
(write-region (point-min) (point-max) filename t))))
|
||||
|
||||
|
||||
(provide 'mu4e-icalendar)
|
||||
;;; mu4e-icalendar.el ends here
|
||||
|
|
|
@ -439,6 +439,22 @@ Useful when this is not equal to the From: address."
|
|||
This is the message being replied to, forwarded or edited; used
|
||||
in `mu4e-compose-pre-hook'. For new messages, it is nil.")
|
||||
|
||||
(defgroup mu4e-icalendar nil
|
||||
"Icalendar related settings."
|
||||
:group 'mu4e)
|
||||
|
||||
(defcustom mu4e-icalendar-trash-after-reply nil
|
||||
"If non-nil, trash the icalendar invitation after replying."
|
||||
:type 'boolean
|
||||
:group 'mu4e-icalendar)
|
||||
|
||||
(defcustom mu4e-icalendar-diary-file nil
|
||||
"If non-nil, the file in which to add events upon reply."
|
||||
:type '(choice (const :tag "Do not insert a diary entry" nil)
|
||||
(string :tag "Insert a diary entry in this file"))
|
||||
:group 'mu4e-icalendar)
|
||||
|
||||
|
||||
;; Folders
|
||||
(defgroup mu4e-folders nil
|
||||
"Special folders."
|
||||
|
|
Loading…
Reference in New Issue