Function: message-buffer-name
message-buffer-name is a byte-compiled function defined in
message.el.gz.
Signature
(message-buffer-name TYPE &optional TO GROUP)
Documentation
Return a new (unique) buffer name based on TYPE and TO.
Source Code
;; Defined in /usr/src/emacs/lisp/gnus/message.el.gz
(defun message-buffer-name (type &optional to group)
"Return a new (unique) buffer name based on TYPE and TO."
(cond
;; Generate a new buffer name The Message Way.
((memq message-generate-new-buffers '(unique t))
(generate-new-buffer-name
(concat "*" type
(if to
(concat " to "
(or (car (mail-extract-address-components to))
to))
"")
(if (and group (not (string= group ""))) (concat " on " group) "")
"*")))
;; Check whether `message-generate-new-buffers' is a function,
;; and if so, call it.
((functionp message-generate-new-buffers)
(funcall message-generate-new-buffers type to group))
((eq message-generate-new-buffers 'unsent)
(generate-new-buffer-name
(concat "*unsent " type
(if to
(concat " to "
(or (car (mail-extract-address-components to))
to))
"")
(if (and group (not (string= group ""))) (concat " on " group) "")
"*")))
;; Search for the existing message buffer with the specified name.
(t
(let* ((new (if (eq message-generate-new-buffers 'standard)
(generate-new-buffer-name (concat "*" type " message*"))
(let ((message-generate-new-buffers 'unique))
(message-buffer-name type to group))))
(regexp (concat "\\`"
(regexp-quote
(if (string-match "<[0-9]+>\\'" new)
(substring new 0 (match-beginning 0))
new))
"\\(?:<\\([0-9]+\\)>\\)?\\'"))
(case-fold-search nil))
(or (cdar
(last
(sort
(delq nil
(mapcar
(lambda (b)
(when (and (string-match regexp (setq b (buffer-name b)))
(eq (with-current-buffer b major-mode)
'message-mode))
(cons (string-to-number (or (match-string 1 b) "1"))
b)))
(buffer-list)))
#'car-less-than-car)))
new)))))