Function: erc-nickname-in-use
erc-nickname-in-use is a byte-compiled function defined in erc.el.gz.
Signature
(erc-nickname-in-use NICK REASON)
Documentation
If NICK is unavailable, tell the user the REASON.
See also erc-display-error-notice.
Source Code
;; Defined in /usr/src/emacs/lisp/erc/erc.el.gz
(defun erc-nickname-in-use (nick reason)
"If NICK is unavailable, tell the user the REASON.
See also `erc-display-error-notice'."
(if (or (not erc-try-new-nick-p)
;; how many default-nicks are left + one more try...
(eq erc-nick-change-attempt-count
(if (consp erc-nick)
(+ (length erc-nick) 1)
1)))
(erc-display-error-notice
nil
(format "Nickname %s is %s, try another." nick reason))
(setq erc-nick-change-attempt-count (+ erc-nick-change-attempt-count 1))
(let ((newnick (nth 1 erc-default-nicks))
(nicklen (cdr (assoc "NICKLEN"
(erc-with-server-buffer
erc-server-parameters)))))
(setq erc-bad-nick t)
;; try to use a different nick
(if erc-default-nicks
(setq erc-default-nicks (cdr erc-default-nicks)))
(if (not newnick)
(setq newnick (concat (truncate-string-to-width
nick
(if (and erc-server-connected nicklen)
(- (string-to-number nicklen)
(length erc-nick-uniquifier))
;; rfc2812 max nick length = 9
;; we must assume this is the
;; server's setting if we haven't
;; established a connection yet
(- 9 (length erc-nick-uniquifier))))
erc-nick-uniquifier)))
(erc-cmd-NICK newnick)
(erc-display-error-notice
nil
(format "Nickname %s is %s, trying %s"
nick reason newnick)))))