Kristell's Commonplace


emacs

Tags:
| Desktop | | Dotfiles |

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:

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

(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))

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-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:

(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")

12 - Home and Vehicles

("12" "12 - Home and Vehicles")

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"))