From 1a20d6329e567d9d998ac27a7fc3e6fd39c7fb59 Mon Sep 17 00:00:00 2001 From: Case Duckworth Date: Mon, 24 May 2021 17:08:32 -0500 Subject: Further customize ERC I also added acdw-erc.el. --- init.el | 43 +++++++++++++++++--------- lisp/acdw-erc.el | 85 +++++++++++++++++++++++++++++++++++++++++++++++++++ lisp/acdw-modeline.el | 3 +- 3 files changed, 115 insertions(+), 16 deletions(-) create mode 100644 lisp/acdw-erc.el diff --git a/init.el b/init.el index b8002a3..2c18993 100644 --- a/init.el +++ b/init.el @@ -260,22 +260,35 @@ ;; I don't really use ERC that much, but if/when I start ... I'll be ready. (setup erc - (:option erc-track-position-in-mode-line 'before-modes - erc-hide-list '("329" "332" "333" "353" "MODE" - "TOPIC" "JOIN" "PART" "QUIT" "NICK")) - ;; https://www.emacswiki.org/emacs/ErcModeline#h5o-1 - (defface erc-header-line-disconnected - '((t (:foreground "black" :background "indianred"))) - "Face to use when ERC has been disconnected.") + (:require acdw-erc) + (:also-load erc-autoaway + erc-track) - (defun erc-update-header-line-show-disconnected () - "Use a different face in the header-line when disconnected." - (erc-with-server-buffer - (cond ((erc-server-process-alive) 'erc-header-line) - (t 'erc-header-line-disconnected)))) - - (:option erc-header-line-face-method - #'erc-update-header-line-show-disconnected)) + (:option erc-auto-discard-away t + erc-autoaway-idle-seconds 600 + erc-autojoin-channels-alist '(("libera.chat" + "#emacs" "##webpals") + ("tilde.chat" + "#meta" "#team" "#gemini")) + erc-header-line-face-method + #'erc/update-header-line-show-disconnected + erc-hide-list '("JOIN" "NICK" "PART" "QUIT" "MODE" + "324" "329" "332" "333" "353" "477") + erc-interpret-mirc-color t + erc-kill-buffer-on-part t + erc-kill-queries-on-quit t + erc-kill-server-buffer-on-quit t + erc-nick "acdw" + erc-prompt-for-password nil ; use ~/.authinfo + erc/servers '("irc.libera.chat" + "irc.tilde.chat") + erc-server-coding-system '(utf-8 . utf-8) + erc-track-exclude-types erc-hide-list + erc-track-position-in-mode-line 'before-modes) + + (:hook erc-autoaway-mode + erc-track-mode + erc-truncate-mode)) (setup eshell (: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 @@ +;;; acdw-erc.el -*- lexical-binding: t; coding: utf-8-unix -*- + +;; Author: Case Duckworth +;; Created: 24 May 2021 +;; Keywords: configuration +;; URL: https://tildegit.org/acdw/emacs + +;; This file is NOT part of GNU Emacs. + +;;; License: +;; Everyone is permitted to do whatever with this software, without +;; limitation. This software comes without any warranty whatsoever, +;; but with two pieces of advice: +;; - Don't hurt yourself. +;; - Make good choices. + +;;; Commentary: +;; `acdw-erc' is a dumping ground for functions and stuff for ERC, so they +;; don't clutter up `init.el'. + +;;; Code: + +(defgroup acdw-erc nil + "Customizations for ERC." + :group 'erc) + + +;;; Show a different header-line face when ERC is disconnected. +;; https://www.emacswiki.org/emacs/ErcModeline#h5o-1 + +(defface erc/header-line-disconnected + '((t (:foreground "black" :background "indianred"))) + "Face to use when ERC has been disconnected.") + +(defun erc/update-header-line-show-disconnected () + "Use a different face in the header-line when disconnected." + (erc-with-server-buffer + (cond ((erc-server-process-alive) 'erc-header-line) + (t 'erc/header-line-disconnected)))) + + +;;; Convenience functions +;; from Prelude: +;; https://github.com/bbatsov/prelude/blob/master/modules/prelude-erc.el#L114 + +(defcustom erc/servers nil + "The list of IRC servers to connect to with `erc/connect'." + :type '(list string)) + +(defcustom erc/bye-message "See You Space Cowpokes." + "Quit message sent when calling `erc/disconnect'." + :type 'string) + +(defun connect-to-erc (server &optional use-tls port nick) + "Connects to IRC SERVER at PORT with NICK. +If USE-TLS is non-nil, use TLS." + (let* ((use-tls (or use-tls t)) + (erc-fn (if use-tls #'erc-tls #'erc)) + (port (or port (if use-tls 6697 6667))) + (nick (or nick erc-nick))) + (funcall erc-fn + :server server + :port port + :nick nick))) + +(defun erc/connect () + "Connect to all the servers in `erc/servers'." + (interactive) + (mapcar #'connect-to-erc erc/servers)) + +(defun filter-server-buffers () + (delq nil (mapcar (lambda (x) + (and (erc-server-buffer-p x) x)) + (buffer-list)))) + +(defun erc/disconnect () + "Disconnect from all IRC servers." + (interactive) + (dolist (buffer (filter-server-buffers)) + (with-message (format "Killing server buffer: %s" (buffer-name buffer)) + (with-current-buffer buffer + (erc-quit-server acdw-erc/bye-message))))) + +(provide 'acdw-erc) +;;; 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 @@ (defun acdw-modeline/erc () "ERC indicator for the modeline." - (format-mode-line erc-modified-channels-object)) + (when (boundp 'erc-modified-channels-object) + (format-mode-line erc-modified-channels-object))) (defun acdw-modeline/god-mode-indicator () (when (bound-and-true-p god-local-mode) -- cgit 1.4.1-21-gabe81