summaryrefslogtreecommitdiff
path: root/lisp/erc/erc-backend.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/erc/erc-backend.el')
-rw-r--r--lisp/erc/erc-backend.el80
1 files changed, 41 insertions, 39 deletions
diff --git a/lisp/erc/erc-backend.el b/lisp/erc/erc-backend.el
index 1e2526f35ce..4f3d85ba3c8 100644
--- a/lisp/erc/erc-backend.el
+++ b/lisp/erc/erc-backend.el
@@ -520,7 +520,8 @@ If no subword-mode is active, then this is
"Set up a timer to periodically ping the current server.
The current buffer is given by BUFFER."
(with-current-buffer buffer
- (and erc-server-ping-handler (erc-cancel-timer erc-server-ping-handler))
+ (when erc-server-ping-handler
+ (cancel-timer erc-server-ping-handler))
(when erc-server-send-ping-interval
(setq erc-server-ping-handler (run-with-timer
4 erc-server-send-ping-interval
@@ -533,7 +534,7 @@ The current buffer is given by BUFFER."
(if timer-tuple
;; this buffer already has a timer. Cancel it and set the new one
(progn
- (erc-cancel-timer (cdr timer-tuple))
+ (cancel-timer (cdr timer-tuple))
(setf (cdr (assq buffer erc-server-ping-timer-alist)) erc-server-ping-handler))
;; no existing timer for this buffer. Add new one
@@ -731,7 +732,7 @@ Conditionally try to reconnect and take appropriate action."
(erc-with-all-buffers-of-server cproc nil
(setq erc-server-connected nil))
(when erc-server-ping-handler
- (progn (erc-cancel-timer erc-server-ping-handler)
+ (progn (cancel-timer erc-server-ping-handler)
(setq erc-server-ping-handler nil)))
(run-hook-with-args 'erc-disconnected-hook
(erc-current-nick) (system-name) "")
@@ -856,7 +857,7 @@ Additionally, detect whether the IRC process has hung."
;; remove timer if the server buffer has been killed
(let ((timer (assq buf erc-server-ping-timer-alist)))
(when timer
- (erc-cancel-timer (cdr timer))
+ (cancel-timer (cdr timer))
(setcdr timer nil)))))
;; From Circe
@@ -864,41 +865,42 @@ Additionally, detect whether the IRC process has hung."
"Send messages in `erc-server-flood-queue'.
See `erc-server-flood-margin' for an explanation of the flood
protection algorithm."
- (with-current-buffer buffer
- (let ((now (current-time)))
- (when erc-server-flood-timer
- (erc-cancel-timer erc-server-flood-timer)
- (setq erc-server-flood-timer nil))
- (when (time-less-p erc-server-flood-last-message now)
- (setq erc-server-flood-last-message (erc-emacs-time-to-erc-time now)))
- (while (and erc-server-flood-queue
- (time-less-p erc-server-flood-last-message
- (time-add now erc-server-flood-margin)))
- (let ((msg (caar erc-server-flood-queue))
- (encoding (cdar erc-server-flood-queue)))
- (setq erc-server-flood-queue (cdr erc-server-flood-queue)
- erc-server-flood-last-message
- (+ erc-server-flood-last-message
- erc-server-flood-penalty))
- (erc-log-irc-protocol msg 'outbound)
- (erc-log (concat "erc-server-send-queue: "
- msg "(" (buffer-name buffer) ")"))
- (when (erc-server-process-alive)
- (condition-case nil
- ;; Set encoding just before sending the string
- (progn
- (when (fboundp 'set-process-coding-system)
- (set-process-coding-system erc-server-process
- 'raw-text encoding))
- (process-send-string erc-server-process msg))
- ;; Sometimes the send can occur while the process is
- ;; being killed, which results in a weird SIGPIPE error.
- ;; Catch this and ignore it.
- (error nil)))))
- (when erc-server-flood-queue
- (setq erc-server-flood-timer
- (run-at-time (+ 0.2 erc-server-flood-penalty)
- nil #'erc-server-send-queue buffer))))))
+ (when (buffer-live-p buffer)
+ (with-current-buffer buffer
+ (let ((now (current-time)))
+ (when erc-server-flood-timer
+ (cancel-timer erc-server-flood-timer)
+ (setq erc-server-flood-timer nil))
+ (when (time-less-p erc-server-flood-last-message now)
+ (setq erc-server-flood-last-message (erc-emacs-time-to-erc-time now)))
+ (while (and erc-server-flood-queue
+ (time-less-p erc-server-flood-last-message
+ (time-add now erc-server-flood-margin)))
+ (let ((msg (caar erc-server-flood-queue))
+ (encoding (cdar erc-server-flood-queue)))
+ (setq erc-server-flood-queue (cdr erc-server-flood-queue)
+ erc-server-flood-last-message
+ (+ erc-server-flood-last-message
+ erc-server-flood-penalty))
+ (erc-log-irc-protocol msg 'outbound)
+ (erc-log (concat "erc-server-send-queue: "
+ msg "(" (buffer-name buffer) ")"))
+ (when (erc-server-process-alive)
+ (condition-case nil
+ ;; Set encoding just before sending the string
+ (progn
+ (when (fboundp 'set-process-coding-system)
+ (set-process-coding-system erc-server-process
+ 'raw-text encoding))
+ (process-send-string erc-server-process msg))
+ ;; Sometimes the send can occur while the process is
+ ;; being killed, which results in a weird SIGPIPE error.
+ ;; Catch this and ignore it.
+ (error nil)))))
+ (when erc-server-flood-queue
+ (setq erc-server-flood-timer
+ (run-at-time (+ 0.2 erc-server-flood-penalty)
+ nil #'erc-server-send-queue buffer)))))))
(defun erc-message (message-command line &optional force)
"Send LINE to the server as a privmsg or a notice.