1 d9dcf59e 2022-03-31 lh ;; -*- lexical-binding: t; -*-
2 7c7ad7d3 2025-08-31 lh ;;; My emacs config
4 2b7a791c 2025-09-01 lh (require 'cl-lib)
6 984e27bd 2025-09-01 lh (setq lh/dir-documents
7 984e27bd 2025-09-01 lh (expand-file-name
8 984e27bd 2025-09-01 lh (cond ((eq system-type 'gnu/linux) (or (xdg-user-dir "DOCUMENTS") "~/Documents"))
9 984e27bd 2025-09-01 lh ((eq system-type 'windows-nt) "~/Documents"))))
10 10233ddc 2025-08-31 lh (setq lh/dir-data-home
11 10233ddc 2025-08-31 lh (expand-file-name
12 10233ddc 2025-08-31 lh (cond ((eq system-type 'gnu/linux) (or (xdg-data-home) "~/.local/share"))
13 10233ddc 2025-08-31 lh ((eq system-type 'windows-nt) (getenv "APPDATA")))))
15 7c7ad7d3 2025-08-31 lh (let ((lisp-dir (expand-file-name "lisp" user-emacs-directory)))
16 7c7ad7d3 2025-08-31 lh (make-directory lisp-dir t)
17 7c7ad7d3 2025-08-31 lh (add-to-list 'load-path lisp-dir))
19 2b7a791c 2025-09-01 lh (defun lh/keymap-set-keys (keymap &rest pairs)
20 2b7a791c 2025-09-01 lh (cl-loop for (key function) on pairs by #'cddr
21 2b7a791c 2025-09-01 lh do (keymap-set keymap key function)))
23 7c7ad7d3 2025-08-31 lh (setopt custom-file (expand-file-name "custom.el" user-emacs-directory))
25 2b7a791c 2025-09-01 lh (lh/keymap-set-keys global-map
26 2b7a791c 2025-09-01 lh "<mouse-8>" 'xref-go-back
27 2b7a791c 2025-09-01 lh "<mouse-9>" 'xref-go-forward)
29 7c7ad7d3 2025-08-31 lh ;;;; package.el setup
30 7c7ad7d3 2025-08-31 lh (setopt package-archives '(("gnu" . "https://elpa.gnu.org/packages/")
31 7c7ad7d3 2025-08-31 lh ("nongnu" . "https://elpa.nongnu.org/nongnu/")
32 7c7ad7d3 2025-08-31 lh ("melpa-stable" . "https://stable.melpa.org/packages/")
33 7c7ad7d3 2025-08-31 lh ("melpa" . "https://melpa.org/packages/"))
34 7c7ad7d3 2025-08-31 lh package-archive-priorities '(("gnu" . 3)
35 7c7ad7d3 2025-08-31 lh ("nongnu" . 2)
36 7c7ad7d3 2025-08-31 lh ("melpa-stable" . 1)
37 7c7ad7d3 2025-08-31 lh ("melpa" . 0))
38 bcada3c2 2025-08-31 lh package-pinned-packages '((sly . "melpa"))
39 984e27bd 2025-09-01 lh package-selected-packages '(csv-mode denote denote-org elfeed magit nhexl-mode notmuch
40 984e27bd 2025-09-01 lh ob-restclient paredit paredit-menu restclient
41 984e27bd 2025-09-01 lh restclient-jq sly))
42 bcada3c2 2025-08-31 lh (package-initialize)
44 7c7ad7d3 2025-08-31 lh ;;;; Completions
45 7c7ad7d3 2025-08-31 lh (setopt tab-always-indent 'complete
46 7c7ad7d3 2025-08-31 lh completion-ignore-case t
47 7c7ad7d3 2025-08-31 lh completion-styles '(basic substring initials flex)
48 7c7ad7d3 2025-08-31 lh completion-preview-mode t
49 7c7ad7d3 2025-08-31 lh completion-auto-select t
50 7c7ad7d3 2025-08-31 lh completion-auto-help 'visible
51 7c7ad7d3 2025-08-31 lh completion-show-help nil
52 7c7ad7d3 2025-08-31 lh completions-sort 'historical
53 7c7ad7d3 2025-08-31 lh completions-format 'one-column
54 7c7ad7d3 2025-08-31 lh completions-max-height 20)
55 7c7ad7d3 2025-08-31 lh (setopt fido-vertical-mode t)
56 2b7a791c 2025-09-01 lh (lh/keymap-set-keys icomplete-fido-mode-map
57 2b7a791c 2025-09-01 lh "TAB" 'icomplete-force-complete
58 2b7a791c 2025-09-01 lh "<left>" 'left-char
59 2b7a791c 2025-09-01 lh "<right>" 'right-char
60 2b7a791c 2025-09-01 lh "^" 'icomplete-fido-backward-updir
61 2b7a791c 2025-09-01 lh "DEL" 'backward-delete-char)
63 7c7ad7d3 2025-08-31 lh ;; This hack allows using my default set of completion styles in fido instead of being forced to
64 7c7ad7d3 2025-08-31 lh ;; use flex. Flex is especially annoying since it does not prioritise prefix matches.
65 7c7ad7d3 2025-08-31 lh (defun lh/advice-fido-setup (func &rest args)
66 7c7ad7d3 2025-08-31 lh (let ((cs completion-styles))
68 7c7ad7d3 2025-08-31 lh (apply func args)
69 7c7ad7d3 2025-08-31 lh (setq-local completion-styles cs))))
70 7c7ad7d3 2025-08-31 lh (advice-add 'icomplete--fido-mode-setup :around 'lh/advice-fido-setup)
72 7c7ad7d3 2025-08-31 lh ;;;; Programming
74 7c7ad7d3 2025-08-31 lh (editorconfig-mode 1)
75 7c7ad7d3 2025-08-31 lh (defun lh/enable-trailing-whitespace ()
76 7c7ad7d3 2025-08-31 lh (setq show-trailing-whitespace t))
77 7c7ad7d3 2025-08-31 lh (add-hook 'prog-mode-hook 'lh/enable-trailing-whitespace)
80 896d94b8 2025-08-31 lh (setopt inferior-lisp-program "sbcl")
81 896d94b8 2025-08-31 lh (defun lh/enable-paredit-menu ()
82 896d94b8 2025-08-31 lh (require 'paredit-menu))
83 896d94b8 2025-08-31 lh (add-hook 'paredit-mode-hook 'lh/enable-paredit-menu)
84 896d94b8 2025-08-31 lh (add-hook 'lisp-mode-hook 'paredit-mode)
85 896d94b8 2025-08-31 lh (add-hook 'emacs-lisp-mode-hook 'paredit-mode)
86 2b7a791c 2025-09-01 lh (with-eval-after-load "sly"
87 2b7a791c 2025-09-01 lh (lh/keymap-set-keys sly-inspector-mode-map
88 2b7a791c 2025-09-01 lh "<mouse-8>" 'sly-inspector-pop
89 2b7a791c 2025-09-01 lh "<mouse-9>" 'sly-inspector-next))
92 c895727b 2025-09-01 lh (add-hook 'csv-mode-hook 'csv-align-mode)
95 10233ddc 2025-08-31 lh (let ((elfeed-feeds-file (expand-file-name "feeds.el" user-emacs-directory))
96 10233ddc 2025-08-31 lh (elfeed-data-dir (expand-file-name "elfeed" lh/dir-data-home)))
97 10233ddc 2025-08-31 lh (when (file-exists-p elfeed-feeds-file)
98 10233ddc 2025-08-31 lh (load elfeed-feeds-file))
99 10233ddc 2025-08-31 lh (make-directory elfeed-data-dir t)
100 10233ddc 2025-08-31 lh (setopt elfeed-db-directory elfeed-data-dir))
103 10233ddc 2025-08-31 lh (setopt notmuch-archive-tags '("-inbox" "-unread")
104 10233ddc 2025-08-31 lh notmuch-poll-script "notmuch-poll") ; TODO: deprecated, use hooks
106 c1d75839 2025-08-31 lh ;;;; restclient
107 c1d75839 2025-08-31 lh (with-eval-after-load 'restclient
108 c1d75839 2025-08-31 lh (require 'restclient-capf))
110 984e27bd 2025-09-01 lh ;;;; org + denote
111 984e27bd 2025-09-01 lh (let* ((org-dir (expand-file-name "org" lh/dir-documents))
112 984e27bd 2025-09-01 lh (denote-dir (expand-file-name "notes" org-dir)))
113 984e27bd 2025-09-01 lh (make-directory org-dir t)
114 984e27bd 2025-09-01 lh (make-directory denote-dir t)
115 984e27bd 2025-09-01 lh (setopt org-directory org-dir
116 984e27bd 2025-09-01 lh denote-directory denote-dir))
119 7c7ad7d3 2025-08-31 lh (setopt focus-follows-mouse t
120 984e27bd 2025-09-01 lh mouse-autoselect-window 0.2
121 7c7ad7d3 2025-08-31 lh frame-resize-pixelwise t
122 7c7ad7d3 2025-08-31 lh scroll-conservatively 100
123 7c7ad7d3 2025-08-31 lh pixel-scroll-precision-mode t
124 7c7ad7d3 2025-08-31 lh use-short-answers t
125 7c7ad7d3 2025-08-31 lh cursor-type 'bar
126 7c7ad7d3 2025-08-31 lh ring-bell-function 'ignore
127 7c7ad7d3 2025-08-31 lh create-lockfiles nil
128 7c7ad7d3 2025-08-31 lh recentf-max-saved-items 200
129 7c7ad7d3 2025-08-31 lh recentf-mode t
130 7c7ad7d3 2025-08-31 lh indent-tabs-mode nil
131 7c7ad7d3 2025-08-31 lh delete-selection-mode t
132 7c7ad7d3 2025-08-31 lh context-menu-mode t
133 7c7ad7d3 2025-08-31 lh repeat-mode t
134 7c7ad7d3 2025-08-31 lh save-place-mode t
135 7c7ad7d3 2025-08-31 lh savehist-mode t
136 7c7ad7d3 2025-08-31 lh which-key-mode t
137 766612c4 2025-09-01 lh column-number-mode t
138 766612c4 2025-09-01 lh delete-old-versions t)
140 7c7ad7d3 2025-08-31 lh (let ((backup-dir (expand-file-name "backup" user-emacs-directory)))
141 7c7ad7d3 2025-08-31 lh (make-directory backup-dir t)
142 7c7ad7d3 2025-08-31 lh (setopt backup-directory-alist `(("." . ,backup-dir))))
144 7c7ad7d3 2025-08-31 lh (put 'narrow-to-region 'disabled nil)
146 7c7ad7d3 2025-08-31 lh ;;;; Private and custom overrides
147 7c7ad7d3 2025-08-31 lh (let ((private-file (expand-file-name "private.el" user-emacs-directory)))
148 7c7ad7d3 2025-08-31 lh (when (file-exists-p custom-file)
149 7c7ad7d3 2025-08-31 lh (load custom-file))
150 7c7ad7d3 2025-08-31 lh (when (file-exists-p private-file)
151 7c7ad7d3 2025-08-31 lh (load private-file)))