about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--init.el43
-rw-r--r--lisp/acdw-erc.el85
-rw-r--r--lisp/acdw-modeline.el3
3 files changed, 115 insertions, 16 deletions
diff --git a/init.el b/init.el index b8002a3..2c18993 100644 --- a/init.el +++ b/init.el
@@ -260,22 +260,35 @@
260 260
261;; I don't really use ERC that much, but if/when I start ... I'll be ready. 261;; I don't really use ERC that much, but if/when I start ... I'll be ready.
262(setup erc 262(setup erc
263 (:option erc-track-position-in-mode-line 'before-modes 263 (:require acdw-erc)
264 erc-hide-list '("329" "332" "333" "353" "MODE" 264 (:also-load erc-autoaway
265 "TOPIC" "JOIN" "PART" "QUIT" "NICK")) 265 erc-track)
266 ;; https://www.emacswiki.org/emacs/ErcModeline#h5o-1
267 (defface erc-header-line-disconnected
268 '((t (:foreground "black" :background "indianred")))
269 "Face to use when ERC has been disconnected.")
270 266
271 (defun erc-update-header-line-show-disconnected () 267 (:option erc-auto-discard-away t
272 "Use a different face in the header-line when disconnected." 268 erc-autoaway-idle-seconds 600
273 (erc-with-server-buffer 269 erc-autojoin-channels-alist '(("libera.chat"
274 (cond ((erc-server-process-alive) 'erc-header-line) 270 "#emacs" "##webpals")
275 (t 'erc-header-line-disconnected)))) 271 ("tilde.chat"
276 272 "#meta" "#team" "#gemini"))
277 (:option erc-header-line-face-method 273 erc-header-line-face-method
278 #'erc-update-header-line-show-disconnected)) 274 #'erc/update-header-line-show-disconnected
275 erc-hide-list '("JOIN" "NICK" "PART" "QUIT" "MODE"
276 "324" "329" "332" "333" "353" "477")
277 erc-interpret-mirc-color t
278 erc-kill-buffer-on-part t
279 erc-kill-queries-on-quit t
280 erc-kill-server-buffer-on-quit t
281 erc-nick "acdw"
282 erc-prompt-for-password nil ; use ~/.authinfo
283 erc/servers '("irc.libera.chat"
284 "irc.tilde.chat")
285 erc-server-coding-system '(utf-8 . utf-8)
286 erc-track-exclude-types erc-hide-list
287 erc-track-position-in-mode-line 'before-modes)
288
289 (:hook erc-autoaway-mode
290 erc-track-mode
291 erc-truncate-mode))
279 292
280(setup eshell 293(setup eshell
281 (:option eshell-directory-name (acdw/dir "eshell/" t) 294 (:option eshell-directory-name (acdw/dir "eshell/" t)
diff --git a/lisp/acdw-erc.el b/lisp/acdw-erc.el new file mode 100644 index 0000000..937505f --- /dev/null +++ b/lisp/acdw-erc.el
@@ -0,0 +1,85 @@
1;;; acdw-erc.el -*- lexical-binding: t; coding: utf-8-unix -*-
2
3;; Author: Case Duckworth <acdw@acdw.net>
4;; Created: 24 May 2021
5;; Keywords: configuration
6;; URL: https://tildegit.org/acdw/emacs
7
8;; This file is NOT part of GNU Emacs.
9
10;;; License:
11;; Everyone is permitted to do whatever with this software, without
12;; limitation. This software comes without any warranty whatsoever,
13;; but with two pieces of advice:
14;; - Don't hurt yourself.
15;; - Make good choices.
16
17;;; Commentary:
18;; `acdw-erc' is a dumping ground for functions and stuff for ERC, so they
19;; don't clutter up `init.el'.
20
21;;; Code:
22
23(defgroup acdw-erc nil
24 "Customizations for ERC."
25 :group 'erc)
26
27
28;;; Show a different header-line face when ERC is disconnected.
29;; https://www.emacswiki.org/emacs/ErcModeline#h5o-1
30
31(defface erc/header-line-disconnected
32 '((t (:foreground "black" :background "indianred")))
33 "Face to use when ERC has been disconnected.")
34
35(defun erc/update-header-line-show-disconnected ()
36 "Use a different face in the header-line when disconnected."
37 (erc-with-server-buffer
38 (cond ((erc-server-process-alive) 'erc-header-line)
39 (t 'erc/header-line-disconnected))))
40
41
42;;; Convenience functions
43;; from Prelude:
44;; https://github.com/bbatsov/prelude/blob/master/modules/prelude-erc.el#L114
45
46(defcustom erc/servers nil
47 "The list of IRC servers to connect to with `erc/connect'."
48 :type '(list string))
49
50(defcustom erc/bye-message "See You Space Cowpokes."
51 "Quit message sent when calling `erc/disconnect'."
52 :type 'string)
53
54(defun connect-to-erc (server &optional use-tls port nick)
55 "Connects to IRC SERVER at PORT with NICK.
56If USE-TLS is non-nil, use TLS."
57 (let* ((use-tls (or use-tls t))
58 (erc-fn (if use-tls #'erc-tls #'erc))
59 (port (or port (if use-tls 6697 6667)))
60 (nick (or nick erc-nick)))
61 (funcall erc-fn
62 :server server
63 :port port
64 :nick nick)))
65
66(defun erc/connect ()
67 "Connect to all the servers in `erc/servers'."
68 (interactive)
69 (mapcar #'connect-to-erc erc/servers))
70
71(defun filter-server-buffers ()
72 (delq nil (mapcar (lambda (x)
73 (and (erc-server-buffer-p x) x))
74 (buffer-list))))
75
76(defun erc/disconnect ()
77 "Disconnect from all IRC servers."
78 (interactive)
79 (dolist (buffer (filter-server-buffers))
80 (with-message (format "Killing server buffer: %s" (buffer-name buffer))
81 (with-current-buffer buffer
82 (erc-quit-server acdw-erc/bye-message)))))
83
84(provide 'acdw-erc)
85;;; acdw-erc.el ends here
diff --git a/lisp/acdw-modeline.el b/lisp/acdw-modeline.el index d5589a9..ccc07cb 100644 --- a/lisp/acdw-modeline.el +++ b/lisp/acdw-modeline.el
@@ -32,7 +32,8 @@
32 32
33(defun acdw-modeline/erc () 33(defun acdw-modeline/erc ()
34 "ERC indicator for the modeline." 34 "ERC indicator for the modeline."
35 (format-mode-line erc-modified-channels-object)) 35 (when (boundp 'erc-modified-channels-object)
36 (format-mode-line erc-modified-channels-object)))
36 37
37(defun acdw-modeline/god-mode-indicator () 38(defun acdw-modeline/god-mode-indicator ()
38 (when (bound-and-true-p god-local-mode) 39 (when (bound-and-true-p god-local-mode)