dotfiles/config/dot_config/doom/config.org

11 KiB

Emacs Config

This config file is built on doom-emacs 3.0.0-pre and emacs 29.2.

Header

This header will be the first codeblock in the config file.

;;; $DOOMDIR/config.el -*- lexical-binding: t; -*-

Keybindings

These keybindings extend the default doom bindings, either because the defaults were confusing to me or because the binding did not yet exist.

Key Description State
F12 Show Org-Agenda N
Ctrl-Alt-+ Increase Font Size
Ctrl-# Toggle Line Comment
DEL Up Directory Dired
F6 Toggle Light/Dark Theme
F7 Start Org-Drill
SPC m g s Go to habit stats Org
M-UP Move line up
M-DOWN Move line down
M-LEFT Move region left
(map! :n "<f12>" #'org-agenda-list)
(map! :n "<f7>" #'org-drill)
(map! "C-M-+" #'doom/increase-font-size)
(map! "C-#" #'comment-line)
(evil-define-key 'normal dired-mode-map
  (kbd "DEL") 'dired-up-directory)

Base Config

;; Basic User Settings
(setq user-full-name "Jonathan Jenne"
      user-mail-address "johnnie@posteo.de")

;; Default Shell
;; Useful if default system shell is not bash
(setq shell-file-name (executable-find "bash"))

;; This is where all org files are sourced from
(setq +user-org-path "~/Notes/Org")

;; Display Line numbers
(setq display-line-numbers-type t)

Appearance

;; Fonts
(setq doom-font
      (font-spec :family "IBM Plex Mono" :size 18 :weight 'medium))
(setq doom-variable-pitch-font
      (font-spec :family "IBM Plex Serif" :size 18 :weight 'medium))
(setq variable-pitch
      (font-spec :family "IBM Plex Serif" :size 18 :weight 'medium))

;; Dashboard
(setq +doom-dashboard-ascii-banner-fn #'my-weebery-is-always-greater)
(remove-hook '+doom-dashboard-functions #'doom-dashboard-widget-shortmenu)
(remove-hook '+doom-dashboard-functions #'doom-dashboard-widget-footer)
(remove-hook '+doom-dashboard-functions #'doom-dashboard-widget-loaded)

;; Themes

Org Mode

Org Mode is a tool for note taking, habit tracking, writing, outlining and much much more. You might have heard of it already.

There are a few things to point out here:

  • org-drill items are excluded from the agenda
  • toc headings are excluded from exports
(use-package! org
  :config
  (setq ;; General
   org-directory +user-org-path
   org-src-tab-acts-natively t

   ;; Org Export
   org-export-exclude-tags '("toc")

   ;; Org Agenda
   org-agenda-show-all-dates t
   org-agenda-span 4
   org-agenda-start-day "+0d"
   org-agenda-tag-filter-preset '("-drill")
   org-agenda-time-grid
   '((daily today require-timed)
     (800 1000 1200 1400 1600 1800 2000)
     " ┄┄┄┄┄ " "┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄")
   org-agenda-current-time-string
   "◀── now ──────────────────────────────────────────────── \\o/"
   org-agenda-block-separator ?─
   ;; Consider all org files part of the org-agenda
   org-agenda-files (list +user-org-path)
   ;; org-agenda-spillover-skip-function '(org-agenda-skip-entry-if 'todo 'done)

   ;; Org Todo
   org-todo-keywords
   '((sequence "TODO(t)" "|" "DONE(d)")
     (sequence "THIS(T)" "EXAMPLE"))

   ;; Org Capture
   +org-capture-notes-file (org-path "Notes.org")
   +org-capture-todo-file (org-path "Todo.org")
   +org-capture-journal-file (org-path "Journal.org")
   +org-capture-cooking-file (org-path "Cooking.org")
   +org-capture-nepali-file (org-path "Nepali.org")
   org-capture-templates
   '(("t" "Personal Todo" entry
      (file +org-capture-todo-file)
      "* TODO %?\n" :prepend t)

     ("r" "Recipe" entry
      (file+headline +org-capture-cooking-file "Unsorted")
      "* NEVERMADE %?
:PROPERTIES:
:Author:
:Source:
:Sent_by:
:Yield:
:Prep_Time:
:Cook_Time:
:Total_Time:
:Cost:
:Description:
:URL:
:Added: %u
:END:

- [ ] Ingredient 1


1. First Step")

     ("n" "Nepali")

     ("nw" "Nepali Word" entry
      (file+headline +org-capture-nepali-file "Nepali Words")
      "* %^{Nepali Word} :drill:\n%\\1\n** Answer\n%^{Translation}" :prepend t :immediate-finish t)

     ("j" "Daily Journal" entry
      (file+olp+datetree +org-capture-journal-file)
      "* %U %?\n" :prepend t)))


  :bind (:map org-mode-map ("<localleader> g s" . #'org-habit-stats-view-habit-at-point))
  :hook (org-after-todo-state-change . org-habit-stats-update-properties)
  :init
  (add-to-list 'org-modules 'org-habit)
  (add-hook 'org-export-before-processing-functions 'my-org-inline-css-hook))

Packages

doom-modeline

The doom modeline can be configured to show different information like time and date, battery info and more.

(after! doom-modeline
  (setq doom-modeline-battery t)
  (setq doom-modeline-major-mode-icon t))

(add-hook 'doom-after-init-hook #'display-battery-mode)
(add-hook 'doom-after-init-hook #'display-time-mode)

drag-stuff

With drag stuff you can use M-UP and M-DOWN to move lines. You can also mark a region and use M-LEFT and M-RIGHT to move it left and right.

(drag-stuff-global-mode t)

evil-snipe

(after! evil-snipe (setq evil-snipe-scope 'whole-visible))

heaven-and-hell

Heaven and hell is a theme switcher, which allows you to select a dark and light theme and toggle between them using a key.

(use-package! heaven-and-hell
  :ensure t
  :config
  (setq heaven-and-hell-theme-type 'dark ;; Omit to use light by default
        heaven-and-hell-themes
        '((light . doom-gruvbox-light)
          (dark . doom-gruvbox)) ;; Themes can be the list: (dark . (tsdh-dark wombat))
        heaven-and-hell-load-theme-no-confirm t)
  :hook (after-init . heaven-and-hell-init-hook)
  :bind (("<f6>" . heaven-and-hell-toggle-theme)))

hl-todo

(use-package! hl-todo
  :config
  (setq hl-todo-keyword-faces
        '(("TODO" warning bold)
          ("EXAMPLE" font-lock-keyword-face bold)
          ("HACK" font-lock-constant-face bold)
          ("DEPRECATED" font-lock-doc-face bold)
          ("NOTE" success bold)
          ("BUG" error bold)
          ("THIS" font-lock-constant-face bold)))
  :hook (org-mode . hl-todo-mode))

nov.el

(use-package! nov
  :mode ("\\.epub\\'" . nov-mode)
  :config
  (setq nov-text-width 70))

(add-hook! 'nov-mode-hook '(olivetti-mode))

olivetti

Centers the text. This is used for reading books in

;; (after! olivetti (setq olivetti-body-width 70))

(use-package! olivetti
  :init
  (add-hook! 'org-mode-hook '(olivetti-mode (lambda () (display-line-numbers-mode -1)))))

;; (add-hook! 'org-mode-hook '(olivetti-mode (lambda () (display-line-numbers-mode -1))))

org-auto-tangle

This package automatically tangles all sourceblocks in an org file whenever that file is saved. It is very handy to not have to call the tangle command everytime you save.

(use-package! org-auto-tangle
  :defer t
  :config (setq org-auto-tangle-default nil)
  :hook (org-mode . org-auto-tangle-mode))

org-drill

A package for learning and memorizing using spaced repetition, inspired by applications like Anki.

(after! org-drill
  (setq org-drill-scope 'agenda))

org-noter

A annotation tool for org-mode

(after! org-noter
  (setq org-noter-notes-search-path '("~/Notes/Org"))
  (setq org-noter-always-create-frame nil)
  (setq org-noter-doc-split-fraction '(0.75 . 0.75))
  (setq org-noter-default-notes-file-names '()))

org-roam

;; (use-package! roam
;;   :config (setq org-roam-directory "~/Notes/Org/Roam"
;;                 org-roam-dailies-directory "Daily"))

(after! org-roam
  (setq org-roam-directory "~/Notes/Org/Roam")
  (setq org-roam-dailies-directory "Daily"))

Functions

(defun org-path (filename)
  "Expand filename relative to the default org-path"
  (expand-file-name filename +user-org-path))

(defun my-org-inline-css-hook (exporter)
  "Insert custom inline css"
  (when (eq exporter 'html)
    (let* ((dir (ignore-errors (file-name-directory (buffer-file-name))))
           (path (concat dir "style.css"))
           (fallback-style (or (null dir) (null (file-exists-p path))))
           (final (if fallback-style "~/.config/doom/style.css" path))) ;; <- set your own style file path
      (setq org-html-head-include-default-style t)
      (setq org-html-head (concat
                           "<style type=\"text/css\">\n"
                           "<!--/*--><![CDATA[/*><!--*/\n"
                           (with-temp-buffer
                             (insert-file-contents final)
                             (buffer-string))
                           "/*]]>*/-->\n"
                           "</style>\n")))))

(defun my-weebery-is-always-greater ()
  (let* ((banner '("EMACS                                "
                   "███▄ ▄███▓ ▒█████   ▒█████  ▓█████▄  "
                   "▓██▒▀█▀ ██▒▒██▒  ██▒▒██▒  ██▒▒██▀ ██▌"
                   "▓██    ▓██░▒██░  ██▒▒██░  ██▒░██   █▌"
                   "▒██    ▒██ ▒██   ██░▒██   ██░░▓█▄   ▌"
                   "▒██▒   ░██▒░ ████▓▒░░ ████▓▒░░▒████▓ "
                   "░ ▒░   ░  ░░ ▒░▒░▒░ ░ ▒░▒░▒░  ▒▒▓  ▒ "
                   "░  ░      ░  ░ ▒ ▒░   ░ ▒ ▒░  ░ ▒  ▒ "
                   "░      ░   ░ ░ ░ ▒  ░ ░ ░ ▒   ░ ░  ░ "
                   "       ░       ░ ░      ░ ░     ░    "
                   "                              ░      "))
         (longest-line (apply #'max (mapcar #'length banner))))
    (put-text-property
     (point)
     (dolist (line banner (point))
       (insert (+doom-dashboard--center
                +doom-dashboard--width
                (concat line (make-string (max 0 (- longest-line (length line))) 32)))
               "\n"))
     'face 'doom-dashboard-banner)))