aboutsummaryrefslogtreecommitdiff
path: root/modules/erc-config.el
diff options
context:
space:
mode:
Diffstat (limited to 'modules/erc-config.el')
-rw-r--r--modules/erc-config.el70
1 files changed, 48 insertions, 22 deletions
diff --git a/modules/erc-config.el b/modules/erc-config.el
index 067b1e577..3e98a66a3 100644
--- a/modules/erc-config.el
+++ b/modules/erc-config.el
@@ -33,6 +33,33 @@
;; is read at load time below (erc-user-full-name), so a standalone .elc needs it.
(require 'user-constants)
+;; ERC loads lazily (use-package :commands), so these symbols aren't bound at
+;; this file's compile time. Declare them to keep the byte-compiler quiet
+;; without forcing an eager require.
+
+;; Functions provided by the erc package.
+(declare-function erc-buffer-list "erc")
+(declare-function erc-server-process-alive "erc")
+(declare-function erc-server-or-unjoined-channel-buffer-p "erc")
+(declare-function erc-current-nick "erc")
+(declare-function erc-join-channel "erc")
+(declare-function erc-part-from-channel "erc")
+(declare-function erc-quit-server "erc")
+
+;; Variables read/set in the use-package :config block below.
+(defvar erc-log-channels-directory)
+(defvar erc-track-exclude-types)
+(defvar erc-track-exclude-server-buffer)
+(defvar erc-track-visibility)
+(defvar erc-track-switch-direction)
+(defvar erc-track-showcount)
+;; NOTE: erc-unique-buffers and erc-generate-buffer-name-function are not ERC
+;; variables in Emacs 30.x (no defcustom/defvar in the package); the setq below
+;; only creates inert globals. Declared here to silence the warning without
+;; changing the existing (no-op) behavior -- see the SUSPICIOUS note.
+(defvar erc-unique-buffers)
+(defvar erc-generate-buffer-name-function)
+
;; ------------------------------------ ERC ------------------------------------
;; Server definitions and connection settings
@@ -99,7 +126,7 @@ Change this value to use a different nickname.")
(let ((server-buffers '()))
(dolist (buf (erc-buffer-list))
(with-current-buffer buf
- (when (and (erc-server-buffer-p) (erc-server-process-alive))
+ (when (and (erc-server-or-unjoined-channel-buffer-p) (erc-server-process-alive))
(unless (member (buffer-name) server-buffers)
(push (buffer-name) server-buffers)))))
@@ -132,7 +159,7 @@ Buffer names are shown with server context for clarity."
"Return t if the current buffer is an active ERC server buffer."
(and (derived-mode-p 'erc-mode)
(erc-server-process-alive)
- (erc-server-buffer-p)))
+ (erc-server-or-unjoined-channel-buffer-p)))
(defun cj/erc-get-channels-for-current-server ()
@@ -158,7 +185,7 @@ Auto-adds # prefix if missing. Offers completion from configured channels."
(let ((server-buffers (cl-remove-if-not
(lambda (buf)
(with-current-buffer buf
- (and (erc-server-buffer-p)
+ (and (erc-server-or-unjoined-channel-buffer-p)
(erc-server-process-alive))))
(erc-buffer-list))))
(if server-buffers
@@ -184,6 +211,14 @@ Auto-adds # prefix if missing. Offers completion from configured channels."
(erc-join-channel channel)))
(message "Failed to establish an active ERC connection")))
+(defun cj/erc-generate-buffer-name (parms)
+ "Generate buffer name in the format SERVER-CHANNEL."
+ (let ((network (plist-get parms :server))
+ (target (plist-get parms :target)))
+ (if target
+ (concat (or network "") "-" (or target ""))
+ (or network ""))))
+
;; Keymap for ERC commands (must be defined before use-package erc)
(defvar-keymap cj/erc-keymap
:doc "Keymap for ERC-related commands"
@@ -259,15 +294,7 @@ Auto-adds # prefix if missing. Offers completion from configured channels."
;; Note: erc-rename-buffers is obsolete as of Emacs 29.1 (old behavior is now permanent)
(setq erc-unique-buffers t)
- ;; Custom buffer naming function
- (defun cj/erc-generate-buffer-name (parms)
- "Generate buffer name in the format SERVER-CHANNEL."
- (let ((network (plist-get parms :server))
- (target (plist-get parms :target)))
- (if target
- (concat (or network "") "-" (or target ""))
- (or network ""))))
-
+ ;; Custom buffer naming (cj/erc-generate-buffer-name is defined at top level)
(setq erc-generate-buffer-name-function 'cj/erc-generate-buffer-name)
;; Configure erc-track (show channel activity in modeline)
@@ -338,16 +365,15 @@ NICK is the sender and MESSAGE is the message text."
:after erc
:hook (erc-mode . erc-nicks-mode))
-;; ------------------------------ ERC Yank To Gist -----------------------------
-;; automatically create a Gist if pasting more than 5 lines
-;; this module requires https://github.com/defunkt/gist
-;; via ruby: 'gem install gist' via the aur: yay -S gist
-
-(use-package erc-yank
- :after erc
- :bind
- (:map erc-mode-map
- ("C-y" . erc-yank)))
+;; -------------------------------- ERC Yank ----------------------------------
+;; The erc-yank package was dropped 2026-06-20: a paste over 5 lines became a
+;; PUBLIC gist (it called `gist -P', the clipboard paste flag, with no
+;; `--private'), behind only a single y-or-n-p and with no guard if the `gist'
+;; binary was absent -- a one-keystroke path to publishing whatever sat on the
+;; system clipboard. No replacement binding is needed: erc-mode-map defines no
+;; C-y of its own, so with erc-yank gone C-y falls through to the ordinary
+;; global `yank' and a paste stays local. Gist a large snippet by hand when
+;; that's actually wanted.
(provide 'erc-config)
;;; erc-config.el ends here