[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master e2130fe9272 4/9: Always run erc-server-send-queue via timer
From: |
F. Jason Park |
Subject: |
master e2130fe9272 4/9: Always run erc-server-send-queue via timer |
Date: |
Sun, 12 Nov 2023 23:56:29 -0500 (EST) |
branch: master
commit e2130fe9272b6fdc3d32f19734570347a8d580fd
Author: F. Jason Park <jp@neverwas.me>
Commit: F. Jason Park <jp@neverwas.me>
Always run erc-server-send-queue via timer
* lisp/erc/erc-backend.el (erc--server-send, erc-server-send): Convert
the latter into a wrapper that calls the former, a "new" internal
generic function, so that built-in modules can do things like prepend
tags to outgoing messages and send messages over other transports or
proxy protocols. Extend the `no-penalty' parameter to mean ERC will
schedule an imminent send via a timer. And always run the function
`erc-server-send-queue' on a timer. (Bug#67031)
---
lisp/erc/erc-backend.el | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/lisp/erc/erc-backend.el b/lisp/erc/erc-backend.el
index 32d891cd1c6..9281c107d06 100644
--- a/lisp/erc/erc-backend.el
+++ b/lisp/erc/erc-backend.el
@@ -1171,7 +1171,7 @@ Use DISPLAY-FN to show the results."
When FORCE is non-nil, bypass flood protection so that STRING is
sent directly without modifying the queue. When FORCE is the
symbol `no-penalty', exempt this round from accumulating a
-timeout penalty.
+timeout penalty and schedule it to run ASAP instead of blocking.
If TARGET is specified, look up encoding information for that
channel in `erc-encoding-coding-alist' or
@@ -1179,6 +1179,11 @@ channel in `erc-encoding-coding-alist' or
See `erc-server-flood-margin' for an explanation of the flood
protection algorithm."
+ (erc--server-send string force target))
+
+(cl-defmethod erc--server-send (string force target)
+ "Encode and send STRING to `erc-server-process'.
+Expect STRING, FORCE, and TARGET to originate from `erc-server-send'."
(erc-log (concat "erc-server-send: " string "(" (buffer-name) ")"))
(setq erc-server-last-sent-time (erc-current-time))
(let ((encoding (erc-coding-system-for-target target)))
@@ -1199,14 +1204,17 @@ protection algorithm."
(when (fboundp 'set-process-coding-system)
(set-process-coding-system erc-server-process
'raw-text encoding))
- (process-send-string erc-server-process str))
+ (if (and (eq force 'no-penalty))
+ (run-at-time nil nil #'process-send-string
+ erc-server-process str)
+ (process-send-string erc-server-process str)))
;; See `erc-server-send-queue' for full
;; explanation of why we need this condition-case
(error nil)))
(setq erc-server-flood-queue
(append erc-server-flood-queue
(list (cons str encoding))))
- (erc-server-send-queue (current-buffer))))
+ (run-at-time nil nil #'erc-server-send-queue (current-buffer))))
t)
(message "ERC: No process running")
nil)))
- master updated (52afc64bad7 -> ece62f5c1c3), F. Jason Park, 2023/11/12
- master 29029529cb2 1/9: Don't use func-arity to trigger API warning in url-irc, F. Jason Park, 2023/11/12
- master ece62f5c1c3 9/9: ; Prepare for ERC 5.6 release, F. Jason Park, 2023/11/12
- master beb60a9027c 3/9: Make ERC's error-notice formatting more consistent, F. Jason Park, 2023/11/12
- master e2130fe9272 4/9: Always run erc-server-send-queue via timer,
F. Jason Park <=
- master 174b3dd9bd7 5/9: Make nested input handling more robust in ERC, F. Jason Park, 2023/11/12
- master 5baa0f61f8d 2/9: Offer alternate pool-creation strategies in erc-nicks, F. Jason Park, 2023/11/12
- master 4ed6ba90e7c 6/9: Allow opting out of empty message padding in ERC, F. Jason Park, 2023/11/12
- master 583d73e9a0e 7/9: Simplify default text props for ERC input, F. Jason Park, 2023/11/12
- master 1d2aa130cae 8/9: Revive erc-command-indicator as new module, F. Jason Park, 2023/11/12