aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRaul Benencia <id@rbenencia.name>2023-02-21 07:58:52 -0800
committerRaul Benencia <id@rbenencia.name>2023-02-21 07:59:48 -0800
commit4cd3b3371dcf77171b98dc12f48da248b2f703b2 (patch)
tree2aa66db67ff38b2a8c3d39802f2cd619cb378fbf
parent259fae280c5d10d08defaa03c8c86aa97ca59cf5 (diff)
emacs: export calendar to ics
-rw-r--r--.emacs.local.d/lisp/config/rul-config-org.el3
-rw-r--r--.emacs.local.d/modes/org.el29
2 files changed, 31 insertions, 1 deletions
diff --git a/.emacs.local.d/lisp/config/rul-config-org.el b/.emacs.local.d/lisp/config/rul-config-org.el
index 020efa4..a16e525 100644
--- a/.emacs.local.d/lisp/config/rul-config-org.el
+++ b/.emacs.local.d/lisp/config/rul-config-org.el
@@ -13,6 +13,9 @@
my-org-journal-time-format ""
my-org-refile-path "~/refile.org"
my-org-roam-directory "~/org/roam/"
+
+ my-org-agenda-private-local-path "/tmp/example.ics"
+ my-org-agenda-private-remote-path "/sshx:user@host:example.ics"
)
(provide 'rul-config-org)
diff --git a/.emacs.local.d/modes/org.el b/.emacs.local.d/modes/org.el
index ce4695a..c22047e 100644
--- a/.emacs.local.d/modes/org.el
+++ b/.emacs.local.d/modes/org.el
@@ -110,7 +110,15 @@
;; Based on Prot's config:
;; https://protesilaos.com/codelog/2021-12-09-emacs-org-block-agenda/
(setq my-org-agenda-custom-commands
- `(("P" "Projects and tasks"
+ `(
+ ("X" "Export files" agenda "-CANCELLED"
+ ((org-agenda-with-colors nil)
+ (org-agenda-prefix-format "%t %s")
+ (org-agenda-current-time-string ,(car (last org-agenda-time-grid)))
+ (org-agenda-fontify-priorities nil)
+ (org-agenda-remove-tags t))
+ ,(list my-org-agenda-private-local-path))
+ ("P" "Projects and tasks"
(
(agenda "" (
(org-agenda-overriding-header "📌 Today's agenda\n")
@@ -686,3 +694,22 @@ as the default task."
;; org-modern
(add-hook 'org-mode-hook 'org-modern-mode)
(add-hook 'org-agenda-finalize-hook #'org-modern-agenda)
+
+;; Credits: https://200ok.ch/posts/2022-02-13_integrating_org_mode_agenda_into_other_calendar_apps.html
+(defun org-agenda-export-to-ics ()
+ (set-org-agenda-files)
+ ;; Run all custom agenda commands that have a file argument.
+ (org-batch-store-agenda-views)
+
+ ;; Org mode correctly exports TODO keywords as VTODO events in ICS.
+ ;; However, some proprietary calendars do not really work with
+ ;; standards (looking at you Google), so VTODO is ignored and only
+ ;; VEVENT is read.
+ (with-current-buffer (find-file-noselect org-agenda-private-local-path)
+ (goto-char (point-min))
+ (while (re-search-forward "VTODO" nil t)
+ (replace-match "VEVENT"))
+ (save-buffer))
+
+ ;; Copy the ICS file to a remote server (Tramp paths work).
+ (copy-file org-agenda-private-local-path org-agenda-private-remote-path t))
nihil fit ex nihilo