Subject: Re: bug#6836: 23.2; ERC -vs- uniquify

From: Lars Ingebrigtsen <[email-masked]>
Date: Sun, 27 Dec 2015 22:54:21 +0100

Tom Tromey <[email-masked]> writes:

> I have uniquify-buffer-name-style set to post-forward-angle-brackets.
>
> In ERC I connect to multiple servers, which sometimes have the same
> channel names.  For example I have two "#gdb" channels I join.
>
> The channel buffers are named #gdb and #gdb<2> -- but I would prefer
> something based on the server name instead.  Ideally, ERC and uniquify
> would work together to achieve this.

I think this was fixed in 2011.  If there's more than one server, the
second one gets called "buf-name/server"...

So I'm closing this bug report.  If this is still a problem in Emacs
25.1, please reopen.

    ;; 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 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)))

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no