Function: erc-server-NICK
erc-server-NICK is a byte-compiled function defined in
erc-backend.el.gz.
Signature
(erc-server-NICK PROC PARSED)
Documentation
Handle nick change messages.
Handler for a NICK server response.
PROC is the server process which returned the response.
PARSED is the actual response as an erc-response struct.
If you want to add responses don't modify this function, but rather
add things to erc-server-NICK-functions instead.
Source Code
;; Defined in /usr/src/emacs/lisp/erc/erc-backend.el.gz
(define-erc-response-handler (NICK)
"Handle nick change messages." nil
(let ((nn (erc-response.contents parsed))
bufs)
(pcase-let ((`(,nick ,login ,host)
(erc-parse-user (erc-response.sender parsed))))
(setq bufs (erc-buffer-list-with-nick nick proc))
(erc-log (format "NICK: %s -> %s" nick nn))
;; if we had a query with this user, make sure future messages will be
;; sent to the correct nick. also add to bufs, since the user will want
;; to see the nick change in the query, and if it's a newly begun query,
;; erc-channel-users won't contain it
;;
;; Possibly still relevant: bug#12002
(when-let ((buf (erc-get-buffer nick erc-server-process))
(tgt (erc--target-from-string nn)))
(with-current-buffer buf
(setq erc-default-recipients (cons nn (cdr erc-default-recipients))
erc--target tgt))
(with-current-buffer (erc-get-buffer-create erc-session-server
erc-session-port nil tgt
(erc-networks--id-given
erc-networks--id))
;; Current buffer is among bufs
(erc-update-mode-line)))
(erc-update-user-nick nick nn host nil nil login)
(cond
((string= nick (erc-current-nick))
(cl-pushnew (erc-server-buffer) bufs)
(erc-set-current-nick nn)
;; Rename session, possibly rename server buf and all targets
(when erc-server-connected
(erc-networks--id-reload erc-networks--id proc parsed))
(erc-update-mode-line)
(setq erc-nick-change-attempt-count 0)
(setq erc-default-nicks (if (consp erc-nick) erc-nick (list erc-nick)))
(erc-display-message
parsed 'notice bufs
'NICK-you ?n nick ?N nn)
(run-hook-with-args 'erc-nick-changed-functions nn nick))
(t
(when erc-server-connected
(erc-networks--id-reload erc-networks--id proc parsed))
(erc-handle-user-status-change 'nick (list nick login host) (list nn))
(erc-display-message parsed 'notice bufs 'NICK ?n nick
?u login ?h host ?N nn))))))