modularized config.org

This commit is contained in:
2025-04-11 21:10:53 -06:00
parent 3b58498192
commit c8afcac4c5

View File

@@ -16,6 +16,43 @@ friends to use.
+ [[https://github.com/psamim/dotfiles][Agenda/org prettify stuff]] + [[https://github.com/psamim/dotfiles][Agenda/org prettify stuff]]
+ [[https://gitlab.com/dwt1/dotfiles/-/tree/master/.config/doom][DT's original repo]] + [[https://gitlab.com/dwt1/dotfiles/-/tree/master/.config/doom][DT's original repo]]
** Variables
Below are some variables, which effect a lot of paths on the configuration,
putting these variables on top, will make it easier to make this file modular.
#+begin_src emacs-lisp :tangle ./config.el
(defvar my/org-device (or (getenv "ORG_DEVICE") "default"))
(defvar my/org-base-dir
(cond
((string= my/org-device "galaxy") "~/notes")
((string= my/org-device "workstation") "~/Documents/Notes/")
(t "~/Documents/Notes/")))
(defvar my/doom-config-dir
(cond
((string= my/org-device "galaxy") "~/.config/doom/")
((string= my/org-device "workstation") "~/Development/NixOS/dotfiles/doom/")
(t "~/.config/doom/")))
(defvar my/doom-data-dir
(cond
((string= my/org-device "galaxy") "~/.config/doom")
((string= my/org-device "workstation") "~/.local/share/doom/")
(t "~/.config/doom/")))
(defvar my/hugo-posts-dir
(cond
((string= my/org-device "galaxy") "~/portfolio/content-org/")
((string= my/org-device "workstation") "~/Development/Websites/portfolio/content-org/")
(t "~/portfolio/content-org/")))
(defvar my/org-agenda-cache-file (expand-file-name ".cache" my/org-base-dir)
"Path to the org-agenda cache file.")
(defvar my/org-always-included-agenda-files
(list
(expand-file-name "20220823172331-chores.org" my/org-base-dir))
"Org files to always include in the agenda, even if no TODOs are found.")
(defvar my/doom-template-dir (expand-file-name "templates/" my/doom-data-dir)
"Directory for org-roam capture templates.")
#+end_src
* BIBLE * BIBLE
Allows me to insert bible quotes into my org notes. Allows me to insert bible quotes into my org notes.
=NOTE= I'm not religious just for worldbuilding purposes lol. =NOTE= I'm not religious just for worldbuilding purposes lol.
@@ -49,7 +86,7 @@ bookmarks is to record where you were reading in bookmarked files.
| bookmark-save | /Save current bookmark to bookmark file/ | SPC b w | | bookmark-save | /Save current bookmark to bookmark file/ | SPC b w |
#+BEGIN_src emacs-lisp :tangle ./config.el #+BEGIN_src emacs-lisp :tangle ./config.el
(setq bookmark-default-file "~/.local/share/doom/bookmarks") (setq bookmark-default-file (expand-file-name "bookmarks" my/doom-data-dir))
(map! :leader (map! :leader
(:prefix ("b". "buffer") (:prefix ("b". "buffer")
@@ -273,37 +310,6 @@ counsel-load-theme with 'SPC h t'.
'doom-opera-light)) 'doom-opera-light))
#+end_src #+end_src
* EMMS
One of the media players available for Emacs is emms, which stands for Emacs
Multimedia System. By default, Doom Emacs does not use 'SPC m p d',' so the format
I use for these bindings is 'SPC a' plus 'key'.
| COMMAND | DESCRIPTION | KEYBINDING |
|-----------------------+---------------------------------+------------|
| emms-playlist-mode-go | /Switch to the playlist buffer/ | SPC a a |
| emms-pause | /Pause the track/ | SPC a x |
| emms-stop | /Stop the track/ | SPC a s |
| emms-previous | /Play previous track in playlist/ | SPC a p |
| emms-next | /Play next track in playlist/ | SPC a n |
#+begin_src emacs-lisp :tangle ./config.el
;; (emms-all)
;; (emms-default-players)
;; (emms-mode-line 1)
;; (emms-playing-time 1)
;; (setq emms-source-file-default-directory "~/Music/"
;; emms-playlist-buffer-name "*Music*"
;; emms-info-asynchronously t
;; emms-source-file-directory-tree-function 'emms-source-file-directory-tree-find)
;; (map! :leader
;; (:prefix ("m p d". "EMMS audio player")
;; :desc "Go to emms playlist" "a" #'emms-playlist-mode-go
;; :desc "Emms pause track" "x" #'emms-pause
;; :desc "Emms stop track" "s" #'emms-stop
;; :desc "Emms play previous track" "p" #'emms-previous
;; :desc "Emms play next track" "n" #'emms-next))
#+end_src
* EVALUATE ELISP EXPRESSIONS * EVALUATE ELISP EXPRESSIONS
Changing some keybindings from their defaults to better fit with Doom Emacs, and Changing some keybindings from their defaults to better fit with Doom Emacs, and
to avoid conflicts with my window managers which sometimes use the control key to avoid conflicts with my window managers which sometimes use the control key
@@ -486,7 +492,7 @@ Capture template for new hugo posts.
;; It is assumed that below file is present in `org-directory' ;; It is assumed that below file is present in `org-directory'
;; and that it has a "Blog Ideas" heading. It can even be a ;; and that it has a "Blog Ideas" heading. It can even be a
;; symlink pointing to the actual location of all-posts.org! ;; symlink pointing to the actual location of all-posts.org!
(file+olp "/home/jawz/Development/Websites/portfolio/content-org/posts.org" "blog") (file+olp (expand-file-name "posts.org" my/hugo-posts-dir) "blog")
(function org-hugo-new-subtree-post-capture-template)) (function org-hugo-new-subtree-post-capture-template))
)) ))
#+end_src #+end_src
@@ -612,25 +618,30 @@ non-interactively since we specify exactly what file to open. The format I use
for these bindings is 'SPC =' plus 'key' since Doom Emacs does not use 'SPC ='. for these bindings is 'SPC =' plus 'key' since Doom Emacs does not use 'SPC ='.
| PATH TO FILE | DESCRIPTION | KEYBINDING | | PATH TO FILE | DESCRIPTION | KEYBINDING |
|------------------------------+-----------------------+------------| |---------------------+-----------------------+------------|
| ~/Documents/Notes/Agenda.org | /Edit agenda file/ | SPC = a | | ../Agenda.org | /Edit agenda file/ | SPC = a |
| ~/.config/doom/config.org | /Edit doom config.org/ | SPC = c | | ../doom/config.org | /Edit doom config.org/ | SPC = c |
| ~/.config/doom/init.el | /Edit doom init.el/ | SPC = i | | ../doom/init.el | /Edit doom init.el/ | SPC = i |
| ~/.config/doom/packages.el | /Edit doom packages.el/ | SPC = p | | ../doom/packages.el | /Edit doom packages.el/ | SPC = p |
#+begin_src emacs-lisp :tangle ./config.el #+begin_src emacs-lisp :tangle ./config.el
(map! :leader (map! :leader
(:prefix ("=" . "open file") (:prefix ("=" . "open file")
:desc "Edit agenda file" "a" #'(lambda () (interactive) :desc "Edit agenda file" "a"
(find-file #'(lambda () (interactive)
"~/Documents/Notes/20220819130052-agenda.org")) (find-file (expand-file-name "20220819130052-agenda.org" my/org-base-dir)))
:desc "Edit doom config.org" "c" #'(lambda () (interactive)
(find-file :desc "Edit doom config.org" "c"
"~/Development/NixOS/dotfiles/doom/config.org")) #'(lambda () (interactive)
:desc "Edit doom init.el" "i" #'(lambda () (interactive) (find-file (expand-file-name "config.org" my/doom-config-dir)))
(find-file "~/Development/NixOS/dotfiles/doom/init.el"))
:desc "Edit doom packages.el" "p" #'(lambda () (interactive) :desc "Edit doom init.el" "i"
(find-file "~/Development/NixOS/dotfiles/doom/packages.el")))) #'(lambda () (interactive)
(find-file (expand-file-name "init.el" my/doom-config-dir)))
:desc "Edit doom packages.el" "p"
#'(lambda () (interactive)
(find-file (expand-file-name "packages.el" my/doom-config-dir)))))
#+end_src #+end_src
* LSP * LSP
@@ -662,9 +673,9 @@ Doom Emacs.
#+begin_src emacs-lisp :tangle ./config.el #+begin_src emacs-lisp :tangle ./config.el
(after! org (after! org
(setq org-directory "~/Documents/Notes/" (setq org-directory my/org-base-dir
org-id-locations-file "~/Documents/Notes/.orgids" org-id-locations-file (expand-file-name ".orgids" my/org-base-dir)
org-attach-id-dir "~/Documents/Notes/images" org-attach-id-dir (expand-file-name "images" my/org-base-dir)
org-ellipsis "" org-ellipsis ""
org-superstar-headline-bullets-list '("" "" "" "" "" "" "") org-superstar-headline-bullets-list '("" "" "" "" "" "" "")
org-superstar-item-bullet-alist '((?+ . ?+) (?- . ?-)) org-superstar-item-bullet-alist '((?+ . ?+) (?- . ?-))
@@ -677,10 +688,10 @@ Doom Emacs.
"PROJ(p)" ; A project, which usually contains other tasks "PROJ(p)" ; A project, which usually contains other tasks
"ART(a)" ; Similar to PROJ but focused on drawing "ART(a)" ; Similar to PROJ but focused on drawing
"IDEA(i)" ; Misc tasks, usually to elaborate on writing later "IDEA(i)" ; Misc tasks, usually to elaborate on writing later
"HOLD(h)" ; This task is paused/on hold because I'm a lazy fuck "HOLD(h)" ; This task on hold because I'm a lazy fuck
"|" "|"
"DONE(d)" ; Task succesfully completed "DONE(d)" ; Task succesfully completed
"CANCELED(c)") ; Task was cancelled "CANCELED(c)") ; Cancelled task
(sequence (sequence
"[ ](T)" ; A task that needs doing "[ ](T)" ; A task that needs doing
"[-](S)" ; A task in progress "[-](S)" ; A task in progress
@@ -699,22 +710,15 @@ Doom Emacs.
#+end_src #+end_src
** Org Agenda Cache ** Org Agenda Cache
Reads the `.cache` file in `~/Documents/Notes/`, which contains only Org files Reads the `.cache` file in `my/org-base-dir`, which contains only Org files
with active TODOs, and sets `org-agenda-files` accordingly. Falls back to an with active TODOs, and sets `org-agenda-files` accordingly. Falls back to an
empty list if the cache doesnt exist. empty list if the cache doesnt exist.
#+begin_src emacs-lisp :tangle ./config.el #+begin_src emacs-lisp :tangle ./config.el
(defvar my/org-agenda-cache-file "~/Documents/Notes/.cache"
"Path to the org-agenda cache file.")
(defvar my/org-always-included-agenda-files
'("~/Documents/Notes/20220823172331-chores.org")
"Org files to always include in the agenda, even if no TODOs are found.")
(defun my/update-org-agenda-cache () (defun my/update-org-agenda-cache ()
"Scan Org files and cache those with TODOs, checkboxes, or timestamped entries." "Scan Org files and cache those with TODOs, checkboxes, or timestamped entries."
(interactive) (interactive)
(let* ((org-dir "~/Documents/Notes/") (let* ((org-dir my/org-base-dir)
(files (directory-files-recursively org-dir "\\.org$")) (files (directory-files-recursively org-dir "\\.org$"))
(todo-files '()) (todo-files '())
(regex (concat (regex (concat
@@ -837,39 +841,44 @@ templates for dailies, and nodes.
| org-roam-dailies-find-yesterday | org roam dailies find yesterday | SPC n r d y | | org-roam-dailies-find-yesterday | org roam dailies find yesterday | SPC n r d y |
#+begin_src emacs-lisp :tangle ./config.el #+begin_src emacs-lisp :tangle ./config.el
(setq deft-directory "~/Documents/Notes/") (setq deft-directory my/org-base-dir)
(use-package org-roam (use-package org-roam
:ensure t :ensure t
:custom :custom
(org-roam-directory "~/Documents/Notes/") (org-roam-directory my/org-base-dir)
(org-roam-completion-everywhere t) (org-roam-completion-everywhere t)
(org-roam-dailies-capture-templates (org-roam-dailies-capture-templates
'(("d" "default" entry "* %<%I:%M %p>: %?" '(("d" "default" entry "* %<%I:%M %p>: %?"
:if-new (file+head "%<%Y-%m-%d>.org" "#+title: %<%Y-%m-%d>\n")))) :if-new (file+head "%<%Y-%m-%d>.org" "#+title: %<%Y-%m-%d>\n"))))
(org-roam-capture-templates (org-roam-capture-templates
'(("d" "default" plain `(("d" "default" plain
"%?" "%?"
:if-new (file+head "%<%Y%m%d%H%M%S>-${slug}.org" "#+title: ${title}\n") :if-new (file+head "%<%Y%m%d%H%M%S>-${slug}.org" "#+title: ${title}\n")
:unnarrowed t) :unnarrowed t)
("l" "programming language" plain ("l" "programming language" plain
(file "/home/jawz/.local/share/doom/templates/programming.org") (file ,(expand-file-name "programming.org" my/doom-template-dir))
:if-new (file+head "%<%Y%m%d%H%M%S>-${slug}.org" "#+filetags: :programming:language:${title}:\n#+title: ${title}") :if-new (file+head "%<%Y%m%d%H%M%S>-${slug}.org"
"#+filetags: :programming:language:${title}:\n#+title: ${title}")
:unnarrowed t) :unnarrowed t)
("e" "political events" plain ("e" "political events" plain
(file "/home/jawz/.local/share/doom/templates/events.org") (file ,(expand-file-name "events.org" my/doom-template-dir))
:if-new (file+head "%<%Y%m%d%H%M%S>-${slug}.org" "#+filetags: :politics:conflicts:\n#+title: ${title}") :if-new (file+head "%<%Y%m%d%H%M%S>-${slug}.org"
"#+filetags: :politics:conflicts:\n#+title: ${title}")
:unnarrowed t) :unnarrowed t)
("p" "project" plain ("p" "project" plain
"* PROJ ${title}\n%?\n* Tasks" "* PROJ ${title}\n%?\n* Tasks"
:if-new (file+head "%<%Y%m%d%H%M%S>-${slug}.org" "#+category: ${title}\n#+filetags: :project:\n#+title: ${title}") :if-new (file+head "%<%Y%m%d%H%M%S>-${slug}.org"
:unnarrowed t) "#+category: ${title}\n#+filetags: :project:\n#+title: ${title}")
)) :unnarrowed t)))
:bind() :bind()
:bind-keymap() :bind-keymap()
:config :config
(org-roam-db-autosync-mode)) (org-roam-db-autosync-mode))
(setq completion-ignore-case t) (setq completion-ignore-case t)
(set-file-template! "~/Documents/Notes/.+\\.org$" 'org-mode :ignore t) (set-file-template!
(concat (regexp-quote my/org-base-dir) ".+\\.org$")
'org-mode
:ignore t)
#+end_src #+end_src
** Org-Roam-UI ** Org-Roam-UI