[Org] Generalize export of org-mode calendar to ics

The location to which the calendar will be exported is not taken from the
customized value of ‘org-icalendar-combined-agenda-file’, which is not fixed
anymore in the configuration.  If this variable is not set (i.e. nil), the no
exporting is done.
This commit is contained in:
Daniel - 2017-10-21 09:02:46 +02:00
parent b5397920eb
commit d515b9480d
Signed by: dbo
GPG Key ID: 4F63DB96D45AA9C6
3 changed files with 27 additions and 25 deletions

View File

@ -554,8 +554,7 @@ _h_ _l_ _o_k _y_ank
(mapc #'find-file-noselect org-agenda-files) (mapc #'find-file-noselect org-agenda-files)
(run-with-timer 0 3600 #'org-clock-save) (run-with-timer 0 3600 #'org-clock-save)
(unless (eq system-type 'windows-nt) (run-with-idle-timer 1200 t #'db/export-diary)))
(run-with-idle-timer 1200 t #'db/export-diary))))
(use-package org-ref (use-package org-ref
:defer t :defer t

@ -1 +1 @@
Subproject commit 48735ebca3133c6d6f757aa8f4ffbab8ee92687b Subproject commit b2855d779c32bad518836b9fdf5dcaf5b998db9b

View File

@ -786,31 +786,34 @@ _y_: ?y? year _q_: quit _L__l__c_: ?l?
org-icalendar-use-deadline nil org-icalendar-use-deadline nil
org-icalendar-use-scheduled nil org-icalendar-use-scheduled nil
org-icalendar-include-todo nil org-icalendar-include-todo nil
org-icalendar-exclude-tags '("NO_EXPORT") org-icalendar-exclude-tags '("NO_EXPORT"))))
org-icalendar-combined-agenda-file "~/Public/daniel.ics")))
(defun db/export-diary () (defun db/export-diary ()
"Export diary.org as ics file to ~/Public." "Export diary.org as ics file to the current value of `org-icalendar-combined-agenda-file.
This is done only if the value of this variable is not null."
(interactive) (interactive)
(require 'ox-icalendar) (if (null org-icalendar-combined-agenda-file)
(org-save-all-org-buffers) (message "`org-icalendar-combined-agenda-file not set, not exporting diary.")
(let ((org-agenda-files (list db/org-default-home-file (progn
db/org-default-work-file)) (require 'ox-icalendar)
(org-agenda-new-buffers nil)) (org-save-all-org-buffers)
;; check whether we need to do something (let ((org-agenda-files (list db/org-default-home-file
(when (some (lambda (org-file) db/org-default-work-file))
(file-newer-than-file-p org-file (org-agenda-new-buffers nil))
org-icalendar-combined-agenda-file)) ;; check whether we need to do something
org-agenda-files) (when (some (lambda (org-file)
(message "Exporting diary ...") (file-newer-than-file-p org-file
;; open files manually to avoid polluting `org-agenda-new-buffers; we dont org-icalendar-combined-agenda-file))
;; want these buffers to be closed after exporting org-agenda-files)
(mapc #'find-file-noselect (cl-remove-if #'null org-agenda-files)) (message "Exporting diary ...")
;; actual export; calls `org-release-buffers and may thus close buffers ;; open files manually to avoid polluting `org-agenda-new-buffers; we dont
;; we want to keep around … which is why we set `org-agenda-new-buffers ;; want these buffers to be closed after exporting
;; to nil (mapc #'find-file-noselect (cl-remove-if #'null org-agenda-files))
(org-icalendar-combine-agenda-files) ;; actual export; calls `org-release-buffers and may thus close buffers
(message "Exporting diary ... done.")))) ;; we want to keep around … which is why we set `org-agenda-new-buffers
;; to nil
(org-icalendar-combine-agenda-files)
(message "Exporting diary ... done."))))))
(defun db/ical-to-org (ical-file-name org-file-name category filetags) (defun db/ical-to-org (ical-file-name org-file-name category filetags)
"Convert ICAL-FILE-NAME to ORG-FILE-NAME using ical2org. "Convert ICAL-FILE-NAME to ORG-FILE-NAME using ical2org.