about summary refs log tree commit diff stats
path: root/lisp
diff options
context:
space:
mode:
Diffstat (limited to 'lisp')
-rw-r--r--lisp/acdw-erc.el85
-rw-r--r--lisp/acdw-modeline.el3
2 files changed, 87 insertions, 1 deletions
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)