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#51753: ERC switches to channel buffer on reconnect Date: Fri, 19 Nov 2021 02:36:40 -0800 Message-ID: <87czmwjutj.fsf__36418.2339211524$1637318297$gmane$org@neverwas.me> References: <877ddfgz8q.fsf__46160.5365084083$1636600524$gmane$org@neverwas.me> <87bl2re5eg.fsf@gnus.org> <87lf1ve0m4.fsf@neverwas.me> <877ddf9sht.fsf@gnus.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="21860"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.60 (gnu/linux) Cc: Amin Bandali , 51753@debbugs.gnu.org, emacs-erc@gnu.org, Stefan Kangas To: Lars Ingebrigtsen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Nov 19 11:38:11 2021 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 1mo1HV-0005RJ-4E for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 19 Nov 2021 11:38:10 +0100 Original-Received: from localhost ([::1]:53246 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mo1HS-00039x-Vr for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 19 Nov 2021 05:38:07 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:33880) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mo1GQ-0002dA-Ak for bug-gnu-emacs@gnu.org; Fri, 19 Nov 2021 05:37:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:54854) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mo1GQ-0003Fq-2M for bug-gnu-emacs@gnu.org; Fri, 19 Nov 2021 05:37:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mo1GP-0004F3-Uv for bug-gnu-emacs@gnu.org; Fri, 19 Nov 2021 05: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: Fri, 19 Nov 2021 10:37:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 51753 X-GNU-PR-Package: emacs Original-Received: via spool by 51753-submit@debbugs.gnu.org id=B51753.163731821616292 (code B ref 51753); Fri, 19 Nov 2021 10:37:01 +0000 Original-Received: (at 51753) by debbugs.gnu.org; 19 Nov 2021 10:36:56 +0000 Original-Received: from localhost ([127.0.0.1]:38167 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mo1GK-0004Ei-AZ for submit@debbugs.gnu.org; Fri, 19 Nov 2021 05:36:56 -0500 Original-Received: from mail-108-mta1.mxroute.com ([136.175.108.1]:33647) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mo1GI-0004EQ-9a for 51753@debbugs.gnu.org; Fri, 19 Nov 2021 05:36:54 -0500 Original-Received: from filter004.mxroute.com ([149.28.56.236] filter004.mxroute.com) (Authenticated sender: mN4UYu2MZsgR) by mail-108-mta1.mxroute.com (ZoneMTA) with ESMTPSA id 17d37c51a74000177f.001 for <51753@debbugs.gnu.org> (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES128-GCM-SHA256); Fri, 19 Nov 2021 10:36:44 +0000 X-Zone-Loop: 1fff201c1f01186f20230320652282322cf5beb6dd80 X-Originating-IP: [149.28.56.236] 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:In-Reply-To:Date:References: 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=gbQyTSHdOqntVd/EB8nNcy26pFx7UNxKBVEmqR+c7rc=; b=iiseloqpHYydprl1iNDA7ypyC9 3Cb8gzoncfFvbGdmXItChyPU0wTj3lNxlSGI+5uZIGPo3TcI3nuVwqyfhMQMOTtiq+KVAsTfiVidp ozimx+S5SrlC5vDp35+iI4bwMBKu5LxKkZwFN+z2AEVLBNKtD+05eviOu0Zin8yi1AJIZzm6q2has jSIqOG8IYhAziyhR7agHRtfy4b2UwAFLZA33V4UhiW6Br+beFQ2ZoKyyuFuQ1Qv7XzjLa8aC+884s 0Ingaz/eChsJs/dxTZ/1Lenwwu7IK7IF9vlCd5PubPkOClcEXDkUmka0RtUWHYP2s68A+rSu6BWfK 9rcZQLBA==; In-Reply-To: <877ddf9sht.fsf@gnus.org> (Lars Ingebrigtsen's message of "Thu, 11 Nov 2021 06:22:06 +0100") X-AuthUser: masked@neverwas.me X-Zone-Spam-Resolution: no action X-Zone-Spam-Status: No, score=-0.1, required=15, tests=[ARC_NA=0, FROM_HAS_DN=0, TO_DN_SOME=0, HAS_ATTACHMENT=0, FROM_EQ_ENVFROM=0, MIME_TRACE=0, MIME_GOOD=-0.1, RCPT_COUNT_FIVE=0, MID_RHS_MATCH_FROM=0, RCVD_COUNT_ZERO=0, NEURAL_SPAM=0] 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" Xref: news.gmane.io gmane.emacs.bugs:220404 Archived-At: --=-=-= Content-Type: text/plain Lars Ingebrigtsen writes: >> However, if people want something different to happen when >> automatically reconnecting, we'd probably have to remember whether >> `erc-server-reconnect-count' was ever positive before crossing the >> logical connection threshold for the current session. >> >> This may come down to having `erc-connection-established' record the >> count prior to resetting it (perhaps in a new, internal variable). And >> then, during re-JOINs, `erc-setup-buffer' could weigh that recorded >> value against some new option, like an `erc-display-reconnect' (or >> whatever), and proceed accordingly. > > Sounds good to me. I wasn't sure if that meant I was supposed to work on this. If not, please disregard. Otherwise, the tests are in #48598 [1]. As for the name of the option itself, I basically punted by going with `erc-reconnect-buffer' to try and stay close to `erc-join-buffer'. If that doesn't matter, perhaps `erc-reconnect-display' would be a better fit since we already have an `erc-query-display' (even though that one's not as closely related). Anyone with an opinion, please advise. Thanks. [1] Around line 4736: https://gitlab.com/jpneverwas/erc-tools/-/raw/master/bugs/48598/patches/wip/0013-Update-ERC-scenarios-with-session-centric-naming.patch Or browsable (JS): https://gitlab.com/jpneverwas/erc-v3/-/blob/1333bda3c0d11ff06b1b2acbb27864c90d5ba303/test/erc-scenarios.el#L1668 --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Customize-displaying-of-ERC-buffers-on-reconnect.patch >From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: "F. Jason Park" Date: Thu, 18 Nov 2021 23:39:54 -0800 Subject: [PATCH 01/29] Customize displaying of ERC buffers on reconnect * lisp/erc/erc-backend.el (erc--server-last-reconnect-count): Add variable to record last reconnect tally. * lisp/erc/erc.el (erc-reconnect-buffer): Add option to specify channel-buffer display behavior on reconnect. (erc-setup-buffer): Use option `erc-reconnect-buffer' if warranted. (erc-connection-established): Record reconnect count in internal var before resetting. --- lisp/erc/erc-backend.el | 3 +++ lisp/erc/erc.el | 24 ++++++++++++++++++++++-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/lisp/erc/erc-backend.el b/lisp/erc/erc-backend.el index 69f63dfbc4..4b39bd8a30 100644 --- a/lisp/erc/erc-backend.el +++ b/lisp/erc/erc-backend.el @@ -193,6 +193,9 @@ erc-server-connected (defvar-local erc-server-reconnect-count 0 "Number of times we have failed to reconnect to the current server.") +(defvar-local erc--server-last-reconnect-count 0 + "Snapshot of reconnect count when connection established.") + (defvar-local erc-server-quitting nil "Non-nil if the user requests a quit.") diff --git a/lisp/erc/erc.el b/lisp/erc/erc.el index c5a4fbe5a0..21ae25d920 100644 --- a/lisp/erc/erc.el +++ b/lisp/erc/erc.el @@ -1521,6 +1521,22 @@ erc-join-buffer (const :tag "Use current buffer" buffer) (const :tag "Use current buffer" t))) +(defcustom erc-reconnect-buffer nil + "How (and whether) to display a channel buffer upon reconnecting. + +This only affects automatic reconnections and is ignored when issuing a +/reconnect command or reinvoking `erc-tls' with the same args (assuming +success, of course). See `erc-join-buffer' for a description of +possible values." + :group 'erc-buffers + :type '(choice (const :tag "Use value of `erc-join-buffer'" nil) + (const :tag "Split window and select" window) + (const :tag "Split window, don't select" window-noselect) + (const :tag "New frame" frame) + (const :tag "Bury in new buffer" bury) + (const :tag "Use current buffer" buffer) + (const :tag "Use current buffer" t))) + (defcustom erc-frame-alist nil "Alist of frame parameters for creating erc frames. A value of nil means to use `default-frame-alist'." @@ -1950,7 +1966,10 @@ erc-update-modules (defun erc-setup-buffer (buffer) "Consults `erc-join-buffer' to find out how to display `BUFFER'." - (pcase erc-join-buffer + (pcase (if (zerop (erc-with-server-buffer + erc--server-last-reconnect-count)) + erc-join-buffer + (or erc-reconnect-buffer erc-join-buffer)) ('window (if (active-minibuffer-window) (display-buffer buffer) @@ -4722,7 +4741,8 @@ erc-connection-established (nick (car (erc-response.command-args parsed))) (buffer (process-buffer proc))) (setq erc-server-connected t) - (setq erc-server-reconnect-count 0) + (setq erc--server-last-reconnect-count erc-server-reconnect-count + erc-server-reconnect-count 0) (erc-update-mode-line) (erc-set-initial-user-mode nick buffer) (erc-server-setup-periodical-ping buffer) -- 2.31.1 --=-=-=--