Tweak ERC settings, including enabling logging
[~bandali/configs] / .emacs.d / lisp / bandali-erc.el
... / ...
CommitLineData
1;;; bandali-erc.el --- bandali's ERC setup -*- lexical-binding: t; -*-
2
3;; Copyright (C) 2018-2020 Amin Bandali
4
5;; Author: Amin Bandali <bandali@gnu.org>
6;; Keywords: tools
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. It uses my fork of ZNC.el.
24
25;;; Code:
26
27(defvar b/erc-detach-on-kill t
28 "Whether killing a channel should send a DETACH command (for ZNC).")
29
30(with-eval-after-load 'erc
31 (make-directory (b/var "erc/dcc/") t)
32 (csetq
33 erc-auto-query 'bury
34 erc-autojoin-domain-only nil
35 erc-dcc-get-default-directory (b/var "erc/dcc")
36 erc-email-userid "bandali"
37 erc-format-nick-function 'erc-format-@nick
38 erc-join-buffer 'bury
39 erc-lurker-hide-list '("JOIN" "PART" "QUIT")
40 erc-nick "bandali"
41 erc-prompt "erc>"
42 erc-prompt-for-password nil
43 erc-query-display 'buffer
44 erc-rename-buffers t
45 erc-server-reconnect-attempts 5
46 erc-server-reconnect-timeout 3)
47
48 (declare-function erc-message "erc-backend"
49 (message-command line &optional force))
50 (declare-function erc-default-target "erc")
51 (declare-function erc-current-nick "erc")
52 (defun erc-cmd-OPME ()
53 "Request chanserv to op me."
54 (erc-message "PRIVMSG"
55 (format "chanserv op %s %s"
56 (erc-default-target)
57 (erc-current-nick))
58 nil))
59 (declare-function erc-cmd-DEOP "erc" (&rest people))
60 (defun erc-cmd-DEOPME ()
61 "Deop myself from current channel."
62 (erc-cmd-DEOP (format "%s" (erc-current-nick))))
63 (add-to-list 'erc-modules 'keep-place)
64 (add-to-list 'erc-modules 'log)
65 (when (display-graphic-p)
66 (add-to-list 'erc-modules 'notifications)
67 (add-to-list 'erc-modules 'smiley))
68 (add-to-list 'erc-modules 'spelling)
69 (declare-function erc-update-modules "erc")
70 (erc-update-modules)
71
72 ;; (set-face-attribute
73 ;; 'erc-nick-default-face nil
74 ;; ;; :weight 'semibold
75 ;; ;; :background "#f2f2f2"
76 ;; ;; :foreground "#222222"
77 ;; :weight 'bold
78 ;; :background "#f8f8f8"
79 ;; :foreground "#6a6a6a")
80
81 ;; (set-face-attribute
82 ;; 'erc-notice-face nil
83 ;; ;; :background "#fffadf"
84 ;; ;; :background "#f9f9f9"
85 ;; :background 'unspecified
86 ;; ;; :foreground "#809de5"
87 ;; :foreground "steel blue")
88
89 ;; erc-fill
90 ;; (csetq
91 ;; erc-fill-column 77
92 ;; erc-fill-function 'erc-fill-variable
93 ;; erc-fill-static-center 18)
94 ;; to disable:
95 ;; (erc-fill-mode -1)
96
97 ;; erc-log
98 (csetq
99 ;; erc-enable-logging 'erc-log-all-but-server-buffers
100 erc-generate-log-file-name-function 'erc-generate-log-file-name-with-date
101 erc-log-channels-directory (b/var "erc/logs")
102 erc-log-file-coding-system 'utf-8
103 erc-log-write-after-insert t
104 erc-log-write-after-send t
105 erc-save-buffer-on-part nil
106 erc-save-queries-on-quit nil)
107
108 ;; erc-match
109 (csetq
110 erc-pal-highlight-type 'nick
111 erc-pals
112 '("bremner" "^gopar" "^iank" "quidam" "^rwp" "sudoman"
113 "technomancy" "thomzane"))
114 (with-eval-after-load 'erc-match
115 (set-face-attribute
116 'erc-pal-face nil
117 :foreground 'unspecified
118 :weight 'unspecified
119 :inherit 'erc-nick-default-face
120 ;; :background (face-attribute 'font-lock-string-face :background)
121 :background "#ffffdf"))
122
123 ;; erc-pcomplete
124 (csetq erc-pcomplete-nick-postfix ",")
125
126 ;; erc-stamp
127 (csetq erc-timestamp-only-if-changed-flag nil
128 erc-timestamp-format "%T "
129 erc-insert-timestamp-function 'erc-insert-timestamp-left)
130 (with-eval-after-load 'erc-match
131 (set-face-attribute
132 'erc-timestamp-face nil
133 :foreground "#aaaaaa"
134 :weight 'unspecified
135 :background 'unspecified))
136
137 ;; erc-track
138 (csetq
139 erc-track-enable-keybindings nil
140 erc-track-exclude-types '("JOIN" "MODE" "NICK" "PART" "QUIT"
141 "324" "329" "332" "333" "353" "477")
142 erc-track-position-in-mode-line t
143 erc-track-priority-faces-only 'all
144 erc-track-shorten-function nil
145 erc-track-showcount t)
146
147 ;; key bindings
148 (global-set-key (kbd "C-c w e") #'erc-switch-to-buffer-other-window)
149 (define-key erc-mode-map (kbd "M-a") #'erc-track-switch-buffer)
150
151 ;; hooks
152 (defun b/erc-detach-or-kill-channel ()
153 (if b/erc-detach-on-kill
154 (when (erc-server-process-alive)
155 (let ((tgt (erc-default-target)))
156 (erc-server-send (format "DETACH %s" tgt) nil tgt)))
157 (erc-kill-channel)))
158 (add-hook 'erc-kill-channel-hook #'b/erc-detach-or-kill-channel)
159 (remove-hook 'erc-kill-channel-hook #'erc-kill-channel))
160
161;; global key bindings
162(global-set-key
163 (kbd "C-c a e f")
164 (lambda ()
165 (interactive)
166 (let* ((auth (auth-source-search :host "znca"))
167 (p (if (null auth)
168 (error "Couldn't find znca's authinfo")
169 (funcall (plist-get (car auth) :secret)))))
170 (erc-tls :server "znc.emacsconf.org" :port 6697
171 :password (concat "bandali/freenode:" p)))))
172(global-set-key
173 (kbd "C-c a e o")
174 (lambda ()
175 (interactive)
176 (let* ((auth (auth-source-search :host "znca"))
177 (p (if (null auth)
178 (error "Couldn't find znca's authinfo")
179 (funcall (plist-get (car auth) :secret)))))
180 (erc-tls :server "znc.emacsconf.org" :port 6697
181 :password (concat "bandali/oftc:" p)))))
182(global-set-key
183 (kbd "C-c a e t")
184 (lambda ()
185 (interactive)
186 (let* ((auth (auth-source-search :host "znca"))
187 (p (if (null auth)
188 (error "Couldn't find znca's authinfo")
189 (funcall (plist-get (car auth) :secret)))))
190 (erc-tls :server "znc.emacsconf.org" :port 6697
191 :password (concat "bandali/tildechat:" p)))))
192
193(provide 'bandali-erc)
194;;; bandali-erc.el ends here