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
      (dolist (buf (erc--wrangle-query-buffers-on-nick-change nick nn))
        (cl-pushnew buf bufs))
      (erc-update-user-nick nick nn host login)
      (cond
       ((string= nick (erc-current-nick))
        (cl-pushnew (erc-server-buffer) bufs)
        ;; Show message in all query buffers.
        (setq bufs (append (erc--query-list) 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--ensure-query-member nn))
        (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))))))