From d515b9480d796a1eb5e7aaad4431bbcc276f533a Mon Sep 17 00:00:00 2001 From: Daniel Borchmann Date: Sat, 21 Oct 2017 09:02:46 +0200 Subject: [PATCH] [Org] Generalize export of org-mode calendar to ics MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- init.el | 3 +-- private | 2 +- site-lisp/db-org.el | 47 ++++++++++++++++++++++++--------------------- 3 files changed, 27 insertions(+), 25 deletions(-) diff --git a/init.el b/init.el index 59800ac..ac459f0 100644 --- a/init.el +++ b/init.el @@ -554,8 +554,7 @@ _h_ _l_ _o_k _y_ank (mapc #'find-file-noselect org-agenda-files) (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 :defer t diff --git a/private b/private index 48735eb..b2855d7 160000 --- a/private +++ b/private @@ -1 +1 @@ -Subproject commit 48735ebca3133c6d6f757aa8f4ffbab8ee92687b +Subproject commit b2855d779c32bad518836b9fdf5dcaf5b998db9b diff --git a/site-lisp/db-org.el b/site-lisp/db-org.el index 7c96566..05ea86a 100644 --- a/site-lisp/db-org.el +++ b/site-lisp/db-org.el @@ -786,31 +786,34 @@ _y_: ?y? year _q_: quit _L__l__c_: ?l? org-icalendar-use-deadline nil org-icalendar-use-scheduled nil org-icalendar-include-todo nil - org-icalendar-exclude-tags '("NO_EXPORT") - org-icalendar-combined-agenda-file "~/Public/daniel.ics"))) + org-icalendar-exclude-tags '("NO_EXPORT")))) (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) - (require 'ox-icalendar) - (org-save-all-org-buffers) - (let ((org-agenda-files (list db/org-default-home-file - db/org-default-work-file)) - (org-agenda-new-buffers nil)) - ;; check whether we need to do something - (when (some (lambda (org-file) - (file-newer-than-file-p org-file - org-icalendar-combined-agenda-file)) - org-agenda-files) - (message "Exporting diary ...") - ;; open files manually to avoid polluting `org-agenda-new-buffers’; we don’t - ;; want these buffers to be closed after exporting - (mapc #'find-file-noselect (cl-remove-if #'null org-agenda-files)) - ;; actual export; calls `org-release-buffers’ and may thus close buffers - ;; 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.")))) + (if (null org-icalendar-combined-agenda-file) + (message "`org-icalendar-combined-agenda-file’ not set, not exporting diary.") + (progn + (require 'ox-icalendar) + (org-save-all-org-buffers) + (let ((org-agenda-files (list db/org-default-home-file + db/org-default-work-file)) + (org-agenda-new-buffers nil)) + ;; check whether we need to do something + (when (some (lambda (org-file) + (file-newer-than-file-p org-file + org-icalendar-combined-agenda-file)) + org-agenda-files) + (message "Exporting diary ...") + ;; open files manually to avoid polluting `org-agenda-new-buffers’; we don’t + ;; want these buffers to be closed after exporting + (mapc #'find-file-noselect (cl-remove-if #'null org-agenda-files)) + ;; actual export; calls `org-release-buffers’ and may thus close buffers + ;; 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) "Convert ICAL-FILE-NAME to ORG-FILE-NAME using ical2org.