Support Org mode calendar management in full.
[Dotty.git] / emacs / .emacs.d / init.el
index dec61b7798d52fdcf32c465c569d2466843a62cd..6f6fc165983834033c318fd49d8c3f27f8b9285c 100644 (file)
@@ -53,6 +53,9 @@ vc-follow-symlinks t
 (load "/usr/share/emacs/site-lisp/ess/lisp/ess-site")
 (setq inferior-julia-program-name "/usr/bin/julia")
 
+(use-package ess-view-data
+  :ensure t)
+
 ;; enable autocomplete
 (use-package corfu
   :ensure t
@@ -111,7 +114,7 @@ vc-follow-symlinks t
    ("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
@@ -122,8 +125,8 @@ vc-follow-symlinks t
       (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
@@ -139,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")
-      "* 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>\"")))
@@ -171,17 +174,31 @@ vc-follow-symlinks 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")
-  (setq org-caldav-calendar-id "orgmode")
+  (setq org-caldav-calendar-id "default%20calendar")
   ;; 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
-  (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 tex
   :ensure auctex
@@ -232,10 +249,24 @@ vc-follow-symlinks t
  ;; If there is more than one, they won't work right.
  '(browse-url-browser-function 'browse-url-firefox)
  '(custom-safe-themes
-   '("8d146df8bd640320d5ca94d2913392bc6f763d5bc2bb47bed8e14975017eea91" "9a977ddae55e0e91c09952e96d614ae0be69727ea78ca145beea1aae01ac78d2" "0cf95236abcf59e05b1ea69b4edd53d293a5baec4fe4c3484543fee99bfd2204" "80b00f3bf7cdbdca6c80aadfbbb03145f3d0aacf6bf2a559301e61109954e30a" default))
+   '("8d146df8bd640320d5ca94d2913392bc6f763d5bc2bb47bed8e14975017eea91"
+     "9a977ddae55e0e91c09952e96d614ae0be69727ea78ca145beea1aae01ac78d2"
+     "0cf95236abcf59e05b1ea69b4edd53d293a5baec4fe4c3484543fee99bfd2204"
+     "80b00f3bf7cdbdca6c80aadfbbb03145f3d0aacf6bf2a559301e61109954e30a"
+     default))
  '(org-export-backends '(ascii html icalendar latex md odt))
  '(package-selected-packages
-   '(devdocs straight calfw calfw-org engrave-faces org-caldav nov eat mu4e ellama emms mpdel-embark libmpdel pass password-store fontaine osm orderless embark-consult embark consult jinx dired-preview ftable flx nerd-icons-dired nerd-icons all-the-icons-dired marginalia vertico denote ox-rss org-ql org-contrib mustache org-static-blog haskell-mode julia-mode elfeed-protocol ack company magit auctex lsp-mode elpy ## org htmlize leuven-theme lua-mode ess-smart-underscore ess-R-data-view ess))
+   '(## ack all-the-icons-dired auctex calfw calfw-org company consult
+           consult-denote denote devdocs dired-preview
+           dired-quick-sort eat elfeed-protocol ellama elpy embark
+           embark-consult emms engrave-faces ess ess-R-data-view
+           ess-smart-underscore ess-view-data flx fontaine ftable
+           haskell-mode htmlize jinx julia-mode leuven-theme libmpdel
+           lsp-mode lua-mode magit marginalia mpdel-embark mu4e
+           mustache nerd-icons nerd-icons-dired nov orderless org
+           org-caldav org-contrib org-ql org-static-blog osm ox-rss
+           pass password-store powerthesaurus request straight
+           vertico))
  '(use-package-compute-statistics t))
 (custom-set-faces
  ;; custom-set-faces was added by Custom.
@@ -363,6 +394,7 @@ vc-follow-symlinks t
               (replace-match outfile t t nil 2)))
          (mapcar #'shell-command cmds)))))
   (add-hook 'message-send-hook 'mu4e-resize-image-attachments)
+  (add-hook 'dired-mode-hook 'turn-on-gnus-dired-mode) ;; Attach files to messages using dired C-c RET C-a
   (defun mu4e-inhibit-resize()
     (interactive)
     (set (make-local-variable 'mu4e-inhibit-resize) t)))
@@ -445,6 +477,25 @@ vc-follow-symlinks t
   (keymap-global-set "M-$" #'jinx-correct)
   :hook (emacs-startup . global-jinx-mode))
 
+(use-package powerthesaurus
+  :ensure t
+  :init
+  (require 'transient)
+  (transient-define-prefix my/transient-spelling ()
+    "Spelling commands"
+    ["Spelling"
+      ["Lookups"
+        ("y" "Synonyms" powerthesaurus-lookup-synonyms-dwim)
+        ("a" "Antonyms" powerthesaurus-lookup-antonyms-dwim)]
+      ["Spelling Tools"
+        ("x" "Jinx" jinx-mode)
+        ("c" "Jinx correct" jinx-correct)]
+      ["Dictionary"
+        ("d" "Lookup" dictionary-lookup-definition)]
+      ["Miscellaneous"
+        ("q" "Quit" transient-quit-one)]])
+  :bind
+  ("C-c s" . my/transient-spelling))
 
 ;; Bind embark
 (use-package embark
@@ -482,6 +533,9 @@ vc-follow-symlinks t
   (consult-mu-action #'consult-mu--view-action)
   )
 
+(use-package consult-denote
+  :ensure t)
+
 ;; Configure `world-clock'
 (use-package time
   :ensure nil
@@ -572,6 +626,21 @@ vc-follow-symlinks t
   :bind
   ("C-h D" . devdocs-lookup))
 
+(use-package emms
+  :ensure t
+  :config
+  (require 'emms-setup)
+  (require 'emms-player-mpd)
+  (emms-all) ; don't change this to values you see on stackoverflow questions if you expect emms to work
+  (setq emms-player-list '(emms-player-mpd))
+  (add-to-list 'emms-info-functions 'emms-info-mpd)
+  (add-to-list 'emms-player-list 'emms-player-mpd)
+  
+  ;; Socket is not supported
+  (setq emms-player-mpd-server-name "mea-hookani-pila")
+  (setq emms-player-mpd-server-port "6600")
+  (emms-player-mpd-connect))
+
 ;; Custom functions
 
 ;; Might want to run this automatically