* .emacs.d/lisp/bandali-erc.el: Look up certs from authinfo file
[~bandali/configs] / .emacs.d / lisp / bandali-erc.el
1 ;;; bandali-erc.el --- bandali's ERC setup -*- lexical-binding: t; -*-
2
3 ;; Copyright (C) 2018-2021 Amin Bandali
4
5 ;; Author: Amin Bandali <bandali@gnu.org>
6 ;; Keywords: IRC, chat, client, Internet
7
8 ;; This program is free software; you can redistribute it and/or modify
9 ;; it under the terms of the GNU General Public License as published by
10 ;; the Free Software Foundation, either version 3 of the License, or
11 ;; (at your option) any later version.
12
13 ;; This program is distributed in the hope that it will be useful,
14 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ;; GNU General Public License for more details.
17
18 ;; You should have received a copy of the GNU General Public License
19 ;; along with this program. If not, see <https://www.gnu.org/licenses/>.
20
21 ;;; Commentary:
22
23 ;; My ERC setup for IRC in GNU Emacs.
24
25 ;;; Code:
26
27 (with-eval-after-load 'erc
28 (make-directory (b/var "erc/dcc") t)
29 (csetq
30 erc-auto-query 'bury
31 erc-autojoin-domain-only nil
32 erc-dcc-get-default-directory (b/var "erc/dcc")
33 erc-email-userid "bandali"
34 erc-format-nick-function 'erc-format-@nick
35 erc-join-buffer 'bury
36 erc-lurker-hide-list '("JOIN" "PART" "QUIT")
37 erc-nick "bandali"
38 erc-prompt "erc>"
39 erc-prompt-for-password nil
40 erc-query-display 'buffer
41 erc-rename-buffers t
42 erc-server-reconnect-attempts 5
43 erc-server-reconnect-timeout 3)
44
45 (declare-function erc-message "erc-backend"
46 (message-command line &optional force))
47 (declare-function erc-default-target "erc")
48 (declare-function erc-current-nick "erc")
49 (defun erc-cmd-OPME ()
50 "Ask chanserv to op me in the current channel."
51 (erc-message "PRIVMSG"
52 (format "chanserv op %s %s"
53 (erc-default-target)
54 (erc-current-nick))
55 nil))
56 (declare-function erc-cmd-DEOP "erc" (&rest people))
57 (defun erc-cmd-DEOPME ()
58 "Deop myself in the current channel."
59 (erc-cmd-DEOP (format "%s" (erc-current-nick))))
60 (add-to-list 'erc-modules 'keep-place)
61 (add-to-list 'erc-modules 'log)
62 (when (display-graphic-p)
63 (add-to-list 'erc-modules 'notifications)
64 (add-to-list 'erc-modules 'smiley))
65 (add-to-list 'erc-modules 'spelling)
66 (declare-function erc-update-modules "erc")
67 (erc-update-modules)
68
69 ;; (set-face-attribute
70 ;; 'erc-nick-default-face nil
71 ;; ;; :weight 'semibold
72 ;; ;; :background "#f2f2f2"
73 ;; ;; :foreground "#222222"
74 ;; :weight 'bold
75 ;; :background "#f8f8f8"
76 ;; :foreground "#6a6a6a")
77
78 ;; (set-face-attribute
79 ;; 'erc-notice-face nil
80 ;; ;; :background "#fffadf"
81 ;; ;; :background "#f9f9f9"
82 ;; :background 'unspecified
83 ;; ;; :foreground "#809de5"
84 ;; :foreground "steel blue")
85
86 ;; erc-fill
87 ;; (csetq
88 ;; erc-fill-column 77
89 ;; erc-fill-function 'erc-fill-variable
90 ;; erc-fill-static-center 18)
91 ;; to disable:
92 ;; (erc-fill-mode -1)
93
94 ;; erc-log
95 (csetq
96 ;; erc-enable-logging 'erc-log-all-but-server-buffers
97 erc-generate-log-file-name-function 'erc-generate-log-file-name-with-date
98 erc-log-channels-directory (b/var "erc/logs")
99 erc-log-file-coding-system 'utf-8
100 erc-log-write-after-insert t
101 erc-log-write-after-send t
102 erc-save-buffer-on-part nil
103 erc-save-queries-on-quit nil)
104
105 ;; erc-match
106 (csetq
107 erc-pal-highlight-type 'nick
108 erc-pals
109 '("bremner" "^gopar" "^iank" "quidam" "^rwp" "sudoman"
110 "technomancy" "thomzane"))
111 (with-eval-after-load 'erc-match
112 (set-face-attribute
113 'erc-pal-face nil
114 :foreground 'unspecified
115 :weight 'unspecified
116 :inherit 'erc-nick-default-face
117 ;; :background (face-attribute 'font-lock-string-face :background)
118 :background "#ffffdf"))
119
120 ;; erc-pcomplete
121 (csetq erc-pcomplete-nick-postfix ",")
122
123 ;; erc-stamp
124 (csetq erc-timestamp-only-if-changed-flag nil
125 erc-timestamp-format "%T "
126 erc-insert-timestamp-function 'erc-insert-timestamp-left)
127 (with-eval-after-load 'erc-match
128 (set-face-attribute
129 'erc-timestamp-face nil
130 :foreground "#aaaaaa"
131 :weight 'unspecified
132 :background 'unspecified))
133
134 ;; erc-track
135 (csetq
136 erc-track-enable-keybindings nil
137 erc-track-exclude-types '("JOIN" "MODE" "NICK" "PART" "QUIT"
138 "324" "329" "332" "333" "353" "477")
139 erc-track-position-in-mode-line t
140 erc-track-priority-faces-only 'all
141 erc-track-shorten-function nil
142 erc-track-showcount t)
143
144 ;; key bindings
145 (global-set-key (kbd "C-c w e") #'erc-switch-to-buffer-other-window)
146 (define-key erc-mode-map (kbd "M-a") #'erc-track-switch-buffer))
147
148 ;; global key bindings
149 (global-set-key
150 (kbd "C-c a e f")
151 (lambda ()
152 (interactive)
153 (erc-tls :server "chat.freenode.net" :port 6697
154 :client-certificate t)))
155 (global-set-key
156 (kbd "C-c a e o")
157 (lambda ()
158 (interactive)
159 (erc-tls :server "irc.oftc.net" :port 6697
160 :client-certificate t)))
161 (global-set-key
162 (kbd "C-c a e t")
163 (lambda ()
164 (interactive)
165 (erc-tls :server "na.tilde.chat" :port 6697
166 :client-certificate t)))
167
168 (provide 'bandali-erc)
169 ;;; bandali-erc.el ends here