* .emacs.d/init.el: Add 'b/invert-default-face' as a simple light/dark theme toggle.
[~bandali/configs] / .emacs.d / lisp / bandali-erc.el
CommitLineData
4c05c418
AB
1;;; bandali-erc.el --- bandali's ERC setup -*- lexical-binding: t; -*-
2
ccb32b49 3;; Copyright (C) 2018-2021 Amin Bandali
4c05c418
AB
4
5;; Author: Amin Bandali <bandali@gnu.org>
ccb32b49 6;; Keywords: IRC, chat, client, Internet
4c05c418
AB
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
ccb32b49 23;; My ERC setup for IRC in GNU Emacs.
4c05c418
AB
24
25;;; Code:
26
c84be134 27(with-eval-after-load 'erc
ccb32b49 28 (make-directory (b/var "erc/dcc") t)
c84be134
AB
29 (csetq
30 erc-auto-query 'bury
31 erc-autojoin-domain-only nil
5b853dff
AB
32 erc-dcc-get-default-directory (b/var "erc/dcc")
33 erc-email-userid "bandali"
c84be134
AB
34 erc-format-nick-function 'erc-format-@nick
35 erc-join-buffer 'bury
6b9cf67b 36 ;; erc-lurker-hide-list '("JOIN" "PART" "QUIT")
c84be134
AB
37 erc-nick "bandali"
38 erc-prompt "erc>"
8c4704d0 39 erc-prompt-for-password nil
9867e4bb 40 erc-query-display 'buffer
c84be134
AB
41 erc-rename-buffers t
42 erc-server-reconnect-attempts 5
43 erc-server-reconnect-timeout 3)
44
5361eed6
AB
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")
39c1c073 49 (defun erc-cmd-OPME ()
ccb32b49 50 "Ask chanserv to op me in the current channel."
39c1c073
AB
51 (erc-message "PRIVMSG"
52 (format "chanserv op %s %s"
53 (erc-default-target)
0ef64d0d
AB
54 (erc-current-nick))
55 nil))
5361eed6 56 (declare-function erc-cmd-DEOP "erc" (&rest people))
39c1c073 57 (defun erc-cmd-DEOPME ()
ccb32b49 58 "Deop myself in the current channel."
39c1c073
AB
59 (erc-cmd-DEOP (format "%s" (erc-current-nick))))
60 (add-to-list 'erc-modules 'keep-place)
5b853dff 61 (add-to-list 'erc-modules 'log)
adba94a7 62 (when (display-graphic-p)
5b853dff
AB
63 (add-to-list 'erc-modules 'notifications)
64 (add-to-list 'erc-modules 'smiley))
39c1c073 65 (add-to-list 'erc-modules 'spelling)
5361eed6 66 (declare-function erc-update-modules "erc")
c84be134
AB
67 (erc-update-modules)
68
9867e4bb
AB
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")
927b50b7
AB
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")
86dd267a 85
c84be134 86 ;; erc-fill
8c4704d0
AB
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)
c84be134 93
5b853dff 94 ;; erc-log
07e38945
AB
95 (defun b/erc-log-directory (buffer target _nick server _port)
96 (let ((directory (concat (b/var "erc/logs/")
97 ;; (or (with-current-buffer buffer
98 ;; (symbol-name erc-network))
99 ;; server)
100 server
101 (if (erc-server-buffer-p buffer)
102 (concat "/" server)
103 (and target (concat "/" target))))))
104 (unless (file-exists-p directory)
105 (make-directory directory 'make-parents))
106 directory))
107 (defun b/erc-log-file-name (&rest _)
108 (concat (format-time-string "%Y-%m-%d") ".log"))
5b853dff
AB
109 (csetq
110 ;; erc-enable-logging 'erc-log-all-but-server-buffers
07e38945
AB
111 erc-generate-log-file-name-function #'b/erc-log-file-name
112 erc-log-channels-directory #'b/erc-log-directory
5b853dff
AB
113 erc-log-file-coding-system 'utf-8
114 erc-log-write-after-insert t
115 erc-log-write-after-send t
116 erc-save-buffer-on-part nil
117 erc-save-queries-on-quit nil)
118
c84be134 119 ;; erc-match
8c4704d0
AB
120 (csetq
121 erc-pal-highlight-type 'nick
927b50b7 122 erc-pals
9867e4bb
AB
123 '("bremner" "^gopar" "^iank" "quidam" "^rwp" "sudoman"
124 "technomancy" "thomzane"))
8c4704d0
AB
125 (with-eval-after-load 'erc-match
126 (set-face-attribute
127 'erc-pal-face nil
128 :foreground 'unspecified
129 :weight 'unspecified
86dd267a 130 :inherit 'erc-nick-default-face
9867e4bb
AB
131 ;; :background (face-attribute 'font-lock-string-face :background)
132 :background "#ffffdf"))
c84be134
AB
133
134 ;; erc-pcomplete
adba94a7 135 (csetq erc-pcomplete-nick-postfix ",")
c84be134 136
8c4704d0
AB
137 ;; erc-stamp
138 (csetq erc-timestamp-only-if-changed-flag nil
139 erc-timestamp-format "%T "
140 erc-insert-timestamp-function 'erc-insert-timestamp-left)
141 (with-eval-after-load 'erc-match
142 (set-face-attribute
143 'erc-timestamp-face nil
144 :foreground "#aaaaaa"
145 :weight 'unspecified
146 :background 'unspecified))
147
c84be134
AB
148 ;; erc-track
149 (csetq
150 erc-track-enable-keybindings nil
151 erc-track-exclude-types '("JOIN" "MODE" "NICK" "PART" "QUIT"
152 "324" "329" "332" "333" "353" "477")
153 erc-track-position-in-mode-line t
154 erc-track-priority-faces-only 'all
155 erc-track-shorten-function nil
156 erc-track-showcount t)
157
158 ;; key bindings
159 (global-set-key (kbd "C-c w e") #'erc-switch-to-buffer-other-window)
ccb32b49 160 (define-key erc-mode-map (kbd "M-a") #'erc-track-switch-buffer))
8c4704d0 161
c84be134 162;; global key bindings
8c4704d0 163(global-set-key
62e41ec5 164 (kbd "C-c a e l")
8c4704d0
AB
165 (lambda ()
166 (interactive)
62e41ec5 167 (erc-tls :server "irc.libera.chat" :port 6697
42afc39e 168 :client-certificate t)))
8c4704d0
AB
169(global-set-key
170 (kbd "C-c a e o")
171 (lambda ()
172 (interactive)
ccb32b49 173 (erc-tls :server "irc.oftc.net" :port 6697
42afc39e 174 :client-certificate t)))
8c4704d0
AB
175(global-set-key
176 (kbd "C-c a e t")
177 (lambda ()
178 (interactive)
ccb32b49 179 (erc-tls :server "na.tilde.chat" :port 6697
42afc39e 180 :client-certificate t)))
39c1c073
AB
181
182(provide 'bandali-erc)
4c05c418 183;;; bandali-erc.el ends here