diff options
| author | F. Jason Park | 2024-11-29 15:56:47 -0800 |
|---|---|---|
| committer | F. Jason Park | 2024-12-20 18:18:02 -0800 |
| commit | 1c960bda91237c92f9f602bcb8538ad500c0bc49 (patch) | |
| tree | e84e32174dfb1653b852de397f7f3854d60c21ea /lisp/erc | |
| parent | e9591fae5e7ba772b63c6cc548bb5ebe68f583e6 (diff) | |
| download | emacs-1c960bda91237c92f9f602bcb8538ad500c0bc49.tar.gz emacs-1c960bda91237c92f9f602bcb8538ad500c0bc49.zip | |
Use smarter default for erc-server-reconnect-function
* doc/misc/erc.texi (Sample Configuration): Remove customization in
`use-package' declaration for `erc-server-reconnect-function' as well as
related language in the customization walk-through. Do this because the
new default incorporates `erc-server-delayed-check-reconnect' behavior
for compatible connect functions.
* etc/ERC-NEWS: Announce new default for `erc-server-reconnect-function'.
* lisp/erc/erc-backend.el (erc-server-reconnect-function): Change
default to `erc-server-prefer-check-reconnect'.
(erc-server-delayed-check-reconnect): Use `process-send-string' instead
of `send-string'.
(erc--server-delayed-check-connectors): New variable.
(erc-server-prefer-check-reconnect): New function.
* test/lisp/erc/erc-scenarios-base-auto-recon.el
(erc-scenarios-base-auto-recon-unavailable)
(erc-scenarios-base-auto-recon-no-proto): Remove unnecessary
`erc-server-reconnect-function' binding because the new default
incorporates the behavior being tested for.
* test/lisp/erc/erc-scenarios-base-buffer-display.el
(erc-scenarios-base-buffer-display--reconnect-common):
* test/lisp/erc/erc-scenarios-base-compat-rename-bouncer.el
(erc-scenarios-common--base-compat-no-rename-bouncer):
* test/lisp/erc/erc-scenarios-base-netid-bouncer-recon-base.el
(erc-scenarios-base-netid-bouncer--recon-base):
* test/lisp/erc/erc-scenarios-base-netid-bouncer-recon-both.el
(erc-scenarios-base-netid-bouncer--recon-both):
* test/lisp/erc/erc-scenarios-base-netid-bouncer-recon-id.el
(erc-scenarios-base-netid-bouncer--reconnect-id-foo)
(erc-scenarios-base-netid-bouncer--reconnect-id-bar):
* test/lisp/erc/erc-scenarios-base-reconnect.el
(erc-scenarios-base-reconnect-timer)
(erc-scenarios-base-cancel-reconnect):
* test/lisp/erc/erc-scenarios-services-misc.el
(erc-scenarios-services-misc--reconnect-retry-nick):
* test/lisp/erc/erc-scenarios-stamp.el
(erc-scenarios-stamp--date-mode/reconnect): Explicitly bind
`erc-server-reconnect-function' to `erc-server-delayed-reconnect', the
former default, which does not do any probing. (Bug#62044)
Diffstat (limited to 'lisp/erc')
| -rw-r--r-- | lisp/erc/erc-backend.el | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/lisp/erc/erc-backend.el b/lisp/erc/erc-backend.el index 311e3a624e6..ab26a3715f1 100644 --- a/lisp/erc/erc-backend.el +++ b/lisp/erc/erc-backend.el | |||
| @@ -429,15 +429,16 @@ this value to 120 or greater and/or exploring the option | |||
| 429 | means of handling this situation on some servers." | 429 | means of handling this situation on some servers." |
| 430 | :type 'number) | 430 | :type 'number) |
| 431 | 431 | ||
| 432 | (defcustom erc-server-reconnect-function 'erc-server-delayed-reconnect | 432 | (defcustom erc-server-reconnect-function 'erc-server-prefer-check-reconnect |
| 433 | "Function called by the reconnect timer to create a new connection. | 433 | "Function called by the reconnect timer to create a new connection. |
| 434 | Called with a server buffer as its only argument. Potential uses | 434 | Called with a server buffer as its only argument. Potential uses |
| 435 | include exponential backoff and probing for connectivity prior to | 435 | include exponential backoff and probing for connectivity prior to |
| 436 | dialing. Use `erc-schedule-reconnect' to instead try again later | 436 | dialing. Use `erc-schedule-reconnect' to instead try again later |
| 437 | and optionally alter the attempts tally." | 437 | and optionally alter the attempts tally." |
| 438 | :package-version '(ERC . "5.5") | 438 | :package-version '(ERC . "5.6.1") |
| 439 | :type '(choice (function-item erc-server-delayed-reconnect) | 439 | :type '(choice (function-item erc-server-delayed-reconnect) |
| 440 | (function-item erc-server-delayed-check-reconnect) | 440 | (function-item erc-server-delayed-check-reconnect) |
| 441 | (function-item erc-server-prefer-check-reconnect) | ||
| 441 | function)) | 442 | function)) |
| 442 | 443 | ||
| 443 | (defcustom erc-split-line-length 440 | 444 | (defcustom erc-split-line-length 440 |
| @@ -879,7 +880,7 @@ Expect BUFFER to be the server buffer for the current connection." | |||
| 879 | (sentinel (lambda (proc event) | 880 | (sentinel (lambda (proc event) |
| 880 | (pcase event | 881 | (pcase event |
| 881 | ("open\n" | 882 | ("open\n" |
| 882 | (run-at-time nil nil #'send-string proc | 883 | (run-at-time nil nil #'process-send-string proc |
| 883 | (format "PING %d\r\n" | 884 | (format "PING %d\r\n" |
| 884 | (time-convert nil 'integer)))) | 885 | (time-convert nil 'integer)))) |
| 885 | ((or "connection broken by remote peer\n" | 886 | ((or "connection broken by remote peer\n" |
| @@ -901,6 +902,19 @@ Expect BUFFER to be the server buffer for the current connection." | |||
| 901 | (set-process-sentinel proc sentinel)) | 902 | (set-process-sentinel proc sentinel)) |
| 902 | (file-error (funcall reschedule nil))))))) | 903 | (file-error (funcall reschedule nil))))))) |
| 903 | 904 | ||
| 905 | (defvar erc--server-delayed-check-connectors | ||
| 906 | '(erc-open-tls-stream erc-open-network-stream) | ||
| 907 | "Functions compatible with `erc-server-delayed-check-reconnect'.") | ||
| 908 | |||
| 909 | (defun erc-server-prefer-check-reconnect (buffer) | ||
| 910 | "Defer to another reconnector based on BUFFER's `erc-session-connector'. | ||
| 911 | Prefer `erc-server-delayed-check-reconnect' if the connector is known to | ||
| 912 | be \"check-aware\". Otherwise, use `erc-server-delayed-reconnect'." | ||
| 913 | (if (memq (buffer-local-value 'erc-session-connector buffer) | ||
| 914 | erc--server-delayed-check-connectors) | ||
| 915 | (erc-server-delayed-check-reconnect buffer) | ||
| 916 | (erc-server-delayed-reconnect buffer))) | ||
| 917 | |||
| 904 | (defun erc-server-filter-function (process string) | 918 | (defun erc-server-filter-function (process string) |
| 905 | "The process filter for the ERC server." | 919 | "The process filter for the ERC server." |
| 906 | (with-current-buffer (process-buffer process) | 920 | (with-current-buffer (process-buffer process) |