Add some missing bins
[~bandali/configs] / .emacs.d / lisp / bandali-erc.el
CommitLineData
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
9867e4bb 43 erc-query-display 'buffer
c84be134
AB
44 erc-rename-buffers t
45 erc-server-reconnect-attempts 5
46 erc-server-reconnect-timeout 3)
47
5361eed6
AB
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")
39c1c073
AB
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)
0ef64d0d
AB
57 (erc-current-nick))
58 nil))
5361eed6 59 (declare-function erc-cmd-DEOP "erc" (&rest people))
39c1c073
AB
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)
adba94a7
AB
64 (when (display-graphic-p)
65 (add-to-list 'erc-modules 'notifications))
39c1c073
AB
66 (add-to-list 'erc-modules 'smiley)
67 (add-to-list 'erc-modules 'spelling)
5361eed6 68 (declare-function erc-update-modules "erc")
c84be134
AB
69 (erc-update-modules)
70
9867e4bb
AB
71 ;; (set-face-attribute
72 ;; 'erc-nick-default-face nil
73 ;; ;; :weight 'semibold
74 ;; ;; :background "#f2f2f2"
75 ;; ;; :foreground "#222222"
76 ;; :weight 'bold
77 ;; :background "#f8f8f8"
78 ;; :foreground "#6a6a6a")
927b50b7
AB
79
80 ;; (set-face-attribute
81 ;; 'erc-notice-face nil
82 ;; ;; :background "#fffadf"
83 ;; ;; :background "#f9f9f9"
84 ;; :background 'unspecified
85 ;; ;; :foreground "#809de5"
86 ;; :foreground "steel blue")
86dd267a 87
c84be134 88 ;; erc-fill
8c4704d0
AB
89 ;; (csetq
90 ;; erc-fill-column 77
91 ;; erc-fill-function 'erc-fill-variable
92 ;; erc-fill-static-center 18)
93 ;; to disable:
94 ;; (erc-fill-mode -1)
c84be134
AB
95
96 ;; erc-match
8c4704d0
AB
97 (csetq
98 erc-pal-highlight-type 'nick
927b50b7 99 erc-pals
9867e4bb
AB
100 '("bremner" "^gopar" "^iank" "quidam" "^rwp" "sudoman"
101 "technomancy" "thomzane"))
8c4704d0
AB
102 (with-eval-after-load 'erc-match
103 (set-face-attribute
104 'erc-pal-face nil
105 :foreground 'unspecified
106 :weight 'unspecified
86dd267a 107 :inherit 'erc-nick-default-face
9867e4bb
AB
108 ;; :background (face-attribute 'font-lock-string-face :background)
109 :background "#ffffdf"))
c84be134
AB
110
111 ;; erc-pcomplete
adba94a7 112 (csetq erc-pcomplete-nick-postfix ",")
c84be134 113
8c4704d0
AB
114 ;; erc-stamp
115 (csetq erc-timestamp-only-if-changed-flag nil
116 erc-timestamp-format "%T "
117 erc-insert-timestamp-function 'erc-insert-timestamp-left)
118 (with-eval-after-load 'erc-match
119 (set-face-attribute
120 'erc-timestamp-face nil
121 :foreground "#aaaaaa"
122 :weight 'unspecified
123 :background 'unspecified))
124
c84be134
AB
125 ;; erc-track
126 (csetq
127 erc-track-enable-keybindings nil
128 erc-track-exclude-types '("JOIN" "MODE" "NICK" "PART" "QUIT"
129 "324" "329" "332" "333" "353" "477")
130 erc-track-position-in-mode-line t
131 erc-track-priority-faces-only 'all
132 erc-track-shorten-function nil
133 erc-track-showcount t)
134
135 ;; key bindings
136 (global-set-key (kbd "C-c w e") #'erc-switch-to-buffer-other-window)
8c4704d0
AB
137 (define-key erc-mode-map (kbd "M-a") #'erc-track-switch-buffer)
138
139 ;; hooks
140 (defun b/erc-detach-or-kill-channel ()
141 (if b/erc-detach-on-kill
142 (when (erc-server-process-alive)
143 (let ((tgt (erc-default-target)))
144 (erc-server-send (format "DETACH %s" tgt) nil tgt)))
145 (erc-kill-channel)))
146 (add-hook 'erc-kill-channel-hook #'b/erc-detach-or-kill-channel)
147 (remove-hook 'erc-kill-channel-hook #'erc-kill-channel))
148
c84be134 149;; global key bindings
8c4704d0
AB
150(global-set-key
151 (kbd "C-c a e f")
152 (lambda ()
153 (interactive)
154 (let* ((auth (auth-source-search :host "znca"))
155 (p (if (null auth)
156 (error "Couldn't find znca's authinfo")
157 (funcall (plist-get (car auth) :secret)))))
158 (erc-tls :server "znc.emacsconf.org" :port 6697
159 :password (concat "bandali/freenode:" p)))))
160(global-set-key
161 (kbd "C-c a e o")
162 (lambda ()
163 (interactive)
164 (let* ((auth (auth-source-search :host "znca"))
165 (p (if (null auth)
166 (error "Couldn't find znca's authinfo")
167 (funcall (plist-get (car auth) :secret)))))
168 (erc-tls :server "znc.emacsconf.org" :port 6697
169 :password (concat "bandali/oftc:" p)))))
170(global-set-key
171 (kbd "C-c a e t")
172 (lambda ()
173 (interactive)
174 (let* ((auth (auth-source-search :host "znca"))
175 (p (if (null auth)
176 (error "Couldn't find znca's authinfo")
177 (funcall (plist-get (car auth) :secret)))))
178 (erc-tls :server "znc.emacsconf.org" :port 6697
179 :password (concat "bandali/tildechat:" p)))))
39c1c073
AB
180
181(provide 'bandali-erc)
4c05c418 182;;; bandali-erc.el ends here