From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: "J.P." Newsgroups: gmane.emacs.bugs Subject: bug#68401: 30.0.50; ERC 5.6-git: `erc-cmd-GMSG', `erc-cmd-AMSG', `erc-cmd-GME', `erc-cmd-AME'. 2nd attempt Date: Tue, 23 Jan 2024 16:36:06 -0800 Message-ID: <87bk9bh8jt.fsf__34675.6314321951$1706056632$gmane$org@neverwas.me> References: <87v87yvnly.fsf@dataswamp.org> <834jfikb4d.fsf@gnu.org> <87mstavias.fsf@dataswamp.org> <87wmseoskl.fsf@dataswamp.org> <87plxyowpg.fsf__13716.8874776521$1705633220$gmane$org@neverwas.me> <87wms1k6xg.fsf@dataswamp.org> <87plxt2yjx.fsf@neverwas.me> <87ttn5job9.fsf@dataswamp.org> <87r0i9jhp6.fsf@dataswamp.org> <87zfwxxdmn.fsf__6793.81943061657$1705958905$gmane$org@neverwas.me> <87zfwwism6.fsf@dataswamp.org> <87wms0is9o.fsf@dataswamp.org> <87sf2oin9p.fsf@dataswamp.org> <87le8gi3bn.fsf@dataswamp.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="30984"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: emacs-erc@gnu.org To: 68401@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Jan 24 01:37:04 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rSRGJ-0007s3-BI for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 24 Jan 2024 01:37:03 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rSRGE-0006Ni-Kq; Tue, 23 Jan 2024 19:36:58 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rSRGD-0006NW-4B for bug-gnu-emacs@gnu.org; Tue, 23 Jan 2024 19:36:57 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rSRGC-0004QW-Sb for bug-gnu-emacs@gnu.org; Tue, 23 Jan 2024 19:36:56 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rSRGH-0000A7-Pe for bug-gnu-emacs@gnu.org; Tue, 23 Jan 2024 19:37:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: "J.P." Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 24 Jan 2024 00:37:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 68401 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 68401-submit@debbugs.gnu.org id=B68401.1706056579573 (code B ref 68401); Wed, 24 Jan 2024 00:37:01 +0000 Original-Received: (at 68401) by debbugs.gnu.org; 24 Jan 2024 00:36:19 +0000 Original-Received: from localhost ([127.0.0.1]:44187 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rSRFa-00009A-O7 for submit@debbugs.gnu.org; Tue, 23 Jan 2024 19:36:19 -0500 Original-Received: from mail-108-mta254.mxroute.com ([136.175.108.254]:33013) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rSRFY-000093-W5 for 68401@debbugs.gnu.org; Tue, 23 Jan 2024 19:36:17 -0500 Original-Received: from filter006.mxroute.com ([136.175.111.2] filter006.mxroute.com) (Authenticated sender: mN4UYu2MZsgR) by mail-108-mta254.mxroute.com (ZoneMTA) with ESMTPSA id 18d38e550680003727.001 for <68401@debbugs.gnu.org> (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384); Wed, 24 Jan 2024 00:36:08 +0000 X-Zone-Loop: a87e17d3a2aa6ee336349d139d21ebc2551a92c8f6bc X-Originating-IP: [136.175.111.2] DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=neverwas.me ; s=x; h=Content-Type:MIME-Version:Message-ID:Date:References:In-Reply-To: Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=o0u5NYYHHDrwR9RMrqGomCtLPYj9bqToHDpH7XQ9i8g=; b=OP+OrZaLLEkDxOsuNu7ZzsIeLW zVQvfwSNJ9ij32KWDDqd7JS8aafpIjMgZTKVClG2edjhrHq3ZN4gBSikskiBeTbg3sa45+qAflDPd nhAQ9stG2hdk/4xdXYZhjQ56KiIEKmN/9KFHCx1XZ/XK+uRLr01c9LRxoVjVYvgi4VZeGSNNBu6j+ LETg85k99xirWKO29MJfJch7xWlx5mqiRz3aonMyOe/9DIEgEsvYAunbWFp6JNtVoIJMpI/+viMfD WwmntbmeZe0JiA71SXIeF+EzzIkdpyUUWo2XdSFmkQIByo/WYNh/x/8maMCUAKBpJO5gFdal59aOP BEAb1X6w==; In-Reply-To: <87le8gi3bn.fsf@dataswamp.org> (Emanuel Berg's message of "Tue, 23 Jan 2024 14:31:24 +0100") X-Authenticated-Id: masked@neverwas.me X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:278753 Archived-At: Emanuel Berg writes: > Tags: patch > > Here is a patch with the latest version. > > I'll run the unit test now. > >> 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)) I took your initial remarks advocating for a DRY helper and, in particular, this bit about error-proneness Okay, but instead of having these checks embedded and hopefully correctly repeated four times, shouldn't we ... to mean you wanted to factor out more than just a predicate, e.g., with something like (defun erc--run-in-joined-buffers (line-function line &optional proc) (erc-with-all-buffers-of-server proc #'erc--connected-and-joined-p (funcall line-function line))) (Not that I think such a thing is needed.) > + > +(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) I don't understand the point of adding your purpose-built predicate `erc--connected-and-joined-p' if you're not going to use it to replace (lambda () (erc-channel-p (erc-default-target))) completely. IOW, having both is redundant. If you're not already doing so, please try expanding your macro use sites to verify correctness. > + > +(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