summaryrefslogtreecommitdiff
path: root/lisp/erc/erc-backend.el
diff options
context:
space:
mode:
authorF. Jason Park <jp@neverwas.me>2021-06-11 03:55:07 -0700
committerLars Ingebrigtsen <larsi@gnus.org>2021-11-06 19:13:35 +0100
commitdedab1c30da26d3741928cdad5e9fcf3075a2726 (patch)
tree9df386471b9d698a16cbffefe944223a3d2302f4 /lisp/erc/erc-backend.el
parent0b8f3c75fccbdf52797bb936ccd9f6ff28159704 (diff)
downloademacs-dedab1c30da26d3741928cdad5e9fcf3075a2726.tar.gz
emacs-dedab1c30da26d3741928cdad5e9fcf3075a2726.tar.bz2
emacs-dedab1c30da26d3741928cdad5e9fcf3075a2726.zip
Deprecate instead of redefine erc-server-reconnecting
* lisp/erc/erc-backend.el (erc-server-reconnecting, erc--server-reconnecting): obsolete and replace the former with new internal variant, which carries a simplified meaning. (erc-server-reconnect-p, erc--server-reconnect-p): Obsolete and replace the former with an internal function, and change behavior to disregard `erc-server-reconnecting' when rendering verdict. (erc-process-sentinel-2): ensure local var `erc--server-reconnecting' is t when timers are scheduled or firing, and nil otherwise, including after retries exhausted. This agrees with the straightforward way `erc-server-reconnecting' has always been used by `erc-cmd-RECONNECT'. (erc-server-connect): set `erc--server-reconnecting'. * lisp/erc/erc.el (erc-cmd-RECONNECT): use `erc--server-reconnecting' instead of `erc-server-reconnecting'.
Diffstat (limited to 'lisp/erc/erc-backend.el')
-rw-r--r--lisp/erc/erc-backend.el26
1 files changed, 21 insertions, 5 deletions
diff --git a/lisp/erc/erc-backend.el b/lisp/erc/erc-backend.el
index 6e5a768b70f..69f63dfbc44 100644
--- a/lisp/erc/erc-backend.el
+++ b/lisp/erc/erc-backend.el
@@ -197,7 +197,13 @@ active, use the `erc-server-process-alive' function instead.")
"Non-nil if the user requests a quit.")
(defvar-local erc-server-reconnecting nil
- "Non-nil if reconnecting or scheduled to.")
+ "Non-nil if the user requests an explicit reconnect, and the
+current IRC process is still alive.")
+(make-obsolete-variable 'erc-server-reconnecting
+ "see `erc--server-reconnecting'" "29.1")
+
+(defvar-local erc--server-reconnecting nil
+ "Non-nil when reconnecting.")
(defvar-local erc-server-timed-out nil
"Non-nil if the IRC server failed to respond to a ping.")
@@ -532,7 +538,8 @@ TLS (see `erc-session-client-certificate' for more details)."
(with-current-buffer buffer
(setq erc-server-process process)
(setq erc-server-quitting nil)
- (setq erc-server-reconnecting nil)
+ (setq erc-server-reconnecting nil
+ erc--server-reconnecting nil)
(setq erc-server-timed-out nil)
(setq erc-server-banned nil)
(setq erc-server-error-occurred nil)
@@ -616,7 +623,7 @@ Make sure you are in an ERC buffer when running this."
(erc-parse-server-response process line)))))))
(defun erc--server-reconnect-p (event)
- "Return non-nil if ERC should attempt to reconnect automatically.
+ "Return non-nil when ERC should attempt to reconnect.
EVENT is the message received from the closed connection process."
(and erc-server-auto-reconnect
(not erc-server-banned)
@@ -631,6 +638,14 @@ EVENT is the message received from the closed connection process."
;; open-network-stream-nowait error for connection refused
(if (string-match "^failed with code 111" event) 'nonblocking t)))
+(defun erc-server-reconnect-p (event)
+ "Return non-nil if ERC should attempt to reconnect automatically.
+EVENT is the message received from the closed connection process."
+ (declare (obsolete "see `erc--server-reconnect-p'" "29.1"))
+ (or (with-suppressed-warnings ((obsolete erc-server-reconnecting))
+ erc-server-reconnecting)
+ (erc--server-reconnect-p event)))
+
(defun erc-process-sentinel-2 (event buffer)
"Called when `erc-process-sentinel-1' has detected an unexpected disconnect."
(if (not (buffer-live-p buffer))
@@ -642,7 +657,7 @@ EVENT is the message received from the closed connection process."
(if (not reconnect-p)
;; terminate, do not reconnect
(progn
- (setq erc-server-reconnecting nil)
+ (setq erc--server-reconnecting nil)
(erc-display-message nil 'error (current-buffer)
'terminated ?e event)
;; Update mode line indicators
@@ -651,7 +666,8 @@ EVENT is the message received from the closed connection process."
;; reconnect
(condition-case nil
(progn
- (setq erc-server-reconnecting t
+ (setq erc-server-reconnecting nil
+ erc--server-reconnecting t
erc-server-reconnect-count (1+ erc-server-reconnect-count))
(setq delay erc-server-reconnect-timeout)
(run-at-time delay nil