diff options
| author | Gregor Kleen <gkleen@yggdrasil.li> | 2026-09-23 21:08:35 +0200 |
|---|---|---|
| committer | Gregor Kleen <gkleen@yggdrasil.li> | 2026-09-23 21:08:35 +0200 |
| commit | ae9a80c1f012686c1f65fce7ce76fdd1b77b0b71 (patch) | |
| tree | 141f738276cf84c6b7e5633c2bd5f2b44e9b0b75 /accounts/gkleen@skadhi/emacs/emacs.el | |
| parent | 6a763272038e637a8a03dd9059d43a1ff44921dd (diff) | |
| download | nixos-ae9a80c1f012686c1f65fce7ce76fdd1b77b0b71.tar nixos-ae9a80c1f012686c1f65fce7ce76fdd1b77b0b71.tar.gz nixos-ae9a80c1f012686c1f65fce7ce76fdd1b77b0b71.tar.bz2 nixos-ae9a80c1f012686c1f65fce7ce76fdd1b77b0b71.tar.xz nixos-ae9a80c1f012686c1f65fce7ce76fdd1b77b0b71.zip | |
...
Diffstat (limited to 'accounts/gkleen@skadhi/emacs/emacs.el')
| -rw-r--r-- | accounts/gkleen@skadhi/emacs/emacs.el | 262 |
1 files changed, 262 insertions, 0 deletions
diff --git a/accounts/gkleen@skadhi/emacs/emacs.el b/accounts/gkleen@skadhi/emacs/emacs.el new file mode 100644 index 00000000..a9d22621 --- /dev/null +++ b/accounts/gkleen@skadhi/emacs/emacs.el | |||
| @@ -0,0 +1,262 @@ | |||
| 1 | (menu-bar-mode -1) | ||
| 2 | (scroll-bar-mode -1) | ||
| 3 | (tool-bar-mode -1) | ||
| 4 | |||
| 5 | (setq inhibit-startup-message t) | ||
| 6 | (defalias 'yes-or-no-p 'y-or-n-p) | ||
| 7 | |||
| 8 | ;; (set-face-attribute 'default nil :font "Fira Code" :height 49) | ||
| 9 | (set-frame-font "Fira Code 8" nil nil) | ||
| 10 | (load-theme 'modus-vivendi t) | ||
| 11 | ;; (add-to-list 'default-frame-alist '(alpha-background . 90)) | ||
| 12 | |||
| 13 | (require 'package) | ||
| 14 | (setq package-archives nil) | ||
| 15 | (package-initialize) | ||
| 16 | (require 'use-package) | ||
| 17 | ;; (use-package use-package-ensure-system-package :ensure t) | ||
| 18 | |||
| 19 | (require 'evil) | ||
| 20 | (evil-mode 1) | ||
| 21 | |||
| 22 | (editorconfig-mode 1) | ||
| 23 | |||
| 24 | (require 'edit-server) | ||
| 25 | (edit-server-start) | ||
| 26 | |||
| 27 | (require 'mediawiki) | ||
| 28 | (setq mediawiki-mode-hook | ||
| 29 | (lambda () | ||
| 30 | (define-key mediawiki-mode-map (kbd "<C-left>") nil) | ||
| 31 | (define-key mediawiki-mode-map (kbd "<C-right>") nil))) | ||
| 32 | |||
| 33 | (require 'typescript-mode) | ||
| 34 | |||
| 35 | (global-subword-mode) | ||
| 36 | (global-undo-tree-mode) | ||
| 37 | (global-fira-code-mode) | ||
| 38 | |||
| 39 | (evil-set-undo-system 'undo-tree) | ||
| 40 | |||
| 41 | (add-hook 'magit-mode-hook (lambda () (magit-delta-mode +1))) | ||
| 42 | |||
| 43 | (global-set-key (kbd "RET") 'newline-and-indent) | ||
| 44 | (global-set-key (kbd "M-g") 'magit-status) | ||
| 45 | (global-set-key (kbd "M-?") 'vc-git-grep) | ||
| 46 | |||
| 47 | (require 'git-gutter) | ||
| 48 | (global-git-gutter-mode t) | ||
| 49 | (custom-set-variables '(git-gutter:update-interval 2)) | ||
| 50 | (custom-set-variables '(git-gutter:hide-gutter t)) | ||
| 51 | |||
| 52 | (require 'scratch) | ||
| 53 | ;; (global-set-key (kbd "C-x b") 'scratch-switch-to-buffer) | ||
| 54 | (global-set-key (kbd "C-x B") 'scratch-create) | ||
| 55 | ;; (setq initial-major-mode 'scratch-mode) | ||
| 56 | (setq initial-scratch-message "") | ||
| 57 | |||
| 58 | (global-set-key (kbd "C-x K") 'kill-current-buffer) | ||
| 59 | |||
| 60 | (setq backup-directory-alist `(("." . "~/.local/state/emacs/saves"))) | ||
| 61 | (setq undo-tree-history-directory-alist `(("." . "~/.local/state/emacs/undo"))) | ||
| 62 | (setq delete-old-versions t | ||
| 63 | kept-new-versions 6 | ||
| 64 | kept-old-versions 2 | ||
| 65 | version-control t) | ||
| 66 | |||
| 67 | (setq undo-tree-visualizer-timestamps t | ||
| 68 | undo-tree-visualizer-diff t | ||
| 69 | ;; 10X bump of the undo limits to avoid issues with premature | ||
| 70 | ;; Emacs GC which truncages the undo history very aggresively | ||
| 71 | undo-limit 800000 | ||
| 72 | undo-strong-limit 12000000 | ||
| 73 | undo-outer-limit 120000000) | ||
| 74 | |||
| 75 | (add-hook 'haskell-mode-hook 'haskell-indentation-mode) | ||
| 76 | (add-hook 'haskell-mode-hook 'subword-mode) | ||
| 77 | (add-hook 'haskell-mode-hook 'highlight-symbol-mode) | ||
| 78 | (add-hook 'haskell-mode-hook 'highlight-paretheses-mode) | ||
| 79 | |||
| 80 | (add-hook 'js-mode-hook 'highlight-symbol-mode) | ||
| 81 | (add-hook 'js-mode-hook 'highlight-parentheses-mode) | ||
| 82 | (defun my-js-mode-hook () | ||
| 83 | "Custom `js-mode' behaviours." | ||
| 84 | (setq js-indent-level 2) | ||
| 85 | ) | ||
| 86 | (add-hook 'js-mode-hook 'my-js-mode-hook) | ||
| 87 | |||
| 88 | (define-derived-mode anansi-mode | ||
| 89 | markdown-mode "Anansi" | ||
| 90 | "Major mode for anansi" | ||
| 91 | (lambda () (setq indent-tabs-mode nil))) | ||
| 92 | (add-to-list 'auto-mode-alist '("\\.anansi\\'" . anansi-mode)) | ||
| 93 | |||
| 94 | (projectile-mode +1) | ||
| 95 | (define-key projectile-mode-map (kbd "s-p") 'projectile-command-map) | ||
| 96 | |||
| 97 | (add-hook 'rustic-mode-hook (lambda () (setq indent-tabs-mode nil))) | ||
| 98 | (add-hook 'rustic-mode-hook #'lsp-deferred) | ||
| 99 | (add-hook 'rustic-mode-hook (lambda () (setq lsp-ui-sideline-enable nil))) | ||
| 100 | (setq lsp-auto-guess-root t) | ||
| 101 | (setq lsp-inlay-hint-enable t) | ||
| 102 | ;; (add-hook 'rust-mode-hook 'lsp-inlay-hints-mode) | ||
| 103 | (setq lsp-rust-analyzer-server-display-inlay-hints t) | ||
| 104 | (setq lsp-rust-analyzer-inlay-hints-mode t) | ||
| 105 | (setq lsp-rust-analyzer-display-parameter-hints t) | ||
| 106 | (setq lsp-rust-analyzer-display-chaining-hints t) | ||
| 107 | (setq lsp-rust-analyzer-hide-named-constructor nil) | ||
| 108 | |||
| 109 | (setq undo-tree-auto-save-history t) | ||
| 110 | |||
| 111 | (defvar expand-file-name-custom-tilde-alist '(("u2w-srv01" . "/ssh:srv01.uniworx.de:/home/gkleen/projects/uni2work") ("fra-srv01" . "/ssh:srv01.uniworx.de:/home/gkleen/projects/fradrive"))) | ||
| 112 | (defun my/add-to-tilde-alist (hash) | ||
| 113 | (let* ((tilde:dir (split-string hash "=")) | ||
| 114 | (tilde (car tilde:dir)) | ||
| 115 | (dir (cadr tilde:dir))) | ||
| 116 | (push (cons tilde dir) expand-file-name-custom-tilde-alist))) | ||
| 117 | (mapc #'my/add-to-tilde-alist | ||
| 118 | (split-string (let ((process-environment (cl-copy-list process-environment))) (setenv "TERM" nil) (with-output-to-string (call-process "script" nil standard-output nil "-qec" "zsh -ic \"hash -d\"" "/dev/null"))) | ||
| 119 | "\r\n" t)) | ||
| 120 | |||
| 121 | (defadvice expand-file-name (before expand-file-name-custom-tilde | ||
| 122 | (name &optional default-directory) | ||
| 123 | activate compile) | ||
| 124 | "User-defined expansions for ~NAME in file names." | ||
| 125 | (save-match-data | ||
| 126 | (when (string-match "\\`\\(\\(.*/\\)?~\\([^:/]+\\)\\)/" name) | ||
| 127 | (let ((replacement (assoc (match-string 3 name) expand-file-name-custom-tilde-alist))) | ||
| 128 | (when replacement | ||
| 129 | (setq name (replace-match (cdr replacement) t t name 1))))))) | ||
| 130 | |||
| 131 | (setq edit-server-new-frame nil) | ||
| 132 | (setq edit-server-url-major-mode-alist '(("rzint\\.mathinst\\.loc" . mediawiki-mode))) | ||
| 133 | |||
| 134 | ;; (setq notmuch-address-internal-completion '(received nil)) | ||
| 135 | ;; (setq notmuch-always-prompt-for-sender t) | ||
| 136 | ;; (setq notmuch-command "notmuch-ssh") | ||
| 137 | ;; (setq notmuch-crypto-process-mime t) | ||
| 138 | ;; (setq notmuch-draft-tags '("+draft" "-inbox")) | ||
| 139 | ;; (setq notmuch-fcc-dirs nil) | ||
| 140 | ;; (setq notmuch-hello-sections '(notmuch-hello-insert-header notmuch-hello-insert-saved-searches)) | ||
| 141 | ;; (setq notmuch-hello-thousands-separator " ") | ||
| 142 | ;; (setq notmuch-identities '("gkleen@yggdrasil.li" "g@141.li" "kleen@cip.ifi.lmu.de" "Gregor.Kleen@stud.ifi.lmu.de" "G.Kleen@campus.lmu.de" "G.Kleen@lmu.de" "gregor.kleen@ifi.lmu.de" "uni2work@ifi.lmu.de" "gregor@kleen.li")) | ||
| 143 | ;; (setq notmuch-message-headers '("Subject" "To" "Cc" "Date")) | ||
| 144 | ;; (setq notmuch-message-replied-tags '("+replied" "-unread" "-inbox")) | ||
| 145 | ;; (setq notmuch-saved-searches | ||
| 146 | ;; (quote | ||
| 147 | ;; ((:name "inbox" :query "tag:inbox" :key "i") | ||
| 148 | ;; (:name "unread" :query "tag:unread AND tag:inbox" :key "u") | ||
| 149 | ;; (:name "drafts" :query "tag:draft" :key "d") | ||
| 150 | ;; (:name "all mail" :query "date:month.." :key "a" :count-query "*") | ||
| 151 | ;; (:name "sent" :query "is:sent" :key "s" :count-query "is:sent") | ||
| 152 | ;; ))) | ||
| 153 | ;; (setq notmuch-search-oldest-first nil) | ||
| 154 | ;; (setq notmuch-show-all-tags-list t) | ||
| 155 | ;; (setq notmuch-show-logo nil) | ||
| 156 | |||
| 157 | (setq send-mail-function 'sendmail-send-it) | ||
| 158 | (setq mail-envelope-from 'header) | ||
| 159 | (setq mail-specify-envelope-from 't) | ||
| 160 | (setq mail-default-headers nil) | ||
| 161 | (setq message-default-headers "") | ||
| 162 | (setq message-default-mail-headers "") | ||
| 163 | (setq message-sendmail-envelope-from 'header) | ||
| 164 | |||
| 165 | (setq highlight-symbol-idle-delay 0) | ||
| 166 | |||
| 167 | (setq indent-tabs-mode nil) | ||
| 168 | |||
| 169 | (setq ido-enable-flex-matching t) | ||
| 170 | (setq ido-everywhere t) | ||
| 171 | (ido-mode 1) | ||
| 172 | |||
| 173 | (setq tramp-default-method "ssh") | ||
| 174 | (customize-set-variable 'tramp-use-ssh-controlmaster-options nil) | ||
| 175 | (setq tramp-allow-unsafe-temporary-files t) | ||
| 176 | |||
| 177 | (direnv-mode) | ||
| 178 | (setq direnv-enabled-hosts '("uni2work-dev1")) | ||
| 179 | |||
| 180 | (setq auth-sources '()) | ||
| 181 | |||
| 182 | (setq ring-bell-function 'ignore) | ||
| 183 | |||
| 184 | (setq enable-remote-dir-locals 't) | ||
| 185 | |||
| 186 | (setq-default indicate-empty-lines t) | ||
| 187 | (setq-default show-trailing-whitespace t) | ||
| 188 | |||
| 189 | (defun tramp-sh-handle-start-file-process@my-direnv (args) | ||
| 190 | "Enable Direnv for hosts in `direnv-enabled-hosts'." | ||
| 191 | (with-parsed-tramp-file-name (expand-file-name default-directory) nil | ||
| 192 | (if (member host direnv-enabled-hosts) | ||
| 193 | (pcase-let ((`(,name ,buffer ,program . ,args) args)) | ||
| 194 | `(,name | ||
| 195 | ,buffer | ||
| 196 | "direnv" | ||
| 197 | "exec" | ||
| 198 | ,localname | ||
| 199 | ,program | ||
| 200 | ,@args)) | ||
| 201 | args))) | ||
| 202 | |||
| 203 | (with-eval-after-load "tramp-sh" | ||
| 204 | (advice-add 'tramp-sh-handle-start-file-process | ||
| 205 | :filter-args #'tramp-sh-handle-start-file-process@my-direnv)) | ||
| 206 | |||
| 207 | (setq mail-host-address "sif.midgard.yggdrasil") | ||
| 208 | (setq user-full-name "Gregor Kleen") | ||
| 209 | |||
| 210 | (defun tell-emacsclients-for-buffer-to-die () | ||
| 211 | "Sends error exit command to every client for the current buffer." | ||
| 212 | (interactive) | ||
| 213 | (dolist (proc server-buffer-clients) | ||
| 214 | (server-send-string proc "-error die"))) | ||
| 215 | |||
| 216 | (defun kill-buffer-with-special-emacsclient-handling () | ||
| 217 | "Wrapper around kill-buffer that ensures tell-emacsclients-for-buffer-to-die is on the hooks" | ||
| 218 | (interactive) | ||
| 219 | (add-hook 'kill-buffer-hook 'tell-emacsclients-for-buffer-to-die nil t) | ||
| 220 | (kill-buffer)) | ||
| 221 | |||
| 222 | ;; (global-set-key (kbd "C-x k") 'kill-buffer) | ||
| 223 | |||
| 224 | (defun install-emacsclient-wrapped-kill-buffer () | ||
| 225 | "Installs wrapped kill-buffer with special emacsclient handling. | ||
| 226 | Best not to install it unconditionally because the server is not | ||
| 227 | necessarily running." | ||
| 228 | (interactive) | ||
| 229 | (global-set-key (kbd "C-x k") 'kill-buffer-with-special-emacsclient-handling)) | ||
| 230 | |||
| 231 | (add-hook 'server-switch-hook 'install-emacsclient-wrapped-kill-buffer) | ||
| 232 | (add-hook 'server-switch-hook #'raise-frame) | ||
| 233 | |||
| 234 | (defun move-file (new-location) | ||
| 235 | "Write this file to NEW-LOCATION, and delete the old one." | ||
| 236 | (interactive (list (expand-file-name | ||
| 237 | (if buffer-file-name | ||
| 238 | (read-file-name "Move file to: ") | ||
| 239 | (read-file-name "Move file to: " | ||
| 240 | default-directory | ||
| 241 | (expand-file-name (file-name-nondirectory (buffer-name)) | ||
| 242 | default-directory)))))) | ||
| 243 | (when (file-exists-p new-location) | ||
| 244 | (delete-file new-location)) | ||
| 245 | (let ((old-location (expand-file-name (buffer-file-name)))) | ||
| 246 | (message "old file is %s and new file is %s" | ||
| 247 | old-location | ||
| 248 | new-location) | ||
| 249 | (write-file new-location t) | ||
| 250 | (when (and old-location | ||
| 251 | (file-exists-p new-location) | ||
| 252 | (not (string-equal old-location new-location))) | ||
| 253 | (delete-file old-location)))) | ||
| 254 | |||
| 255 | (bind-key "C-x C-m" #'move-file) | ||
| 256 | |||
| 257 | (let ((ssh_auth_sock (string-chop-newline (shell-command-to-string "gpgconf --list-dirs agent-ssh-socket")))) (setenv "SSH_AUTH_SOCK" ssh_auth_sock)) | ||
| 258 | (setenv "SSH_ASKPASS_REQUIRE" "prefer") | ||
| 259 | (setenv "SSH_ASKPASS" "@ksshaskpass@") | ||
| 260 | |||
| 261 | (define-key typst-ts-mode-map (kbd "C-<left>") nil) | ||
| 262 | (define-key typst-ts-mode-map (kbd "C-<right>") nil) | ||
