]> git.vanrenterghem.biz Git - Dotty.git/commitdiff
Support Org mode calendar management in full. master
authorFrederik Vanrenterghem <frederik@vanrenterghem.biz>
Wed, 5 Mar 2025 04:31:34 +0000 (12:31 +0800)
committerFrederik Vanrenterghem <frederik@vanrenterghem.biz>
Wed, 5 Mar 2025 04:31:34 +0000 (12:31 +0800)
* Retire secondary Nextcloud calendar.
* Use default calendar for syncing with Org mode.
* Update Org capture template to more easily set appointment duration.
* Default explicitly to asking before deleting calendar events.

emacs/.emacs.d/init.el

index e5c157dfcfa5c3ed104d0cf11b2d524e27e973d1..6f6fc165983834033c318fd49d8c3f27f8b9285c 100644 (file)
@@ -114,7 +114,7 @@ vc-follow-symlinks t
    ("C-c a" . org-agenda))
   :custom
   (org-default-notes-file "~/Nextcloud/notes/inbox.org")
    ("C-c a" . org-agenda))
   :custom
   (org-default-notes-file "~/Nextcloud/notes/inbox.org")
-  (org-agenda-files `(,org-default-notes-file "~/Nextcloud/notes/calendar.org"))
+  (org-agenda-files `(,org-default-notes-file "~/Nextcloud/notes/calendar-nextcloud.org"))
   (org-capture-bookmark nil)
   ;; Capture templates
   (org-capture-templates
   (org-capture-bookmark nil)
   ;; Capture templates
   (org-capture-templates
@@ -125,8 +125,8 @@ vc-follow-symlinks t
       (file "~/Documents/belastingen/FY24-25.org")
       "* %t %a\n")
      ("a" "Appointment" entry
       (file "~/Documents/belastingen/FY24-25.org")
       "* %t %a\n")
      ("a" "Appointment" entry
-           (file+olp+datetree "~/Nextcloud/notes/calendar.org")
-           "* %?\n :PROPERTIES:\n :location: %^{Location}\n :END:\n%^T--%^T\n\n"
+           (file+olp+datetree "~/Nextcloud/notes/calendar-nextcloud.org")
+           "* %?\n :PROPERTIES:\n :location: %^{Location}\n :END:\n%(fv/org-capture-appointment-timestamp)\n\n"
            :jump-to-captured t
           :empty-lines 1
           :tree-type month
            :jump-to-captured t
           :empty-lines 1
           :tree-type month
@@ -142,7 +142,7 @@ vc-follow-symlinks t
       (file+headline org-default-notes-file "Tasks")
       "* TODO %i%?")
      ("e" "Email follow-up" entry (file+headline org-default-notes-file "Tasks")
       (file+headline org-default-notes-file "Tasks")
       "* TODO %i%?")
      ("e" "Email follow-up" entry (file+headline org-default-notes-file "Tasks")
-      "* TODO %:fromname: %a %?\nDEADLINE: %(org-insert-time-stamp (org-read-date nil t \"+2d\"))")))
+      "* TODO %:fromname: %a %?\nDEADLINE: %(org-insert-time-stamp (org-read-date nil t \"+2d\") t)")))
   ;; Agenda views
   (org-agenda-custom-commands
    '(("P" "Expired calendar events" ((tags "TIMESTAMP<=\"<now>\"")))
   ;; Agenda views
   (org-agenda-custom-commands
    '(("P" "Expired calendar events" ((tags "TIMESTAMP<=\"<now>\"")))
@@ -174,17 +174,29 @@ vc-follow-symlinks t
    '((R . t)
      (latex . t))))
 
    '((R . t)
      (latex . t))))
 
+(defun fv/org-capture-appointment-timestamp (&optional duration)
+  "Get an Org timestamp for an appointment.
+Prompt for a start time, calculate the end time by adding DURATION (default 30
+minutes), and return a formatted Org timestamp with start and end times."
+  (let* ((duration (or duration 30))
+         (start-time (org-read-date t t nil "From:"))
+         (end-time (time-add start-time (seconds-to-time (* duration 60)))))
+    (concat (format-time-string (org-time-stamp-format t) start-time)
+            "--"
+            (format-time-string (org-time-stamp-format t) end-time))))
+
 (use-package org-caldav
   :ensure t
   :config
   (setq org-caldav-url "https://owncloud.vanrenterghem.biz/remote.php/dav/calendars/frederik")
 (use-package org-caldav
   :ensure t
   :config
   (setq org-caldav-url "https://owncloud.vanrenterghem.biz/remote.php/dav/calendars/frederik")
-  (setq org-caldav-calendar-id "orgmode")
+  (setq org-caldav-calendar-id "default%20calendar")
   ;; Org filename where new entries from calendar stored
   ;; Org filename where new entries from calendar stored
-  (setq org-caldav-inbox "~/Nextcloud/notes/calendar.org")
+  (setq org-caldav-inbox '(file+olp+datetree "~/Nextcloud/notes/calendar-nextcloud.org"))
   ;; Additional Org files to check for calendar events
   (setq org-caldav-files nil)
   ;; Usually a good idea to set the timezone manually
   ;; Additional Org files to check for calendar events
   (setq org-caldav-files nil)
   ;; Usually a good idea to set the timezone manually
-  (setq org-icalendar-timezone "Australia/Perth"))
+  (setq org-icalendar-timezone "Australia/Perth")
+  (setq org-caldav-delete-calendar-entries 'ask))
 
 (use-package org-protocol)
 
 
 (use-package org-protocol)