UP | HOME

emacs config

to bootstrap, see: bootstrap

emacs-lisp :comments both :mkdirp yes :tangle ~/.emacs.d/init.el

;; THIS IS AUTOGENERATED, ANYTHING THAT CHANGES WILL BE DESTROYED

identity

emacs-lisp :comments both :mkdirp yes :tangle ~/.emacs.d/init.el :noweb no-export

;; basics
(setq user-full-name "chee")
(setq user-mail-address "yay@chee.party")

inhibit default

this doesn’t work and i don’t know why

emacs-lisp :comments both :mkdirp yes :tangle ~/.emacs.d/init.el

(setq inhibit-default-init t)

power ๐Ÿฎฒ๐Ÿฎณ and ๐Ÿฎฒ๐Ÿฎณ speed ๐Ÿฎฒ๐Ÿฎณ

๐Ÿ‘€

emacs-lisp :comments both :mkdirp yes :tangle ~/.emacs.d/init.el

;; no gc until we’ve eaten our init
(setq gc-cons-threshold most-positive-fixnum)

(setq auto-mode-case-fold nil)

(setq inhibit-startup-screen t)

;; vv slightly slower but worth it to have an ever-present effervescent emacs
;; lisp buffer
(setq initial-major-mode 'emacs-lisp-mode)
(setq initial-scratch-message " ")

(setq idle-update-delay 0.2)

(setq native-comp-deferred-compilation t)
(setq read-process-output-max (* 1024 1024))

thanks to doom for some of these speed ideas

emacs-lisp :comments both :mkdirp yes :tangle ~/.emacs.d/init.el

(setq-default
 bidi-display-reordering 'left-to-right
 bidi-paragraph-direction 'left-to-right)

(setq enable-recursive-minibuffers t)
(setq minibuffer-prompt-properties
      '(read-only t cursor-intangible t face minibuffer-prompt))
(add-hook 'minibuffer-setup-hook #'cursor-intangible-mode)

(defun crm-indicator (args)
  (cons (concat "[CRM] " (car args)) (cdr args)))
(advice-add #'completing-read-multiple :filter-args #'crm-indicator)

(setq-default cursor-in-non-selected-windows nil)
(setq highlight-nonselected-windows nil)

(setq fast-but-imprecise-scrolling t)
(setq frame-inhibit-implied-resize t)
(setq ffap-machine-p-known 'reject)

(setq gcmh-idle-delay 3
      gcmh-high-cons-threshold 1073741824
      gcmh-verbose nil
      gc-cons-percentage 0.6)

emacs-lisp :comments both :mkdirp yes :tangle ~/.emacs.d/init.el

(setq custom-file "/dev/null")

emacs-lisp :comments :mkdirp yes :tangle ~/.emacs.d/init.el

(setq apropos-do-all t)
(setq auth-sources (list "~/.authinfo.gpg"))

utf-8

emacs-lisp :comments both :mkdirp yes :tangle ~/.emacs.d/init.el

(prefer-coding-system 'utf-8)
(when (fboundp 'set-charset-priority) (set-charset-priority 'unicode))
(setq locale-coding-system 'utf-8)

package bootstrap

straight.el and use-package.el

emacs-lisp :comments both :mkdirp yes :tangle ~/.emacs.d/init.el

;; straight & use-package config
(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 package-enable-at-startup nil)
(setq straight-check-for-modifications '(watch-files find-when-checking))
(straight-use-package 'use-package)
(straight-use-package 'diminish)
(straight-use-package 'bind-key)
(use-package async :straight t)

subword mode

it lets you move through camelCase as if they are separate word, and also kebab and snake case i really recommend this, but also a command to toggle it for when words need to be words

emacs-lisp :comments both :mkdirp yes :tangle ~/.emacs.d/init.el

(global-subword-mode t)

be more normal

dired

emacs-lisp :comments both :mkdirp yes :tangle ~/.emacs.d/init.el

(setq dired-dwim-target t)
(setq dired-mouse-drag-files t)

๐Ÿ—‘๏ธ๐Ÿฆ

emacs-lisp :comments both :mkdirp yes :tangle ~/.emacs.d/init.el

(setq delete-by-moving-to-trash nil)

parens

  • highlight the matching paren
  • highlight it immediately

emacs-lisp :comments both :mkdirp yes :tangle ~/.emacs.d/init.el

(show-paren-mode t)
(setq show-paren-delay 0)

regions

  • when text is selected, put it in the primary selection
  • when text is selected, typing something new replaces it

emacs-lisp :comments both :mkdirp yes :tangle ~/.emacs.d/init.el

(setq select-active-regions t)
(delete-selection-mode t)
(setq mouse-drag-and-drop-region t)
(setq mouse-drag-and-drop-region-cross-program t)

be more clean

  • disable weird emacs files in the cwd

emacs-lisp :comments both :mkdirp yes :tangle ~/.emacs.d/init.el

(setq backup-inhibited t)
(setq create-lockfiles nil)
(setq
 auto-save-file-name-transforms
 `((".*" ,temporary-file-directory t)))

electricity โšก

  • indent: yes
  • layout: no (maybe?)
  • pair: no, smartparens does that
  • quote: no, it’s annoying with smartparens (pressing ` gives two curlies and a backtick). fix it in post. (org exporter can render the curlies)

emacs-lisp :comments both :mkdirp yes :tangle ~/.emacs.d/init.el

(electric-indent-mode 1)
(electric-layout-mode 1)
(electric-pair-mode -1)
(electric-quote-mode -1)

when i do a git pull iโ€™d like to see whatโ€™s new, you know?

emacs-lisp :comments both :mkdirp yes :tangle ~/.emacs.d/init.el

(global-auto-revert-mode t)

emacs-lisp :comments both :mkdirp yes :tangle ~/.emacs.d/init.el

;; show me what function i'min
(which-function-mode t)
(setq-default fill-column 80)

mouse ๐Ÿlol

emacs-lisp :comments both :mkdirp yes :tangle ~/.emacs.d/init.el

(setq mouse-wheel-scroll-amount '(2 ((shift) . t)))
(setq mouse-wheel-progressive-speed nil)
;; scrolling on a window should scroll that window, even if ffm is off
(setq mouse-wheel-follow-mouse t)

focus follows ๐Ÿญ

emacs-lisp :comments both :mkdirp yes :tangle ~/.emacs.d/init.el

(setq focus-follows-mouse t)
(setq mouse-autoselect-window t)

visuals ๐Ÿ‘€

emacs-lisp :comments both :mkdirp yes :tangle ~/.emacs.d/init.el

;;(global-tab-line-mode 1)
(tool-bar-mode -1)
(menu-bar-mode -1)
(scroll-bar-mode 1)

;; TODO make this not specific to my apple macintosh air lol
(setq default-frame-alist
      '((vertical-scroll-bars . right)
        (height . 35)
        (width . 100)
        (left . 200)
        (top . 40)))

(global-goto-address-mode t)

(setq tab-always-indent 'complete)
(setq ring-bell-function 'ignore)
(setq visible-bell nil)

(add-to-list 'custom-theme-load-path "~/.emacs.d/themes/")

(setq-default line-spacing 1)

;; a nice font for editing and codeblocks
(let ((faces '(default fixed-pitch)))
  (dolist
      (face faces)
    (set-face-attribute
     face nil
     :font "Iosevka"
     :weight 'normal
     :width 'expanded
     :height 190)))

;; pretty plain text
(set-face-attribute
 'variable-pitch nil
 :family "Helvetica Neue"
 :weight 'regular
 :height 1.0)

;; this is nearly free
(load-theme 'lychee t)

feline modeline

Feline modeline, the nearly free modeline.

emacs-lisp :comments both :mkdirp yes :tangle ~/.emacs.d/init.el

(defvar chee-directory
  (expand-file-name "chee" user-emacs-directory)
  "=^.^=")

(add-to-list 'load-path chee-directory)

(use-package feline
  :straight nil
  :config (feline-mode)
  :custom
  (feline-line-prefix "L")
  (feline-column-prefix "C")
  (feline-mode-symbols
   '(emacs-lisp-mode "λ"
                     python-mode "py"
                     typescript-mode "ts"
                     rustic-mode "🦀"
                     rust-mode "🦀"
                     zig-mode "🦎"
                     scheme-mode "🐔")))

this other things

emacs-lisp :comments both :mkdirp yes :tangle ~/.emacs.d/init.el

;; making history
(savehist-mode t)
(add-hook 'after-save-hook 'executable-make-buffer-file-executable-if-script-p)
;; say yes, briefly
(defalias 'yes-or-no-p 'y-or-n-p)
(defun noop nil (interactive))

;; disabling this because it is compusing
;;(add-hook 'before-save-hook 'whitespace-cleanup)


(setq lisp-indent-function 'lisp-indent-function)
(setq native-comp-async-report-warnings-errors nil)

(unbind-key "C-<wheel-down>")
(unbind-key "C-<wheel-up>")

(add-to-list
 'auto-mode-alist
 '("PKGBUILD" . sh-mode))

(setq browse-url-browser-function 'browse-url-default-browser)

(defun byte-compile-current-buffer ()
  "`byte-compile' current buffer if it's `emacs-lisp-mode' and compiled file exists."
  (interactive)
  (when (and (eq major-mode 'emacs-lisp-mode)
             (file-exists-p (byte-compile-dest-file buffer-file-name)))
    (byte-compile-file buffer-file-name)))

(add-hook 'after-save-hook 'byte-compile-current-buffer)

(setq show-paren-context-when-offscreen t)

(defun auto-fill-comments-mode ()
  (interactive)
  (setq-local comment-auto-fill-only-comments t)
  (auto-fill-mode 1))

(add-hook 'prog-mode-hook #'auto-fill-comments-mode)

(add-hook 'compilation-finish-functions
          (lambda (buf strg)
            (let ((win  (get-buffer-window buf 'visible)))
              (when win (delete-window win)))))

env

emacs-lisp :comments both :mkdirp yes :tangle ~/.emacs.d/init.el

;; common lisp
;; (load (expand-file-name "~/programs/quicklisp/slime-helper.el") t t)
;; (setq inferior-lisp-program "sbcl")

(setenv "PATH"
        (concat "/opt/pkg/bin:/opt/homebrew/bin:/Users/chee/.cargo/bin/:/usr/local/bin:"
                (getenv "PATH")))

(add-to-list 'exec-path "/usr/local/bin")

expand region

emacs-lisp :comments both :mkdirp yes :tangle ~/.emacs.d/init.el

(use-package expand-region :straight t
  :bind ("C-c C-=" . er/expand-region)
  ("C-c C--" . er/contract-region))

emacs

This used to be a mode (chee-mode) with a map, but i can’t remember why i did that exactly? going to move it all here under (use-package emacs) and see what happens

emacs-lisp :comments both :mkdirp yes :tangle ~/.emacs.d/init.el

(use-package emacs
  :straight nil
  :config
  (put 'narrow-to-region 'disabled nil)
  (put 'narrow-to-defun 'disabled nil)
  ;; let's free up M-mouse-1
  (unbind-key "M-<mouse-1>")
  (unbind-key "M-<down-mouse-1>")
  (unbind-key "M-<drag-mouse-1>")
  ;; and mouse-three
  (unbind-key "M-<mouse-3>")
  (unbind-key "M-<down-mouse-3>")
  (unbind-key "M-<drag-mouse-3>")
  (unbind-key "<mouse-3>")
  (unbind-key "<down-mouse-3>")
  (unbind-key "<drag-mouse-3>")

  (setq mac-function-modifier 'hyper)
  (setq vc-follow-symlinks t)

  (use-package string-inflection
    :straight t)

  (defun point-at-bol-or-indentation nil
    "Check if point is at bol or bol-ish."
    (let ((point (point)))
      (or (= point (point-at-bol))
          (save-excursion (back-to-indentation) (= point (point))))))

  (defun chee/back-to-indentation-or-beginning (point)
    (interactive "d")
    (back-to-indentation)
    (if (= point (point))
        (beginning-of-line)))

  (defun chee/reindent-buffer nil (interactive)
         (save-excursion
           (mark-whole-buffer)
           (indent-for-tab-command)
           (deactivate-mark)))

  (defun shell-command-filter-region (start end command)
    (interactive
     (let (string)
       (unless (mark)
         (user-error "The mark is not set now, so there is no region"))
       (shell-command-on-region (region-beginning) (region-end)
                                (read-shell-command "Shell command? ")
                                nil t))))

  (defun shell-command-print nil
    (interactive)
    (insert
     (with-temp-buffer
       (shell-command
        (read-shell-command "Shell command? ")
        (current-buffer))
       (buffer-string))))

  (defun chee/scroll-or-bob (&optional arg)
    (interactive "P")
    (condition-case nil
        (if arg (scroll-down) (scroll-up))
      (error (if arg (goto-char (point-min))
               (goto-char (point-max))))))
  (defalias 'chee/page-down 'chee/scroll-or-bob)

  (defun chee/page-up nil
    (interactive)
    (chee/scroll-or-bob t))

  (defun chee/kill-region-or-word (start end &optional arg)
    (interactive "rN")
    (let ((kill-word (key-binding (kbd "M-d"))) (arg (or arg 1)))
      (let ((arg (or arg 1)))
        (if (and (mark) (region-active-p) (not (= start end)))
            (kill-region start end)
          (kill-word (- arg))))))

  (defun chee/comment-or-uncomment-region-or-line ()
    (interactive)
    (chee/with-region-or-line 'comment-or-uncomment-region))

  (defun chee/with-region-or-line (fn)
    "Eval FN (which takes beginning and end), with region if active, or with line as region."
    (let ((region-was-active (region-active-p)))
      (if (region-active-p)
          (progn
            (funcall fn (region-beginning) (region-end))
            (set-mark (region-end))
            (goto-char (region-beginning)))
        (funcall fn (line-beginning-position) (line-end-position)))))

  (defun chee/indent-line-or-region nil
    (interactive)
    (chee/with-region-or-line 'indent-rigidly-right-to-tab-stop))

  (defun chee/unindent-line-or-region nil
    (interactive)
    (chee/with-region-or-line 'indent-rigidly-left-to-tab-stop))


  (defun chee/delete-horizontal-and-vertical-space nil
    (interactive)
    (call-interactively 'delete-horizontal-space)
    (call-interactively 'delete-blank-lines))
  :bind
  (("C-s-n" . make-frame)
   ("C-z" . ignore)
   ("s-<drag-mouse-1>" . mouse-set-region)
   ("<M-tab>" . other-window)
   ("<f5>" . eval-buffer) ;qbasic
   ("<home>" . chee/back-to-indentation-or-beginning)
   ("C-a" . chee/back-to-indentation-or-beginning)
   ("<end>" . end-of-line)
   ("C-v" . chee/page-down)
   ("M-v" . chee/page-up)
   ("M-;" . chee/comment-or-uncomment-region-or-line)
   ("C-<" . backward-sexp)
   ("C->" . forward-sexp)
   ("C-S-w" . kill-region)

   ("C-$" . shell-command-filter-region)

   ;; quic
   ("A-<left>" . previous-buffer)
   ("A-<right>" . next-buffer)

   ;; macintosh bindings
   ("s-a" . mark-whole-buffer)
   ("s-c" . kill-ring-save)
   ("s-o" . find-file)
   ("s-q" . save-bufffers-kill-terminal)
   ("s-s" . save-buffer)
   ("s-v" . yank)

   ("H-<left>" . backward-word)
   ("H-<right>" . forward-word)
   ("H-<up>" . chee/page-up)
   ("H-<down>" . chee/page-down)
   ;;("s-w" . bury-buffer)
   ("s-x" . chee/kill-region-or-word)
   ("s-{" . previous-buffer)
   ("s-}" . next-buffer)
   ("s-[" . chee/unindent-line-or-region)
   ("s-]" . chee/indent-line-or-region)
   :prefix-map chee/string-map
   :prefix "s-r"
   ("s" . subword-mode)
   ("r" . query-replace-regexp)
   ("s-r" . query-replace)))

email

email.el

emacs-lisp :comments both :mkdirp yes :tangle ~/.emacs.d/init.el

(use-package setup-email :straight nil)

org

./config/org.html

emacs-lisp :comments both :mkdirp yes :tangle ~/.emacs.d/init.el

(use-package setup-org :straight nil)

completions

emacs-lisp :comments both :mkdirp yes :tangle ~/.emacs.d/init.el

(use-package setup-completions :straight nil)

generic-x

add basic syntax highlighting for lots of files

emacs-lisp :comments both :mkdirp yes :tangle ~/.emacs.d/init.el

(use-package generic-x :straight nil)

editorconfig

emacs-lisp :comments both :mkdirp yes :tangle ~/.emacs.d/init.el

(use-package editorconfig-mode
  :straight editorconfig
  :hook prog-mode text-mode
  :config (editorconfig-mode t))

Unicode fonts

this provides me with emoji, and little running men. it takes along time to run the first time, but with persistent-soft, it only happens the first time. “iosevka” is here because it seems to have some futuristic glyphs from the Symbols for Legacy Computing block acrobat.gif pdf?

text

+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
| 🬀 | 🬁 | 🬂 | 🬃 | 🬄 | 🬅 | 🬆 | 🬇 | 🬈 | 🬉 | 🬊 | 🬋 | 🬌 | 🬍 | 🬎 | 🬏 |
+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
| 🬐 | 🬑 | 🬒 | 🬓 | 🬔 | 🬕 | 🬖 | 🬗 | 🬘 | 🬙 | 🬚 | 🬛 | 🬜 | 🬝 | 🬞 | 🬟 |
+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
| 🬠 | 🬡 | 🬢 | 🬣 | 🬤 | 🬥 | 🬦 | 🬧 | 🬨 | 🬩 | 🬪 | 🬫 | 🬬 | 🬭 | 🬮 | 🬯 |
+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
| 🬰 | 🬱 | 🬲 | 🬳 | 🬴 | 🬵 | 🬶 | 🬷 | 🬸 | 🬹 | 🬺 | 🬻 | 🬼 | 🬽 | 🬾 | 🬿 |
+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
| 🭀 | 🭁 | 🭂 | 🭃 | 🭄 | 🭅 | 🭆 | 🭇 | 🭈 | 🭉 | 🭊 | 🭋 | 🭌 | 🭍 | 🭎 | 🭏 |
+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
| 🭐 | 🭑 | 🭒 | 🭓 | 🭔 | 🭕 | 🭖 | 🭗 | 🭘 | 🭙 | 🭚 | 🭛 | 🭜 | 🭝 | 🭞 | 🭟 |
+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
| 🭠 | 🭡 | 🭢 | 🭣 | 🭤 | 🭥 | 🭦 | 🭧 | 🭨 | 🭩 | 🭪 | 🭫 | 🭬 | 🭭 | 🭮 | 🭯 |
+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
| 🭰 | 🭱 | 🭲 | 🭳 | 🭴 | 🭵 | 🭶 | 🭷 | 🭸 | 🭹 | 🭺 | 🭻 | 🭼 | 🭽 | 🭾 | 🭿 |
+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
| 🮀 | 🮁 | 🮂 | 🮃 | 🮄 | 🮅 | 🮆 | 🮇 | 🮈 | 🮉 | 🮊 | 🮋 | 🮌 | 🮍 | 🮎 | 🮏 |
+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
| 🮐 | 🮑 | 🮒 |  | 🮔 | 🮕 | 🮖 | 🮗 | 🮘 | 🮙 | 🮚 | 🮛 | 🮜 | 🮝 | 🮞 | 🮟 |
+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
| 🮠 | 🮡 | 🮢 | 🮣 | 🮤 | 🮥 | 🮦 | 🮧 | 🮨 | 🮩 | 🮪 | 🮫 | 🮬 | 🮭 | 🮮 | 🮯 |
+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
| 🮰 | 🮱 | 🮲 | 🮳 | 🮴 | 🮵 | 🮶 | 🮷 | 🮸 | 🮹 | 🮺 | 🮻 | 🮼 | 🮽 | 🮾 | 🮿 |
+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
| 🯀 | 🯁 | 🯂 | 🯃 | 🯄 | 🯅 | 🯆 | 🯇 | 🯈 | 🯉 | 🯊 |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
| 🯰 | 🯱 | 🯲 | 🯳 | 🯴 | 🯵 | 🯶 | 🯷 | 🯸 | 🯹 |   |   |   |   |   |   |
+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+

I’ve disabled unicode-fonts itself, after generating the config, because it was rebuilding its whole world on every boot.

I’ve written some code based on an incredibly trimmed down version of what it generated, and that’s what I’m including here.

It assumes you have Iosevka and Apple Color Emoji installed.

wget https://github.com/samuelngs/apple-emoji-linux/releases/download/latest/AppleColorEmoji.ttf

emacs-lisp :comments both :mkdirp yes :tangle ~/.emacs.d/init.el

(defgroup @emoji nil
  "We get emoji."
  :group 'ui)

(defcustom @emoji/fontname
  "Apple Color Emoji"
  "The emoji to use for the emoji block.  Pick something with nice animals."
  :type 'string
  :group '@emoji)

;; iosevka is the default because it has the wonderful legacy computing block,
;; starring LEFT HALF RUNNING MAN 🮲🮳
(defcustom @emoji/fallback-fontname
  "Iosevka"
  "The emoji to use as the fallback font.  Pick something with LEFT HALF RUNNING MAN."
  :type 'string
  :group '@emoji)

(defconst @emoji/ranges
  '((#x2620 . #x263f) ; some other things
    (#x2700 . #x27bf) ; dingbats
    (#x1f000 . #x1f02f) ; mahjong
    (#x1f0a0 . #x1f19b) ; cards and more
    ;; and just about everything else. big dingbat energy
    (#x1f1e6 . #x1fad7))
  "These ranges were handcrafted.  They might be wrong.")

(defun @emoji/register-font-for-range (font-name &optional range)
  "Set FONT-NAME as the fontset font for unicode codepoint RANGE."
  (set-fontset-font "fontset-default"
                    range
                    (font-spec
                     :name (format "%s:" font-name)
                     :registry "iso10646-1")))

(defun @emoji/register-fallback nil
  "Use `@emoji/fallback-fontname' as the fallback font."
  (@emoji/register-font-for-range @emoji/fallback-fontname))

(defun @emoji/register (range)
  "Use `@emoji/fontname' to cover unicode codepoint RANGE."
  (@emoji/register-font-for-range @emoji/fontname range))

(defun @emoji/lets-effing-go nil
  "Enable the emoji."
  (interactive)
  (@emoji/register-fallback)
  (mapc '@emoji/register @emoji/ranges))

(@emoji/lets-effing-go)

line numbers

  • in programming modes only
  • with 4 spaces, so it doesn’t change size as yous scroll

emacs-lisp :comments both :mkdirp yes :tangle ~/.emacs.d/init.el

(use-package display-line-numbers-mode :straight nil
  :hook prog-mode)

lua mode

emacs-lisp :comments both :mkdirp yes :tangle ~/.emacs.d/init.el

(use-package lua-mode
  :straight t
  :mode "\\.lua\\'")

eslint

emacs-lisp :comments both :mkdirp yes :tangle ~/.emacs.d/init.el

                                        ;(use-package flymake-eslint
                                        ;       )

exec-path-from-shell

this is to make sure my $PATH in emacs matches my shell’s path, so programs aren’t unexpectedly missing.

emacs-lisp :comments both :mkdirp yes :tangle ~/.emacs.d/init.el

(use-package exec-path-from-shell
  :straight t
  :config (exec-path-from-shell-initialize)
  :custom (exec-path-from-shell-check-startup-files nil))

fic-mode

highlight TODO, FIXME and BUG. also KLUDGE, but https://www.emacswiki.org/emacs/fic-mode.el

emacs-lisp :comments both :mkdirp yes :tangle ~/.emacs.d/init.el

(use-package fic-mode
  :straight t
  :hook prog-mode)

fish-mode

fish shell files

emacs-lisp :comments both :mkdirp yes :tangle ~/.emacs.d/init.el

(use-package fish-mode :straight t)

flycheck

emacs-lisp :comments both :mkdirp yes :tangle ~/.emacs.d/init.el

(use-package flycheck-mode
  :custom (flycheck-keymap-prefix (kbd "s-e"))
  :straight flycheck
  :hook prog-mode
  :config
  (global-flycheck-mode)
  (use-package flycheck-posframe-mode
    :hook prog-mode
    :custom-face
    (flycheck-posframe-background-face ((t (:background "#ffeeee"))))))

flymake

i disable its _flymake.ext files because i commit one once and it was embarassing

emacs-lisp :comments both :mkdirp yes :tangle ~/.emacs.d/init.el

(use-package flymake
  :straight t
  :defer
  :custom
  (flymake-run-in-place nil "  ;; don't create gross files please"))

emacs-lisp :comments both :mkdirp yes :tangle ~/.emacs.d/init.el

(use-package flymake-shellcheck
  :straight t
  :commands flymake-shellcheck-load
  :hook (sh-mode . flymake-shellcheck-load))

git

emacs-lisp :comments both :mkdirp yes :tangle ~/.emacs.d/init.el

(use-package git-modes :straight t)

magit

emacs-lisp :comments both :mkdirp yes :tangle ~/.emacs.d/init.el

(use-package magit
  :straight t
  :commands magit-status-mode
  :mode (("COMMIT_EDITMSG" . git-commit-mode))
  :config
  (use-package ghub :straight t)
  (use-package forge :straight t))

graphviz

emacs-lisp :comments both :mkdirp yes :tangle ~/.emacs.d/init.el

(use-package graphviz-dot
  :straight t
  :mode "\\.dot\\'")

json mode

emacs-lisp :comments both :mkdirp yes :tangle ~/.emacs.d/init.el

(use-package json-mode
  :straight t
  :mode "\\.json\'")

emacs-lisp :comments both :mkdirp yes :tangle ~/.emacs.d/init.el

(use-package dap-mode :straight t)

zig

emacs-lisp :comments both :mkdirp yes :tangle ~/.emacs.d/init.el

(use-package zig-mode :straight t)

go

emacs-lisp :comments both :mkdirp yes :tangle ~/.emacs.d/init.el

(use-package go-mode :straight t
  :mode
  ("\\.go\\'" . go-mode))

lsp

emacs-lisp :comments both :mkdirp yes :tangle ~/.emacs.d/init.el

(use-package lsp-mode
  :straight t
  :commands (lsp lsp-deferred)
  :hook
  (shell-script-mode . lsp)
  (python-mode . lsp)
  (ruby-mode . lsp)
  (sass-mode . lsp)
  (scss-mode . lsp)
  (rust-mode . lsp)
  (perl-mode . lsp)
  (swift-mode . lsp)
  (shell-script-mode . lsp)
  (typescript-mode . lsp)
  (js-mode . lsp)
  (scss-mode . lsp)
  (zig-mode . lsp)
  (go-mode . lsp)
  :bind (:map lsp-ui-doc-mode-map
              ("M-<mouse-1>" . lsp-find-definition-mouse))
  :config
  (use-package lsp-ui
    :straight t
    :custom-face
    (lsp-ui-doc-background ((t (:background "#ffffee"))))
    :config
    (define-key lsp-ui-mode-map
      [remap xref-find-definitions] #'lsp-ui-peek-find-definitions)
    (define-key lsp-ui-mode-map
      [remap xref-find-references] #'lsp-ui-peek-find-references))
  ;; https://github.com/minad/corfu/wiki
  (defun lsp:setup-completion-for-corfu ()
    (setf (alist-get 'styles (alist-get 'lsp-capf completion-category-defaults))
          '(orderless))
    (setq-local completion-at-point-functions (list (cape-capf-buster #'lsp-completion-at-point))))

  (add-hook 'lsp-mode-hook #'lsp:setup-completion-for-corfu)

  (defun lsp:big-threshold nil
    (setq-local gcmh-high-cons-threshold
                (* 2 (default-value 'gcmh-high-cons-threshold))))
  (add-hook 'lsp-mode-hook 'lsp:big-threshold)
  :commands lsp
  :custom
  ((lsp-ui-sideline-enable t "a little info over there")
   (lsp-completion-provider :none "we use corfu now baby")
   ;;(lsp-disabled-clients nil '(jsts-ls ts-ls))
   (lsp-ui-doc-enable t "a little info over here")
   (lsp-ui-doc-show-with-cursor t)
   (lsp-idle-delay 0.1 "might need to make this bigger if computers don't like it")
   (lsp-headerline-breadcrumb-enable t "it's cute!")
   (lsp-rust-analyzer-inlay-hints-mode t "analyze me papa")
   (lsp-completion-provider :capf "favoured by the team")
   (lsp-file-watch-threshold nil "i don't care, leave me alone")
   (lsp-eslint-validate '(svelte typescript js javascript))
   (lsp-typescript-server-args (--stdio --allowJs))))

python

emacs-lisp :comments both :mkdirp yes :tangle ~/.emacs.d/init.el

(use-package
  lsp-pyright
  :straight t
  :hook (python-mode . (lambda ()
                         (require 'lsp-pyright)
                         (lsp))))

autopair

emacs-lisp :comments both :mkdirp yes :tangle ~/.emacs.d/init.el

(use-package autopair
  :straight t)

nginx

emacs-lisp :comments both :mkdirp yes :tangle ~/.emacs.d/init.el

(use-package nginx-mode :straight t
  :mode "\\.nginx\\'" "nginx\\.conf\\'")

macos

emacs-lisp :comments both :mkdirp yes :tangle ~/.emacs.d/init.el

(setq mac-command-modifier 'super)
(setq mac-option-modifier 'meta)
(setq mac-right-option-modifier 'alt)

multiple cursors mode

multiple cursors mode is great, but it needs quite a bit of help to feel normal.

emacs-lisp :comments both :mkdirp yes :tangle ~/.emacs.d/init.el

(defun /mc/bind nil
  (bind-keys
   :map mc/keymap
   ("s-u" . mc/unmark-next-like-this)
   ("s-D" . mc/mark-previous-like-this)
   ("s-U" . mc/unmark-previous-like-this)
   ("s-F" . mc/mark-next-like-this)
   ("<down-mouse-1>" . mc/keyboard-quit)
   ("<mouse-1>" . mc/keyboard-quit)
   ("s-k" . mc/skip-to-next-like-this)
   ("s-K" . mc/skip-to-previous-like-this)
   ("s-n" . mc/mark-next-like-this)
   ("s-p" . mc/mark-previous-like-this)
   ("<RET>" . newline)
   ("<return>" . newline)
   :prefix-map chee/multiple-cursors-map
   :prefix "H-m"
   ("S" . mc/mark-next-symbol-like-this)
   ("s" . mc/mark-all-symbols-like-this)
   ("W" . mc/mark-next-word-like-this)
   ("w" . mc/mark-all-words-like-this)
   ("d" . mc/mark-all-words-like-this-in-defun)
   ("<down-mouse-1>" . mc/keyboard-quit))
  (remove-hook 'multiple-cursors-mode-hook '/mc/bind))

(use-package multiple-cursors
  :straight t
  :init
  (bind-keys
   ("s-d" . mc/mark-next-like-this)
   ("s-<mouse-1>" . mc/add-cursor-on-click))
  (add-hook 'multiple-cursors-mode-hook '/mc/bind))

Markdown

./config/markdown.html

emacs-lisp :comments both :mkdirp yes :tangle ~/.emacs.d/init.el

(use-package setup-markdown :straight nil)

php

emacs-lisp :comments both :mkdirp yes :tangle ~/.emacs.d/init.el

(use-package php-mode
  :mode "\\.php\\'"
  :straight t)

dirvish

emacs-lisp :comments both :mkdirp yes :tangle ~/.emacs.d/init.el

(use-package dirvish :straight t
  :init (dirvish-override-dired-mode)
  :bind (("s-\\" . dirvish-side)
         :map dirvish-mode-map
         ("f" . project-find-file)
         ("TAB" . dirvish-subtree-toggle)
         ("<mouse-1>" . dired-find-file)
         ("<mouse-2>" . dired-find-file))
  :config
  (use-package dirvish-extras)

  ;; disabling this because it breaks when it can't find an icon
  ;;(use-package all-the-icons :straight t)
  ;; disabling this because it's slow as f**k on TRAMP
  ;;(dirvish-peek-mode -1)
  :custom
  (dirvish-open-with-programs nil)
  (dirvish-default-layout '(0 0.2 0.8))
  (dirvish-subtree-always-show-state t)
  (dirvish-subtree-state-style 'arrow)
  (dirvish-attributes '(vc-state collapse git-msg file-size)))

project.el

emacs-lisp :comments both :mkdirp yes :tangle ~/.emacs.d/init.el

(use-package project
  :config
  ;; (setq project-switch-commands
  ;;    '((project-find-file "open file")
  ;;      (project-find-dir "open dir")
  ;;      (consult-ripgrep "ripgrep")
  ;;      (magit "magit")
  ;;      (project-shell-command "shell command")
  ;;      (project-async-shell-command "async shell command")))
  (defun chee/open-project nil
    "Get a view of the project."
    (interactive)
    (dirvish)
    (vterm-toggle-show)
    (windmove-up))
  (setq project-switch-commands 'chee/open-project)
  :bind-keymap ("s-p" . project-prefix-map)
  :bind (:map project-prefix-map
              ("t" . vterm)
              ("v" . magit)
              ("s-p" . project-switch-project)))

qml

emacs-lisp :comments both :mkdirp yes :tangle ~/.emacs.d/init.el

(use-package qml-mode :straight t :mode "\\.qml\\'")

restart-emacs

for restarting emacs

emacs-lisp :comments both :mkdirp yes :tangle ~/.emacs.d/init.el

(use-package restart-emacs
  :straight t
  :commands restart-emacs)

rustic mode

rustic mode is great, and it provides an org babel executor for rust too!!

emacs-lisp :comments both :mkdirp yes :tangle ~/.emacs.d/init.el

(use-package rustic
  :straight t
  :mode ("\\.rs\\'" . rustic-mode))

slime

emacs-lisp :comments both :mkdirp yes :tangle ~/.emacs.d/init.el

(use-package slime
  :commands slime-connect
  :straight t)

stylesheets

emacs-lisp :comments both :mkdirp yes :tangle ~/.emacs.d/init.el

(use-package scss-mode
  :straight t
  :mode "\\.scss\\'")
(use-package sass-mode
  :straight t
  :mode "\\.sass\\'")

emacs daemon

turning this off, it’s so cool but it fucks magit and org-protocol

emacs-lisp :comments both :mkdirp yes :tangle ~/.emacs.d/init.el

;;
;; (unless (equal (user-real-uid) 0)
;;   (unless (getenv "SSH_CONNECTION")
;;     (use-package server
;;       :init
;;       (setq server-use-tcp t)
;;       (setq server-port 2020)
;;       (defun send-server-file-to-snoot ()
;;      ;; "Put the server file on party so emacsclient there talks to the daemon here."
;;      (interactive)
;;      (copy-file "~/.emacs.d/server/server" "/ssh:party:.emacs.d/server/server" t))
;;       :config
;;       (unless
;;        (server-running-p)
;;      (server-start)
;;         (send-server-file-to-snoot)))))

i actually don’t need this as much atm, my current emacs boot time is around 60ms for gui.

emacs-lisp :comments both :mkdirp yes :tangle ~/.emacs.d/init.el

(use-package server
  :config (unless (server-running-p) (server-start)))

smartparens

emacs-lisp :comments both :mkdirp yes :tangle ~/.emacs.d/init.el

(use-package setup-smartparens)

ssh conf

emacs-lisp :comments both :mkdirp yes :tangle ~/.emacs.d/init.el

(use-package ssh-config-mode
  :straight t
  :mode "ssh/config\\'")

toml

emacs-lisp :comments both :mkdirp yes :tangle ~/.emacs.d/init.el

(use-package toml-mode
  :straight t
  :mode "\\.toml\\'")

tramp

emacs-lisp :comments both :mkdirp yes :tangle ~/.emacs.d/init.el

(use-package tramp
  :straight t
  :defer 0.5
  :config (add-to-list 'tramp-connection-properties
                       (list (regexp-quote "/ssh:party:")
                             "direct-async-process" t))
  (connection-local-set-profile-variables
   '/bin/bash
   '((explicit-shell-file-name . "/bin/bash")
     (explicit-bash-args . ("-i"))))

  (connection-local-set-profiles
   '(:application tramp :protocol "ssh" :machine "chee.party")
   '/bin/bash)

  (connection-local-set-profiles
   '(:application tramp :protocol "ssh" :machine "party")
   '/bin/bash)

  :custom
  (vc-ignore-dir-regexp
   (format "\\(%s\\)\\|\\(%s\\)"
           vc-ignore-dir-regexp
           tramp-file-name-regexp) "i will simply not use git with tramp" )
  (remote-file-name-inhibit-cache 180 "use the cached version for 2 mins")
  (tramp-use-ssh-controlmaster-options t)
  (tramp-verbose 0)
  (tramp-auto-save-directory (locate-user-emacs-file "tramp-save/"))
  (tramp-chunksize 2048)
  (tramp-default-method "ssh" "not scp!"))

emacs-lisp :comments both :mkdirp yes :tangle ~/.emacs.d/init.el

(use-package typescript-mode :straight t
  :mode   ("\\.js\\'" "\\.jsx\\'" "\\.ts\\'" "\\.tsx\\'"))

undo tree

emacs-lisp :comments both :mkdirp yes :tangle ~/.emacs.d/init.el

(use-package undo-tree
  :straight t
  :commands undo-tree-undo undo-tree-redo
  :config (global-undo-tree-mode t)
  (setq undo-tree-auto-save-history nil)
  :bind
  (("C-_" . 'undo-tree-undo)
   ("M-_" . 'undo-tree-undo)
   ("s-z" . 'undo-tree-undo)
   ("s-Z" . 'undo-tree-redo)
   ("s-y" . 'undo-tree-redo)))

vterm

emacs-lisp :comments both :mkdirp yes :tangle ~/.emacs.d/init.el :noweb no-export

(use-package vterm
  :straight t
  :custom (vterm-shell (getenv "SHELL")) (vterm-always-compile-module t)
  :config (defun vterm-cd-current-project-path nil
            "cd into current project path"
            (interactive)
            (let ((project (project-current)))
              (when project
                (vterm-insert (project-root project))
                (vterm-send "C-j"))))
  :bind (:map vterm-mode-map
              ("C-<backspace>" . vterm-send-meta-backspace)
              ("M-<left>" . vterm-send-M-b)
              ("C-c C-x" . vterm-send-C-x)
              ("C-c M-x" . vterm-send-C-x)
              ("s-v" . vterm-yank)
              ("s-c" . kill-ring-save)
              ("s-{" . previous-buffer)
              ("s-}" . next-buffer)
              ("s-<return>" . vterm-cd-current-project-path))
  :custom-face
  (vterm-color-default
   ((t (:background "<<get-color("snoot-black")>>" :foreground "<<get-color("background")>>"))))
  (vterm-color-black
   ((t (:background "<<get-color("bright-black")>>" :foreground "<<get-color("black")>>"))))
  (vterm-color-white
   ((t (:background "<<get-color("bright-white")>>" :foreground "<<get-color("white")>>"))))
  (vterm-color-yellow
   ((t (:background "<<get-color("bright-yellow")>>" :foreground "<<get-color("yellow")>>"))))
  (vterm-color-blue
   ((t (:background "<<get-color("bright-blue")>>" :foreground "<<get-color("blue")>>"))))
  (vterm-color-magenta
   ((t (:background "<<get-color("bright-magenta")>>" :foreground "<<get-color("magenta")>>"))))
  (vterm-color-green
   ((t (:background "<<get-color("bright-green")>>" :foreground "<<get-color("green")>>"))))
  (vterm-color-cyan
   ((t (:background "<<get-color("bright-cyan")>>" :foreground "<<get-color("cyan")>>"))))
  (vterm-color-yellow
   ((t (:background "<<get-color("bright-yellow")>>" :foreground "<<get-color("yellow")>>")))))

vterm toggle

emacs-lisp :comments both :mkdirp yes :tangle ~/.emacs.d/init.el

(use-package vterm-toggle
  :straight t
  :commands vterm-toggle vterm-toggle-show
  :config
  (add-to-list
   'display-buffer-alist
   '((lambda (buffer-or-name _)
       (let ((buffer (get-buffer buffer-or-name)))
         (with-current-buffer buffer
           (or (equal major-mode 'vterm-mode)
               (string-prefix-p vterm-buffer-name (buffer-name buffer))))))
     (display-buffer-reuse-window
      display-buffer-at-bottom)
     (direction . bottom)
     (inhibit-switch-frame. t)
     (window-height . 0.35)))
  :custom
  (vterm-toggle-hide-method 'delete-window)
  (vterm-toggle-scope 'project)
  :bind (("s-j" . vterm-toggle)
         :map vterm-mode-map
         ([(control return)] . vterm-toggle-insert-cd)
         ("s-j" . vterm-toggle)))

which key

emacs-lisp :comments both :mkdirp yes :tangle ~/.emacs.d/init.el

(use-package which-key
  :straight t
  :bind ("s-?" . which-key-mode)
  :config
  (defun chee/which-key-delay (seq len)
    "Delay certain sequences a little.
Reason: it's distracting when pressing C-x C-s to see a popup because it happens automatically 100 times a minute."
    (when (member seq '("C-x")) 0.5))
  (add-to-list 'which-key-delay-functions 'chee/which-key-delay)
  :custom (which-key-mode t) (which-key-idle-delay 0.01))

yaml

emacs-lisp :comments both :mkdirp yes :tangle ~/.emacs.d/init.el

(use-package yaml-mode
  :straight t
  :mode ("\\.yaml\\'" "\\.yml\\'")
  :config
  (add-hook 'yaml-mode-hook
            (lambda ()
              (setq indent-tabs-mode nil)
              (setq tab-width 2)
              (setq yaml-indent-offset 2))))

gcmh

emacs-lisp :comments both :mkdirp yes :tangle ~/.emacs.d/init.el

(use-package gcmh
  :straight t
  :init
  (setq gc-cons-threshold 100000000)
  (setq gc-cons-percentage 0.1)
  (gcmh-mode t))

bootstrap

this will get you started when setting up docfiles on a new machine.

remove :eval no before running.

after emacs closes:

  1. run emacs ~/notebook/inbox.org
  2. wait for all the packages to install
  3. M-x ~docfiles/export
  4. hmm actually you might need to import the gpg keys?
  5. M-x ~docfiles/export
  6. hmm, i should maybe distribute a built version of this in a zip for myself?

emacs-lisp :results none

(defun byte-compile-current-buffer ()
  "`byte-compile' current buffer if it's `emacs-lisp-mode' and compiled file exists."
  (interactive)
  (when (and (eq major-mode 'emacs-lisp-mode)
             (file-exists-p (byte-compile-dest-file buffer-file-name)))
    (byte-compile-file buffer-file-name)))

(setq docfiles/deets
      '(name "chee"
             email "yay@chee.party"
             zodiac "pisces"))

(org-babel-lob-ingest "../../meta/library.org")
(setq org-confirm-babel-evaluate nil) ; yeet

(mapc
 'org-babel-tangle-file
 '("./pale-rose.org"
   "./init.org"
   "./feline.org"
   "./docfiles.org"))

;;(use-package org-crypt)

(mapc
 'org-babel-tangle-file
 (directory-files "./packages/" t "\\.org$"))

(kill-emacs)

glhf

+beginsrc emacs-lisp :comments both :mkdirp yes :tangle ~/.emacs.d/init.el