#+TITLE: Chris's Personal Emacs Config #+AUTHOR: Chris Cochrun * Table of Contents :toc: - [[#init][Init]] - [[#startup-performance][Startup Performance]] - [[#keep-folders-clean][Keep Folders Clean]] - [[#set-basic-ui-config][Set basic UI config]] - [[#lets-bootstrap-straightel][Let's bootstrap straight.el]] - [[#ligatures][Ligatures]] - [[#keybindings][Keybindings]] - [[#undo-tree][Undo-Tree]] - [[#better-ui][Better UI]] - [[#completion][Completion]] - [[#help][Help]] - [[#format][Format]] - [[#fennel][Fennel]] - [[#file-management][File Management]] - [[#org-mode][Org Mode]] - [[#calendar][Calendar]] - [[#magit][Magit]] - [[#eshell][Eshell]] - [[#pdf-tools][PDF-Tools]] - [[#window-management][Window Management]] - [[#garbage-collection][Garbage Collection]] - [[#early-init][Early Init]] * Init :PROPERTIES: :header-args: emacs-lisp :tangle init.el :END: This init section tangles out to =init.el=. We'll do most of our configuring here. ** Startup Performance Let's create a message that will tell us how long it takes emacs to load in order to keep an eye on performance. #+begin_src emacs-lisp ;;; init.el -*- lexical-binding: t; -*- (defun chris/display-startup-time () (message "Emacs loaded in %s with %d garbage collections." (format "%.2f seconds" (float-time (time-subtract after-init-time before-init-time))) gcs-done)) (add-hook 'emacs-startup-hook #'chris/display-startup-time) #+end_src Let's also set the =gc-cons-threshold= variable to a high setting for the remainder of our setup process to speed things up. #+begin_src emacs-lisp :tangle no (setq gc-cons-threshold 50000000) #+end_src ** Keep Folders Clean Let's use =no-littering= in order to stop emacs from filling all our folders with junk. #+begin_src emacs-lisp :tangle no (use-package no-littering) ;; no-littering doesn't set this by default so we must place ;; auto save files in the same path as it uses for sessions (setq auto-save-file-name-transforms `((".*" ,(no-littering-expand-var-file-name "auto-save/") t))) #+end_src ** Set basic UI config Let's start by making some basic ui changes like turning off the scrollbar, toolbar, menu, tooltips, and setting our font and some things. #+begin_src emacs-lisp (setq inhibit-startup-message t) (scroll-bar-mode -1) (tool-bar-mode -1) (tooltip-mode -1) (set-fringe-mode 1) (menu-bar-mode -1) (blink-cursor-mode -1) (column-number-mode +1) #+end_src In order to have this config work on both my desktop with regular joe-schmoe monitors and my laptop with new-hotness HiDPI monitor, I will set the font size if my system is the laptop to much higher. #+begin_src emacs-lisp (if (string-equal (system-name) "chris-linuxlaptop") (defvar chris/default-font-size 240) (defvar chris/default-font-size 120)) (set-face-attribute 'default nil :font "VictorMono Nerd Font" :height chris/default-font-size) (set-face-attribute 'fixed-pitch nil :font "VictorMono Nerd Font" :height chris/default-font-size) (set-face-attribute 'variable-pitch nil :font "Cantarell" :height chris/default-font-size :weight 'regular) #+end_src Then let's make sure line-numbers are relative and on. And let's turn on visual-line-mode globally. #+begin_src emacs-lisp (setq display-line-numbers-type 'relative) (global-display-line-numbers-mode +1) (add-hook 'prog-mode-hook (display-line-numbers-mode +1)) (global-visual-line-mode +1) #+end_src Let's make doc-view better #+begin_src emacs-lisp (setq doc-view-resolution 192) #+end_src Also, real quick let's make sure that ~~ works as the same as ~~ #+begin_src emacs-lisp (global-set-key (kbd "") 'keyboard-escape-quit) #+end_src ** Let's bootstrap straight.el #+begin_src emacs-lisp (defvar bootstrap-version) (let ((bootstrap-file (expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory)) (bootstrap-version 5)) (unless (file-exists-p bootstrap-file) (with-current-buffer (url-retrieve-synchronously "https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el" 'silent 'inhibit-cookies) (goto-char (point-max)) (eval-print-last-sexp))) (load bootstrap-file nil 'nomessage)) (setq straight-use-package-by-default t) (straight-use-package 'use-package) (setq use-package-verbose t) #+end_src #+begin_src emacs-lisp (use-package command-log-mode :commands command-log-mode) #+end_src #+begin_src emacs-lisp (use-package all-the-icons) #+end_src #+begin_src emacs-lisp (use-package doom-modeline :ensure t :init (doom-modeline-mode 1) (setq doom-modeline-height 35 doom-modeline-bar-width 3 all-the-icons-scale-factor 0.9)) #+end_src #+begin_src emacs-lisp (use-package doom-themes :ensure t :init (load-theme 'doom-snazzy t)) #+end_src #+begin_src emacs-lisp (use-package rainbow-delimiters :hook (prog-mode . rainbow-delimiters-mode)) #+end_src #+begin_src emacs-lisp (use-package smartparens :defer 1 :config (smartparens-global-mode +1)) #+end_src #+begin_src emacs-lisp (use-package adaptive-wrap :defer t) #+end_src #+begin_src emacs-lisp (use-package which-key :config (setq which-key-idle-delay 0.3) (which-key-mode) :defer 1) #+end_src ** Ligatures Here let's try to add ligatures to our font system since the VictorMono Nerd Font supports all ligatures being a "Nerd Font". #+begin_src emacs-lisp (let ((alist '((?! . "\\(?:!\\(?:==\\|[!=]\\)\\)") (?# . "\\(?:#\\(?:###?\\|_(\\|[!#(:=?[_{]\\)\\)") (?$ . "\\(?:\\$>\\)") (?& . "\\(?:&&&?\\)") (?* . "\\(?:\\*\\(?:\\*\\*\\|[/>]\\)\\)") (?+ . "\\(?:\\+\\(?:\\+\\+\\|[+>]\\)\\)") (?- . "\\(?:-\\(?:-[>-]\\|<<\\|>>\\|[<>|~-]\\)\\)") (?. . "\\(?:\\.\\(?:\\.[.<]\\|[.=?-]\\)\\)") (?/ . "\\(?:/\\(?:\\*\\*\\|//\\|==\\|[*/=>]\\)\\)") (?: . "\\(?::\\(?:::\\|\\?>\\|[:<-?]\\)\\)") (?\; . "\\(?:;;\\)") (?< . "\\(?:<\\(?:!--\\|\\$>\\|\\*>\\|\\+>\\|-[<>|]\\|/>\\|<[<=-]\\|=\\(?:=>\\|[<=>|]\\)\\||\\(?:||::=\\|[>|]\\)\\|~[>~]\\|[$*+/:<=>|~-]\\)\\)") (?= . "\\(?:=\\(?:!=\\|/=\\|:=\\|=[=>]\\|>>\\|[=>]\\)\\)") (?> . "\\(?:>\\(?:=>\\|>[=>-]\\|[]:=-]\\)\\)") (?? . "\\(?:\\?[.:=?]\\)") (?\[ . "\\(?:\\[\\(?:||]\\|[<|]\\)\\)") (?\ . "\\(?:\\\\/?\\)") (?\] . "\\(?:]#\\)") (?^ . "\\(?:\\^=\\)") (?_ . "\\(?:_\\(?:|?_\\)\\)") (?{ . "\\(?:{|\\)") (?| . "\\(?:|\\(?:->\\|=>\\||\\(?:|>\\|[=>-]\\)\\|[]=>|}-]\\)\\)") (?~ . "\\(?:~\\(?:~>\\|[=>@~-]\\)\\)")))) (dolist (char-regexp alist) (set-char-table-range composition-function-table (car char-regexp) `([,(cdr char-regexp) 0 font-shape-gstring])))) #+end_src ** Keybindings There are two major packages we need to get the functionality I desire. Evil and general. #+begin_src emacs-lisp (use-package evil :init (setq evil-want-integration t evil-want-keybinding nil evil-want-C-i-jump nil evil-want-C-u-scroll t evil-respect-visual-line-mode t evil-want-C-u-delete t) :config (evil-mode +1) (setq evil-undo-system 'undo-tree)) #+end_src This evil-collection package includes a lot of other evil based things. #+begin_src emacs-lisp (use-package evil-collection :after evil :config (evil-collection-init)) #+end_src #+begin_src emacs-lisp (use-package general :init (general-evil-setup) :config (general-create-definer chris/leader-keys :keymaps '(normal visual emacs) :prefix "SPC") (chris/leader-keys "b" '(:ignore t :which-key "buffer") "t" '(:ignore t :which-key "toggle") "f" '(:ignore t :which-key "file") "w" '(:ignore t :which-key "window") "s" '(:ignore t :which-key "search") "o" '(:ignore t :which-key "open") "h" '(:ignore t :which-key "help") "n" '(:ignore t :which-key "notes") "bs" '(consult-buffer :which-key "buffer search") "bd" '(kill-this-buffer :which-key "kill buffer") "bi" '(ibuffer :which-key "ibuffer") "tt" '(consult-theme :which-key "choose theme") "ff" '(find-file :which-key "find file") "fr" '(consult-recent-file :which-key "recent file") "fs" '(save-buffer :which-key "save") "hf" '(helpful-function :which-key "describe-function") "hv" '(helpful-variable :which-key "describe-variable") "hk" '(helpful-key :which-key "describe-key") "hi" '(info :which-key "info manual") "ss" '(consult-line :which-key "consult search") "ww" '(other-window :which-key "other window") "wd" '(delete-window :which-key "other window") )) #+end_src #+begin_src emacs-lisp (use-package evil-escape :after evil :init (evil-escape-mode +1) :config (setq evil-escape-key-sequence "fd" evil-escape-delay 0.3)) #+end_src ** Undo-Tree #+begin_src emacs-lisp (use-package undo-tree :defer 1 :config (global-undo-tree-mode +1) :general (general-def 'normal undo-tree-visualize-mode-map "j" 'undo-tree-visualize-redo "k" 'undo-tree-visualize-undo)) #+end_src ** Better UI *** Olivetti #+begin_src emacs-lisp (use-package olivetti :after org :config (setq olivetti-body-width 0.6 olivetti-minimum-body-width 100)) #+end_src *** TOC-ORG #+begin_src emacs-lisp (use-package toc-org :after org) #+end_src ** Completion My completion framework is a combination of packages so that everything remains seperate and lightweight. *** SELECTRUM I prefer selectrum over Ivy or Helm for completions. It is using the basic completing read system and therefore it is more inline with basic emacs. Also, let's add prescient to be able to filter selectrum well. We'll add some keybindings too for easier navigation on the home row. #+BEGIN_SRC emacs-lisp (use-package selectrum :init (selectrum-mode +1) :config (general-define-key :keymaps 'selectrum-minibuffer-map "C-j" 'selectrum-next-candidate "C-k" 'selectrum-previous-candidate "C-S-j" 'selectrum-goto-end "C-S-k" 'selectrum-goto-beginning "TAB" 'selectrum-insert-current-candidate) :commands completing-read) #+END_SRC We need prescient so we can have smarter sorting and filtering by default. Ontop of that, setting persistance in prescient makes it get better over time. #+begin_src emacs-lisp (use-package prescient :config (prescient-persist-mode +1) :after selectrum) #+end_src #+BEGIN_SRC emacs-lisp (use-package selectrum-prescient :init (selectrum-prescient-mode +1) :after selectrum) #+END_SRC #+BEGIN_SRC elisp :tangle no ;; enable company use of prescient (company-prescient-mode +1) ;; enable magit to read with prescient (setq magit-completing-read-function #'selectrum-completing-read) #+END_SRC Here we use posframe to make a prettier minibuffer. Posframe will work with EXWM with some tweaking, but I only stole some code for Ivy's posframe version, not selectrum's. So, I'll need to work on that. #+BEGIN_SRC elisp :tangle no (setq selectrum-display-action '(display-buffer-show-in-posframe)) (setq selectrum-display-action nil) (defun display-buffer-show-in-posframe (buffer _alist) (frame-root-window (posframe-show buffer :min-height 10 :min-width (/ (frame-width) 2) :internal-border-width 1 :left-fringe 18 :right-fringe 18 :parent-frame nil :z-group 'above :poshandler 'posframe-poshandler-frame-center))) (add-hook 'minibuffer-exit-hook 'posframe-delete-all) #+END_SRC #+RESULTS: This is similar but using mini-frame. Mini-frame works well, but not if using exwm. With exwm the X windows get displayed above the mini-frame, so the minibuffer isn't visible. Best to let Selectrum or Consult push the frame up and view the vertical completions below the frame. #+BEGIN_SRC elisp :tangle no (mini-frame-mode +1) (mini-frame-mode -1) (setq resize-mini-frames t) (custom-set-variables '(mini-frame-show-parameters '((top . 400) (width . 0.7) (left . 0.5)))) ;; workaround bug#44080, should be fixed in version 27.2 and above, see #169 (define-advice fit-frame-to-buffer (:around (f &rest args) dont-skip-ws-for-mini-frame) (cl-letf* ((orig (symbol-function #'window-text-pixel-size)) ((symbol-function #'window-text-pixel-size) (lambda (win from to &rest args) (apply orig (append (list win from (if (and (window-minibuffer-p win) (frame-root-window-p win) (eq t to)) nil to)) args))))) (apply f args))) #+END_SRC *** CONSULT Consult has a lot of nice functions like Ivy's Counsel functions (enhanced searching functions), lets set some of them in the keymap so they are easily used. #+begin_src emacs-lisp (use-package consult :after selectrum) #+end_src #+begin_src emacs-lisp :tangle no (map! :leader "s s" 'consult-line :leader "f r" 'consult-recent-file) #+end_src *** MARGINALIA Marginalia makes for some great decoration to our minibuffer completion items. Works great with Selectrum which does not have this out of the box. #+begin_src emacs-lisp (use-package marginalia :bind (:map minibuffer-local-map ("C-M-a" . marginalia-cycle) ;; :map embark-general-map ;; ("A" . marginalia-cycle) ) ;; The :init configuration is always executed (Not lazy!) :init ;; Must be in the :init section of use-package such that the mode gets ;; enabled right away. Note that this forces loading the package. (marginalia-mode) ;; When using Selectrum, ensure that Selectrum is refreshed when cycling annotations. (advice-add #'marginalia-cycle :after (lambda () (when (bound-and-true-p selectrum-mode) (selectrum-exhibit)))) ;; Prefer richer, more heavy, annotations over the lighter default variant. (setq marginalia-annotators '(marginalia-annotators-heavy marginalia-annotators-light nil)) :after selectrum) #+end_src ** Help #+begin_src emacs-lisp (use-package helpful :commands (helpful-callable helpful-variable helpful-command helpful-key)) #+end_src ** Format #+begin_src emacs-lisp (use-package format-all :config (format-all-mode +1) (setq format-all-formatters '("Emacs Lisp" emacs-lisp)) :defer 1) #+end_src ** Fennel I use fennel to build my awesomewm config. So, we'll need that downloaded. #+begin_src emacs-lisp (use-package fennel-mode :mode ("\\.fnl\\'" . fennel-mode)) #+end_src ** File Management *** Dired #+begin_src emacs-lisp (use-package dired :ensure nil :straight nil :general (chris/leader-keys "od" '(dired-jump :which-key "open dired here")) (general-def 'normal dired-mode-map "q" 'kill-this-buffer)) #+end_src #+begin_src emacs-lisp (use-package all-the-icons-dired :hook (dired-mode . all-the-icons-dired-mode)) #+end_src #+begin_src emacs-lisp (use-package dired-single :after dired :general (general-def 'normal dired-mode-map "h" 'dired-single-up-directory "l" 'dired-single-buffer)) #+end_src #+begin_src emacs-lisp :tangle no (use-package dired-rainbow :after dired) #+end_src #+begin_src emacs-lisp (use-package diredfl :after dired :config (diredfl-global-mode +1)) #+end_src ** Org Mode Let's start by creating a self contained function of what I'd like started on every org buffer. #+begin_src emacs-lisp (defun chris/org-mode-setup () (org-indent-mode +1) (toc-org-mode +1) (olivetti-mode +1) (display-line-numbers-mode -1)) #+end_src This is the use-package definition with a lot of customization. Need to setup auto tangle and make sure I have some structure templates for org-mode. Part of this config includes some special capture templates for my work as a youth minister. I create lessons through both org-mode and org-roam capture templates. The first part comes from org-roam, then the next is org-mode. #+begin_src emacs-lisp (use-package org :config (setq org-startup-indented t org-edit-src-content-indentation 0) (add-hook 'org-mode-hook 'chris/org-mode-setup) (org-babel-do-load-languages 'org-babel-load-languages '((emacs-lisp . t) (python . t) (shell . t))) (require 'org-tempo) (add-to-list 'org-structure-template-alist '("el" . "src emacs-lisp")) (add-to-list 'org-structure-template-alist '("py" . "src python")) (add-to-list 'org-structure-template-alist '("sh" . "src shell")) (add-to-list 'org-structure-template-alist '("q" . "quote")) (setq org-capture-templates '(("t" "Personal todo" entry (file+headline +org-capture-todo-file "Inbox") "* TODO %^{TODO name}\nSCHEDULED: %T\n%a\n%i%?" :prepend t) ("n" "Personal notes" entry (file+headline +org-capture-notes-file "Inbox") "* %u %?\n%i\n%a" :prepend t) ("j" "Journal" entry (file+olp+datetree +org-capture-journal-file) "* %U %?\n%i\n%a" :prepend t) ("p" "TFC Plan" entry (function chris/org-roam-capture-lesson-file) (file ".templates/tfcplantemplate.org") :prepend nil :jump-to-captured t :empty-lines 1) ("r" "Templates for projects") ("rt" "Project-local todo" entry (file+headline +org-capture-project-todo-file "Inbox") "* TODO %?\n%i\n%a" :prepend t) ("rn" "Project-local notes" entry (file+headline +org-capture-project-notes-file "Inbox") "* %U %?\n%i\n%a" :prepend t) ("rc" "Project-local changelog" entry (file+headline +org-capture-project-changelog-file "Unreleased") "* %U %?\n%i\n%a" :prepend t) ("o" "Centralized templates for projects") ("ot" "Project todo" entry #'+org-capture-central-project-todo-file "* TODO %?\n %i\n %a" :heading "Tasks" :prepend nil) ("on" "Project notes" entry #'+org-capture-central-project-notes-file "* %U %?\n %i\n %a" :heading "Notes" :prepend t) ("oc" "Project changelog" entry #'+org-capture-central-project-changelog-file "* %U %?\n %i\n %a" :heading "Changelog" :prepend t)) org-capture-use-agenda-date t) ;;(setq org-superstar-headline-bullets-list '("◉" "◈" "▸" "✬" "◎" "◇" "❉" "✙" "❖")) (setq org-imenu-depth 4) (setq org-odt-styles-file "/home/chris/org/style.odt") (setq org-export-with-toc nil) (setq org-export-with-author nil) (setq org-todo-keywords '((sequence "TODO(t)" "PROJ(p)" "STRT(s)" "WAIT(w)" "HOLD(h)" "|" "DONE(d)" "CNCL(c)") (sequence "[ ](T)" "[-](S)" "[?](W)" "|" "[X](D)"))) (setq org-agenda-files '("/home/chris/org/DMPREADME.org" "/home/chris/org/DMPTODO.org" "/home/chris/org/inbox.org" "/home/chris/org/notes.org" "/home/chris/org/repetition.org" "/home/chris/org/tasks.org" "/home/chris/org/tfc_plans.org" "/home/chris/org/ministry_team.org" "/home/chris/org/todo.org" "/home/chris/org/newsletter.org")) (setq org-id-method 'ts) :general (chris/leader-keys "o a" 'org-agenda "c" 'org-capture "so" 'consult-imenu)) #+end_src We need to create a lesson capture function to find our lesson files differently each time we run our TFC plan capture. This is the most unique part of my capture template. This function uses =org-roam-find-file= to pick the lesson file that I need to add my lesson plan to. This way the lesson itself is created before the plan. #+begin_src emacs-lisp (defun chris/org-roam-capture-lesson-file () "Function to return the lesson file that is needed for TFC plan capture and move to correct position for plan insertion" (interactive) (unless org-roam-mode (org-roam-mode)) (let* ((completions (org-roam--get-title-path-completions)) (title-with-tags (org-roam-completion--completing-read "Lesson: " completions)) (res (cdr (assoc title-with-tags completions))) (file-path (plist-get res :path))) (find-file file-path) (goto-char (point-min)) (search-forward "PLAN"))) #+end_src We are also going to make our config auto-tangle. This is so helpful on saving the .org file tangles out the config automatically. #+begin_src emacs-lisp (defun chris/org-babel-tangle-config () (when (string-equal (buffer-file-name) (expand-file-name "~/.dotemacs/README.org")) (let ((org-confirm-babel-evaluate nil)) (org-babel-tangle)))) (add-hook 'org-mode-hook (lambda () (add-hook 'after-save-hook #'chris/org-babel-tangle-config :append :local))) #+end_src We also need to add =evil-org= to make better keybindings. #+begin_src emacs-lisp (use-package evil-org :after org) #+end_src *** Org-Super-Agenda Super Agenda gives me a really nice way of making the agenda view look a lot better with some better information included. #+begin_src emacs-lisp (use-package org-super-agenda :after org-agenda :init (setq org-super-agenda-groups '((:name "Today" :time-grid t :scheduled today) (:name "Due Today" :deadline today) (:name "Important" :priority "A") (:name "Overdue" :time-grid t :scheduled today) (:name "Due soon" :deadline future))) :config (org-super-agenda-mode) (setq org-super-agenda-header-map nil)) #+end_src *** Org-Roam Here we are going to add org-roam. This is a note-takers paradise by adding an automatic backlinking function. Basic Org-Roam setup. We select the directory and the basic width of the Org-Roam buffer so that it doesn't take too much space on my laptop. We also want to exclude certain files from Org-Roam. All files are synced between machines using syncthing and kept in a version history. I'd like to exclude the version history from Org-Roam using =org-roam-file-exclude-regexp=. We also need to setup some capture templates to use some specific setups with my journalling. These include a space for my [[file:../../org/homework_for_life.org][Homework For Life]], tasks for the day, and how I can love on my family. #+BEGIN_SRC emacs-lisp (use-package org-roam :hook (org-load . org-roam-mode) :commands (org-roam org-roam-find-file) :config (setq org-roam-directory "~/org") (setq org-roam-buffer-width 0.25) (setq org-roam-file-exclude-regexp ".stversion.*\|.stfolder.*\|.*~.*\|.*sync.*") (setq org-roam-db-location "~/.dotemacs/org-roam.db") (setq org-roam-capture-templates '(("d" "default" plain (function org-roam--capture-get-point) "%?" :file-name "${slug}" :head "#+TITLE: ${title}\n#+AUTHOR: Chris Cochrun\n#+CREATED: %<%D - %I:%M %p>\n\nj ") ("b" "bible" plain (function org-roam--capture-get-point) "%?" :file-name "${slug}" :head "#+TITLE: ${title}\n#+AUTHOR: Chris Cochrun\n#+CREATED: %<%D - %I:%M %p>\n- tags %^G\n\n* ") ("l" "TFC Lesson" plain (function org-roam--capture-get-point) (file ".templates/lessontemplate.org") :file-name "${slug}" :head "#+TITLE: ${title}\n#+AUTHOR: Chris Cochrun\n#+CREATED: %<%D - %I:%M %p>\n"))) (setq org-roam-dailies-capture-templates '(("d" "daily" plain #'org-roam-capture--get-point "" :immediate-finish t :file-name "%<%Y-%m-%d>" :head "#+TITLE: %<%Y-%m-%d>\n#+AUTHOR: Chris Cochrun\n#+CREATED: %<%D - %I:%M %p>\n\n* HFL\n* Tasks\n* Family\n** How Do I Love Abbie?") ("b" "biblical daily" plain #'org-roam-capture--get-point "" :immediate-finish t :file-name "%<%Y-%m-%d>-bib" :head "#+TITLE: %<%Y-%m-%d> - Biblical\n#+AUTHOR: Chris Cochrun"))) :general (chris/leader-keys "nf" '(org-roam-find-file :which-key "org roam ff") "nr" 'org-roam)) #+END_SRC Org-Roam server. This let's me visualize my notes. In order to use it, I need to go to http://localhost:8080 #+BEGIN_SRC emacs-lisp (use-package org-roam-server :config (setq org-roam-server-host "127.0.0.1" org-roam-server-port 8080 org-roam-server-export-inline-images t org-roam-server-authenticate nil org-roam-server-serve-files t org-roam-server-network-label-truncate t org-roam-server-network-label-truncate-length 60 org-roam-server-network-label-wrap-length 20) :after org-roam) (add-hook 'org-roam-mode-hook org-roam-server-mode t) #+END_SRC *** Org-Superstar #+begin_src emacs-lisp (use-package org-superstar :after org :config (org-superstar-mode +1) (setq org-superstar-headline-bullets-list '("\u25c9" "\u25c8" "\u25b8" "\u25ce" "\u272c" "\u25c7" "\u2749" "\u2719" "\u2756"))) #+end_src ** Calendar #+begin_src emacs-lisp (use-package calfw :commands chris/calfw-calendar-open :config (defun chris/calfw-calendar-open () (interactive) (cfw:open-calendar-buffer :contents-sources (list (cfw:org-create-source "Cyan") ; org-agenda source (cfw:ical-create-source "NV" "https://www.nvhuskies.org/vnews/display.v?ical" "Green") ; School Calendar (cfw:ical-create-source "Outlook" "https://outlook.office365.com/owa/calendar/62a0d491bec4430e825822afd2fd1c01@tfcconnection.org/9acc5bc27ca24ce7a900c57284959f9d8242340735661296952/S-1-8-2197686000-2519837503-3687200543-3873966527/reachcalendar.ics" "Yellow") ; Outlook Calendar ))) :general (chris/leader-keys "ac" 'chris/calfw-calendar-open) (general-def cfw:calendar-mode-map "q" 'kill-this-buffer "RET" 'cfw:show-details-command) (general-def 'normal cfw:details-mode-map "q" 'cfw:details-kill-buffer-command)) #+end_src *** Calfw-Org Here we can use org as a way to create calfw sources in the calendar view. #+begin_src emacs-lisp (use-package calfw-org :after calfw) #+end_src *** Calfw-ical Here we setup an easy way to use ical as a source for calendar views. #+begin_src emacs-lisp (use-package calfw-ical :after calfw) #+end_src ** Magit Use magit, because why wouldn't you? duh! #+begin_src emacs-lisp (use-package magit :commands (magit-status magit-get-current-branch) :general (chris/leader-keys "g g" 'magit-status) :custom (magit-display-buffer-function #'magit-display-buffer-same-window-except-diff-v1)) #+end_src ** Eshell Let's add our own eshell prompt. and set the password cache to a significantly higher time in order to not need to constantly reuse my password. #+begin_src emacs-lisp (use-package eshell :ensure nil :straight nil :config (require 'em-tramp) (with-eval-after-load 'esh-module ;; REVIEW: It used to work, but now the early `provide' seems to backfire. (unless (boundp 'eshell-modules-list) (load "esh-module")) ;; Don't print the banner. (push 'eshell-tramp eshell-modules-list)) (setq password-cache t password-cache-expiry 3600) (setq eshell-history-size 1024) ;;; Extra execution information (defvar chris/eshell-status-p t "If non-nil, display status before prompt.") (defvar chris/eshell-status--last-command-time nil) (make-variable-buffer-local 'chris/eshell-status--last-command-time) (defvar chris/eshell-status-min-duration-before-display 0 "If a command takes more time than this, display its duration.") (defun chris/eshell-status-display () (if chris/eshell-status--last-command-time (let ((duration (time-subtract (current-time) chris/eshell-status--last-command-time))) (setq chris/eshell-status--last-command-time nil) (when (> (time-to-seconds duration) chris/eshell-status-min-duration-before-display) (format "  %.3fs %s" (time-to-seconds duration) (format-time-string "| %F %T" (current-time))))) (format "  0.000s"))) (defun chris/eshell-status-record () (setq chris/eshell-status--last-command-time (current-time))) (add-hook 'eshell-pre-command-hook 'chris/eshell-status-record) (setq eshell-prompt-function (lambda nil (let ((path (abbreviate-file-name (eshell/pwd)))) (concat (if (or (string= system-name "archdesktop") (string= system-name "chris-linuxlaptop")) nil (format (propertize "\n(%s@%s)" 'face '(:foreground "#606580")) (propertize (user-login-name) 'face '(:inherit compilation-warning)) (propertize (system-name) 'face '(:inherit compilation-warning)))) (if (and (require 'magit nil t) (or (magit-get-current-branch) (magit-get-current-tag))) (let* ((root (abbreviate-file-name (magit-rev-parse "--show-toplevel"))) (after-root (substring-no-properties path (min (length path) (1+ (length root)))))) (format (propertize "\n[ %s | %s@%s ]" 'face font-lock-comment-face) (propertize root 'face `(:inherit org-warning)) (propertize after-root 'face `(:inherit org-level-1)) (propertize (or (magit-get-current-branch) (magit-get-current-tag)) 'face `(:inherit org-macro)))) (format (propertize "\n[%s]" 'face font-lock-comment-face) (propertize path 'face `(:inherit org-level-1)))) (when chris/eshell-status-p (propertize (or (chris/eshell-status-display) "") 'face font-lock-comment-face)) (propertize "\n" 'face '(:inherit org-todo :weight ultra-bold)) " ")))) ;;; If the prompt spans over multiple lines, the regexp should match ;;; last line only. (setq-default eshell-prompt-regexp "^ ") (setq eshell-destroy-buffer-when-process-dies t) :general (chris/leader-keys "oe" 'eshell) (general-def '(normal insert) eshell-mode-map "C-d" 'kill-this-buffer)) #+end_src ** PDF-Tools Let's use pdf-tools for a lot better interaction with pdfs. #+begin_src emacs-lisp (use-package pdf-tools :straight (:host github :repo "flatwhatson/pdf-tools" :branch "fix-macros") :defer 1 :config (pdf-tools-install)) #+end_src ** Window Management #+begin_src emacs-lisp (setq display-buffer-alist '(("\\*e?shell\\*" (display-buffer-in-side-window) (window-width . 0.3) (side . right)))) (setq display-buffer-alist nil) #+end_src ** Garbage Collection We set the =gc-cons-threshold= variable to really high, now lets set it back low to make sure emacs performs properly. #+begin_src emacs-lisp (setq gc-cons-threshold 2000000) #+end_src * Early Init :PROPERTIES: :header-args: emacs-lisp :tangle early-init.el :END: As of right now I haven't fully setup my early-init file, this does not export into the early-init.el file currently as it's just a copy from Doom's early-init. #+begin_src emacs-lisp :tangle early-init.el ;;; early-init.el -*- lexical-binding: t; -*- ;; Emacs 27.1 introduced early-init.el, which is run before init.el, before ;; package and UI initialization happens, and before site files are loaded. ;; A big contributor to startup times is garbage collection. We up the gc ;; threshold to temporarily prevent it from running, then reset it later by ;; enabling `gcmh-mode'. Not resetting it will cause stuttering/freezes. (setq gc-cons-threshold 50000000) (message "set gc-cons-threshold to 50000000") ;; ;; In noninteractive sessions, prioritize non-byte-compiled source files to ;; ;; prevent the use of stale byte-code. Otherwise, it saves us a little IO time ;; ;; to skip the mtime checks on every *.elc file. ;; (setq load-prefer-newer noninteractive) ;; ;; In Emacs 27+, package initialization occurs before `user-init-file' is ;; ;; loaded, but after `early-init-file'. Doom handles package initialization, so ;; ;; we must prevent Emacs from doing it early! ;; (setq package-enable-at-startup nil) ;; (fset #'package--ensure-init-file #'ignore) ; DEPRECATED Removed in 28 ;; ;; `file-name-handler-alist' is consulted on every `require', `load' and various ;; ;; path/io functions. You get a minor speed up by nooping this. However, this ;; ;; may cause problems on builds of Emacs where its site lisp files aren't ;; ;; byte-compiled and we're forced to load the *.el.gz files (e.g. on Alpine) ;; (unless (daemonp) ;; (defvar doom--initial-file-name-handler-alist file-name-handler-alist) ;; (setq file-name-handler-alist nil) ;; ;; Restore `file-name-handler-alist' later, because it is needed for handling ;; ;; encrypted or compressed files, among other things. ;; (defun doom-reset-file-handler-alist-h () ;; ;; Re-add rather than `setq', because changes to `file-name-handler-alist' ;; ;; since startup ought to be preserved. ;; (dolist (handler file-name-handler-alist) ;; (add-to-list 'doom--initial-file-name-handler-alist handler)) ;; (setq file-name-handler-alist doom--initial-file-name-handler-alist)) ;; (add-hook 'emacs-startup-hook #'doom-reset-file-handler-alist-h)) ;; ;; Ensure Doom is running out of this file's directory ;; (setq user-emacs-directory (file-name-directory load-file-name)) ;; ;; Load the heart of Doom Emacs ;; (load (concat user-emacs-directory "core/core") nil 'nomessage) #+end_src