From b4248461e88241cb81f64ea6c073dad82df8b48c Mon Sep 17 00:00:00 2001 From: Emanuel Berg Date: Tue, 23 Jan 2024 14:21:49 +0100 Subject: [PATCH] Make erc-cmd-AMSG session local; add /GMSG, /AME and /GME * lisp/erc/erc.el (erc-cmd-AMSG): Make it consistent with the doc string by only affecting the current connection. (erc-cmd-GMSG, erc-cmd-AME, erc-cmd-GME): new IRC slash commands (Bug#68401) --- lisp/erc/erc.el | 44 +++++++++++++++++++++++++++++++++++++------- 1 file changed, 37 insertions(+), 7 deletions(-) diff --git a/lisp/erc/erc.el b/lisp/erc/erc.el index 767a693a52e..e89733e7871 100644 --- a/lisp/erc/erc.el +++ b/lisp/erc/erc.el @@ -4004,16 +4004,46 @@ erc--split-string-shell-cmd ;; Input commands handlers ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -(defun erc-cmd-AMSG (line) - "Send LINE to all channels of the current server that you are on." - (interactive "sSend to all channels you're on: ") - (setq line (erc-trim-string line)) +(defun erc--connected-and-joined-p () + (and (erc--current-buffer-joined-p) + erc-server-connected)) + +(defun erc-cmd-GMSG (line) + "Send LINE to all channels on all networks you are on." + (setq line (string-remove-prefix " " line)) (erc-with-all-buffers-of-server nil - (lambda () - (erc-channel-p (erc-default-target))) - (erc-send-message line))) + (lambda () (erc-channel-p (erc-default-target))) + (when (erc--connected-and-joined-p) + (erc-send-message line)))) +(put 'erc-cmd-GMSG 'do-not-parse-args t) + +(defun erc-cmd-AMSG (line) + "Send LINE to all channels of the current network. +Interactively, prompt for the line of text to send." + (interactive "sSend to all channels on this network: ") + (setq line (string-remove-prefix " " line)) + (erc-with-all-buffers-of-server erc-server-process + (lambda () (erc-channel-p (erc-default-target))) + (when (erc--connected-and-joined-p) + (erc-send-message line)))) (put 'erc-cmd-AMSG 'do-not-parse-args t) +(defun erc-cmd-GME (line) + "Send LINE as an action to all channels on all networks you are on." + (erc-with-all-buffers-of-server nil + (lambda () (erc-channel-p (erc-default-target))) + (when (erc--connected-and-joined-p) + (erc-cmd-ME line)))) +(put 'erc-cmd-GME 'do-not-parse-args t) + +(defun erc-cmd-AME (line) + "Send LINE as an action to all channels on the current network." + (erc-with-all-buffers-of-server erc-server-process + (lambda () (erc-channel-p (erc-default-target))) + (when (erc--connected-and-joined-p) + (erc-cmd-ME line)))) +(put 'erc-cmd-AME 'do-not-parse-args t) + (defun erc-cmd-SAY (line) "Send LINE to the current query or channel as a message, not a command. -- 2.39.2