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