Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I use ZNC to connect to IRC, and since ZNC seems to have the unfortunate characteristic of making me create a new "login" for each server I want to connect to (i.e Freenode and Quakenet), when erc starts I have a bunch of buffers all named the same thing.

My erc config looks like:

(defun djcb-erc-start-or-switch ()
  "Connect to ERC, or switch to last active buffer"
  (if (get-buffer "") ;; ERC already active?

    (erc-track-switch-buffer 1) ;; yes: switch to last active
    (when (y-or-n-p "Start ERC? ") ;; no: maybe start ERC
      ;; I use ZNC so I need to hit my server
      (erc :server "" :port 60667 :nick "nick1")
      (erc :server "" :port 60667 :nick "nick2")

How can I get it to start and alias the server buffer names for nick1 to Freenode and nick2 to whateverrandomserver?

share|improve this question
This should be simple, but ERC is heavily magical around the mode line so it's not; I tried hooking erc-mode-hook and renaming the buffer, but there's an automated mode line update that instantly stepped on my change. Best advice I have is to spend some time staring at the definition of erc-update-mode-line-buffer and frowning mightily; it seems like some around-advice that plays with the values in the format spec might work well, but I ran out of time to play with it before I found something that actually does the job. HTH -- – Aaron Miller Nov 13 '13 at 16:19

It's not the perfect solution, as I'm still looking for it and coming short... but what you can do is address the problem from a DNS perspective rather than an emacs one.

What I mean is, add local DNS entries such as:

freenode => <ip address of> whateverrandomserver => <also ip address of> This can be done by changing the file on /etc/hosts on *nix-based systems or in %SystemRoot%\System32\drivers\etc\hosts on Windows-based systems. It's fairly trivial as those files are essentially space-separated mappings between domain names and IP addresses. Just add a new line with those entries and off you go.

Then basically have emacs connect to what is essentially the same server using different domain names, et voilà, you got yourself different buffer names for different servers.

If you ever do come across a proper emacs-only solution though, please do share!

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .