summaryrefslogtreecommitdiff
path: root/emacs/init.el
diff options
context:
space:
mode:
authorThomas Ulmer <thomasmulmer02@gmail.com>2026-01-13 19:12:23 -0800
committerThomas Ulmer <thomasmulmer02@gmail.com>2026-01-13 19:12:23 -0800
commitd65d477b16a553cbf80011ccf96c980a65970e6c (patch)
tree7e023389598f6f03d19859d41749be820d55c44b /emacs/init.el
parent3c54c06a71c731f585b3780642d19c344ea8885d (diff)
emacs: organize and document init
Diffstat (limited to 'emacs/init.el')
-rw-r--r--emacs/init.el680
1 files changed, 358 insertions, 322 deletions
diff --git a/emacs/init.el b/emacs/init.el
index 3dba4f7..fda4b98 100644
--- a/emacs/init.el
+++ b/emacs/init.el
@@ -1,4 +1,19 @@
-;; -*- lexical-binding: t; -*-
+;;; init.el --- tmu init file -*- lexical-binding: t; -*-
+
+;;; Commentary:
+;;; This file is organized with
+;;;
+;;; Stuff that needs to be at the start (package init, some fast
+;;; startup stuff, etc)
+;;; then my custom functions and variables
+;;; then builtin customization
+;;; then external packages
+;;; then other files that contain config I don't need all the time
+;;; then things Emacs sets programtically.
+
+;;; Code:
+
+;;; Init header:
(progn ; performance stuff:
;; delay initial gc until after loading init if possible
@@ -18,19 +33,19 @@
:config
(add-hook 'after-init-hook 'benchmark-init/deactivate))
+;;; Custom definitions, with prefix "my/"
+
(defvar surround-keys '("(" "{" "[" "$" "\"" "'"))
(defun my/wrap-pair ()
- "Ensure the region is active and then insert-pair."
+ "Ensure the region is active and then \"insert-pair\"."
(interactive)
(activate-mark)
(insert-pair))
-
(eval
`(define-keymap
:full nil
:name "Surround"
:prefix 'surround-prefix
-
,@(mapcan
(lambda (key) (list key ''my/wrap-pair))
surround-keys
@@ -46,32 +61,45 @@
(defvar my/prog-cleanup-excluded-modes
'(makefile-gmake-mode makefile-mode makefile-imake-mode
- makefile-makepp-mode makefile-bsdmake-mode makefile-automake-mode))
+ makefile-makepp-mode makefile-bsdmake-mode
+ makefile-automake-mode
+ fundamental-mode)
+ "Major modes for which \"my/clean-prog-file\" should not be run before save.")
(defvar my/prog-cleanup-want-tabs-modes
'(makefile-gmake-mode makefile-mode makefile-imake-mode
- makefile-makepp-mode makefile-bsdmake-mode makefile-automake-mode))
+ makefile-makepp-mode makefile-bsdmake-mode makefile-automake-mode)
+ "Major modes that need tabs instead of spaces.
+\"my/clean-prog-file\" should convert spaces to tabs instead of tabs to spaces.")
-(defvar my/prog-cleanup-indent-max-lines 500 "Nil for no limit.")
+(defvar my/prog-cleanup-indent-max-lines 500
+ "Skip reindenting the buffer if it is longer than this many lines.
+Nil for no limit.")
(defun my/clean-prog-file (&optional buffer)
- "Fixes whitespace etc in BUFFER or current buffer."
+ "Perform whitespace cleanup and some normalization on `buffer'.
+Defaults to the current BUFFER. Converts tabs to spaces unless the
+major mode is in `my/prog-cleanup-want-tabs-modes', otherwise do the
+reverse. Delete trailing whitespace."
(unless buffer (setq buffer (current-buffer)))
(with-current-buffer buffer
(cond
- ((derived-mode-p '(c-mode c++-mode))
+ ((and (functionp 'clang-format-buffer)
+ ; safety valve for undef'd
+ (derived-mode-p '(c-mode c++-mode)))
(clang-format-buffer))
- ((not (eq major-mode 'fundamental-mode))
+ (t
(when (and my/prog-cleanup-indent-max-lines
(< (car (buffer-line-statistics buffer))
- my/prog-cleanup-indent-max-lines))
+ my/prog-cleanup-indent-max-lines))
(indent-region (point-min) (point-max)))))
- (unless (member major-mode my/prog-cleanup-want-tabs-modes)
+ (if (member major-mode my/prog-cleanup-want-tabs-modes)
+ (tabify (point-min) (point-max))
(untabify (point-min) (point-max)))
(delete-trailing-whitespace)))
(defun my/prog-buffer-setup ()
- "Do setup in for mode buffers."
+ "Do setup in for code buffers."
(superword-mode 1)
(modify-syntax-entry ?_ "w")
(hs-minor-mode 1)
@@ -83,6 +111,7 @@
(lambda ()
(unless (member major-mode my/prog-cleanup-excluded-modes)
(my/clean-prog-file)))))
+(add-hook 'prog-mode-hook 'my/prog-buffer-setup)
(defun my/wrap-region-paren ()
"Wraps the region in parens. Similar to pressing ( with the region active."
@@ -109,8 +138,8 @@
(defun my/wrap-sexp (&optional arg)
"Wraps the following sexp in a pair of parens.
-Places inside the new pair, with prefix arg do the same backwards, pushing the
-mark. Does the same of ARG number sexps if given"
+Places point inside the new pair, pushing the mark before the new pair.
+With prefix ARG do ARG number sexps if given, including backwards."
(interactive "p")
(message "%s" arg)
(if arg
@@ -120,7 +149,7 @@ mark. Does the same of ARG number sexps if given"
(insert-pair 1 ?\( ?\))))
(defun my/close-or-kill ()
- "If this is the sole frame, kill emacs. Otherwise close the frame."
+ "If this is the only frame, kill Emacs. Otherwise close the frame."
(interactive)
(save-buffers-kill-terminal))
@@ -129,15 +158,18 @@ mark. Does the same of ARG number sexps if given"
(interactive)
(let* ((win (get-buffer-window (current-buffer)))
(current (window-parameter win 'no-other-window)))
- (set-window-parameter win 'no-other-window (not current))))
-
+ (set-window-parameter win 'no-other-window (not current))
+ (force-mode-line-update)))
+;; small hack to make other window reachability visible like window dedication
(advice-add 'mode-line-window-control :around
(lambda (f) (concat (funcall f)
(if (window-parameter nil 'no-other-window) "o" "")))
'(:name "other-window-indicator"))
+;; TODO find a bind for this
(defun my/open-window-by-buffer (buffer)
- "Move focus to an extant window by the buffer it contains."
+ "Move focus to an extant window by the buffer it contains.
+If no such window exists, switch to BUFFER in the current window."
(interactive "bBuffer: ")
(let ((win (get-buffer-window buffer t)))
(if win
@@ -145,8 +177,7 @@ mark. Does the same of ARG number sexps if given"
(switch-to-buffer buffer))))
(defun my/shorten-path (path)
- "Shortens each directory in PATH except for the last directory to
-its first character."
+ "Shorten string PATH. Initialize all but the last path component."
(let* ((components (split-string path "/"))
(last-component (-last (lambda (s) (not (string-empty-p s))) components))
(shortened-components
@@ -158,9 +189,9 @@ its first character."
(mapconcat 'identity shortened-components "/")))
(defun my/swap-other-window-buffer ()
- "Try to switch the buffer contents of the current window and the
-next in the cyclic ordering. Don't involve windows that are
-dedicated."
+ "Exchange buffer contents with the next window.
+Tries to switch the buffer contents of the current window and the next
+in the cyclic ordering. Doesn't consider windows that are dedicated."
(interactive)
(let* ((cw (get-mru-window nil nil nil t))
(cb (window-buffer cw))
@@ -186,8 +217,8 @@ Useful in combination with `query-replace' for acting on the region."
(activate-mark)))
(defun my/c-x-n-to-m-n (&optional keymap)
- "Rebind the keys starting with C-x [number] to M-[number] in the
-given keymap or in the global keymap."
+ "Copy bindings from C-x [n] to M-[n] in KEYMAP, defaulting to the global
+keymap."
(unless keymap (setq keymap global-map))
(mapc (lambda (n)
(let* ((from (concat "C-x " (format "%d" n)))
@@ -213,11 +244,10 @@ given keymap or in the global keymap."
(defun my/eshell (&optional arg)
"Create a new eshell or switch to an existing one.
-With ARG, make anew shell. If the current buffer is an eshell, switch
+With ARG, make a new shell. If the current buffer is an eshell, switch
back to the previous selected buffer."
(interactive "P")
(if (eq major-mode 'eshell-mode)
- ;; switch back
(switch-to-prev-buffer)
(eshell arg)))
@@ -225,27 +255,27 @@ back to the previous selected buffer."
"Open a vc dir buffer at the project root.
With ARG, open a Dired buffer instead."
(interactive "P")
- (let ((dir (project-root(project-current t))))
+ (let ((dir (project-root (project-current t))))
(if arg
(dired dir)
(vc-dir dir))))
(defun my/kill-buffer (&optional arg)
- "Kill the current buffer.
-With ARG kill the window as well."
+ "Kill the current buffer. With ARG kill the window as well."
(interactive "P")
(if arg
(kill-buffer-and-window)
(kill-buffer)))
-(defvar my/layout-pair (cons nil nil) "Cons pair of window configurations.")
+(defvar my/layout-pair (cons nil nil)
+ "Cons pair of window configurations.")
(add-hook 'after-init-hook
(lambda ()
(setq my/layout-pair (cons (current-window-configuration)
(current-window-configuration)))))
(defun my/layout-swap (&optional arg)
- "Swap between the two saved configurations. With ARG, don't save the
-current layout."
+ "Swap between the two saved window configurations.
+With ARG, don't save the current layout."
(interactive "P")
(let ((left (car my/layout-pair))
(right (cdr my/layout-pair)))
@@ -265,8 +295,6 @@ current layout."
(add-to-list 'emulation-mode-map-alists
'((my/keys-mode . my/keys-keymap)))
- (setq delete-pair-blink-delay 0)
-
(keymap-set my/keys-mode-map "C-x C-C" 'save-buffers-kill-terminal)
(keymap-set my/keys-mode-map "C-x C-c" 'my/close-or-kill)
(keymap-set my/keys-mode-map "C-x -" 'my/swap-other-window-buffer)
@@ -293,6 +321,8 @@ current layout."
(my/keys-mode 1))
+;;; Builtin config:
+
(use-package server ; allow emacsclient
:demand t
:config
@@ -304,6 +334,208 @@ current layout."
(setq-default proced-auto-update-flag t)
(setq-default proced-auto-update-interval 1))
+(use-package dabbrev ; dynamic abbreviations
+ :demand t
+ :config
+ (add-to-list 'dabbrev-ignored-buffer-modes 'exwm-mode)
+ (add-to-list 'dabbrev-ignored-buffer-modes 'pdf-view-mode)
+ (add-to-list 'dabbrev-ignored-buffer-modes 'tags-table-mode)
+ (add-to-list 'dabbrev-ignored-buffer-modes 'doc-view-mode))
+
+(progn ; dired directory editor
+ (require 'dired)
+ (defun dired-do-find-marked-files ()
+ (interactive)
+ (seq-do 'find-file (dired-get-marked-files)))
+ (define-key dired-mode-map (kbd "C-o") 'dired-display-file)
+ (define-key dired-mode-map (kbd "F") 'dired-do-find-marked-files))
+
+(use-package ibuffer ; give a nice list of buffers with extra info
+ :commands (ibuffer)
+ :custom
+ (ibuffer-formats
+ '((mark modified read-only " "
+ (name 50 50 :left :elide) ; was originally 18
+ " "
+ (size 9 -1 :right)
+ " "
+ (mode 16 16 :left :elide)
+ " " filename-and-process)
+ (mark " "
+ (name 16 -1)
+ " " filename)))
+ :bind
+ ("C-x C-b" . ibuffer))
+
+(progn ; isearch search in buffer
+ ;; swap basic and regex binds
+ (keymap-set global-map "C-s" 'isearch-forward-regexp)
+ (keymap-set global-map "C-r" 'isearch-backward-regexp)
+ (keymap-set global-map "C-M-s" 'isearch-forward)
+ (keymap-set global-map "C-M-r" 'isearch-backward))
+
+(use-package eshell ; emacs shell
+ :demand t
+ :config
+ (use-package esh-help)
+ (require 'em-hist)
+ (require 'em-term)
+ (setup-esh-help-eldoc)
+ :bind (:map eshell-mode-map
+ ("C-l" . eshell/clear)) ; todo make smarter with centering
+ :hook (eshell-mode . eldoc-mode))
+
+(use-package ediff ; emacs interactive diff
+ :custom
+ (ediff-window-setup-function 'ediff-setup-windows-plain))
+
+(progn ; comint, doesn't play with use-package
+ (require 'comint)
+ (setq-default comint-scroll-to-bottom-on-input t)
+ (setq-default comint-scroll-to-bottom-on-output t)
+ (add-to-list 'comint-output-filter-functions #'comint-truncate-buffer)
+ (add-to-list 'comint-output-filter-functions #'ansi-color-process-output))
+
+(use-package tramp ; remote access for files
+ :demand t
+ :custom
+ (tramp-allow-unsafe-temporary-files t))
+
+(use-package asm-mode ; asm comments and tags generation
+ :demand t
+ :custom
+ (asm-comment-char ?#) ; prefer # over ; for asm comments
+ :init
+ (defun add-asm-label-tag-generation-hook ()
+ (add-hook 'after-save-hook
+ (lambda ()
+ (shell-command
+ "find . -iregex '.*\\.[sS]' -exec etags -l none -r '/\\([a-zA-Z0-9\\-_]+\\):/\1/' {} +"))
+ 0 t))
+ :hook
+ (asm-mode . 'add-asm-label-tag-generation-hook))
+
+(use-package compile ; compliation buffers and easy bind
+ :custom
+ (compilation-always-kill t)
+ (compilation-scroll-output t)
+ :bind (:map my/keys-mode-map ("M-M" . 'recompile))
+ :config
+ ;; Allow compilation buffer to be dedicated across frames
+ (add-to-list 'display-buffer-alist '("\\*compilation\\*" (nil (reusable-frames . t))))
+ (add-hook 'compilation-filter-hook #'ansi-color-compilation-filter))
+
+(use-package man ; view manuals in emacs
+ :custom
+ (Man-switches "-a"))
+
+(use-package imenu ; jump to items in the current buffer
+ :bind
+ ("M-i" . imenu)
+ :custom
+ (imenu-auto-rescan t)
+ (imenu-flatten t))
+
+(use-package xref ; jump to syntactic elements in project
+ ;; (add-hook 'xref-backend-functions 'gxref-xref-backend)
+ :bind ("M-I" . xref-find-definitions))
+
+(use-package time ; time if I want it in the modeline etc
+ :custom
+ (display-time-day-and-date t)
+ (display-time-24hr-format t))
+
+(use-package battery ; battery in modeline etc
+ )
+
+(progn ; viper, anchient vi emulation
+ (setq-default viper-want-ctl-h-help t)
+ (setq-default viper-inhibit-startup-message 't)
+ (setq-default viper-expert-level 5)
+ (setq-default viper-is-in-minibuffer nil)
+ (setq-default viper-vi-style-in-minibuffer nil)
+ (setq-default viper-enable-minibuffer-faces nil)
+ (setq-default viper-syntax-preference 'emacs)
+ (setq-default viper-ex-style-motion nil)
+ (setq-default viper-auto-indent t)
+ (setq-default viper-buffer-search-char ?g)
+ (setq viper-mode nil)
+ (require 'viper)
+ (define-key viper-vi-global-user-map (kbd "C-y") 'yank)
+ (define-key viper-vi-global-user-map (kbd "C-e") 'end-of-line)
+ (define-key viper-vi-global-user-map (kbd "C-f") 'forward-char)
+ (define-key viper-vi-global-user-map (kbd "C-b") 'backward-char)
+ (define-key viper-vi-global-user-map (kbd "C-u") 'universal-argument)
+ (define-key viper-insert-global-user-map (kbd "C-u") 'universal-argument)
+ (define-key viper-insert-global-user-map (kbd "C-d") 'delete-char)
+ (define-key viper-insert-global-user-map (kbd "C-m")
+ #'(lambda ()
+ (interactive)
+ (if completion-in-region-mode
+ (corfu-insert)
+ (viper-autoindent)))))
+
+(progn ; indent code when pasting
+ (require 'dash)
+ (defvar yank-indent-modes '(prog-mode LaTeX-mode TeX-mode)
+ "Modes in which to indent regions that are yanked (or yank-popped).")
+
+ (defun yank-indent-func (&optional arg)
+ (let* ((parents (derived-mode-all-parents major-mode))
+ (helper (lambda (acc v) (or acc (member v yank-indent-modes))))
+ (included (-reduce helper parents)))
+ (when (and (not arg) included)
+ (indent-region (region-beginning) (region-end)))))
+
+ (advice-add 'yank :after 'yank-indent-func)
+ (advice-add 'yank-pop :after 'yank-indent-func))
+
+(progn ; better commenting binds
+ (global-set-key (kbd "C-x C-;") 'comment-or-uncomment-region)
+ (global-set-key (kbd "C-x ;") 'comment-line)
+ (global-set-key (kbd "C-x :") 'comment-or-uncomment-region)
+ ;; ^ duped for terminal w/o C-;
+ )
+
+(progn ; default modeline config additions
+ (let ((dir '("" (:eval (let ((str (concat (format " [%s] " (my/shorten-path default-directory)))))
+ (add-face-text-property
+ 0 (length str)
+ '(:weight bold :foreground "green2")
+ t str)
+ str)))))
+ (push dir global-mode-string)))
+
+(progn ; comfy scratch buffer
+ (require 'iimage)
+ (setq inhibit-startup-screen t)
+ (setq initial-scratch-message
+ (concat (propertize ";; " 'invisible t)
+ "</home/tmu/.emacs.d/splashLaputa.png>
+;; scratch for lisp evaluation and unsaved text
+
+"))
+ (add-hook 'emacs-startup-hook
+ (lambda ()
+ (with-current-buffer "*scratch*"
+ (emacs-lock-mode 'kill)
+ (iimage-mode 1)))))
+
+(progn ; confirm fewer things
+ (setq kill-buffer-query-functions
+ (delq 'process-kill-buffer-query-function kill-buffer-query-functions))
+ (setq confirm-kill-processes nil)
+ (setq async-shell-command-buffer 'new-buffer)
+ (setq vc-follow-symlinks t))
+
+;; misc vars
+(setq delete-pair-blink-delay 0
+ enable-recursive-minibuffers t
+ frame-resize-pixelwise t)
+(electric-pair-mode 1)
+
+;;; External packages:
+
(use-package orderless ; ordering (minibuffer) completions
:demand t
:custom
@@ -326,8 +558,9 @@ current layout."
;; (vertico-flat-mode)
(vertico-mode 1))
-(use-package posframe)
-(use-package vertico-posframe
+(use-package posframe ; child frames inside normal frames
+ )
+(use-package vertico-posframe ; use posframes to display minibuffer
:after vertico
:demand t
:custom
@@ -385,7 +618,7 @@ current layout."
:config
(global-corfu-mode 1))
-(use-package tempel
+(use-package tempel ; templates
:demand t
:custom
(tempel-path "~/.emacs.d/templates/*.eld")
@@ -394,13 +627,9 @@ current layout."
(keymap-set tempel-map "<remap> <forward-word>" #'tempel-next)
(keymap-set tempel-map "<remap> <backward-word>" #'tempel-previous))
-(use-package dabbrev ; dynamic abbreviations
- :demand t
- :config
- (add-to-list 'dabbrev-ignored-buffer-modes 'exwm-mode)
- (add-to-list 'dabbrev-ignored-buffer-modes 'pdf-view-mode)
- (add-to-list 'dabbrev-ignored-buffer-modes 'tags-table-mode)
- (add-to-list 'dabbrev-ignored-buffer-modes 'doc-view-mode))
+(use-package tempel-collection ; other people's templates
+ :after tempel
+ :demand t)
(use-package cape ; extend completion frameworks
:demand t
@@ -408,39 +637,10 @@ current layout."
:config
(advice-add 'pcomplete-completions-at-point :around 'cape-wrap-silent)
;; (advice-add 'pcomplete-completions-at-point :around 'cape-wrap-purify)
- (defvar completion-at-point-functions-always-include
+ (defvar my/completion-at-point-functions-always-include
(list 'tags-completion-at-point-function 'cape-dabbrev 'cape-dict 'tempel-complete))
;; local settings should include t to also include global settings
- (setq completion-at-point-functions completion-at-point-functions-always-include))
-
-(use-package tempel-collection
- :after tempel
- :demand t)
-
-(progn ; dired directory editor
- (require 'dired)
- (defun dired-do-find-marked-files ()
- (interactive)
- (seq-do 'find-file (dired-get-marked-files)))
- (define-key dired-mode-map (kbd "C-o") 'dired-display-file)
- (define-key dired-mode-map (kbd "F") 'dired-do-find-marked-files))
-
-(use-package ibuffer ; give a nice list of buffers with extra info
- :commands (ibuffer)
- :custom
- (ibuffer-formats
- '((mark modified read-only " "
- (name 50 50 :left :elide) ; was originally 18
- " "
- (size 9 -1 :right)
- " "
- (mode 16 16 :left :elide)
- " " filename-and-process)
- (mark " "
- (name 16 -1)
- " " filename)))
- :bind
- ("C-x C-b" . ibuffer))
+ (setq completion-at-point-functions my/completion-at-point-functions-always-include))
(use-package ibuffer-vc ; group buffers by vcs directory
:after ibuffer
@@ -452,7 +652,8 @@ current layout."
(unless (eq ibuffer-sorting-mode 'alphabetic)
(ibuffer-do-sort-by-alphabetic)))))
-(use-package free-keys)
+(use-package free-keys ; display a list of unbound keys
+ )
(use-package which-key ; show list of next keys after prefix & delay
:demand t
@@ -464,16 +665,10 @@ current layout."
:config
(winum-mode 1))
-(use-package savehist
- :init
- (savehist-mode))
-
-(progn ; basic isearch
- ;; swap basic and regex binds
- (keymap-set global-map "C-s" 'isearch-forward-regexp)
- (keymap-set global-map "C-r" 'isearch-backward-regexp)
- (keymap-set global-map "C-M-s" 'isearch-forward)
- (keymap-set global-map "C-M-r" 'isearch-backward))
+;; (use-package savehist ; preserve minibuffer history across sessions
+;; :demand t
+;; :init
+;; (savehist-mode))
;; (use-package consult ; more encompassing buffer switch and searching
;; :demand t
@@ -491,7 +686,6 @@ current layout."
;; ("M-s f" . consult-find)
;; ;; move some standard binds
;; ("M-s s" . consult-line))
-
;; (use-package embark-consult
;; :after embark consult)
@@ -523,18 +717,7 @@ current layout."
(use-package balanced-windows ; auto rebalance windows
:bind ("C-x w b" . balanced-windows-mode))
-(use-package eshell ; emacs shell
- :demand t
- :config
- (use-package esh-help)
- (require 'em-hist)
- (require 'em-term)
- (setup-esh-help-eldoc)
- :bind (:map eshell-mode-map
- ("C-l" . eshell/clear))
- :hook (eshell-mode . eldoc-mode))
-
-(use-package eat ; terminal override to make eshell behave better
+(use-package eat ; terminal emu + make eshell behave better
:demand t
:custom
(eat-enable-auto-line-mode t)
@@ -562,22 +745,7 @@ current layout."
(eat-update-semi-char-mode-map)
(eat-eshell-update-semi-char-mode-map)))
-
-;; (add-to-list 'display-buffer-alist
-;; '("*shelldon:"
-;; (display-buffer-reuse-window display-buffer-in-previous-window display-buffer-in-side-window display-buffer-pop-up-window)
-;; (side . right)
-;; (slot . 0)
-;; (window-width . 80)))
-
-(progn ; comint, doesn't play with use-package
- (require 'comint)
- (setq-default comint-scroll-to-bottom-on-input t)
- (setq-default comint-scroll-to-bottom-on-output t)
- (add-to-list 'comint-output-filter-functions #'comint-truncate-buffer)
- (add-to-list 'comint-output-filter-functions #'ansi-color-process-output))
-
-(use-package bash-completion
+(use-package bash-completion ; allow bash completion in eshell mostly
:demand t
:config
(add-hook 'shell-dynamic-complete-functions
@@ -587,13 +755,16 @@ current layout."
(add-hook 'completion-at-point-functions
'bash-completion-capf-nonexclusive nil t))))
-(use-package pinentry)
+(use-package pinentry ; allow some passwords to be entered with emacs
+ )
-(use-package pass ; password integration
+(use-package password-store ; gnu pass integration
+ :demand t)
+(use-package auth-source-pass ; allow pass to act as auth within emacs
+ :init (auth-source-pass-enable))
+(use-package pass ; nice interface for gnu pass
:demand t
- :init
- (use-package password-store)
- (use-package auth-source-pass :init (auth-source-pass-enable))
+ :after password-store auth-source-pass
:custom
(pass-suppress-confirmations t)
(epg-pinentry-mode 'loopback)
@@ -603,67 +774,27 @@ current layout."
display-buffer-in-side-window
(side . right))))
-(use-package tramp ; remote access for files
- :demand t
- :custom
- (tramp-allow-unsafe-temporary-files t))
-
-(use-package asm-mode ; asm comments and tags generation
- :demand t
- :custom
- (asm-comment-char ?#) ; prefer # over ; for asm comments
- :init
- (defun add-asm-label-tag-generation-hook ()
- (add-hook 'after-save-hook
- (lambda ()
- (shell-command
- "find . -iregex '.*\\.[sS]' -exec etags -l none -r '/\\([a-zA-Z0-9\\-_]+\\):/\1/' {} +"))
- 0 t))
- :hook
- (asm-mode . 'add-asm-label-tag-generation-hook))
-
-(use-package pyvenv)
-
-(use-package sideline ; put warnings on the side of the same line
- :init
- (use-package sideline-flycheck)
- (use-package sideline-flymake)
- :custom
- (sideline-backends-right '(sideline-flycheck sideline-flymake)))
-
-(use-package flycheck
- :config
- ;; flymake stuff to be less annoying
- ;; (face-spec-set 'flycheck-note '((t :underline nil)))
- ;; (face-spec-set 'flycheck-info '((t :underline nil)))
- ;; (face-spec-set 'flycheck-warning '((t :underline nil)))
- ;; (face-spec-set 'flycheck-error '((t :underline nil)))
- :hook
- (prog-mode . flycheck-mode))
-
-(progn ; better commenting binds
- (global-set-key (kbd "C-x C-;") 'comment-or-uncomment-region)
- (global-set-key (kbd "C-x ;") 'comment-line)
- (global-set-key (kbd "C-x :") 'comment-or-uncomment-region)
- ;; ^ duped for terminal w/o C-;
+(use-package pyvenv ; respect python environments
)
-(use-package imenu ; jump to items in the current buffer
- :bind
- ("M-i" . imenu)
- :custom
- (imenu-auto-rescan t)
- (imenu-flatten t))
-
-(use-package xref ; jump to syntactic elements in project
- ;; (add-hook 'xref-backend-functions 'gxref-xref-backend)
- :bind ("M-I" . xref-find-definitions))
-
-(use-package ediff
- :custom
- (ediff-window-setup-function 'ediff-setup-windows-plain))
-
-(progn ; collected folding binds
+;; (use-package sideline ; put warnings on the side of the same line
+;; :init
+;; (use-package sideline-flycheck)
+;; (use-package sideline-flymake)
+;; :custom
+;; (sideline-backends-right '(sideline-flycheck sideline-flymake)))
+
+;; (use-package flycheck
+;; :config
+;; ;; flymake stuff to be less annoying
+;; ;; (face-spec-set 'flycheck-note '((t :underline nil)))
+;; ;; (face-spec-set 'flycheck-info '((t :underline nil)))
+;; ;; (face-spec-set 'flycheck-warning '((t :underline nil)))
+;; ;; (face-spec-set 'flycheck-error '((t :underline nil)))
+;; :hook
+;; (prog-mode . flycheck-mode))
+
+(progn ; collected folding binds, hs + fold this
(define-prefix-command 'my/fold-map)
(global-set-key (kbd "M-F") 'my/fold-map)
(define-keymap :full nil
@@ -671,81 +802,66 @@ current layout."
:suppress nil
:keymap nil
:name "my/fold-map"
- :prefix 'my/fold-map))
-
-(use-package fold-this ; fold arbitrary region
- :init
- (defun my/fold-this-fold-forward (&optional arg)
- "Fold forward ARG number of sexps, defaulting to one."
- (interactive "p")
- (push-mark)
- (forward-sexp arg)
- (fold-this (mark) (point))
- (pop-mark))
-
- (defun my/fold-this-fold-backward (&optional arg)
- "Fold backward ARG number of sexps, defaulting to one."
- (interactive "p")
- (push-mark)
- (backward-sexp arg)
- (fold-this (point) (mark))
- (pop-mark))
-
- :bind (:map my/fold-map
- ("c" . fold-this)
- ("e" . fold-this-unfold-at-point)
- ("f" . my/fold-this-fold-forward)
- ("b" . my/fold-this-fold-backward)))
-
-(progn ; hideshow folding
- (keymap-set my/fold-map (kbd "t") 'hs-toggle-hiding)
- (keymap-set my/fold-map (kbd "l") 'hs-hide-level))
+ :prefix 'my/fold-map)
+ (progn ; hideshow folding
+ (keymap-set my/fold-map "t" 'hs-toggle-hiding)
+ (keymap-set my/fold-map "l" 'hs-hide-level)
+ (keymap-set my/fold-map "C-t" 'hs-hide-all)
+ (keymap-set my/fold-map "C-a" 'hs-show-all))
+
+ (use-package fold-this ; fold arbitrary region
+ :init
+ (defun my/fold-this-fold-forward (&optional arg)
+ "Fold forward ARG number of sexps, defaulting to one."
+ (interactive "p")
+ (push-mark)
+ (forward-sexp arg)
+ (fold-this (mark) (point))
+ (pop-mark))
+
+ (defun my/fold-this-fold-backward (&optional arg)
+ "Fold backward ARG number of sexps, defaulting to one."
+ (interactive "p")
+ (push-mark)
+ (backward-sexp arg)
+ (fold-this (point) (mark))
+ (pop-mark))
+
+ :bind (:map my/fold-map
+ ("c" . fold-this)
+ ("e" . fold-this-unfold-at-point)
+ ("f" . my/fold-this-fold-forward)
+ ("b" . my/fold-this-fold-backward))))
+
+(use-package clang-format ; let clang do c formatting
+ )
-(add-hook 'prog-mode-hook 'my/prog-buffer-setup)
-(electric-pair-mode 1)
-(setq enable-recursive-minibuffers t)
-(setq frame-resize-pixelwise t)
+(use-package rust-mode ; rust lang syntax
+ )
-(use-package haskell-mode
+(use-package haskell-mode ; haskell + cabal integrations
:custom
(haskell-tags-on-save t)
(haskell-process-type 'cabal-repl)
(haskell-process-auto-import-loaded-modules t)
:hook (haskell-mode . interactive-haskell-mode))
-(use-package rust-mode)
-
-(use-package clang-format)
-
-(use-package opam-switch-mode
+(use-package opam-switch-mode ; make emacs mode respect switch
:config
(when (and (file-exists-p "~/.opam") (executable-find "opam"))
(opam-switch-set-switch "default")))
-(use-package tuareg
+(use-package tuareg ; ocaml mode
:after opam-switch-mode)
-(use-package ocp-indent
+(use-package ocp-indent ; indentation for ocaml
:after tuareg
:hook (tuareg-mode . ocp-setup-indent))
-(use-package merlin
+(use-package merlin ; ocaml completion
:after tuareg
:hook (tuareg-mode . merlin-mode)
:custom (merlin-command 'opam))
-(use-package racket-mode)
-
-(use-package compile
- :custom
- (compilation-always-kill t)
- (compilation-scroll-output t)
- :bind (:map my/keys-mode-map ("M-M" . 'recompile))
- :config
- ;; Allow compilation buffer to be dedicated across frames
- (add-to-list 'display-buffer-alist '("\\*compilation\\*" (nil (reusable-frames . t))))
- (add-hook 'compilation-filter-hook #'ansi-color-compilation-filter))
-
-(use-package man
- :custom
- (Man-switches "-a"))
+(use-package racket-mode ; basic racket integration
+ )
(use-package sdcv ; dictionary, requires sdcv install
:demand t
@@ -789,58 +905,13 @@ current layout."
(erc-track-faces-priority-list '(erc-current-nick-face erc-keyword-face))
(erc-track-priority-faces-only 'all))
-(progn ; indent code when pasting
- (defvar yank-indent-modes '(prog-mode LaTeX-mode TeX-mode)
- "Modes in which to indent regions that are yanked (or yank-popped).")
-
- (defun yank-indent-func (&optional arg)
- (let* ((parents (derived-mode-all-parents major-mode))
- (helper (lambda (acc v) (or acc (member v yank-indent-modes))))
- (included (-reduce helper parents)))
- (when (and (not arg) included)
- (indent-region (region-beginning) (region-end)))))
-
- (advice-add 'yank :after 'yank-indent-func)
- (advice-add 'yank-pop :after 'yank-indent-func))
-
-(use-package minions
+(use-package minions ; show less on the modeline
:demand t
:config
(minions-mode 1)
:custom
(minions-prominent-modes '(persp-mode auto-fill-mode eldoc-mode eglot-mode lsp-mode)))
-(progn ; default modeline config additions
- (let ((dir '("" (:eval (let ((str (concat (format " [%s] " (my/shorten-path default-directory)))))
- (add-face-text-property
- 0 (length str)
- '(:weight bold :foreground "green2")
- t str)
- str)))))
- (push dir global-mode-string)))
-
-(progn ; comfy scratch buffer
- (require 'iimage)
- (setq inhibit-startup-screen t)
- (setq initial-scratch-message
- (concat (propertize ";; " 'invisible t)
- "</home/tmu/.emacs.d/splashLaputa.png>
-;; scratch for lisp evaluation and unsaved text
-
-"))
- (add-hook 'emacs-startup-hook
- (lambda ()
- (with-current-buffer "*scratch*"
- (emacs-lock-mode 'kill)
- (iimage-mode 1)))))
-
-(progn ; confirm fewer things
- (setq kill-buffer-query-functions
- (delq 'process-kill-buffer-query-function kill-buffer-query-functions))
- (setq confirm-kill-processes nil)
- (setq async-shell-command-buffer 'new-buffer)
- (setq vc-follow-symlinks t))
-
(use-package ispell ; spellchecker
:demand t
:custom
@@ -853,55 +924,20 @@ current layout."
(advice-add 'ispell-mode :before 'debug)
(setq-default text-mode-hook (cons 'ispell-minor-mode (remove 'ispell-mode text-mode-hook))))
-(use-package time
- :custom
- (display-time-day-and-date t)
- (display-time-24hr-format t))
-
-(use-package battery)
-
-(use-package ednc)
-
-(progn ; viper
- (setq-default viper-want-ctl-h-help t)
- (setq-default viper-inhibit-startup-message 't)
- (setq-default viper-expert-level 5)
- (setq-default viper-is-in-minibuffer nil)
- (setq-default viper-vi-style-in-minibuffer nil)
- (setq-default viper-enable-minibuffer-faces nil)
- (setq-default viper-syntax-preference 'emacs)
- (setq-default viper-ex-style-motion nil)
- (setq-default viper-auto-indent t)
- (setq-default viper-buffer-search-char ?g)
- (setq viper-mode nil)
- (require 'viper)
- (define-key viper-vi-global-user-map (kbd "C-y") 'yank)
- (define-key viper-vi-global-user-map (kbd "C-e") 'end-of-line)
- (define-key viper-vi-global-user-map (kbd "C-f") 'forward-char)
- (define-key viper-vi-global-user-map (kbd "C-b") 'backward-char)
- (define-key viper-vi-global-user-map (kbd "C-u") 'universal-argument)
- (define-key viper-insert-global-user-map (kbd "C-u") 'universal-argument)
- (define-key viper-insert-global-user-map (kbd "C-d") 'delete-char)
- (define-key viper-insert-global-user-map (kbd "C-m")
- #'(lambda ()
- (interactive)
- (if completion-in-region-mode
- (corfu-insert)
- (viper-autoindent)))))
+;;; Optional files for occasional loading:
;; if you want exwm, include from ~/.emacs.d/site-lisp/my-exwm.el
;; if you want mail, include from ~/.emacs.d/site-lisp/my-mail.el
;; if you want eglot, include from ~/.emacs.d/site-lisp/my-eglot.el
-;; ----------------------------------------------------------------------
-;; theme stuff
+;;; Theming:
(require 'tmu-custom-theme)
(push "~/.emacs.d/site-lisp/" custom-theme-load-path)
(load-theme 'tmu-custom t)
+;;; Things emacs sets programatically:
;; ----------------------------------------------------------------------
-;; Things emacs sets programatically
(put 'dired-find-alternate-file 'disabled nil)
(put 'upcase-region 'disabled nil)