emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/trunk r104941: * erc.el (erc-generate-new-b


From: Lars Magne Ingebrigtsen
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r104941: * erc.el (erc-generate-new-buffer-name): Reuse old buffer names
Date: Mon, 04 Jul 2011 15:23:04 +0200
User-agent: Bazaar (2.3.1)

------------------------------------------------------------
revno: 104941
fixes bug(s): http://debbugs.gnu.org/5563
author: Vivek Dasmohapatra <address@hidden>
committer: Lars Magne Ingebrigtsen <address@hidden>
branch nick: trunk
timestamp: Mon 2011-07-04 15:23:04 +0200
message:
  * erc.el (erc-generate-new-buffer-name): Reuse old buffer names
  when reconnecting.
modified:
  lisp/erc/ChangeLog
  lisp/erc/erc.el
=== modified file 'lisp/erc/ChangeLog'
--- a/lisp/erc/ChangeLog        2011-06-23 00:17:41 +0000
+++ b/lisp/erc/ChangeLog        2011-07-04 13:23:04 +0000
@@ -1,3 +1,8 @@
+2011-07-04  Vivek Dasmohapatra  <address@hidden>
+
+       * erc.el (erc-generate-new-buffer-name): Reuse old buffer names
+       when reconnecting (bug#5563).
+
 2011-06-23  Lars Magne Ingebrigtsen  <address@hidden>
 
        * erc.el (erc-ssl): Made into a synonym for erc-tls, which

=== modified file 'lisp/erc/erc.el'
--- a/lisp/erc/erc.el   2011-07-01 01:29:04 +0000
+++ b/lisp/erc/erc.el   2011-07-04 13:23:04 +0000
@@ -1555,26 +1555,33 @@
 (defun erc-generate-new-buffer-name (server port target &optional proc)
   "Create a new buffer name based on the arguments."
   (when (numberp port) (setq port (number-to-string port)))
-  (let* ((buf-name (or target
-                      (or (let ((name (concat server ":" port)))
-                            (when (> (length name) 1)
-                              name))
-                          ; This fallback should in fact never happen
-                          "*erc-server-buffer*"))))
+  (let ((buf-name (or target
+                      (or (let ((name (concat server ":" port)))
+                            (when (> (length name) 1)
+                              name))
+                          ;; This fallback should in fact never happen
+                          "*erc-server-buffer*")))
+        buffer-name)
     ;; Reuse existing buffers, but not if the buffer is a connected server
     ;; buffer and not if its associated with a different server than the
     ;; current ERC buffer.
-    (if (and erc-reuse-buffers
-            (get-buffer buf-name)
-            (or target
-                (with-current-buffer (get-buffer buf-name)
-                  (and (erc-server-buffer-p)
-                       (not (erc-server-process-alive)))))
-            (with-current-buffer (get-buffer buf-name)
-              (and (string= erc-session-server server)
-                   (erc-port-equal erc-session-port port))))
-       buf-name
-      (generate-new-buffer-name buf-name))))
+    ;; if buf-name is taken by a different connection (or by something !erc)
+    ;; then see if "buf-name/server" meets the same criteria
+    (dolist (candidate (list buf-name (concat buf-name "/" server))) 
+      (if (and (not buffer-name)
+               erc-reuse-buffers
+               (get-buffer candidate)
+               (or target
+                   (with-current-buffer (get-buffer candidate)
+                     (and (erc-server-buffer-p)
+                          (not (erc-server-process-alive)))))
+               (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)
   "Create a new buffer based on the arguments."


reply via email to

[Prev in Thread] Current Thread [Next in Thread]