aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/erc
diff options
context:
space:
mode:
authorF. Jason Park2021-11-18 23:39:54 -0800
committerF. Jason Park2022-06-30 15:03:26 -0700
commitc5b78a337900fd2a8d29317df7a27dd4e7006e89 (patch)
treecdc720b38409df68fef0774b0801f5dbc8ddaa57 /lisp/erc
parenta63ed6f78a6f7169574cfb0a2d5df45890b540d6 (diff)
downloademacs-c5b78a337900fd2a8d29317df7a27dd4e7006e89.tar.gz
emacs-c5b78a337900fd2a8d29317df7a27dd4e7006e89.zip
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 new option to specify channel-buffer display behavior on reconnect. (erc-setup-buffer): Use option `erc-reconnect-display' if warranted. (erc-cmd-JOIN): Forget last reconnect count when issuing a manual /JOIN command. (erc-connection-established): Record reconnect count in internal var before resetting. (Bug#51753)
Diffstat (limited to 'lisp/erc')
-rw-r--r--lisp/erc/erc-backend.el3
-rw-r--r--lisp/erc/erc.el26
2 files changed, 27 insertions, 2 deletions
diff --git a/lisp/erc/erc-backend.el b/lisp/erc/erc-backend.el
index 7aec02e897d..13303c71f5f 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.")
200(defvar-local erc-server-reconnect-count 0 200(defvar-local erc-server-reconnect-count 0
201 "Number of times we have failed to reconnect to the current server.") 201 "Number of times we have failed to reconnect to the current server.")
202 202
203(defvar-local erc--server-last-reconnect-count 0
204 "Snapshot of reconnect count when the connection was established.")
205
203(defvar-local erc-server-quitting nil 206(defvar-local erc-server-quitting nil
204 "Non-nil if the user requests a quit.") 207 "Non-nil if the user requests a quit.")
205 208
diff --git a/lisp/erc/erc.el b/lisp/erc/erc.el
index f9bff7e0c00..2ee461a6635 100644
--- a/lisp/erc/erc.el
+++ b/lisp/erc/erc.el
@@ -131,6 +131,7 @@
131 :group 'erc) 131 :group 'erc)
132 132
133;; Defined in erc-backend 133;; Defined in erc-backend
134(defvar erc--server-last-reconnect-count)
134(defvar erc--server-reconnecting) 135(defvar erc--server-reconnecting)
135(defvar erc-channel-members-changed-hook) 136(defvar erc-channel-members-changed-hook)
136(defvar erc-server-367-functions) 137(defvar erc-server-367-functions)
@@ -1562,6 +1563,22 @@ The available choices are:
1562 (const :tag "Use current buffer" buffer) 1563 (const :tag "Use current buffer" buffer)
1563 (const :tag "Use current buffer" t))) 1564 (const :tag "Use current buffer" t)))
1564 1565
1566(defcustom erc-reconnect-display nil
1567 "How (and whether) to display a channel buffer upon reconnecting.
1568
1569This only affects automatic reconnections and is ignored when
1570issuing a /reconnect command or reinvoking `erc-tls' with the
1571same args (assuming success, of course). See `erc-join-buffer'
1572for a description of possible values."
1573 :package-version '(ERC . "5.4.1") ; FIXME increment upon publishing to ELPA
1574 :group 'erc-buffers
1575 :type '(choice (const :tag "Use value of `erc-join-buffer'" nil)
1576 (const :tag "Split window and select" window)
1577 (const :tag "Split window, don't select" window-noselect)
1578 (const :tag "New frame" frame)
1579 (const :tag "Bury in new buffer" bury)
1580 (const :tag "Use current buffer" buffer)))
1581
1565(defcustom erc-frame-alist nil 1582(defcustom erc-frame-alist nil
1566 "Alist of frame parameters for creating erc frames. 1583 "Alist of frame parameters for creating erc frames.
1567A value of nil means to use `default-frame-alist'." 1584A value of nil means to use `default-frame-alist'."
@@ -1983,7 +2000,10 @@ removed from the list will be disabled."
1983 2000
1984(defun erc-setup-buffer (buffer) 2001(defun erc-setup-buffer (buffer)
1985 "Consults `erc-join-buffer' to find out how to display `BUFFER'." 2002 "Consults `erc-join-buffer' to find out how to display `BUFFER'."
1986 (pcase erc-join-buffer 2003 (pcase (if (zerop (erc-with-server-buffer
2004 erc--server-last-reconnect-count))
2005 erc-join-buffer
2006 (or erc-reconnect-display erc-join-buffer))
1987 ('window 2007 ('window
1988 (if (active-minibuffer-window) 2008 (if (active-minibuffer-window)
1989 (display-buffer buffer) 2009 (display-buffer buffer)
@@ -3250,6 +3270,7 @@ were most recently invited. See also `invitation'."
3250 (switch-to-buffer (if (get-buffer chnl-name) 3270 (switch-to-buffer (if (get-buffer chnl-name)
3251 chnl-name 3271 chnl-name
3252 (concat chnl-name "/" server))) 3272 (concat chnl-name "/" server)))
3273 (setq erc--server-last-reconnect-count 0)
3253 (erc-server-join-channel server chnl key))))) 3274 (erc-server-join-channel server chnl key)))))
3254 t) 3275 t)
3255 3276
@@ -4741,7 +4762,8 @@ Set user modes and run `erc-after-connect' hook."
4741 (nick (car (erc-response.command-args parsed))) 4762 (nick (car (erc-response.command-args parsed)))
4742 (buffer (process-buffer proc))) 4763 (buffer (process-buffer proc)))
4743 (setq erc-server-connected t) 4764 (setq erc-server-connected t)
4744 (setq erc-server-reconnect-count 0) 4765 (setq erc--server-last-reconnect-count erc-server-reconnect-count
4766 erc-server-reconnect-count 0)
4745 (erc-update-mode-line) 4767 (erc-update-mode-line)
4746 (erc-set-initial-user-mode nick buffer) 4768 (erc-set-initial-user-mode nick buffer)
4747 (erc-server-setup-periodical-ping buffer) 4769 (erc-server-setup-periodical-ping buffer)