Blame


1 472975b7 2022-04-06 op ;; get rid of custom from my init file
2 472975b7 2022-04-06 op (setq custom-file "~/.emacs.d/emacs-custom.el")
3 472975b7 2022-04-06 op (load custom-file)
4 472975b7 2022-04-06 op
5 678b3cb3 2022-03-16 op (defconst op/backup-dir
6 678b3cb3 2022-03-16 op (expand-file-name "backups" user-emacs-directory))
7 678b3cb3 2022-03-16 op (unless (file-exists-p op/backup-dir)
8 678b3cb3 2022-03-16 op (make-directory op/backup-dir))
9 678b3cb3 2022-03-16 op (setq backup-directory-alist `(("." . ,op/backup-dir)))
10 678b3cb3 2022-03-16 op
11 678b3cb3 2022-03-16 op (setq use-dialog-box nil
12 678b3cb3 2022-03-16 op x-stretch-cursor t
13 678b3cb3 2022-03-16 op require-final-newline t
14 678b3cb3 2022-03-16 op visible-bell nil
15 678b3cb3 2022-03-16 op load-prefer-newer t
16 678b3cb3 2022-03-16 op tab-bar-show 1
17 678b3cb3 2022-03-16 op enable-recursive-minibuffers t
18 4b9538ff 2022-04-06 op imenu-auto-rescan 1
19 26a80648 2022-04-06 op use-short-answers t
20 26a80648 2022-04-06 op next-error-message-highlight t
21 1e970624 2022-04-06 op read-minibuffer-restore-windows nil
22 d55310b3 2022-04-06 op isearch-allow-motion t
23 c4b35be5 2022-05-09 op calc-make-windows-dedicated t
24 c4b35be5 2022-05-09 op user-mail-address "op@omarpolo.com")
25 678b3cb3 2022-03-16 op
26 678b3cb3 2022-03-16 op (setq completion-ignore-case t
27 678b3cb3 2022-03-16 op read-file-name-completion-ignore-case t
28 678b3cb3 2022-03-16 op read-buffer-completion-ignore-case t)
29 678b3cb3 2022-03-16 op
30 678b3cb3 2022-03-16 op (define-key global-map (kbd "C-x C-b") #'ibuffer)
31 678b3cb3 2022-03-16 op (define-key global-map (kbd "M-g i") #'imenu)
32 678b3cb3 2022-03-16 op
33 472975b7 2022-04-06 op (defun op/imenu ()
34 472975b7 2022-04-06 op "Just like `imenu', but always flattened!"
35 472975b7 2022-04-06 op (interactive ))
36 472975b7 2022-04-06 op
37 678b3cb3 2022-03-16 op ;; mg-like
38 678b3cb3 2022-03-16 op (define-key minibuffer-mode-map (kbd "C-w") #'backward-kill-word)
39 678b3cb3 2022-03-16 op
40 71c456de 2022-03-30 op (defun op/reverse-other-window ()
41 71c456de 2022-03-30 op "Like `other-window', but reverse."
42 71c456de 2022-03-30 op (interactive "")
43 71c456de 2022-03-30 op (other-window -1))
44 71c456de 2022-03-30 op (define-key global-map (kbd "C-x O") #'op/reverse-other-window)
45 71c456de 2022-03-30 op
46 678b3cb3 2022-03-16 op (setq uniquify-buffer-name-style 'forward
47 678b3cb3 2022-03-16 op uniquify-strip-common-suffix t)
48 678b3cb3 2022-03-16 op
49 678b3cb3 2022-03-16 op (setq-default scroll-up-aggressively 0.0
50 678b3cb3 2022-03-16 op scroll-down-aggressively 0.0
51 678b3cb3 2022-03-16 op scroll-preserve-screen-position t
52 678b3cb3 2022-03-16 op next-screen-context-lines 1)
53 678b3cb3 2022-03-16 op
54 678b3cb3 2022-03-16 op (define-key global-map (kbd "M-z") #'zap-up-to-char)
55 678b3cb3 2022-03-16 op
56 678b3cb3 2022-03-16 op (require 'whitespace)
57 678b3cb3 2022-03-16 op (setq whitespace-style '(face trailing)
58 678b3cb3 2022-03-16 op backward-delete-char-untabify-method 'hungry
59 678b3cb3 2022-03-16 op tab-always-indent 'complete
60 678b3cb3 2022-03-16 op tab-width 8
61 678b3cb3 2022-03-16 op sentence-end-double-space t)
62 678b3cb3 2022-03-16 op (setq-default indent-tabs-mode t)
63 678b3cb3 2022-03-16 op
64 678b3cb3 2022-03-16 op (defun op/enable-tabs ()
65 678b3cb3 2022-03-16 op "Enable `indent-tabs-mode' in the current buffer."
66 678b3cb3 2022-03-16 op (interactive)
67 678b3cb3 2022-03-16 op (setq-local indent-tabs-mode t))
68 678b3cb3 2022-03-16 op
69 678b3cb3 2022-03-16 op (defun op/disable-tabs ()
70 678b3cb3 2022-03-16 op "Disable `indent-tabs-mode' in the current buffer."
71 678b3cb3 2022-03-16 op (interactive)
72 678b3cb3 2022-03-16 op (setq-local indent-tabs-mode nil))
73 678b3cb3 2022-03-16 op
74 678b3cb3 2022-03-16 op (add-hook 'conf-mode-hook #'op/enable-tabs)
75 678b3cb3 2022-03-16 op (add-hook 'text-mode-hook #'op/enable-tabs)
76 678b3cb3 2022-03-16 op (add-hook 'prog-mode-hook #'op/enable-tabs)
77 678b3cb3 2022-03-16 op (add-hook 'prog-mode-hook #'whitespace-mode)
78 678b3cb3 2022-03-16 op (add-hook 'text-mode-hook #'whitespace-mode)
79 678b3cb3 2022-03-16 op
80 23efdfd9 2022-03-17 op (dolist (hook '(emacs-lisp-mode-hook
81 23efdfd9 2022-03-17 op clojure-mode-hook
82 23efdfd9 2022-03-17 op clojurescript-mode-hook
83 23efdfd9 2022-03-17 op clojurec-mode-hook
84 23efdfd9 2022-03-17 op scss-mode-hook))
85 23efdfd9 2022-03-17 op (add-hook hook #'op/disable-tabs))
86 23efdfd9 2022-03-17 op
87 678b3cb3 2022-03-16 op (with-eval-after-load 'log-edit
88 678b3cb3 2022-03-16 op (add-hook 'log-edit-mode #'auto-fill-mode))
89 678b3cb3 2022-03-16 op
90 678b3cb3 2022-03-16 op ;; free the c-z binding
91 678b3cb3 2022-03-16 op (define-key global-map (kbd "C-z") nil)
92 678b3cb3 2022-03-16 op (define-key global-map (kbd "C-z V") #'variable-pitch-mode)
93 678b3cb3 2022-03-16 op (define-key global-map (kbd "C-z n") #'display-line-numbers-mode)
94 678b3cb3 2022-03-16 op
95 678b3cb3 2022-03-16 op (define-key global-map (kbd "M-SPC") #'cycle-spacing)
96 678b3cb3 2022-03-16 op (define-key global-map (kbd "M-u") #'upcase-dwim)
97 678b3cb3 2022-03-16 op (define-key global-map (kbd "M-l") #'downcase-dwim)
98 678b3cb3 2022-03-16 op (define-key global-map (kbd "M-c") #'capitalize-dwim)
99 678b3cb3 2022-03-16 op
100 678b3cb3 2022-03-16 op (let ((font "-misc-fixed-medium-r-semicondensed--13-120-75-75-c-60-iso10646-1"))
101 678b3cb3 2022-03-16 op (set-frame-font font nil t)
102 678b3cb3 2022-03-16 op (add-to-list 'default-frame-alist `(font . ,font)))
103 472975b7 2022-04-06 op
104 472975b7 2022-04-06 op ;; fix the emojis too
105 472975b7 2022-04-06 op (set-fontset-font t 'emoji '("Noto Emoji" . "iso10646-1")
106 472975b7 2022-04-06 op nil 'prepend)
107 678b3cb3 2022-03-16 op
108 678b3cb3 2022-03-16 op ;; some cool stuff
109 678b3cb3 2022-03-16 op (save-place-mode +1)
110 678b3cb3 2022-03-16 op (savehist-mode +1)
111 678b3cb3 2022-03-16 op (setq history-delete-duplicates t
112 678b3cb3 2022-03-16 op history-length 1000
113 678b3cb3 2022-03-16 op savehist-save-minibuffer-history t)
114 678b3cb3 2022-03-16 op (electric-pair-mode +1)
115 678b3cb3 2022-03-16 op
116 678b3cb3 2022-03-16 op (define-key global-map (kbd "M-/") #'hippie-expand)
117 678b3cb3 2022-03-16 op (setq hippie-expand-try-functions-list
118 678b3cb3 2022-03-16 op '(try-expand-dabbrev
119 678b3cb3 2022-03-16 op try-expand-dabbrev-all-buffers
120 678b3cb3 2022-03-16 op try-expand-dabbrev-from-kill
121 678b3cb3 2022-03-16 op try-complete-file-name-partially
122 678b3cb3 2022-03-16 op try-complete-file-name
123 678b3cb3 2022-03-16 op try-expand-all-abbrevs
124 678b3cb3 2022-03-16 op try-expand-list
125 678b3cb3 2022-03-16 op try-expand-line
126 678b3cb3 2022-03-16 op try-complete-lisp-symbol-partially
127 678b3cb3 2022-03-16 op try-complete-lisp-symbol))
128 678b3cb3 2022-03-16 op
129 678b3cb3 2022-03-16 op (setq isearch-lazy-count t
130 678b3cb3 2022-03-16 op search-whitespace-regexp ".*?"
131 678b3cb3 2022-03-16 op isearch-allow-scroll 'unlimited)
132 678b3cb3 2022-03-16 op
133 678b3cb3 2022-03-16 op (defun op/buffer-to-side-window (place)
134 678b3cb3 2022-03-16 op "Place the current buffer in the side window at PLACE."
135 678b3cb3 2022-03-16 op (interactive (list (intern
136 678b3cb3 2022-03-16 op (completing-read "Which side: "
137 678b3cb3 2022-03-16 op '(top left right bottom)))))
138 678b3cb3 2022-03-16 op (let ((buf (current-buffer)))
139 678b3cb3 2022-03-16 op (display-buffer-in-side-window
140 678b3cb3 2022-03-16 op buf `((window-height . 0.15)
141 678b3cb3 2022-03-16 op (side . ,place)
142 678b3cb3 2022-03-16 op (slot . -1)
143 678b3cb3 2022-03-16 op (window-parameters . ((no-delete-other-windows . t)))))
144 678b3cb3 2022-03-16 op (delete-window)))
145 93201a02 2022-04-01 op
146 93201a02 2022-04-01 op (defun op/visit-new-migration-file (name)
147 93201a02 2022-04-01 op "Visit a new SQL migration file named after NAME."
148 93201a02 2022-04-01 op (interactive "Mname: ")
149 93201a02 2022-04-01 op (let* ((name (replace-regexp-in-string " " "-" (string-trim name)))
150 93201a02 2022-04-01 op (f (format "%s-%s.sql"
151 93201a02 2022-04-01 op (format-time-string "%Y%m%d%H%M")
152 93201a02 2022-04-01 op name)))
153 93201a02 2022-04-01 op (find-file f)))
154 678b3cb3 2022-03-16 op
155 678b3cb3 2022-03-16 op (defun op/fill-or-unfill (fn &optional justify region)
156 678b3cb3 2022-03-16 op "Meant to be an adviced :around `fill-paragraph'.
157 678b3cb3 2022-03-16 op FN is the original `fill-column'. If `last-command' is
158 678b3cb3 2022-03-16 op `fill-paragraph', unfill it, fill it otherwise. Inspired from a
159 678b3cb3 2022-03-16 op post on endless parentheses. Optional argument JUSTIFY and
160 678b3cb3 2022-03-16 op REGION are passed to `fill-paragraph'."
161 678b3cb3 2022-03-16 op (let ((fill-column
162 678b3cb3 2022-03-16 op (if (eq last-command 'fill-paragraph)
163 678b3cb3 2022-03-16 op (progn (setq this-command nil)
164 678b3cb3 2022-03-16 op (point-max))
165 678b3cb3 2022-03-16 op fill-column)))
166 678b3cb3 2022-03-16 op (funcall fn justify region)))
167 678b3cb3 2022-03-16 op (advice-add 'fill-paragraph :around #'op/fill-or-unfill)
168 678b3cb3 2022-03-16 op
169 678b3cb3 2022-03-16 op (defmacro op/deftranspose (name scope key doc)
170 678b3cb3 2022-03-16 op "Macro to produce transposition functions.
171 678b3cb3 2022-03-16 op NAME is the function's symbol. SCOPE is the text object to
172 678b3cb3 2022-03-16 op operate on. Optional DOC is the function's docstring.
173 678b3cb3 2022-03-16 op
174 678b3cb3 2022-03-16 op Transposition over an active region will swap the object at
175 678b3cb3 2022-03-16 op mark (region beginning) with the one at point (region end).
176 678b3cb3 2022-03-16 op
177 678b3cb3 2022-03-16 op It can optionally define a key for the defined function in the
178 678b3cb3 2022-03-16 op `global-map' if KEY is passed.
179 678b3cb3 2022-03-16 op
180 678b3cb3 2022-03-16 op Originally from protesilaos' dotemacs."
181 678b3cb3 2022-03-16 op (declare (indent defun))
182 678b3cb3 2022-03-16 op `(progn
183 678b3cb3 2022-03-16 op (defun ,name (arg)
184 678b3cb3 2022-03-16 op ,doc
185 678b3cb3 2022-03-16 op (interactive "p")
186 678b3cb3 2022-03-16 op (let ((x (intern (format "transpose-%s" ,scope))))
187 678b3cb3 2022-03-16 op (if (use-region-p)
188 678b3cb3 2022-03-16 op (funcall x 0)
189 678b3cb3 2022-03-16 op (funcall x arg))))
190 678b3cb3 2022-03-16 op ,(when key
191 678b3cb3 2022-03-16 op `(define-key global-map (kbd ,key) #',name))))
192 678b3cb3 2022-03-16 op
193 678b3cb3 2022-03-16 op (op/deftranspose op/transpose-lines "lines" "C-x C-t"
194 678b3cb3 2022-03-16 op "Transpose lines or swap over active region.")
195 678b3cb3 2022-03-16 op
196 678b3cb3 2022-03-16 op (op/deftranspose op/transpose-paragraphs "paragraphs" "C-S-t"
197 678b3cb3 2022-03-16 op "Transpose paragraph or swap over active region.")
198 678b3cb3 2022-03-16 op
199 678b3cb3 2022-03-16 op (op/deftranspose op/transpose-sentences "sentences" "C-x M-t"
200 678b3cb3 2022-03-16 op "Transpose sentences or swap over active region.")
201 678b3cb3 2022-03-16 op
202 678b3cb3 2022-03-16 op (op/deftranspose op/transpose-sexps "sexps" "C-M-t"
203 678b3cb3 2022-03-16 op "Transpose sexps or swap over active region.")
204 678b3cb3 2022-03-16 op
205 678b3cb3 2022-03-16 op (op/deftranspose op/transpose-words "words" "M-t"
206 678b3cb3 2022-03-16 op "Transpose words or swap over active region.")
207 678b3cb3 2022-03-16 op
208 678b3cb3 2022-03-16 op (defun op/narrow-or-widen-dwim (p)
209 678b3cb3 2022-03-16 op "Widen if the buffer is narrowed, narrow-dwim otherwise.
210 678b3cb3 2022-03-16 op Dwim means: region, org-src-block, org-subtree or defun,
211 678b3cb3 2022-03-16 op whichever applies first. Narrowing to org-src-blocks actually
212 678b3cb3 2022-03-16 op calls `org-edit-src-code'.
213 678b3cb3 2022-03-16 op
214 678b3cb3 2022-03-16 op With prefix P, don't widen, just narrow even if buffer is already
215 678b3cb3 2022-03-16 op narrowed. With P being -, narrow to page instead of to defun.
216 678b3cb3 2022-03-16 op
217 678b3cb3 2022-03-16 op Taken from endless parentheses."
218 678b3cb3 2022-03-16 op (interactive "P")
219 678b3cb3 2022-03-16 op (declare (interactive-only))
220 678b3cb3 2022-03-16 op (cond ((and (buffer-narrowed-p) (not p)) (widen))
221 678b3cb3 2022-03-16 op ((region-active-p)
222 678b3cb3 2022-03-16 op (narrow-to-region (region-beginning)
223 678b3cb3 2022-03-16 op (region-end)))
224 678b3cb3 2022-03-16 op ((derived-mode-p 'org-mode)
225 678b3cb3 2022-03-16 op ;; `org-edit-src-code' isn't a real narrowing
226 678b3cb3 2022-03-16 op (cond ((ignore-errors (org-edit-src-code) t))
227 678b3cb3 2022-03-16 op ((ignore-errors (org-narrow-to-block) t))
228 678b3cb3 2022-03-16 op (t (org-narrow-to-subtree))))
229 678b3cb3 2022-03-16 op ((eql p '-) (narrow-to-page))
230 678b3cb3 2022-03-16 op (t (narrow-to-defun))))
231 678b3cb3 2022-03-16 op
232 678b3cb3 2022-03-16 op (define-key global-map (kbd "C-c w") #'op/narrow-or-widen-dwim)
233 678b3cb3 2022-03-16 op
234 678b3cb3 2022-03-16 op (with-eval-after-load 'dired
235 678b3cb3 2022-03-16 op (add-hook 'dired-mode-hook #'dired-hide-details-mode)
236 678b3cb3 2022-03-16 op (add-hook 'dired-mode-hook #'dired-omit-mode)
237 678b3cb3 2022-03-16 op
238 678b3cb3 2022-03-16 op (define-key dired-mode-map (kbd "C-c w") #'wdired-change-to-wdired-mode)
239 678b3cb3 2022-03-16 op
240 678b3cb3 2022-03-16 op (require 'dired-x)
241 678b3cb3 2022-03-16 op (setq dired-listing-switches "-lahF"
242 678b3cb3 2022-03-16 op dired-dwim-target t
243 3bc75ece 2022-04-06 op dired-deletion-confirmer #'y-or-n-p
244 c4b35be5 2022-05-09 op dired-do-revert-buffer t))
245 678b3cb3 2022-03-16 op
246 678b3cb3 2022-03-16 op ;; just like telescope!
247 678b3cb3 2022-03-16 op (with-eval-after-load 'diff-mode
248 678b3cb3 2022-03-16 op (define-key diff-mode-map (kbd "M-SPC") #'scroll-down-command))
249 678b3cb3 2022-03-16 op
250 678b3cb3 2022-03-16 op (with-eval-after-load 'elisp-mode
251 678b3cb3 2022-03-16 op (add-hook 'emacs-lisp-mode-hook #'checkdoc-minor-mode)
252 678b3cb3 2022-03-16 op (add-hook 'emacs-lisp-mode-hook #'prettify-symbols-mode)
253 678b3cb3 2022-03-16 op (let ((map emacs-lisp-mode-map))
254 678b3cb3 2022-03-16 op (define-key map (kbd "C-c C-k") #'eval-buffer)
255 678b3cb3 2022-03-16 op (define-key map (kbd "C-c k") #'op/ert-all)
256 678b3cb3 2022-03-16 op (define-key map (kbd "C-c C-z") #'op/ielm-repl)))
257 678b3cb3 2022-03-16 op
258 678b3cb3 2022-03-16 op (with-eval-after-load 'help
259 678b3cb3 2022-03-16 op (add-hook 'help-mode-hook #'visual-line-mode))
260 678b3cb3 2022-03-16 op
261 678b3cb3 2022-03-16 op ;; add melpa
262 678b3cb3 2022-03-16 op (add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
263 678b3cb3 2022-03-16 op
264 678b3cb3 2022-03-16 op ;; packages that i want to be installed
265 678b3cb3 2022-03-16 op (dolist (pkg '(vc-got pdf-tools eglot nameless sly cider go-mode web-mode
266 71c456de 2022-03-30 op lua-mode markdown-mode yaml-mode gemini-mode elfeed
267 74647cc8 2022-04-06 op form-feed shackle embark consult mct puni))
268 678b3cb3 2022-03-16 op (unless (package-installed-p pkg)
269 678b3cb3 2022-03-16 op (message "Installing %s" pkg)
270 678b3cb3 2022-03-16 op (package-install pkg)))
271 678b3cb3 2022-03-16 op
272 678b3cb3 2022-03-16 op (global-form-feed-mode +1)
273 678b3cb3 2022-03-16 op
274 23efdfd9 2022-03-17 op (add-hook 'text-mode-hook #'puni-mode)
275 23efdfd9 2022-03-17 op (add-hook 'prog-mode-hook #'puni-mode)
276 23efdfd9 2022-03-17 op (define-key puni-mode-map (kbd "C-)") #'puni-slurp-forward)
277 23efdfd9 2022-03-17 op (define-key puni-mode-map (kbd "C-(") #'puni-barf-forward)
278 23efdfd9 2022-03-17 op
279 678b3cb3 2022-03-16 op (setq completion-styles '(basic substring initials flex partial-completion))
280 472975b7 2022-04-06 op
281 472975b7 2022-04-06 op (require 'consult) ;; some stuff lacks an autoload and i don't want to debug it
282 472975b7 2022-04-06 op
283 472975b7 2022-04-06 op (cl-loop for (key . func) in '(("C-x :" . consult-complex-command)
284 472975b7 2022-04-06 op ("C-x b" . consult-buffer)
285 472975b7 2022-04-06 op ("C-x 4 b" . consult-buffer-other-window)
286 472975b7 2022-04-06 op ("C-x 5 b" . consult-buffer-other-frame)
287 472975b7 2022-04-06 op ("C-x r b" . consult-bookmark)
288 472975b7 2022-04-06 op ("C-x p b" . consult-project-buffer)
289 472975b7 2022-04-06 op ("M-y" . consult-yank-pop)
290 472975b7 2022-04-06 op ("M-g g" . consult-goto-line)
291 472975b7 2022-04-06 op ("M-g M-g" . consult-goto-line)
292 472975b7 2022-04-06 op ("M-g m" . consult-mark)
293 472975b7 2022-04-06 op ("M-g i" . consult-imenu)
294 472975b7 2022-04-06 op ("M-s l" . consult-line)
295 472975b7 2022-04-06 op ("M-s L" . consult-line-multi)
296 472975b7 2022-04-06 op ("M-s m" . consult-multi-occur))
297 472975b7 2022-04-06 op do (define-key global-map (kbd key) func))
298 472975b7 2022-04-06 op (add-hook 'completion-list-mode-hook #'consult-preview-at-point-mode)
299 678b3cb3 2022-03-16 op
300 74647cc8 2022-04-06 op (setq completions-detailed t)
301 678b3cb3 2022-03-16 op (mct-minibuffer-mode +1)
302 678b3cb3 2022-03-16 op (mct-region-mode +1)
303 93201a02 2022-04-01 op
304 93201a02 2022-04-01 op ;; override the binding for the annoying mct-backward-updir.
305 93201a02 2022-04-01 op (define-key mct-minibuffer-local-filename-completion-map
306 93201a02 2022-04-01 op (kbd "DEL") #'backward-delete-char)
307 93201a02 2022-04-01 op
308 678b3cb3 2022-03-16 op (setq mct-remove-shadowed-file-names t
309 678b3cb3 2022-03-16 op mct-completions-format 'one-column
310 678b3cb3 2022-03-16 op mct-completion-passlist '(Info-goto-node
311 678b3cb3 2022-03-16 op Info-index
312 678b3cb3 2022-03-16 op Info-menu
313 678b3cb3 2022-03-16 op vc-retrieve-tag
314 678b3cb3 2022-03-16 op imenu
315 678b3cb3 2022-03-16 op file
316 678b3cb3 2022-03-16 op buffer
317 472975b7 2022-04-06 op kill-ring
318 472975b7 2022-04-06 op consult-buffer))
319 678b3cb3 2022-03-16 op
320 23efdfd9 2022-03-17 op (with-eval-after-load 'go-mode
321 23efdfd9 2022-03-17 op (add-hook 'go-mode-hook #'subword-mode))
322 23efdfd9 2022-03-17 op
323 678b3cb3 2022-03-16 op (with-eval-after-load 'eglot
324 678b3cb3 2022-03-16 op (define-key eglot-mode-map (kbd "<f1>") #'eglot-code-actions)
325 678b3cb3 2022-03-16 op (define-key eglot-mode-map (kbd "<f2>") #'eglot-format)
326 678b3cb3 2022-03-16 op (add-to-list 'eglot-ignored-server-capabilites
327 678b3cb3 2022-03-16 op :documentHighlightProvider)
328 678b3cb3 2022-03-16 op (add-to-list 'eglot-server-programs
329 678b3cb3 2022-03-16 op '(c-mode . ("clangd" "--header-insertion=never"))))
330 678b3cb3 2022-03-16 op
331 8c9af136 2022-03-30 op (add-hook 'emacs-lisp-mode #'nameless-mode)
332 678b3cb3 2022-03-16 op (with-eval-after-load 'nameless
333 678b3cb3 2022-03-16 op (setq nameless-private-prefix t
334 678b3cb3 2022-03-16 op nameless-affect-indentation-and-filling nil)
335 678b3cb3 2022-03-16 op (define-key emacs-lisp-mode-map (kbd "_") #'nameless-insert-name-or-self-insert))
336 678b3cb3 2022-03-16 op
337 39b78340 2022-04-01 op (add-to-list 'auto-mode-alist '("\\.html\\'" . web-mode))
338 678b3cb3 2022-03-16 op (with-eval-after-load 'web-mode
339 678b3cb3 2022-03-16 op (setq web-mode-markup-indent-offset 2
340 678b3cb3 2022-03-16 op web-mode-css-indent-offset 2
341 678b3cb3 2022-03-16 op web-mode-style-padding 0
342 678b3cb3 2022-03-16 op web-mode-enable-engine-detection t)
343 39b78340 2022-04-01 op (add-hook 'web-mode-hook #'op/disable-tabs)
344 678b3cb3 2022-03-16 op
345 39b78340 2022-04-01 op ;; fix .dir-locals.el
346 39b78340 2022-04-01 op (defun op/web-mode-fix-dir-locals ()
347 39b78340 2022-04-01 op (when (derived-mode-p major-mode 'web-mode)
348 39b78340 2022-04-01 op (web-mode-guess-engine-and-content-type)))
349 39b78340 2022-04-01 op (add-hook 'hack-local-variables-hook #'op/web-mode-fix-dir-locals))
350 39b78340 2022-04-01 op
351 678b3cb3 2022-03-16 op (with-eval-after-load 'css-mode
352 678b3cb3 2022-03-16 op (add-hook 'css-mode-hook #'op/disable-tabs))
353 c48a945e 2022-03-30 op
354 c48a945e 2022-03-30 op (with-eval-after-load 'flymake
355 c48a945e 2022-03-30 op (define-key prog-mode-map (kbd "C-c ! n") #'flymake-goto-next-error)
356 c48a945e 2022-03-30 op (define-key prog-mode-map (kbd "C-c ! p") #'flymake-goto-prev-error))
357 678b3cb3 2022-03-16 op
358 678b3cb3 2022-03-16 op (with-eval-after-load 'cc-mode
359 678b3cb3 2022-03-16 op (setq c-basic-offset 8
360 71c456de 2022-03-30 op c-default-style "K&R")
361 678b3cb3 2022-03-16 op (dolist (hook '(c-mode-hook c++-mode-hook))
362 678b3cb3 2022-03-16 op (add-hook hook #'abbrev-mode)
363 678b3cb3 2022-03-16 op (add-hook hook #'subword-mode))
364 71c456de 2022-03-30 op (defun op/c-indent ()
365 71c456de 2022-03-30 op (interactive)
366 71c456de 2022-03-30 op (c-set-offset 'arglist-intro '+)
367 71c456de 2022-03-30 op (c-set-offset 'arglist-cont-nonempty '*))
368 71c456de 2022-03-30 op (add-hook 'c-mode-hook #'op/c-indent)
369 678b3cb3 2022-03-16 op ;; TODO: improve it!
370 678b3cb3 2022-03-16 op (defun op/c-add-include (path &optional localp)
371 678b3cb3 2022-03-16 op "Include PATH at the start of the file.
372 678b3cb3 2022-03-16 op If LOCALP is non-nil, the include will be \"local\"."
373 678b3cb3 2022-03-16 op (interactive "Mheader to include: \nP")
374 678b3cb3 2022-03-16 op (save-excursion
375 678b3cb3 2022-03-16 op (let ((re (if localp
376 678b3cb3 2022-03-16 op "^#[ \t]*include[ \t]*\""
377 678b3cb3 2022-03-16 op "^#[ \t]*include[ \t]*<"))
378 678b3cb3 2022-03-16 op (ignore-re "^#include \"compat.h\"")
379 678b3cb3 2022-03-16 op start)
380 678b3cb3 2022-03-16 op (goto-char (point-min))
381 678b3cb3 2022-03-16 op (while (not (or (and (looking-at re)
382 678b3cb3 2022-03-16 op (not (looking-at ignore-re)))
383 678b3cb3 2022-03-16 op (eobp)))
384 678b3cb3 2022-03-16 op (forward-line))
385 678b3cb3 2022-03-16 op (when (eobp)
386 678b3cb3 2022-03-16 op (error "Don't know where to insert the header"))
387 678b3cb3 2022-03-16 op (open-line 1)
388 678b3cb3 2022-03-16 op (insert "#include " (if localp "\"\"" "<>"))
389 678b3cb3 2022-03-16 op (backward-char)
390 678b3cb3 2022-03-16 op (insert path)
391 678b3cb3 2022-03-16 op (move-beginning-of-line 1)
392 678b3cb3 2022-03-16 op (setq start (point))
393 678b3cb3 2022-03-16 op (forward-line)
394 678b3cb3 2022-03-16 op (while (and (looking-at re)
395 678b3cb3 2022-03-16 op (not (eobp)))
396 678b3cb3 2022-03-16 op (forward-line))
397 678b3cb3 2022-03-16 op (sort-lines nil start (point)))))
398 678b3cb3 2022-03-16 op (define-key c-mode-map (kbd "C-c C-a") #'op/c-add-include))
399 678b3cb3 2022-03-16 op
400 678b3cb3 2022-03-16 op (with-eval-after-load 'perl-mode
401 678b3cb3 2022-03-16 op (setq perl-indent-level 8))
402 678b3cb3 2022-03-16 op
403 678b3cb3 2022-03-16 op (with-eval-after-load 'sh-script
404 678b3cb3 2022-03-16 op (setq sh-basic-offset 8
405 678b3cb3 2022-03-16 op sh-indent-after-loop-construct 8
406 678b3cb3 2022-03-16 op sh-indent-after-continuation nil))
407 678b3cb3 2022-03-16 op
408 678b3cb3 2022-03-16 op
409 678b3cb3 2022-03-16 op
410 d55310b3 2022-04-06 op (setq eshell-hist-ignoredups t)
411 d55310b3 2022-04-06 op
412 678b3cb3 2022-03-16 op (defun op/eshell-bufname (dir)
413 678b3cb3 2022-03-16 op (concat "*eshell " (expand-file-name dir) "*"))
414 678b3cb3 2022-03-16 op
415 678b3cb3 2022-03-16 op (defun op/eshell (arg)
416 678b3cb3 2022-03-16 op "Run or jump to eshell in current project.
417 678b3cb3 2022-03-16 op If called with prefix argument ARG always create a new eshell
418 678b3cb3 2022-03-16 op buffer."
419 678b3cb3 2022-03-16 op (interactive "P")
420 678b3cb3 2022-03-16 op (let* ((proj (project-current))
421 678b3cb3 2022-03-16 op (dir (if (and proj (not arg))
422 678b3cb3 2022-03-16 op (project-root proj)
423 678b3cb3 2022-03-16 op default-directory))
424 678b3cb3 2022-03-16 op (default-directory dir)
425 678b3cb3 2022-03-16 op (eshell-buffer-name (let ((name (op/eshell-bufname dir)))
426 678b3cb3 2022-03-16 op (if arg
427 678b3cb3 2022-03-16 op (generate-new-buffer name)
428 678b3cb3 2022-03-16 op name))))
429 678b3cb3 2022-03-16 op (eshell)))
430 678b3cb3 2022-03-16 op (define-key global-map (kbd "C-c e") #'op/eshell)
431 678b3cb3 2022-03-16 op
432 678b3cb3 2022-03-16 op (with-eval-after-load 'eshell
433 678b3cb3 2022-03-16 op (setq eshell-save-history-on-exit t
434 678b3cb3 2022-03-16 op eshell-history-size 1024
435 678b3cb3 2022-03-16 op
436 678b3cb3 2022-03-16 op eshell-compl-dir-ignore
437 678b3cb3 2022-03-16 op "\\`\\(\\.\\.?\\|CVS\\|\\.svn\\|\\.git\\|\\.got\\)/\\'")
438 678b3cb3 2022-03-16 op
439 678b3cb3 2022-03-16 op (defun op/eshell-after-cd (&rest _)
440 678b3cb3 2022-03-16 op (rename-buffer (op/eshell-bufname default-directory) t))
441 678b3cb3 2022-03-16 op
442 c4b35be5 2022-05-09 op (advice-add #'eshell/cd :after #'op/eshell-after-cd))
443 678b3cb3 2022-03-16 op
444 c4b35be5 2022-05-09 op (with-eval-after-load 'esh-mode
445 678b3cb3 2022-03-16 op (defun op/clear-eshell ()
446 678b3cb3 2022-03-16 op (interactive "")
447 678b3cb3 2022-03-16 op (let ((inhibit-read-only t))
448 678b3cb3 2022-03-16 op (erase-buffer)
449 678b3cb3 2022-03-16 op (eshell-send-input)))
450 678b3cb3 2022-03-16 op
451 c4b35be5 2022-05-09 op (define-key eshell-command-map (kbd "M-o") #'op/clear-eshell))
452 678b3cb3 2022-03-16 op
453 678b3cb3 2022-03-16 op
454 678b3cb3 2022-03-16 op ;; sndio.el
455 678b3cb3 2022-03-16 op (unless (package-installed-p 'sndio)
456 678b3cb3 2022-03-16 op (package-install-file "~/w/sndio.el/sndio.el"))
457 678b3cb3 2022-03-16 op
458 678b3cb3 2022-03-16 op
459 678b3cb3 2022-03-16 op ;; saturn
460 678b3cb3 2022-03-16 op (unless (package-installed-p 'saturn)
461 678b3cb3 2022-03-16 op (package-install-file "~/w/saturn/GUI/saturn.el"))
462 678b3cb3 2022-03-16 op
463 678b3cb3 2022-03-16 op
464 678b3cb3 2022-03-16 op ;; simple-pass
465 678b3cb3 2022-03-16 op (unless (package-installed-p 'simple-pass)
466 678b3cb3 2022-03-16 op (package-install-file "~/.emacs.d/simple-pass.el"))
467 678b3cb3 2022-03-16 op (define-key global-map (kbd "C-z p") #'simple-pass-copy)
468 678b3cb3 2022-03-16 op
469 678b3cb3 2022-03-16 op
470 678b3cb3 2022-03-16 op
471 678b3cb3 2022-03-16 op ;; elfeed
472 678b3cb3 2022-03-16 op
473 678b3cb3 2022-03-16 op (define-key global-map (kbd "C-x w") #'elfeed)
474 678b3cb3 2022-03-16 op (with-eval-after-load 'elfeed
475 678b3cb3 2022-03-16 op (define-key elfeed-show-mode-map (kbd "q") #'delete-window)
476 678b3cb3 2022-03-16 op (define-key elfeed-show-mode-map (kbd "S-SPC") #'scroll-down-command)
477 678b3cb3 2022-03-16 op (define-key elfeed-show-mode-map (kbd "M-SPC") #'scroll-down-command)
478 678b3cb3 2022-03-16 op (setq elfeed-show-entry-switch #'pop-to-buffer
479 678b3cb3 2022-03-16 op elfeed-feeds
480 678b3cb3 2022-03-16 op '("https://undeadly.org/cgi?action=rss&full=yes&items=10"
481 678b3cb3 2022-03-16 op "http://www.tedunangst.com/flak/rss"
482 678b3cb3 2022-03-16 op "https://www.dragonflydigest.com/feed"
483 678b3cb3 2022-03-16 op "https://www.mirbsd.org/news.rss"
484 678b3cb3 2022-03-16 op "https://www.mirbsd.org/announce.rss"
485 678b3cb3 2022-03-16 op "https://bentsukun.ch/index.xml"
486 678b3cb3 2022-03-16 op "https://drewdevault.com/feed.xml"
487 678b3cb3 2022-03-16 op "https://www.cambus.net/atom.xml"
488 678b3cb3 2022-03-16 op "https://dataswamp.org/~solene/rss.xml"
489 678b3cb3 2022-03-16 op "https://briancallahan.net/blog/feed.xml"
490 678b3cb3 2022-03-16 op "https://www.poolp.org/index.xml"
491 678b3cb3 2022-03-16 op "https://jcs.org/rss"
492 678b3cb3 2022-03-16 op "https://sanctum.geek.nz/arabesque/feed/"
493 678b3cb3 2022-03-16 op "https://tech.toryanderson.com/"
494 678b3cb3 2022-03-16 op "https://alexschroeder.ch/wiki?action=journal;search=-tag:rpg -tag:rsp;lang=en;title=English Diary without RPG Pages"
495 678b3cb3 2022-03-16 op "http://boston.conman.org/bostondiaries.rss"
496 678b3cb3 2022-03-16 op "https://emacsninja.com/feed.atom"
497 678b3cb3 2022-03-16 op "https://bsdly.blogspot.com/feeds/posts/default"
498 678b3cb3 2022-03-16 op "https://crawshaw.io/atom.xml"
499 678b3cb3 2022-03-16 op "https://nullprogram.com/feed/"
500 678b3cb3 2022-03-16 op "http://pragmaticemacs.com/feed/"
501 678b3cb3 2022-03-16 op "https://emacsnotes.wordpress.com/feed/"
502 678b3cb3 2022-03-16 op "https://metaredux.com/feed.xml"
503 678b3cb3 2022-03-16 op "https://emacsredux.com/atom.xml"
504 678b3cb3 2022-03-16 op "https://endlessparentheses.com/atom.xml"
505 678b3cb3 2022-03-16 op "https://www.masteringemacs.org/feed"
506 678b3cb3 2022-03-16 op "https://cestlaz.github.io/rss.xml"
507 678b3cb3 2022-03-16 op "https://utcc.utoronto.ca/~cks/space/blog/?atom"
508 678b3cb3 2022-03-16 op "https://irreal.org/blog/?feed=rss2"
509 678b3cb3 2022-03-16 op "https://jao.io/blog/rss.xml"
510 678b3cb3 2022-03-16 op "https://planet.lisp.org/rss20.xml"
511 678b3cb3 2022-03-16 op "https://insideclojure.org/feed.xml"
512 678b3cb3 2022-03-16 op "https://tech.toryanderson.com/index.xml"
513 678b3cb3 2022-03-16 op "https://vermaden.wordpress.com/feed/"
514 678b3cb3 2022-03-16 op "https://www.arp242.net/feed.xml"
515 678b3cb3 2022-03-16 op "https://tymoon.eu/api/reader/atom"
516 678b3cb3 2022-03-16 op "https://venam.nixers.net/blog/feed.xml"
517 678b3cb3 2022-03-16 op "https://www.omarpolo.com/rss.xml"
518 678b3cb3 2022-03-16 op "https://owarisubs.lacumpa.biz/feed/"
519 678b3cb3 2022-03-16 op "https://asenshi.moe/feed/"
520 678b3cb3 2022-03-16 op "https://godotengine.org/rss.xml"
521 678b3cb3 2022-03-16 op
522 678b3cb3 2022-03-16 op "https://adventofcomputing.libsyn.com/rss"
523 678b3cb3 2022-03-16 op
524 678b3cb3 2022-03-16 op "https://github.com/go-gitea/gitea/releases.atom"
525 678b3cb3 2022-03-16 op
526 678b3cb3 2022-03-16 op "https://nitter.pussthecat.org/NanoRaptor/rss"
527 678b3cb3 2022-03-16 op
528 678b3cb3 2022-03-16 op "https://github.com/yshui/picom/releases.atom"
529 678b3cb3 2022-03-16 op "https://github.com/vslavik/poedit/releases.atom"
530 678b3cb3 2022-03-16 op "https://github.com/TokTok/c-toxcore/releases.atom"
531 678b3cb3 2022-03-16 op "https://github.com/alexander-akhmetov/python-telegram/releases.atom"
532 678b3cb3 2022-03-16 op "https://github.com/paul-nameless/tg/releases.atom"
533 678b3cb3 2022-03-16 op "https://github.com/YACReader/yacreader/releases.atom"
534 678b3cb3 2022-03-16 op "https://github.com/luarocks/luarocks/releases.atom"
535 678b3cb3 2022-03-16 op "https://github.com/okbob/pspg/releases.atom"
536 678b3cb3 2022-03-16 op "https://github.com/taisei-project/taisei/releases.atom"
537 678b3cb3 2022-03-16 op "https://github.com/recp/cglm/releases.atom"
538 c4b35be5 2022-05-09 op "https://git.sr.ht/~rjarry/aerc/refs/rss.xml"
539 678b3cb3 2022-03-16 op
540 678b3cb3 2022-03-16 op "https://causal.agency/list/pounce.atom"
541 678b3cb3 2022-03-16 op
542 678b3cb3 2022-03-16 op "https://www.crimsonmagic.me/feed/"
543 c4b35be5 2022-05-09 op "https://fullybookedtls.wordpress.com/feed/"
544 678b3cb3 2022-03-16 op
545 c4b35be5 2022-05-09 op "https://draculadaily.substack.com/feed")))
546 c4b35be5 2022-05-09 op
547 678b3cb3 2022-03-16 op (setq shackle-default-rule nil
548 678b3cb3 2022-03-16 op shackle-rules
549 678b3cb3 2022-03-16 op (let ((repls "\\*\\(cider-repl\\|sly-mrepl\\|ielm\\)")
550 678b3cb3 2022-03-16 op (godot "\\*godot - .*\\*")
551 678b3cb3 2022-03-16 op (vcs "\\*\\(Flymake\\|Package-Lint\\|vc-\\(git\\|got\\) :\\).*")
552 678b3cb3 2022-03-16 op (elfeed "\\*elfeed-entry\\*")
553 678b3cb3 2022-03-16 op (vmd "\\*vmd console .*"))
554 678b3cb3 2022-03-16 op `((compilation-mode :noselect t
555 678b3cb3 2022-03-16 op :align above
556 678b3cb3 2022-03-16 op :size 0.2)
557 678b3cb3 2022-03-16 op ("*Async Shell Command*" :ignore t)
558 678b3cb3 2022-03-16 op (,repls :regexp t
559 678b3cb3 2022-03-16 op :align below
560 678b3cb3 2022-03-16 op :size 0.3)
561 678b3cb3 2022-03-16 op (,godot :regexp t
562 678b3cb3 2022-03-16 op :align t
563 678b3cb3 2022-03-16 op :size 0.3)
564 678b3cb3 2022-03-16 op (occur-mode :select t
565 678b3cb3 2022-03-16 op :align right
566 678b3cb3 2022-03-16 op :size 0.3)
567 678b3cb3 2022-03-16 op (diff-mode :select t)
568 678b3cb3 2022-03-16 op (help-mode :select t
569 678b3cb3 2022-03-16 op :align left
570 678b3cb3 2022-03-16 op :size 0.3)
571 678b3cb3 2022-03-16 op (,vcs :regexp t
572 678b3cb3 2022-03-16 op :align above
573 678b3cb3 2022-03-16 op :size 0.15
574 678b3cb3 2022-03-16 op :select t)
575 678b3cb3 2022-03-16 op (,elfeed :regexp t
576 678b3cb3 2022-03-16 op :align t
577 678b3cb3 2022-03-16 op :select t
578 678b3cb3 2022-03-16 op :size 0.75)
579 678b3cb3 2022-03-16 op (,vmd :regexp t
580 678b3cb3 2022-03-16 op :align below
581 678b3cb3 2022-03-16 op :select t
582 678b3cb3 2022-03-16 op :size 0.3))))
583 678b3cb3 2022-03-16 op (shackle-mode +1)
584 678b3cb3 2022-03-16 op
585 678b3cb3 2022-03-16 op (define-key global-map (kbd "M-g e") #'embark-act)