1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
|
#+title: Miscellaneous config bits that i don't use anymore
* enwc
#+BEGIN_SRC emacs-lisp
(use-package enwc
:ensure t
:init (setq enwc-default-backend 'nm
enwc-backend 'nm
enwc-display-mode-line nil
enwc-wired-device "enp3s0f0"
enwc-wireless-device "wlp1s0"))
#+END_SRC
* frm
#+begin_src emacs-lisp
(use-package jao-frm
:init (setq jao-frm-mail-command 'jao-open-gnus-frame))
(defun jao-frm--formatter (mbox n)
(apply #'format "%s/%s: %s" `(,@(last (split-string mbox "/") 2) ,n)))
(defun jao-frm--show ()
(interactive)
(jao-frm-show-mail-numbers #'jao-frm--formatter))
(global-set-key [(f12)] 'jao-frm--show)
(global-set-key [(f8)] 'jao-frm)
#+end_src
* mu4e
#+begin_src emacs-lisp
(jao-load-path "mu4e")
(use-package mu4e
:init
(setq mu4e-attachment-dir (expand-file-name "~/var/download/attachments")
mu4e-change-filenames-when-moving nil
mu4e-completing-read-function 'completing-read
mu4e-display-update-status-in-modeline nil
mu4e-get-mail-command "run-mb.sh || [ $? -eq 1 ]"
mu4e-headers-show-threads t
mu4e-headers-sort-direction 'ascending
mu4e-headers-visible-columns 100
mu4e-headers-visible-lines 12
mu4e-hide-index-messages t
mu4e-index-cleanup t ;; don't do a full cleanup check
mu4e-index-lazy-check t ;; don't consider up-to-date dirs
mu4e-maildir "~/var/mail/"
mu4e-split-view 'horizontal ;; 'vertical
mu4e-update-interval 300
mu4e-use-fancy-chars nil
mu4e-user-mail-address-list jao-mails
mu4e-view-show-addresses t
mu4e-view-show-images t
mu4e-maildir-shortcuts '((:maildir "/jao/inbox" :key ?j)
(:maildir "/bigml/inbox" :key ?b))
jao-mu4e-uninteresting-mail-query
(concat
"flag:unread AND NOT flag:trashed"
" AND NOT (maildir:/bigml/inbox OR maildir:/bigml/bugs OR"
" maildir:/bigml/support OR maildir:/jao/inbox)")
jao-mu4e-interesting-mail-query
(concat
"flag:unread AND NOT flag:trashed"
" AND (maildir:/bigml/inbox OR maildir:/bigml/bugs OR"
" maildir:/bigml/support OR maildir:/jao/inbox)")
mu4e-bookmarks
`((:name "Inbox" :query ,jao-mu4e-interesting-mail-query :key ?i)
(:name "Other messages"
:query ,jao-mu4e-uninteresting-mail-query
:key 117)
(:name "Today's messages" :query "date:today..now"
:key 116)
(:name "Last 7 days" :query "date:7d..now" :hide-unread t
:key 119)
(:name "Messages with PDFs"
:query "mime:application/pdf OR mime:x-application/pdf"
:key 112)))
:config
(defun jao-mu4e--maildir (msg)
(when msg
(let ((md (mu4e-message-field msg :maildir)))
(when (string-match "/\\([^/]+\\)/.*" md)
(match-string 1 md)))))
(defun jao-mu4e--refile-folder (msg)
(let ((md (jao-mu4e--maildir msg)))
(if (string= md "trove")
"/trove/jao"
(format "/trove/%" md))))
(setq mu4e-sent-folder #'jao-mu4e--refile-folder)
(setq mu4e-drafts-folder "/trove/drafts")
(setq mu4e-trash-folder "/trash")
(setq mu4e-refile-folder 'jao-mu4e--refile-folder)
(setq mu4e-contexts nil)
(setq mu4e-view-show-images t)
(when (fboundp 'imagemagick-register-types)
(imagemagick-register-types))
(define-key mu4e-view-mode-map [remap mu4e-view-verify-msg-popup]
'epa-mail-verify)
;; View html message in browser (type aV)
(add-to-list 'mu4e-view-actions
'("ViewInBrowser" . mu4e-action-view-in-browser) t))
#+end_src
* company
#+begin_src emacs-lisp
(use-package company
:ensure t
:custom ((company-backends '(company-capf
company-bbdb
company-files
company-dabbrev
company-keywords))
(company-global-modes '(not slack-message-buffer-mode
circe-channel-mode
telega-chat-mode))
(company-format-margin-function nil) ;; #'company-text-icons-margin
(company-idle-delay 0.2)
(company-lighter "")
(company-lighter-base "")
(company-show-numbers nil)
(company-selection-wrap-around t)
(company-tooltip-limit 15)
(company-tooltip-align-annotations t)
(company-tooltip-offset-display 'lines)) ;; 'scrollbar
:config
(defun jao-complete-at-point ()
"Complete using company unless we're in the minibuffer."
(interactive)
(if (or (not company-mode) (window-minibuffer-p))
(completion-at-point)
(company-manual-begin)))
(defun jao-company-use-in-tab ()
(global-set-key [remap completion-at-point] #'jao-complete-at-point)
(global-set-key [remap completion-symbol] #'jao-complete-at-point)
(global-set-key (kbd "M-TAB") #'jao-complete-at-point))
(jao-company-use-in-tab)
:bind (:map company-active-map
("<tab>" . #'company-complete-common-or-cycle)
("TAB" . #'company-complete-common-or-cycle)
("C-h" . #'company-show-doc-buffer)
("M-." . #'company-show-location)
:filter (or (not (derived-mode-p 'eshell-mode))
(company-explicit-action-p))
("<return>" . #'company-complete-selection)
("RET" . #'company-complete-selection))
:diminish)
(global-company-mode 1)
#+end_src
* rcirc
#+begin_src emacs-lisp :load no
(use-package rcirc
:init
(setq rcirc-server-alist `(("irc.libera.chat"
:encryption tls
:port 6697
:channels ,jao-irc-channels))
rcirc-default-user-full-name "http://jao.io/"
rcirc-buffer-maximum-lines 1000
rcirc-fill-column 82
rcirc-fill-prefix " "
rcirc-time-format "%H:%M "
rcirc-kill-channel-buffers t
rcirc-response-formats
'(("PRIVMSG" . "(%N) %m")
("NOTICE" . "-%N- %m")
("ACTION" . "(... %N %m)")
("COMMAND" . "%m")
("ERROR" . "%fw!!! %m")
(t . "%fp*** %fs%n %r %m"))
rcirc-prompt ": "
rcirc-nick-completion-format "%s, "
rcirc-reconnect-delay 120
rcirc-omit-responses
'("JOIN" "PART" "QUIT" "NICK" "AWAY" "MODE" "KEEPALIVE"))
:config
(let ((fn (jao--get-user/password "libera"))
(btl (jao--get-user/password "bitlbee")))
(setq rcirc-authinfo
`(("libera" nickserv ,(nth 0 fn) ,(nth 1 fn))
("localhost" bitlbee ,(nth 0 btl) ,(nth 1 btl)))))
(jao-shorten-modes 'rcirc-mode)
(define-minor-mode ncm-mode "" nil
(:eval (format " [%S]"
(length (rcirc-channel-nicks (rcirc-buffer-process)
rcirc-target)))))
(defun jao-rcirc-track ()
(dolist (b rcirc-activity) (tracking-add-buffer b))
(jao-minibuffer-refresh))
(add-hook 'rcirc-update-activity-string-hook #'jao-rcirc-track)
(add-hook 'rcirc-mode-hook #'ncm-mode)
(add-hook 'rcirc-mode-hook #'rcirc-omit-mode)
:diminish ((rcirc-omit-mode . "")))
#+end_src
* erc
*** Package
#+begin_src emacs-lisp
(use-package erc
:init
(setq erc-modules
'(autojoin
button
dcc
fill
irccontrols
match
move-to-prompt
netsplit
networks
noncommands
notify
pcomplete
ring
services
stamp
track
truncate))
(setq erc-auto-query 'bury
erc-autojoin-channels-alist `(("libera.chat" ,@jao-libera-channels))
erc-away-nickname "jao"
erc-button-buttonize-nicks t
erc-common-server-suffixes '(("freenode.net$" . "fn")
("libera.chat$" . "lb"))
erc-current-nick-highlight-type 'nick-or-keyword
erc-email-userid (car jao-mails)
erc-fill-column 84
erc-fill-prefix " "
erc-format-nick-function 'erc-format-@nick
erc-header-line-face-method t
erc-header-line-format nil ;; "%l %o"
erc-header-line-uses-tabbar-p nil
erc-hide-list '("JOIN" "PART" "QUIT")
erc-hide-timestamps nil
erc-input-line-position -1
erc-insert-timestamp-function 'erc-insert-timestamp-right
erc-join-buffer 'bury
erc-kill-buffer-on-part t
erc-kill-queries-on-quit t
erc-log-channels-directory nil
erc-mode-line-away-status-format "(a)"
erc-mode-line-format "%t"
erc-nick "jao"
erc-notice-highlight-type 'all
erc-notice-prefix "- "
erc-notify-signoff-hook 'erc-notify-signoff
erc-notify-signon-hook 'erc-notify-signon
erc-pcomplete-nick-postfix ","
erc-rename-buffers t
erc-server-send-ping-timeout 60
erc-prompt ":"
erc-prompt-for-nickserv-password nil
erc-use-auth-source-for-nickserv-password t
erc-prompt-for-password nil
erc-public-away-p t
erc-server "irc.libera.chat"
erc-server-coding-system '(utf-8 . undecided)
erc-server-reconnect-attempts 10
erc-server-reconnect-timeout 10
erc-timestamp-format "%H:%M"
erc-timestamp-only-if-changed-flag t
erc-timestamp-right-column 84
erc-user-full-name "https://jao.io"
erc-user-mode "+i"
erc-whowas-on-nosuchnick t)
:config
(define-minor-mode ncm-erc-mode "" nil
(:eval (format " [%s]" (hash-table-count erc-channel-users))))
(add-hook 'erc-mode-hook (lambda () (ncm-erc-mode 1)))
(add-hook 'erc-mode-hook (lambda () (auto-fill-mode -1))))
#+end_src
*** No angles
#+begin_src emacs-lisp
(defun jao-erc--no-angles (old-func &rest args)
(let ((msg (apply old-func args)))
(replace-regexp-in-string "^<\\([^>]+\\)>" "(\\1)" msg)))
(with-eval-after-load "erc"
(modify-syntax-entry ?\( "." erc-mode-syntax-table)
(modify-syntax-entry ?\) "." erc-mode-syntax-table)
(advice-add 'erc-format-privmessage :around #'jao-erc--no-angles)
(advice-add 'erc-format-my-nick :around #'jao-erc--no-angles))
#+end_src
*** Tracking
#+begin_src emacs-lisp
(defun jao-erc-track-shorten (names)
(let ((names (erc-track-shorten-names names)))
(mapcar (lambda (n) (string-remove-prefix "#" n)) names)))
(setq erc-track-exclude-server-buffer t
erc-track-exclude-types '("NICK" "JOIN" "PART" "QUIT" "MODE" "KICK")
erc-track-remove-disconnected-buffers t
erc-track-shorten-aggressively t ;; 'max
erc-track-shorten-function #'jao-erc-track-shorten
erc-track-switch-direction 'importance
erc-track-visibility nil ;; t all, nil only selected frame
erc-track-position-in-mode-line nil
erc-track-enable-keybindings nil ;; 'ask
erc-track-faces-priority-list '(erc-error-face
erc-current-nick-face
erc-pal-face
erc-direct-msg-face
erc-nick-msg-face
erc-default-face
erc-action-face
erc-notice-face))
(defun jao-track-erc-buffers ()
(dolist (e erc-modified-channels-alist)
(tracking-add-buffer (car e) (list (cddr e)))))
(with-eval-after-load "erc-track"
(require 'tracking nil t)
(add-hook 'exwm-workspace-switch-hook #'erc-modified-channels-update)
(add-hook 'erc-track-list-changed-hook #'jao-track-erc-buffers))
(jao-shorten-modes 'erc-mode)
(jao-tracking-faces 'erc-error-face
'erc-pal-face
'erc-current-nick-face
'erc-direct-msg-face)
#+end_src
*** Commands (/recover &co.)
#+begin_src emacs-lisp
(defun erc-cmd-RECOVER (&rest ignore)
"Recover nick"
(let ((fn (jao--get-user/password "freenode")))
(erc-cmd-MSG (format "nickserv IDENTIFY %s %s" (car fn) (cadr fn)))
(erc-cmd-MSG (format "nickserv GHOST %s" (car fn)))
(erc-cmd-MSG (format "nickserv RELEASE %s" (car fn)))
(erc-cmd-NICK (car fn))))
#+end_src
*** Startup
#+begin_src emacs-lisp
(defun jao-erc (&optional yes)
(interactive "P")
;; (when (or yes (y-or-n-p "Connect to bitlbee using ERC? "))
;; (erc-select :server "localhost"))
(when (or yes (y-or-n-p "Connect to libera using ERC? "))
(erc-select :server "irc.libera.chat")))
#+end_src
* switch window
An alternative for this one is ace-window, but it has the problem
of not displaying its overlay over org buffers (sometimes) and
introducing a dependency (avy).
#+begin_src emacs-lisp
(use-package switch-window
:ensure t
:custom ((switch-window-minibuffer-shortcut ?z)
(switch-window-background t)
(switch-window-shortcut-style 'qwerty)
(switch-window-timeout 7)
(switch-window-threshold 2))
:init (defalias 'jao-other-window 'switch-window)
:config
(defun jao-switch-window--then (prompt cmd)
(let ((f `(lambda ()
(let ((default-directory ,default-directory))
(call-interactively ',cmd)))))
(switch-window--then prompt f f)))
(defun jao-switch-window-then-dired ()
(interactive)
(jao-switch-window--then "Find directory" 'dired))
(defun jao-switch-window-then-find-file ()
(interactive)
(jao-switch-window--then "Find file" 'find-file))
(defun jao-switch-window-then-consult-buffer ()
(interactive)
(jao-switch-window--then "Switch to buffer" 'consult-buffer))
:bind (("M-o" . switch-window)
("M-O" . switch-window-then-swap-buffer)
("H-s-o" . switch-window)
("H-s-O" . switch-window-then-swap-buffer)
("C-x 4 d" . jao-switch-window-then-dired)
("C-x 4 f" . jao-switch-window-then-find-file)
("C-x 4 b" . jao-switch-window-then-consult-buffer)))
#+end_src
|