Function: erc-generate-new-buffer-name
erc-generate-new-buffer-name is a byte-compiled function defined in
erc.el.gz.
Signature
(erc-generate-new-buffer-name SERVER PORT TARGET &optional TGT-INFO ID)
Documentation
Determine the name of an ERC buffer.
When TGT-INFO is nil, assume this is a server buffer. If ID is non-nil,
return ID as a string unless a buffer already exists with a live server
process, in which case signal an error. When ID is nil, return a
temporary name based on SERVER and PORT to be replaced with the network
name when discovered (see erc-networks--rename-server-buffer). Allow
either SERVER or PORT (but not both) to be nil to accommodate oddball
erc-server-connect-functions.
When TGT-INFO is non-nil, expect its string field to match the redundant param TARGET (retained for compatibility). Whenever possible, prefer returning TGT-INFO's string unmodified. But when a case-insensitive collision prevents that, return target@ID when ID is non-nil or target@network otherwise after renaming the conflicting buffer in the same manner.
Source Code
;; Defined in /usr/src/emacs/lisp/erc/erc.el.gz
(defun erc-generate-new-buffer-name (server port target &optional tgt-info id)
"Determine the name of an ERC buffer.
When TGT-INFO is nil, assume this is a server buffer. If ID is non-nil,
return ID as a string unless a buffer already exists with a live server
process, in which case signal an error. When ID is nil, return a
temporary name based on SERVER and PORT to be replaced with the network
name when discovered (see `erc-networks--rename-server-buffer'). Allow
either SERVER or PORT (but not both) to be nil to accommodate oddball
`erc-server-connect-function's.
When TGT-INFO is non-nil, expect its string field to match the redundant
param TARGET (retained for compatibility). Whenever possible, prefer
returning TGT-INFO's string unmodified. But when a case-insensitive
collision prevents that, return target@ID when ID is non-nil or
target@network otherwise after renaming the conflicting buffer in the
same manner."
(when target ; compat
(setq tgt-info (erc--target-from-string target)))
(if tgt-info
(let* ((esid (and erc-networks--id
(erc-networks--id-symbol erc-networks--id)))
(name (if esid
(erc-networks--reconcile-buffer-names tgt-info
erc-networks--id)
(erc--target-string tgt-info))))
(if (and esid (with-suppressed-warnings ((obsolete erc-reuse-buffers))
erc-reuse-buffers))
name
(generate-new-buffer-name name)))
(if (and (with-suppressed-warnings ((obsolete erc-reuse-buffers))
erc-reuse-buffers)
id)
(let ((string (symbol-name (erc-networks--id-symbol
(erc-networks--id-create id)))))
(when-let* ((buf (get-buffer string))
((erc-server-process-alive buf)))
(user-error "Session with ID %S already exists" string))
string)
(generate-new-buffer-name (if (and server port)
(if (with-suppressed-warnings
((obsolete erc-reuse-buffers))
erc-reuse-buffers)
(format "%s:%s" server port)
(format "%s:%s/%s" server port server))
(or server port))))))