Kristell's Commonplace
emacs
My emacs configuration
Startup
Emacsclient default dashboard
Makes it open dashboard.el when first opening
(setq initial-buffer-choice
(lambda ()
(get-buffer-create "*dashboard*")))
Bugfixes
(electric-indent-mode -1)
Packages
Declare repos
(setq package-archives '(("elpa" . "https://elpa.gnu.org/packages/")
("melpa" . "https://melpa.org/packages/")
("nongnu" . "https://elpa.nongnu.org/nongnu/")))
(package-initialize)
Confirm repos enabled
(unless package-archive-contents
(package-refresh-contents))
Declare packages
(require 'package)
(require 'use-package)
(setq use-package-always-ensure t)
Package configuration
These are just various packages I use. If any of them in particular need explaining, I’ll explain them individually, but the short version:
- I use use-package so I can just drop this into a different machine and it’ll download everything
- Dashboard is a homescreen
- Ivy shows command/file/etc search
- Dired-preview allows you to show images in dired (the file browser in emacs)
- Magit shows git info (I don’t use it and should uninstall it)
- Org-bullets changes bullets from just being asterisks to being whatever you want
- Org-roam gives backlinks and such to org files
- Org-roam UI gives a graph view to org-roam
- Renpy is renpy syntax highlighting
- Ox-hugo exports org-mode syntax to hugo compatible markdown
- Lua gives lua syntax highlighting
- i3wm-config-mode is i3/sway config syntax highlighting
- Dired-sidebar gives a sidebar with file view
Dashboard
https://github.com/emacs-dashboard/emacs-dashboard
The docs for this will be more helpful than I can be
(use-package dashboard
:ensure t
:config
(dashboard-setup-startup-hook)
(setq dashboard-startupify-list '(dashboard-insert-banner
dashboard-insert-newline
dashboard-insert-banner-title
dashboard-insert-newline
dashboard-insert-navigator
dashboard-insert-newline
dashboard-insert-init-info
dashboard-insert-items
dashboard-insert-newline
dashboard-insert-footer))
(setq dashboard-display-icons-p t)
(setq dashboard-icon-type 'nerd-icons)
(setq dashboard-banner-logo-title "Welcome to Fallmacs")
(setq dashboard-startup-banner "~/.face")
(setq dashboard-center-content t)
(setq dashboard-items '((bookmarks . 10)
(recents . 5)
(agenda . 5)))
(setq dashboard-item-shortcuts '((recents . "r")
(bookmarks . "m")
(agenda . "a")
(registers . "e"))))
Ivy
(use-package ivy
:ensure t
:config
(ivy-mode))
(when (commandp 'counsel-M-x)
(global-set-key [remap execute-extended-command] #'counsel-M-x))
dired-preview
dired-preview-global-mode enables it automatically in dired buffers
(use-package dired-preview
:config
(dired-preview-global-mode 1))
magit
(use-package magit
:ensure t)
org-bullets
(use-package org-bullets
:ensure t)
(add-hook 'org-mode-hook (lambda () (org-bullets-mode 1)))
org-roam
- buffer-toggle : shows backlinks
- node-find : searches nodes
- node-insert : searches nodes, then inserts a link to the node
- org-id-get-create : you need to use this one to assign an ID to a node, and I do that a lot so I keybound it
(use-package org-roam
:ensure t
:custom
(org-roam-directory "~/johnny.decimal/")
:bind (("C-c n l" . org-roam-buffer-toggle)
("C-c n f" . org-roam-node-find)
("C-c n i" . org-roam-node-insert)
("C-c n n" . org-id-get-create))
:config
(org-roam-setup))
-
org-roam UI
(use-package org-roam-ui :ensure t)
renpy
(use-package renpy)
ox-hugo
(use-package ox-hugo
:ensure t
:pin melpa
:after ox)
lua
(use-package lua-mode)
i3wm-config-mode
(use-package i3wm-config-mode)
smooth-scrolling
This makes it so that emacs scrolls smoothly instead of jumping around.
(use-package smooth-scrolling
:ensure t
:config
(smooth-scrolling-mode 1)
(setq smooth-scroll-margin 10))
visual-fill-column
(use-package visual-fill-column
:ensure t)
org-contrib
(use-package org-contrib)
(require 'ox-extra)
(ox-extras-activate '(ignore-headlines))
org-modules
-
org-habit
(setq org-modules (quote (org-habit)))
Okay but seriously why is this t by default? I spent a solid HOUR trying to figure out why my agenda wasn’t showing habits only to find out it’s because it only shows them for today by default. Whyyyyyyyy
(setq org-habit-show-habits-only-for-today nil)
org-habit-stats
(use-package org-habit-stats)
Visual
Visible bell
Flashes when at top or bottom of buffer instead of dinging
(setq visible-bell t)
Headline indent
This makes it so that instead of seeing “*” you would see " *"
The second line changes how many spaces the *s get replaced by from two to one, since it uses less screen space that way
(setq org-startup-indented t)
(setq org-indent-indentation-per-level 1)
Theme
This handles the theme I like, which is currently dracula.
The configurations turn off the heading enlargement because it makes column view look horrible.
(use-package dracula-theme
:ensure t
:config
(setq dracula-enlarge-headings nil)
(setq dracula-enlarge-doc-title 1.0)
(setq dracula-height-title-1 1.0)
(load-theme 'dracula t))
Font
(custom-set-faces
'(default ((t (
:inherit nil
:extend nil
:stipple nil
:background "#282a36"
:foreground "#f8f8f2"
:inverse-video nil
:box nil
:strike-through nil
:overline nil
:underline nil
:slant normal
:weight regular
:height 120
:width normal
:foundry "NONE"
:family "ComicShannsMono Nerd Font")))))
Disable UI elements
(scroll-bar-mode -1)
(tool-bar-mode -1)
Lines
This turns on line numbers.
(global-display-line-numbers-mode t)
Prettify symbols
This replaces items listed in the quotes with symbols listed on the right. It’s mostly here because it’s prettier, not for anything functional.
(defun org-icons ()
"Beautify org mode keywords."
(setq prettify-symbols-alist
(mapcan (lambda (x) (list x (cons (upcase (car x)) (cdr x))))
'(("#+begin_src" . ?)
("#+end_src" . ?)
("#+begin_example" . ?)
("#+end_example" . ?)
("#+header:" . ?)
("#+results:" . ?)
("#+call:" . ?)
(":properties:" . ?)
(":logbook:" . ?)
(":outline:" . ?)
(":end:" . ?)
("TODO" . ?)
("WAIT" . ?)
("DONE" . ?)
("[#A]" . ?)
("[#B]" . ?)
("[#C]" . ?)
("[ ]" . ?)
("[X]" . ?)
("[-]" . ?))))
(prettify-symbols-mode 1))
(add-hook 'org-mode-hook 'org-icons)
(setq org-ellipsis " ")
Macros
Cycle Column View
This one is kind of me-specific, and only works with 10 column views. If you want to expand it you can just add more “<down>” and “M-<up>” to the macro though.
In the file I use this in I have one top-level heading that has 10 level 2(?) headings that have #+COLUMNS: at the start, defining different column views. This just takes the one from the bottom of the list, shoves it to the top of the list, and then closes the heading, selects the main heading of the file, and re-calls column view. +begin_src elisp (defalias ‘cycle-column-view (kmacro “C-<home> C-c C-<tab> <down> <down> <down> <down> <down> <down> <down> <down> <down> <down> M-<up> M-<up> M-<up> M-<up> M-<up> M-<up> M-<up> M-<up> M-<up> <up> <tab> <down> M-x o r g - c o l u m n s <return>”)) (keymap-global-set “C-x C-k c” ‘cycle-column-view) +end_src
Org-capture templates
Some random notes about these that drove me nuts trying to find:
- To add an ID to a templte use %(org-id-new) in the same format you’d usually find in the :PROPERTIES: drawer
(setq org-capture-templates
This one is a generic test one
'(("t" "Todo" entry
(file+datetree "~/test.org")
"* Test %(org-id-new) \n - %U \n - %^{What's up?}" :tree-type month)
10 - Life Management
("1" "10 - Life Management")
11 - Living Things
("11" "11 - Living Things")
-
11.00 - Living Things Meta
("110" "11.00 - Living Things Meta")
-
11.20 - Physical Health
("112" "11.20 - Physical Health")
-
11.27 - Protective Wellbeing
So it turns out that you can split pre-selected entries by line, and even put multiple lines on things, so… time to put my staple foods into this so I can track them easier, since I have to do that now that I’m an adult with health problems.
("1127" "Protective Wellbeing" entry (file+olp+datetree "~/johnny.decimal/10_life-management.org" "11 - Living Things" "11.20 - Physical Health" "11.27 - Protective Wellbeing") "* %^{What kind of food is it? |TEMPLATE :PROPERTIES: :FAT: :CARB: :PROTEIN: :END: |White bread :PROPERTIES: :FAT: 1.5 :CARB: 23 :PROTEIN: 4 :END: |Chicken Lunch Meat :PROPERTIES: :PROPERTIES: :FAT: 4 :CARB: 1 :PROTEIN: 9 :END: |Cheese (Sliced) :PROPERTIES: :FAT: 4.5 :CARB: 2 :PROTEIN: 3 :END: |Coffee creamer :PROPERTIES: :FAT: 2 :CARB: 10 :PROTEIN: 0 :END: |Milk :PROPERTIES: :FAT: 5 :CARB: 12 :PROTEIN: 8 :END: |Yogurt :PROPERTIES: :FAT: 2.5 :CARB: 22 :PROTEIN: 7 :END:}" :prepend t :tree-type week)
-
-
11.30 - Mental Health
("113" "11.30 - Mental health")
-
11.32 - Journaling
("1132" "11.32 - Journaling")
-
Item
("1132i" "Item" item (id "c90e0413-4ac6-45d3-85be-b8e01288fb6d") "- %U %^{What's up?}" :prepend t :tree-type week)
-
Entry
("1132e" "Entry" entry (id "dfa0b518-c06b-443c-bdca-fa89f1329bb4") "* %U %^{Who hosted?} %^{What kind of thing?} %^{%\\2%\\1|1}p %^{%\\2|1}p" :prepend t :tree-type week)
-
-
-
11.80 - Personal Development
("118" "11.80 - Personal Development")
-
11.82 - Hobbies and Learning
("1182" "11.82 - Hobbies and Learning" entry (file+olp+datetree "~/johnny.decimal/10_life-management.org" "11 - Living Things" "11.80 - Personal Development" "11.82 - Hobbies, and Learning") "* %U %^{What's the thing?} :%^{What tag?}:" :prepend t :tree-type week :clock-in t)
-
12 - Home and Vehicles
("12" "12 - Home and Vehicles")
-
12.10 - Home records
("121" "12.10 - Home Records")
-
12.18 - Chores
This bit warrants some explaining:
%%\\2p
That lets you set a variable with the same name as one of the prompts.
("1218" "12.18 - Chores" entry (file+olp+datetree "~/johnny.decimal/10_life-management.org" "12 - Home and Vehicles" "12.10 - Home Records" "12.18 - Chores") "* %U %^{What type of maintenance?|Clean|Replace|Tidy} %^{What room?|Kitchen|Bathroom|Bedroom|Living_Room} %^{What item?} %^{%\\1_%\\3|1}p %^{%\\1_%\\2|1}p" :prepend t :tree-type week :clock-in t)
-
c Contact template
("c" "Contact template" entry
(file+olp "~/johnny.decimal/10_life-management.org"
"11 - Living Things"
"11.01 - Inbox" "Contact")
"* %^{Name?}
Pronouns:
- Love relationships
- Partner(s)
- Friends
- Work
- Boss
- Colleague
- Subordinate
- Mentor
- Mentee
- Family
- Group affiliations
- Attended events
- Notes
- Hobbies
- Shows
- Games
- Sex
- Pets
- Personal notes
- Conversations
- Phone calls
- Activities
- Gifts
- Ideas
- Given
- Received
- Debts
- Documents")
Bookmark
("b" "Bookmark" item
(here)
"- [[%^{What is the link?}][%^{Link description}]]")
s This is to make source blocks easier
("s" "Source block" plain
(here)
"#+begin_src %^{Language|elisp}\n%?\n#+end_src" :immediate-finish t)
zz Closing parens
Got tired of moving these parens around
))
Org-capture stop bookmarks
Org capture automatically creates a bookmark of the most recent cursor position, and I don’t like it.
(setq org-capture-bookmark nil)
Other variables
org-agenda
(setq org-agenda-remove-tags t)
(setq org-agenda-prefix-format'(
(dashboard-agenda . " ")
(agenda . " ") (todo . " ")
(tags . " ") (search . " ")))
org-use-property-inhertiance
(setq org-use-property-inheritance t)
org-tags-column
This sets how far right tags go, further negative is further right
(setq org-tags-column -67)
fill-column
(setq fill-column 78)
Icalendar
I’m pretty sure I included this because of org-caldav, which I don’t use anymore, but I’m kind of scared it’ll break something and I don’t feel like troubleshooting it rn
(setq org-icalendar-include-sexps t)
(setq org-icalendar-include-todo "all")
(setq org-icalendar-with-timestamps t)
(setq icalendar-export-sexp-enumerate-all t)
(setq icalendar-export-sexp-enumeration-days 365)
Keybindings
(setq org-support-shift-select t)
(global-set-key "\C-c\c" 'org-capture)
(global-set-key "\C-c\a" 'org-agenda)
Aliases
(setq shell-file-name "bash")
(setq shell-command-switch "-ic")
Org directory
Sets where org-mode looks for files
(setq org-directory "~/johnny.decimal/")
(setq org-agenda-files '("~/johnny.decimal/"))
Other org variable
(setq org-link-descriptive nil)
Autosave directory
This doesn’t actually work, but I’m keeping it here in case I make it work. Goal is to make the autosaves stop gunking up my actual directories.
(setq auto-save-file-name-transforms
`((".*" "~/.emacs-saves/" t)))
org-log-into-drawer
Makes org-mode log habits into a drawer
(setq org-log-into-drawer t)
Stop customize from gunking up your init.el
This stops customize from messing with your init.el file
(setq custom-file (file-truename "~/.emacs.d/custom.el"))