Skip to content

Instantly share code, notes, and snippets.

@tapickell
Created August 24, 2024 15:51
Show Gist options
  • Save tapickell/687eb8e12de77f589e4d57d67bab8b16 to your computer and use it in GitHub Desktop.
Save tapickell/687eb8e12de77f589e4d57d67bab8b16 to your computer and use it in GitHub Desktop.
Doom Emacs OrgMode config
;;; $DOOMDIR/config.el -*- lexical-binding: t; -*-
;; Place your private configuration here! Remember, you do not need to run 'doom
;; sync' after modifying this file!
;; Some functionality uses this to identify you, e.g. GPG configuration, email
;; clients, file templates and snippets. It is optional.
(setq user-full-name "Todd Pickell"
user-mail-address "[email protected]")
;; Doom exposes five (optional) variables for controlling fonts in Doom:
;;
;; - `doom-font' -- the primary font to use
;; - `doom-variable-pitch-font' -- a non-monospace font (where applicable)
;; - `doom-big-font' -- used for `doom-big-font-mode'; use this for
;; presentations or streaming.
;; - `doom-symbol-font' -- for symbols
;; - `doom-serif-font' -- for the `fixed-pitch-serif' face
;;
;; See 'C-h v doom-font' for documentation and more examples of what they
;; accept. For example:
;;
;;(setq doom-font (font-spec :family "Fira Code" :size 12 :weight 'semi-light)
;; doom-variable-pitch-font (font-spec :family "Fira Sans" :size 13))
;;
;; If you or Emacs can't find your font, use 'M-x describe-font' to look them
;; up, `M-x eval-region' to execute elisp code, and 'M-x doom/reload-font' to
;; refresh your font settings. If Emacs still can't find your font, it likely
;; wasn't installed correctly. Font issues are rarely Doom issues!
;; There are two ways to load a theme. Both assume the theme is installed and
;; available. You can either set `doom-theme' or manually load a theme with the
;; `load-theme' function. This is the default:
(setq doom-theme 'doom-one)
;; This determines the style of line numbers in effect. If set to `nil', line
;; numbers are disabled. For relative line numbers, set this to `relative'.
(setq display-line-numbers-type `relative)
;; If you use `org' and don't want your org files in the default location below,
;; change `org-directory'. It must be set before org loads!
(setq org-directory "~/org/")
(setq org-roam-directory "~/org-roam/")
(setq org-roam-dailies-directory "~/org-roam/daily")
(setq org-log-done `time)
(setq org-clock-persist 'history)
(org-clock-persistence-insinuate)
(after! org-roam
(use-package! org-roam
:ensure t
:custom
(org-roam-dailies-capture-templates
'(("d" "default" entry "* %<%I:%M %p>: %?"
:if-new (file+head+olp "~/org-roam/daily/%<%Y-%m-%d>-tasks.org" "#+title: Tasks Completed %<%Y-%m-%d>\n\nlinks: [[id:5F5DEE4F-A80A-4E5E-BB9C-48F90C4FD571][dailies]]\n" ("Tasks")))))
(org-roam-capture-templates
'(("x" "default" plain
"%?"
:if-new (file+head "~/org-roam/%<%Y%m%d%H%M%S>-${slug}.org" "#+title: ${title}\n#+date: %U\n")
:unnarrowed t)
("d" "denim-dsu" plain
(file "~/org-roam/templates/dsu_template.org")
:if-new (file+head "~/org-roam/dsu/denim/%<%Y-%m-%d>-denim_dsu.org" "#+title: Denim DSU %<%Y-%m-%d>\n#+date: %U\n#+filetags: :todo:dsu:")
:unnarrowed t)
("o" "okr" plain
(file "~/org-roam/templates/okr_template.org")
:if-new (file+head "~/org-roam/okr/%<%Y-%m-%d>-okr-${slug}.org" "#+title: OKR ${title}\n#+date: %U\n#+filetags: :okr:")
:unnarrowed t)
("j" "journal" plain
(file "~/org-roam/templates/journal_template.org")
:if-new (file+head "~/org-roam/journal/%<%Y-%m-%d>-journal-${slug}.org" "#+title: Journal ${title} %<%Y-%m-%d>\n#+date: %U\n#+filetags: :journal:")
:unnarrowed t)
("q" "quote" plain
(file "~/org-roam/templates/quote_template.org")
:if-new (file+head "~/org-roam/quote/%<%Y-%m-%d>-quote-${slug}.org" "#+title: Quote ${title} %<%Y-%m-%d>\n#+date: %U\n#+filetags: :quote:")
:unnarrowed t)
("w" "writing" plain
(file "~/org-roam/templates/writing_template.org")
:if-new (file+head "~/org-roam/writing/%<%Y-%m-%d>-writing-${slug}.org" "#+title: Writing ${title} %<%Y-%m-%d>\n#+date: %U\n#+filetags: :writing:")
:unnarrowed t)
("t" "todo" plain
(file "~/org-roam/templates/todo_template.org")
:if-new (file+head "~/org-roam/todo/%<%Y-%m-%d>-todo-${slug}.org" "#+title: TODOs ${title} %<%Y-%m-%d>\n#+category: ${title} %<%Y-%m-%d>\n#+date: %U\n#+filetags: :todo:")
:unnarrowed t)
("l" "learning" plain
(file "~/org-roam/templates/learning_template.org")
:if-new (file+head "~/org-roam/learning/%<%Y-%m-%d>-learning-${slug}.org" "#+title: Learning ${title}\n#+date: %U\n#+filetags: :learning:")
:unnarrowed t)
))
:bind (("C-c b t" . org-roam-buffer-toggle)
("C-c n i" . org-roam-node-insert)
("C-c n f" . org-roam-node-find)
("C-c t a" . org-roam-tag-add)
("C-c g t" . org-roam-dailies-capture-today)
("C-c f t" . org-roam-dailies-goto-today)
("C-c f s" . flyspell-correct-next)
)
:config
(org-roam-db-autosync-enable))
(defun pkl/org-roam-filter-by-tag (tag-name)
(lambda (node)
(member tag-name (org-roam-node-tags node))))
(defun pkl/org-roam-list-notes-by-tag (tag-name)
(mapcar #'org-roam-node-file
(seq-filter
(pkl/org-roam-filter-by-tag tag-name)
(org-roam-node-list))))
(defun pkl/org-roam-refresh-agenda-list ()
(interactive)
(setq org-agenda-files (pkl/org-roam-list-notes-by-tag "todo")))
;; Build the agenda list the first time for the session
(pkl/org-roam-refresh-agenda-list)
(defun pkl/org-roam-copy-todo-to-today ()
(interactive)
(let ((org-refile-keep t) ;; Set this to nil to delete the original!
(org-after-refile-insert-hook #'save-buffer)
(org-refile-use-outline-path 'file)
today-file
pos)
(save-window-excursion
(org-roam-dailies--capture (current-time) t)
(setq today-file (buffer-file-name))
(setq pos (point)))
;; Only refile if the target file is different than the current file
(unless (equal (file-truename today-file)
(file-truename (buffer-file-name)))
(org-refile nil nil (list "Tasks" today-file nil pos)))))
(add-to-list 'org-after-todo-state-change-hook
(lambda ()
(when (equal org-state "DONE")
(pkl/org-roam-copy-todo-to-today))))
)
(add-to-list 'auto-mode-alist '("README\\.md\\|*\\.livemd'" . gfm-mode))
(after! drag-stuff
:ensure t
(map! :map evil-visual-state-map
:v "C-j" #'drag-stuff-down
:v "C-k" #'drag-stuff-up))
;; (define-key evil-visual-state-map (kbd "C-j") #'drag-stuff-down)
;; (define-key evil-visual-state-map (kbd "C-k") #'drag-stuff-up)
(define-key evil-normal-state-map (kbd "C-z") 'suspend-emacs)
;; Whenever you reconfigure a package, make sure to wrap your config in an
;; `after!' block, otherwise Doom's defaults may override your settings. E.g.
;;
;; (after! PACKAGE
;; (setq x y))
;;
;; The exceptions to this rule:
;;
;; - Setting file/directory variables (like `org-directory')
;; - Setting variables which explicitly tell you to set them before their
;; package is loaded (see 'C-h v VARIABLE' to look up their documentation).
;; - Setting doom variables (which start with 'doom-' or '+').
;;
;; Here are some additional functions/macros that will help you configure Doom.
;;
;; - `load!' for loading external *.el files relative to this one
;; - `use-package!' for configuring packages
;; - `after!' for running code after a package has loaded
;; - `add-load-path!' for adding directories to the `load-path', relative to
;; this file. Emacs searches the `load-path' when you load packages with
;; `require' or `use-package'.
;; - `map!' for binding new keys
;;
;; To get information about any of these functions/macros, move the cursor over
;; the highlighted symbol at press 'K' (non-evil users must press 'C-c c k').
;; This will open documentation for it, including demos of how they are used.
;; Alternatively, use `C-h o' to look up a symbol (functions, variables, faces,
;; etc).
;;
;; You can also try 'gd' (or 'C-c c d') to jump to their definition and see how
;; they are implemented.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment