whompmacs/whomp/whomp-orgmode.el

200 lines
6.9 KiB
EmacsLisp
Raw Normal View History

2024-07-05 05:48:54 +00:00
;;
;; Org mode settings
2024-07-05 05:48:54 +00:00
;;
;; org layer toggles
2024-07-12 23:32:01 +00:00
(defcustom whomp-orgmode nil
"Choose from the available org-mode packages"
2024-07-10 12:08:51 +00:00
:type '(set (const :tag "Org" orgmode)
(const :tag "Org-Bullets" orgbullets)
(const :tag "Org-SuperAgenda" orgsuperagenda)
(const :tag "Org-Modern" orgmodern)
(const :tag "Org-TimeBlock" orgtimeblock)
(const :tag "Org-Download" orgdownload)
(const :tag "Org-Transclusion" orgtransclusion)
(const :tag "Org-Roam" orgroam)
(const :tag "Org-Publish" orgpublish))
2024-07-12 23:32:01 +00:00
:group 'whomp-config)
;; org-babel extras
2024-07-12 23:32:01 +00:00
(defcustom whomp-orgbabel nil
"Choose extra packages for org-babel"
2024-07-10 12:08:51 +00:00
:type '(set (const :tag "ob-mermaid" obmermaid)
(const :tag "ob-napkin" obnapkin))
2024-07-12 23:32:01 +00:00
:group 'whomp-config)
;;
;; Ensure Org mode is installed and loaded
;;
;; base
2024-07-12 23:32:01 +00:00
(when (memq 'orgmode whomp-orgmode)
2024-07-14 07:18:36 +00:00
(use-package org
:straight t
:defer t
:config
(whomp/ensure-directory-exists "~/org")
(setq browse-url-browser-function 'browse-url-generic
browse-url-generic-program "firefox-esr"
org-log-done 'time
org-startup-indented t
org-hide-leading-stars t
org-support-shift-select t
org-directory "~/org"
org-default-notes-file "~/org/index.org"
org-export-with-sub-superscripts t
org-export-with-toc t)
(whomp/org-agenda-files-update)
(setq org-todo-keywords
'((sequence "TODO(t)" "WAITING(w)" "BLOCKED(b)" "|" "IN-PROGRESS(i)")
2024-10-18 14:55:28 +00:00
(sequence "CANCELLED(c)" "|" "DONE(d)")))
2024-07-14 07:18:36 +00:00
(setq org-capture-templates
`(("t" "TODO" entry (file+headline "~/org/agenda.org" "Tasks")
2024-07-14 07:18:36 +00:00
"* TODO %?\n %a")
("l" "TODO" entry (file+headline "~/org/agenda.org" "LIFE Tasks")
2024-07-14 07:18:36 +00:00
"* TODO %?\n %i\n %a")
("a" "Appointment" entry (file+headline "~/org/events.org" "Appointments")
2024-07-14 07:18:36 +00:00
"* %?\n %i\n %a" :clock-in t :clock-resume t)
("e" "Schedule Event" entry (file+headline "~/org/events.org" "Events")
2024-07-14 07:18:36 +00:00
"* %?\n %i\n %a" :clock-in t :clock-resume t)
("m" "Schedule Meeting" entry (file+headline "~/org/events.org" "Meetings")
2024-07-14 07:18:36 +00:00
"* %?\n %i\n %a" :clock-in t :clock-resume t)
("n" "Note" entry (file "~/org/index.org")
"* %?\n %i\n %a" :clock-in t :clock-resume t)
("i" "Idea" entry (file "~/org/ideas.org")
2024-07-14 07:18:36 +00:00
"* %? :IDEA: \n%t" :clock-in t :clock-resume t)))
(org-babel-do-load-languages
'org-babel-load-languages
'((emacs-lisp . t)
(python . t)
(org . t)
(ruby . t)
(shell . t)))
(add-hook 'org-mode-hook 'whomp/org-agenda-files-update)
(add-hook 'org-mode-hook 'visual-line-mode)
2024-12-18 15:30:28 +00:00
(defun generate-new-file-name () "Ask for a title and generate a file name based on it"
(let* ((file-name (read-string "Title: "))
(my-path (concat
"~/org/" ; Or whatever path you want
(format-time-string "%Y%m%d%H%M%S") "-"
(replace-regexp-in-string "[^a-zA-Z0-9-]+" "-" file-name) ".org"))) ; Replace invalid path characters
(setq mc/org-capture-filename file-name) ; Save variable to be used later in the template
my-path))
(setq org-capture-templates
'(
; ....
("n" "Note" entry (file (lambda () (generate-new-file-name)))
"* %(format mc/org-capture-filename) \n:PROPERTIES:\n:ID: %(org-id-new)\n:CREATED: %U\n:END:\n%?")
; ....
))
;; Org mode stuff
2024-07-14 07:18:36 +00:00
(whomp/add-key-binding "o l" 'org-store-link "Store a link to the current location in the kill ring.")
(whomp/add-key-binding "o C-l" 'org-toggle-link-display "Toggle the display of links.")
(whomp/add-key-binding "o a" 'org-agenda "Open the Org agenda.")
(whomp/add-key-binding "o n" 'org-capture "Capture a new task.")
(whomp/add-key-binding "o t" 'org-todo-list "Open the Org TODO list.")
(whomp/add-key-binding "o c i" 'org-clock-in "Clock in to the current task.")
(whomp/add-key-binding "o c o" 'org-clock-out "Clock out of the current task.")
(whomp/add-key-binding "o c r" 'org-clock-report "Generate a clock report.")
(whomp/add-key-binding "o r" 'org-refile "Refile the current task.")
(whomp/add-key-binding "o e" 'org-export-dispatch "Export the current buffer.")
(message "org-mode loaded")))
;; org-bullets
2024-07-12 23:32:01 +00:00
(when (and (memq 'orgmode whomp-orgmode) (memq 'orgbullets whomp-orgmode))
2024-07-14 07:18:36 +00:00
(use-package org-bullets
:straight t
:defer t
:config
(add-hook 'org-mode-hook (lambda () (org-bullets-mode 1)))
(message "org-bullets loaded")))
;; org-super-agenda
2024-07-12 23:32:01 +00:00
(when (and (memq 'orgmode whomp-orgmode) (memq 'orgsuperagenda whomp-orgmode))
2024-07-14 07:18:36 +00:00
(use-package org-super-agenda
:straight t
:defer t
:config
(add-hook 'org-agenda-mode-hook 'org-super-agenda-mode)
(message "org-super-agenda loaded")))
;; org-modern
2024-07-12 23:32:01 +00:00
(when (and (memq 'orgmode whomp-orgmode) (memq 'orgmodern whomp-orgmode))
2024-07-14 07:18:36 +00:00
(use-package org-modern
:straight t
:defer t
:config
(message "org-modern loaded")))
;; org-timeblock
2024-07-12 23:32:01 +00:00
(when (and (memq 'orgmode whomp-orgmode) (memq 'orgtimeblock whomp-orgmode))
2024-07-14 07:18:36 +00:00
(use-package org-timeblock
:straight t
:defer t
:config
(message "org-timeblock loaded")))
;; org-download
2024-07-12 23:32:01 +00:00
(when (and (memq 'orgmode whomp-orgmode) (memq 'orgdownload whomp-orgmode))
2024-07-10 09:09:09 +00:00
(add-hook 'dired-mode-hook 'org-download-enable)
(message "org-download loaded"))
;; org-roam
2024-07-12 23:32:01 +00:00
(when (and (memq 'orgmode whomp-orgmode) (memq 'orgroam whomp-orgmode))
2024-07-14 07:18:36 +00:00
(use-package org-roam
:straight t
:defer t
:config
(org-roam-db-autosync-mode)
(setq org-roam-v2-ack t)
(setq org-roam-directory "~/org-roam")
(setq org-roam-db-location "~/org-roam/org-roam.db")
(setq org-roam-completion-everywhere t)
(setq org-roam-capture-templates
'(("d" "default" plain "%?"
:if-new (file+head "%<%Y%m%d%H%M%S>-${slug}.org" "#+title: ${title}\n")
:unnarrowed t)))))
2024-07-14 07:18:36 +00:00
;; org-publish
2024-07-12 23:32:01 +00:00
(when (and (memq 'orgmode whomp-orgmode) (memq 'orgpublish whomp-orgmode))
(require 'ox-publish)
(setq org-publish-project-alist
'(
("org-notes"
:base-directory "~/org/"
:base-extension "org"
:publishing-directory "~/www/html/org/"
:recursive t
:publishing-function org-html-publish-to-html
:headline-levels 4 ; Just the default for this project.
:auto-preamble t
)
2024-07-12 23:32:01 +00:00
)))
;; ;; org-roam-ui
2024-07-12 23:32:01 +00:00
;; (when (and whomp-org-enable-org whomp-org-enable-org-roam whomp-org-enable-org-roam-ui)
;; (straight-use-package 'org-roam-ui)
;; (setq org-roam-ui-sync-theme t)
;; (setq org-roam-ui-follow t)
;; (setq org-roam-ui-update-on-save t))
;; org-transclusion
2024-07-12 23:32:01 +00:00
(when (and (memq 'orgmode whomp-orgmode) (memq 'orgtransclusion whomp-orgmode))
2024-07-10 09:09:09 +00:00
(straight-use-package 'org-transclusion)
(message "org-transclusion loaded"))
;; ob-mermaid
2024-07-12 23:32:01 +00:00
(when (and (memq 'orgmode whomp-orgmode) (memq 'obmermaid whomp-orgbabel))
(straight-use-package 'ob-mermaid)
(add-to-list 'org-src-lang-modes '("mermaid" . mermaid))
2024-07-10 09:09:09 +00:00
(add-to-list 'org-babel-load-languages '(mermaid . t))
(message "ob-mermaid loaded"))
2024-07-12 23:32:01 +00:00
(message "W.H.O.M.P. Org-Mode settings loaded")
(provide 'whomp-orgmode)
;; whomp-orgmode.el ends here