[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
fix/bug-48598 a9ef01ec76 06/27: Customize displaying of ERC buffers on r
From: |
F. Jason Park |
Subject: |
fix/bug-48598 a9ef01ec76 06/27: Customize displaying of ERC buffers on reconnect |
Date: |
Fri, 8 Apr 2022 03:06:47 -0400 (EDT) |
branch: fix/bug-48598
commit a9ef01ec76e3b77927e0cad7933914a0732fd13d
Author: F. Jason Park <jp@neverwas.me>
Commit: F. Jason Park <jp@neverwas.me>
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-display): 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.
(erc-cmd-JOIN): Forget last reconnect count when issuing a manual
/JOIN command.
---
lisp/erc/erc-backend.el | 3 +++
lisp/erc/erc.el | 26 ++++++++++++++++++++++++--
2 files changed, 27 insertions(+), 2 deletions(-)
diff --git a/lisp/erc/erc-backend.el b/lisp/erc/erc-backend.el
index 3b33b10998..150c430e6a 100644
--- a/lisp/erc/erc-backend.el
+++ b/lisp/erc/erc-backend.el
@@ -200,6 +200,9 @@ active, use the `erc-server-process-alive' function
instead.")
(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 the connection was 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 c766215a99..74d4d6f148 100644
--- a/lisp/erc/erc.el
+++ b/lisp/erc/erc.el
@@ -131,6 +131,7 @@
:group 'erc)
;; Defined in erc-backend
+(defvar erc--server-last-reconnect-count)
(defvar erc--server-reconnecting)
(defvar erc-channel-members-changed-hook)
(defvar erc-server-367-functions)
@@ -1551,6 +1552,22 @@ The available choices are:
(const :tag "Use current buffer" buffer)
(const :tag "Use current buffer" t)))
+(defcustom erc-reconnect-display 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."
+ :package-version '(ERC . "5.4.1") ; FIXME increment upon publishing to ELPA
+ :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)))
+
(defcustom erc-frame-alist nil
"Alist of frame parameters for creating erc frames.
A value of nil means to use `default-frame-alist'."
@@ -1972,7 +1989,10 @@ removed from the list will be disabled."
(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-display erc-join-buffer))
('window
(if (active-minibuffer-window)
(display-buffer buffer)
@@ -3239,6 +3259,7 @@ were most recently invited. See also `invitation'."
(switch-to-buffer (if (get-buffer chnl-name)
chnl-name
(concat chnl-name "/" server)))
+ (setq erc--server-last-reconnect-count 0)
(erc-server-join-channel server chnl key)))))
t)
@@ -4737,7 +4758,8 @@ Set user modes and run `erc-after-connect' hook."
(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)
- fix/bug-48598 a999ff61fa 19/27: Register erc-kill-buffer-function locally, (continued)
- fix/bug-48598 a999ff61fa 19/27: Register erc-kill-buffer-function locally, F. Jason Park, 2022/04/08
- fix/bug-48598 e0bf4383d7 24/27: Standardize auth-source queries in ERC, F. Jason Park, 2022/04/08
- fix/bug-48598 1978c3178c 10/27: Update ISUPPORT handling in ERC, F. Jason Park, 2022/04/08
- fix/bug-48598 6ee4329b46 02/27: Initialize erc-server-filter-data in erc-backend, F. Jason Park, 2022/04/08
- fix/bug-48598 3c6694d114 20/27: Don't call erc-auto-query twice on PRIVMSG, F. Jason Park, 2022/04/08
- fix/bug-48598 50b3aa88fc 11/27: Recognize ascii and strict CASEMAPPINGs in ERC, F. Jason Park, 2022/04/08
- fix/bug-48598 f9794dea43 15/27: Discourage ill-defined use of buffer targets in ERC, F. Jason Park, 2022/04/08
- fix/bug-48598 bb117dfacb 05/27: [SQUASH-ME] Remove duplicate ERC prompt on reconnect, F. Jason Park, 2022/04/08
- fix/bug-48598 c25371f9d7 08/27: Don't set erc-server-announced-name unless known, F. Jason Park, 2022/04/08
- fix/bug-48598 8558f9434a 12/27: Make ERC respect spaces in server passwords, F. Jason Park, 2022/04/08
- fix/bug-48598 a9ef01ec76 06/27: Customize displaying of ERC buffers on reconnect,
F. Jason Park <=
- fix/bug-48598 eef4fa00e8 01/27: Rework mutual dependency between erc and erc-backend, F. Jason Park, 2022/04/08
- fix/bug-48598 31030f2568 14/27: Add eventual replacement for erc-default-recipients, F. Jason Park, 2022/04/08
- fix/bug-48598 6ece132c35 09/27: Require erc-networks in erc.el, F. Jason Park, 2022/04/08
- fix/bug-48598 346381ffe5 17/27: Address long-standing ERC buffer-naming issues, F. Jason Park, 2022/04/08
- fix/bug-48598 bd8efa668b 18/27: SQUASH-ME: Add user-oriented test scenarios for ERC, F. Jason Park, 2022/04/08
- fix/bug-48598 242c8374b0 22/27: Favor network identities in erc-join, F. Jason Park, 2022/04/08
- fix/bug-48598 11e9bb2b2f 25/27: SQUASH-ME: Add ERC test scenarios involving auth-source, F. Jason Park, 2022/04/08
- fix/bug-48598 ab2d93e564 27/27: Update ERC's Info doc with network-ID related changes, F. Jason Park, 2022/04/08
- fix/bug-48598 dd5a99e891 26/27: SQUASH-ME: Add ERC test scenario for erc-cmd-JOIN, F. Jason Park, 2022/04/08