Commit | Line | Data |
---|---|---|
4c05c418 AB |
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 | ||
8c4704d0 AB |
27 | (defvar b/erc-detach-on-kill t |
28 | "Whether killing a channel should send a DETACH command (for ZNC).") | |
29 | ||
c84be134 | 30 | (with-eval-after-load 'erc |
0596e3cf | 31 | (make-directory (b/var "erc/dcc/") t) |
c84be134 AB |
32 | (csetq |
33 | erc-auto-query 'bury | |
34 | erc-autojoin-domain-only nil | |
0596e3cf | 35 | erc-dcc-get-default-directory (b/var "erc/dcc/") |
c84be134 AB |
36 | erc-format-nick-function 'erc-format-@nick |
37 | erc-join-buffer 'bury | |
0596e3cf | 38 | erc-log-channels-directory (b/var "erc/log-channels/") |
c84be134 AB |
39 | erc-lurker-hide-list '("JOIN" "PART" "QUIT") |
40 | erc-nick "bandali" | |
41 | erc-prompt "erc>" | |
8c4704d0 | 42 | erc-prompt-for-password nil |
c84be134 AB |
43 | erc-rename-buffers t |
44 | erc-server-reconnect-attempts 5 | |
45 | erc-server-reconnect-timeout 3) | |
46 | ||
5361eed6 AB |
47 | (declare-function erc-message "erc-backend" |
48 | (message-command line &optional force)) | |
49 | (declare-function erc-default-target "erc") | |
50 | (declare-function erc-current-nick "erc") | |
39c1c073 AB |
51 | (defun erc-cmd-OPME () |
52 | "Request chanserv to op me." | |
53 | (erc-message "PRIVMSG" | |
54 | (format "chanserv op %s %s" | |
55 | (erc-default-target) | |
56 | (erc-current-nick)) nil)) | |
5361eed6 | 57 | (declare-function erc-cmd-DEOP "erc" (&rest people)) |
39c1c073 AB |
58 | (defun erc-cmd-DEOPME () |
59 | "Deop myself from current channel." | |
60 | (erc-cmd-DEOP (format "%s" (erc-current-nick)))) | |
61 | (add-to-list 'erc-modules 'keep-place) | |
62 | (add-to-list 'erc-modules 'notifications) | |
63 | (add-to-list 'erc-modules 'smiley) | |
64 | (add-to-list 'erc-modules 'spelling) | |
5361eed6 | 65 | (declare-function erc-update-modules "erc") |
c84be134 AB |
66 | (erc-update-modules) |
67 | ||
86dd267a AB |
68 | (set-face-attribute |
69 | 'erc-nick-default-face nil | |
70 | :weight 'semibold | |
71 | :background "#f2f2f2" | |
72 | :foreground "#222222") | |
73 | ||
c84be134 | 74 | ;; erc-fill |
8c4704d0 AB |
75 | ;; (csetq |
76 | ;; erc-fill-column 77 | |
77 | ;; erc-fill-function 'erc-fill-variable | |
78 | ;; erc-fill-static-center 18) | |
79 | ;; to disable: | |
80 | ;; (erc-fill-mode -1) | |
c84be134 AB |
81 | |
82 | ;; erc-match | |
8c4704d0 AB |
83 | (csetq |
84 | erc-pal-highlight-type 'nick | |
85 | erc-pals '("aindilis" "blackbeard" "brettgilio" "civodul" "dto" | |
86 | "ggoes" "jrasata" "mplsCorwin" "rwp" "technomancy")) | |
87 | (with-eval-after-load 'erc-match | |
88 | (set-face-attribute | |
89 | 'erc-pal-face nil | |
90 | :foreground 'unspecified | |
91 | :weight 'unspecified | |
86dd267a AB |
92 | :inherit 'erc-nick-default-face |
93 | :background (face-attribute 'font-lock-string-face :background))) | |
c84be134 AB |
94 | |
95 | ;; erc-pcomplete | |
96 | (csetq erc-pcomplete-nick-postfix ", ") | |
97 | ||
8c4704d0 AB |
98 | ;; erc-stamp |
99 | (csetq erc-timestamp-only-if-changed-flag nil | |
100 | erc-timestamp-format "%T " | |
101 | erc-insert-timestamp-function 'erc-insert-timestamp-left) | |
102 | (with-eval-after-load 'erc-match | |
103 | (set-face-attribute | |
104 | 'erc-timestamp-face nil | |
105 | :foreground "#aaaaaa" | |
106 | :weight 'unspecified | |
107 | :background 'unspecified)) | |
108 | ||
c84be134 AB |
109 | ;; erc-track |
110 | (csetq | |
111 | erc-track-enable-keybindings nil | |
112 | erc-track-exclude-types '("JOIN" "MODE" "NICK" "PART" "QUIT" | |
113 | "324" "329" "332" "333" "353" "477") | |
114 | erc-track-position-in-mode-line t | |
115 | erc-track-priority-faces-only 'all | |
116 | erc-track-shorten-function nil | |
117 | erc-track-showcount t) | |
118 | ||
119 | ;; key bindings | |
120 | (global-set-key (kbd "C-c w e") #'erc-switch-to-buffer-other-window) | |
8c4704d0 AB |
121 | (define-key erc-mode-map (kbd "M-a") #'erc-track-switch-buffer) |
122 | ||
123 | ;; hooks | |
124 | (defun b/erc-detach-or-kill-channel () | |
125 | (if b/erc-detach-on-kill | |
126 | (when (erc-server-process-alive) | |
127 | (let ((tgt (erc-default-target))) | |
128 | (erc-server-send (format "DETACH %s" tgt) nil tgt))) | |
129 | (erc-kill-channel))) | |
130 | (add-hook 'erc-kill-channel-hook #'b/erc-detach-or-kill-channel) | |
131 | (remove-hook 'erc-kill-channel-hook #'erc-kill-channel)) | |
132 | ||
c84be134 | 133 | ;; global key bindings |
8c4704d0 AB |
134 | (global-set-key |
135 | (kbd "C-c a e f") | |
136 | (lambda () | |
137 | (interactive) | |
138 | (let* ((auth (auth-source-search :host "znca")) | |
139 | (p (if (null auth) | |
140 | (error "Couldn't find znca's authinfo") | |
141 | (funcall (plist-get (car auth) :secret))))) | |
142 | (erc-tls :server "znc.emacsconf.org" :port 6697 | |
143 | :password (concat "bandali/freenode:" p))))) | |
144 | (global-set-key | |
145 | (kbd "C-c a e o") | |
146 | (lambda () | |
147 | (interactive) | |
148 | (let* ((auth (auth-source-search :host "znca")) | |
149 | (p (if (null auth) | |
150 | (error "Couldn't find znca's authinfo") | |
151 | (funcall (plist-get (car auth) :secret))))) | |
152 | (erc-tls :server "znc.emacsconf.org" :port 6697 | |
153 | :password (concat "bandali/oftc:" p))))) | |
154 | (global-set-key | |
155 | (kbd "C-c a e t") | |
156 | (lambda () | |
157 | (interactive) | |
158 | (let* ((auth (auth-source-search :host "znca")) | |
159 | (p (if (null auth) | |
160 | (error "Couldn't find znca's authinfo") | |
161 | (funcall (plist-get (car auth) :secret))))) | |
162 | (erc-tls :server "znc.emacsconf.org" :port 6697 | |
163 | :password (concat "bandali/tildechat:" p))))) | |
39c1c073 AB |
164 | |
165 | (provide 'bandali-erc) | |
4c05c418 | 166 | ;;; bandali-erc.el ends here |