* .emacs.d/lisp/bandali-gnus.el: Tweak gnus-posting-styles.
[~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-2022 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 (setq
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
67 ;; (set-face-attribute
68 ;; 'erc-nick-default-face nil
69 ;; ;; :weight 'semibold
70 ;; ;; :background "#f2f2f2"
71 ;; ;; :foreground "#222222"
72 ;; :weight 'bold
73 ;; :background "#f8f8f8"
74 ;; :foreground "#6a6a6a")
75
76 ;; (set-face-attribute
77 ;; 'erc-notice-face nil
78 ;; ;; :background "#fffadf"
79 ;; ;; :background "#f9f9f9"
80 ;; :background 'unspecified
81 ;; ;; :foreground "#809de5"
82 ;; :foreground "steel blue")
83
84 ;; erc-fill
85 ;; (setq
86 ;; erc-fill-column 77
87 ;; erc-fill-function 'erc-fill-variable
88 ;; erc-fill-static-center 18)
89 ;; to disable:
90 ;; (erc-fill-mode -1)
91
92 ;; erc-log
93 (defun b/erc-log-directory (buffer target _nick server _port)
94 (let ((directory (concat (b/var "erc/logs/")
95 ;; (or (with-current-buffer buffer
96 ;; (symbol-name erc-network))
97 ;; server)
98 server
99 (if (erc-server-buffer-p buffer)
100 (concat "/" server)
101 (and target (concat "/" target))))))
102 (unless (file-exists-p directory)
103 (make-directory directory 'make-parents))
104 directory))
105 (defun b/erc-log-file-name (&rest _)
106 (concat (format-time-string "%Y-%m-%d") ".log"))
107 (setq
108 ;; erc-enable-logging 'erc-log-all-but-server-buffers
109 erc-generate-log-file-name-function #'b/erc-log-file-name
110 erc-log-channels-directory #'b/erc-log-directory
111 erc-log-file-coding-system 'utf-8
112 erc-log-write-after-insert t
113 erc-log-write-after-send t
114 erc-save-buffer-on-part nil
115 erc-save-queries-on-quit nil)
116
117 (with-eval-after-load 'erc-match
118 (setq
119 erc-pal-highlight-type 'nick
120 erc-pals
121 '("bremner" "^gopar" "^iank" "quidam" "^rwp" "sudoman"
122 "technomancy" "thomzane"))
123 (set-face-attribute
124 'erc-pal-face nil
125 :foreground 'unspecified
126 :weight 'unspecified
127 :inherit 'erc-nick-default-face
128 ;; :background (face-attribute 'font-lock-string-face :background)
129 :background "#ffffdf"))
130
131 (with-eval-after-load 'erc-pcomplete
132 (setq erc-pcomplete-nick-postfix ",")
133 ;; for matterircd nick (username) completions
134 ;; (advice-add
135 ;; #'pcomplete-erc-nicks
136 ;; :around
137 ;; (lambda (orig-fun &rest args)
138 ;; (let ((nicks (apply orig-fun args)))
139 ;; (if (string-match-p "matterircd" (symbol-name (erc-network)))
140 ;; (mapcar (lambda (nick) (concat "@" nick)) nicks)
141 ;; nicks))))
142 )
143
144 (with-eval-after-load 'erc-stamp
145 (setq erc-timestamp-only-if-changed-flag nil
146 erc-timestamp-format "%T "
147 erc-insert-timestamp-function 'erc-insert-timestamp-left))
148 (with-eval-after-load 'erc-match
149 (set-face-attribute
150 'erc-timestamp-face nil
151 :foreground "#aaaaaa"
152 :weight 'unspecified
153 :background 'unspecified))
154
155 (with-eval-after-load 'erc-track
156 (setq
157 erc-track-enable-keybindings nil
158 erc-track-exclude-types '("JOIN" "MODE" "NICK" "PART" "QUIT"
159 "324" "329" "332" "333" "353" "477")
160 erc-track-position-in-mode-line t
161 erc-track-priority-faces-only 'all
162 erc-track-shorten-function nil
163 erc-track-showcount t))
164
165 (declare-function erc-update-modules "erc")
166 (erc-update-modules)
167
168 ;; key bindings
169 (global-set-key (kbd "C-c w e") #'erc-switch-to-buffer-other-window)
170 (define-key erc-mode-map (kbd "M-a") #'erc-track-switch-buffer))
171
172;; global key bindings
173(global-set-key
174 (kbd "C-c e l")
175 (lambda ()
176 (interactive)
177 (erc-tls :server "irc.libera.chat" :port 6697
178 :client-certificate t)))
179(global-set-key
180 (kbd "C-c e o")
181 (lambda ()
182 (interactive)
183 (erc-tls :server "irc.oftc.net" :port 6697
184 :client-certificate t)))
185(global-set-key
186 (kbd "C-c e t")
187 (lambda ()
188 (interactive)
189 (erc-tls :server "na.tilde.chat" :port 6697
190 :client-certificate t)))
191
192;; (global-set-key
193;; (kbd "C-c e c")
194;; (lambda ()
195;; (interactive)
196;; (erc :server "localhost" :port 6667
197;; :id 'matterircd-canonical)))
198
199(provide 'bandali-erc)
200;;; bandali-erc.el ends here