* erc.el (erc-generate-new-buffer-name): Reuse old buffer names
when reconnecting. Fixes: debbugs:5563
This commit is contained in:
parent
4d19331f6b
commit
c1e57b4760
2 changed files with 29 additions and 17 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
2011-07-04 Vivek Dasmohapatra <vivek@etla.org>
|
||||||
|
|
||||||
|
* erc.el (erc-generate-new-buffer-name): Reuse old buffer names
|
||||||
|
when reconnecting (bug#5563).
|
||||||
|
|
||||||
2011-06-23 Lars Magne Ingebrigtsen <larsi@gnus.org>
|
2011-06-23 Lars Magne Ingebrigtsen <larsi@gnus.org>
|
||||||
|
|
||||||
* erc.el (erc-ssl): Made into a synonym for erc-tls, which
|
* erc.el (erc-ssl): Made into a synonym for erc-tls, which
|
||||||
|
|
|
@ -1555,26 +1555,33 @@ symbol, it may have these values:
|
||||||
(defun erc-generate-new-buffer-name (server port target &optional proc)
|
(defun erc-generate-new-buffer-name (server port target &optional proc)
|
||||||
"Create a new buffer name based on the arguments."
|
"Create a new buffer name based on the arguments."
|
||||||
(when (numberp port) (setq port (number-to-string port)))
|
(when (numberp port) (setq port (number-to-string port)))
|
||||||
(let* ((buf-name (or target
|
(let ((buf-name (or target
|
||||||
(or (let ((name (concat server ":" port)))
|
(or (let ((name (concat server ":" port)))
|
||||||
(when (> (length name) 1)
|
(when (> (length name) 1)
|
||||||
name))
|
name))
|
||||||
; This fallback should in fact never happen
|
;; This fallback should in fact never happen
|
||||||
"*erc-server-buffer*"))))
|
"*erc-server-buffer*")))
|
||||||
|
buffer-name)
|
||||||
;; Reuse existing buffers, but not if the buffer is a connected server
|
;; Reuse existing buffers, but not if the buffer is a connected server
|
||||||
;; buffer and not if its associated with a different server than the
|
;; buffer and not if its associated with a different server than the
|
||||||
;; current ERC buffer.
|
;; current ERC buffer.
|
||||||
(if (and erc-reuse-buffers
|
;; if buf-name is taken by a different connection (or by something !erc)
|
||||||
(get-buffer buf-name)
|
;; then see if "buf-name/server" meets the same criteria
|
||||||
(or target
|
(dolist (candidate (list buf-name (concat buf-name "/" server)))
|
||||||
(with-current-buffer (get-buffer buf-name)
|
(if (and (not buffer-name)
|
||||||
(and (erc-server-buffer-p)
|
erc-reuse-buffers
|
||||||
(not (erc-server-process-alive)))))
|
(get-buffer candidate)
|
||||||
(with-current-buffer (get-buffer buf-name)
|
(or target
|
||||||
(and (string= erc-session-server server)
|
(with-current-buffer (get-buffer candidate)
|
||||||
(erc-port-equal erc-session-port port))))
|
(and (erc-server-buffer-p)
|
||||||
buf-name
|
(not (erc-server-process-alive)))))
|
||||||
(generate-new-buffer-name buf-name))))
|
(with-current-buffer (get-buffer candidate)
|
||||||
|
(and (string= erc-session-server server)
|
||||||
|
(erc-port-equal erc-session-port port))))
|
||||||
|
(setq buffer-name candidate)))
|
||||||
|
;; if buffer-name is unset, neither candidate worked out for us,
|
||||||
|
;; fallback to the old <N> uniquification method:
|
||||||
|
(or buffer-name (generate-new-buffer-name buf-name)) ))
|
||||||
|
|
||||||
(defun erc-get-buffer-create (server port target &optional proc)
|
(defun erc-get-buffer-create (server port target &optional proc)
|
||||||
"Create a new buffer based on the arguments."
|
"Create a new buffer based on the arguments."
|
||||||
|
|
Loading…
Add table
Reference in a new issue