-;;; erc-backend.el --- Backend network communication for ERC
+;;; erc-backend.el --- Backend network communication for ERC -*- lexical-binding:t -*-
;; Copyright (C) 2004-2016 Free Software Foundation, Inc.
:type '(repeat (cons (string :tag "Target")
coding-system)))
-(defcustom erc-server-connect-function 'erc-open-network-stream
+(defcustom erc-server-connect-function #'erc-open-network-stream
"Function used to initiate a connection.
It should take same arguments as `open-network-stream' does."
:group 'erc-server
(when (fboundp 'set-process-coding-system)
(set-process-coding-system process 'raw-text))
;; process handlers
- (set-process-sentinel process 'erc-process-sentinel)
- (set-process-filter process 'erc-server-filter-function)
+ (set-process-sentinel process #'erc-process-sentinel)
+ (set-process-filter process #'erc-server-filter-function)
(set-process-buffer process buffer)
(erc-log "\n\n\n********************************************\n")
(message "%s" (erc-format-message
(setq erc-server-last-sent-time 0)
(setq erc-server-lines-sent 0)
(let ((erc-server-connect-function (or erc-session-connector
- 'erc-open-network-stream)))
+ #'erc-open-network-stream)))
(erc-open erc-session-server erc-session-port erc-server-current-nick
erc-session-user-full-name t erc-session-password)))))
-(defun erc-server-delayed-reconnect (event buffer)
+(defun erc-server-delayed-reconnect (buffer)
(if (buffer-live-p buffer)
(with-current-buffer buffer
(erc-server-reconnect))))
(erc-update-mode-line)
(set-buffer-modified-p nil))
;; reconnect
- (condition-case err
+ (condition-case nil
(progn
(setq erc-server-reconnecting nil
erc-server-reconnect-count (1+ erc-server-reconnect-count))
(setq delay erc-server-reconnect-timeout)
(run-at-time delay nil
- #'erc-server-delayed-reconnect event buffer))
+ #'erc-server-delayed-reconnect buffer))
(error (unless (integerp erc-server-reconnect-attempts)
(message "%s ... %s"
"Reconnecting until we succeed"
"kill the ERC server buffer to stop"))
- (erc-server-delayed-reconnect event buffer))))))))
+ (erc-server-delayed-reconnect buffer))))))))
(defun erc-process-sentinel-1 (event buffer)
"Called when `erc-process-sentinel' has decided that we're disconnecting.
(+ erc-server-flood-penalty
erc-server-flood-last-message))
(erc-log-irc-protocol str 'outbound)
- (condition-case err
+ (condition-case nil
(progn
;; Set encoding just before sending the string
(when (fboundp 'set-process-coding-system)
(erc-log (concat "erc-server-send-queue: "
msg "(" (buffer-name buffer) ")"))
(when (erc-server-process-alive)
- (condition-case err
+ (condition-case nil
;; Set encoding just before sending the string
(progn
(when (fboundp 'set-process-coding-system)
(erc-with-server-buffer
(run-hook-with-args 'erc-timer-hook (erc-current-time)))))
-(add-hook 'erc-default-server-functions 'erc-handle-unknown-server-response)
+(add-hook 'erc-default-server-functions #'erc-handle-unknown-server-response)
(defun erc-handle-unknown-server-response (proc parsed)
"Display unknown server response's message."
" "
(erc-response.command parsed)
" "
- (mapconcat 'identity (erc-response.command-args parsed)
+ (mapconcat #'identity (erc-response.command-args parsed)
" "))))
(erc-display-message parsed 'notice proc line)))
;; value at this point, so I default to nil, and (add-hook)
;; unconditionally
(defvar ,hook-name nil ,(format hook-doc name))
- (add-to-list ',hook-name ',fn-name)
+ (add-hook ',hook-name #',fn-name)
;; Handler function
(defun ,fn-name (proc parsed)
,fn-doc
+ (ignore proc parsed)
,@fn-body)
;; Make find-function and find-variable find them
(define-erc-response-handler (MODE)
"Handle server mode changes." nil
(let ((tgt (car (erc-response.command-args parsed)))
- (mode (mapconcat 'identity (cdr (erc-response.command-args parsed))
+ (mode (mapconcat #'identity (cdr (erc-response.command-args parsed))
" ")))
(pcase-let ((`(,nick ,login ,host)
(erc-parse-user (erc-response.sender parsed))))
(cons nn (cdr erc-default-recipients)))
(rename-buffer nn t) ; bug#12002
(erc-update-mode-line)
- (add-to-list 'bufs (current-buffer)))))
+ (cl-pushnew (current-buffer) bufs))))
(erc-update-user-nick nick nn host nil nil login)
(cond
((string= nick (erc-current-nick))
- (add-to-list 'bufs (erc-server-buffer))
+ (cl-pushnew (erc-server-buffer) bufs)
(erc-set-current-nick nn)
(erc-update-mode-line)
(setq erc-nick-change-attempt-count 0)
;; FIXME: need clean way of specifying extra hooks in
;; define-erc-response-handler.
-(add-hook 'erc-server-PRIVMSG-functions 'erc-auto-query)
+(add-hook 'erc-server-PRIVMSG-functions #'erc-auto-query)
(define-erc-response-handler (QUIT)
"Another user has quit IRC." nil
(define-erc-response-handler (WALLOPS)
"Display a WALLOPS message." nil
(let ((message (erc-response.contents parsed)))
- (pcase-let ((`(,nick ,login ,host)
+ (pcase-let ((`(,nick ,_login ,_host)
(erc-parse-user (erc-response.sender parsed))))
(erc-display-message
parsed 'notice nil
A server may send more than one 005 message."
nil
- (let ((line (mapconcat 'identity
+ (let ((line (mapconcat #'identity
(setf (erc-response.command-args parsed)
(cdr (erc-response.command-args parsed)))
" ")))
(define-erc-response-handler (221)
"Display the current user modes." nil
(let* ((nick (car (erc-response.command-args parsed)))
- (modes (mapconcat 'identity
+ (modes (mapconcat #'identity
(cdr (erc-response.command-args parsed)) " ")))
(erc-set-modes nick modes)
(erc-display-message parsed 'notice 'active 's221 ?n nick ?m modes)))
(define-erc-response-handler (275)
"Display secure connection message." nil
- (pcase-let ((`(,nick ,user ,message)
+ (pcase-let ((`(,nick ,_user ,_message)
(cdr (erc-response.command-args parsed))))
(erc-display-message
parsed 'notice 'active 's275
?n nick
- ?m (mapconcat 'identity (cddr (erc-response.command-args parsed))
+ ?m (mapconcat #'identity (cddr (erc-response.command-args parsed))
" "))))
(define-erc-response-handler (290)
(define-erc-response-handler (307)
"Display nick-identified message." nil
- (pcase-let ((`(,nick ,user ,message)
+ (pcase-let ((`(,nick ,_user ,_message)
(cdr (erc-response.command-args parsed))))
(erc-display-message
parsed 'notice 'active 's307
?n nick
- ?m (mapconcat 'identity (cddr (erc-response.command-args parsed))
+ ?m (mapconcat #'identity (cddr (erc-response.command-args parsed))
" "))))
(define-erc-response-handler (311 314)
"Display a message for the 321 event."
(erc-display-message parsed 'notice proc 's321)
nil)
-(add-hook 'erc-server-321-functions 'erc-server-321-message t)
+(add-hook 'erc-server-321-functions #'erc-server-321-message t)
(define-erc-response-handler (322)
"LIST notice." nil
(let ((topic (erc-response.contents parsed)))
- (pcase-let ((`(,channel ,num-users)
+ (pcase-let ((`(,channel ,_num-users)
(cdr (erc-response.command-args parsed))))
(add-to-list 'erc-channel-list (list channel))
(erc-update-channel-topic channel topic))))
(erc-display-message
parsed 'notice proc 's322
?c channel ?u num-users ?t (or topic "")))))
-(add-hook 'erc-server-322-functions 'erc-server-322-message t)
+(add-hook 'erc-server-322-functions #'erc-server-322-message t)
(define-erc-response-handler (324)
"Channel or nick modes." nil
(let ((channel (cadr (erc-response.command-args parsed)))
- (modes (mapconcat 'identity (cddr (erc-response.command-args parsed))
+ (modes (mapconcat #'identity (cddr (erc-response.command-args parsed))
" ")))
(erc-set-modes channel modes)
(erc-display-message
(define-erc-response-handler (331)
"No topic set for channel." nil
- (let ((channel (cadr (erc-response.command-args parsed)))
- (topic (erc-response.contents parsed)))
+ (let ((channel (cadr (erc-response.command-args parsed))))
(erc-display-message parsed 'notice (erc-get-buffer channel proc)
's331 ?c channel)))
(define-erc-response-handler (352)
"WHO notice." nil
- (pcase-let ((`(,channel ,user ,host ,server ,nick ,away-flag)
+ (pcase-let ((`(,channel ,user ,host ,_server ,nick ,away-flag)
(cdr (erc-response.command-args parsed))))
- (let ((full-name (erc-response.contents parsed))
- hopcount)
+ (let ((full-name (erc-response.contents parsed)))
(when (string-match "\\(^[0-9]+ \\)\\(.*\\)$" full-name)
- (setq hopcount (match-string 1 full-name))
(setq full-name (match-string 2 full-name)))
(erc-update-channel-member channel nick nick nil nil nil nil nil nil host user full-name)
(erc-display-message parsed 'notice 'active 's352