Subject: 27.0.90; ERC incorrectly reuses single buffer for channels of same name on multiple networks

From: Corwin Brust <[email-masked]>
Date: Wed, 18 Mar 2020 11:08:59 -0500

I'm able to get two channels of the same name sharing a single buffer.
I was hunting for this feature once upon a time but I *swear* I didn't
do *anything* :)

1. emacs -Q
  On windows, so I used: D:\projects>c:\emacs-27.0.90\x86_64\bin\runemacs.exe -Q

2. M-x erc RET
  Connect to an IRC network such as freenode.
  Expect: Connection occurs succcessfully; server buffer opens)

3. /join #mytestchannel RET
  Do this in the server buffer after connecting.
  Expect: Channel joined successfully, channel buffer opens.
  Actual: OK

4. M-x erc RET
  Connect to a second IRC network such as efnet
  Expect: Connection occurs succcessfully; server buffer opens)
  Actual: OK

3. /join #mytestchannel RET
  Do this in the new/second server buffer after both network connections
  are successful.
  Expect: Channel joined successfully, new channel buffer opens.
  Actual: NOT OK

When I join a second channel of the same name on a different network,
rather than create a new buffer and switch to it, ERC is reusing the
buffer created for the channel on the first network.  I see a
consolidated feed of messages sent from either network's channel and the
mode line for this "shared" buffer changes to reflect whichever network
last sent traffic to it.

Before confirming I can reproduce in -Q and creating this report I left
my client running and connected to both channels for a couple of days.
ERC was stable this time.  In fact, if I had some way to select which
network's channel I was sending too (and if I had any control over it
happening) this might be a cool feature.  As it is messages are sent to
whichever network last wrote to the buffer.

Using the following expression in M-: with the "shared" buffer selected
I can see that the erc-session-server (which I think of as "IRC network
server") does change as incoming traffic causes each respective network
to "take over" the buffer.

;; list erc buffers and their network
(mapconcat
  (lambda(b)
    (with-current-buffer b
      (format "%s => %s\n" b erc-session-server)))
  (erc-all-buffer-names) " ")

I had some additional issues with nickname autocomplete that may be
related but I've not troubled to research these at all yet.

I'll share additional detail or a patch when/if I develop any.

Thank you!

In GNU Emacs 27.0.90 (build 1, x86_64-w64-mingw32)
 of 2020-03-01 built on CIRROCUMULUS
Repository revision: c5f255d68156926923232b1edadf50faac527861
Repository branch: HEAD
Windowing system distributor 'Microsoft Corp.', version 10.0.18363
System Description: Microsoft Windows 10 Home (v10.0.1909.18363.720)

Recent messages:
Logging in as `mplsCorwin'...
Logging in as ‘mplsCorwin’... done
Connecting to irc.perl.org:6667...
Logging in as `corwin'...
Logging in without password
Logging in as ‘corwin’... done
Making completion list...
Commands: d, s, x, u; f, o, 1, 2, m, v; ~, %; q to quit; ? for help.
Mark set
Making completion list...

Configured using:
 'configure --without-dbus --host=x86_64-w64-mingw32
 --without-compress-install 'CFLAGS=-O2 -static''

Configured features:
XPM JPEG TIFF GIF PNG RSVG SOUND NOTIFY W32NOTIFY ACL GNUTLS LIBXML2
HARFBUZZ ZLIB TOOLKIT_SCROLL_BARS MODULES THREADS PDUMPER LCMS2 GMP

Important settings:
  value of $LANG: ENU
  locale-coding-system: cp1252

Major mode: Buffer Menu

Minor modes in effect:
  erc-list-mode: t
  erc-menu-mode: t
  erc-autojoin-mode: t
  erc-ring-mode: t
  erc-networks-mode: t
  erc-pcomplete-mode: t
  erc-track-mode: t
  erc-track-minor-mode: t
  erc-match-mode: t
  erc-button-mode: t
  erc-fill-mode: t
  erc-stamp-mode: t
  erc-netsplit-mode: t
  erc-irccontrols-mode: t
  erc-noncommands-mode: t
  erc-move-to-prompt-mode: t
  erc-readonly-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  buffer-read-only: t
  line-number-mode: t
  transient-mark-mode: t

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug message rmc puny dired dired-loaddefs
rfc822 mml mml-sec epa derived epg epg-config gnus-util rmail
rmail-loaddefs text-property-search mm-decode mm-bodies mm-encode
mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail rfc2047
rfc2045 ietf-drums mm-util mail-prsvr mail-utils erc-list erc-menu
easymenu erc-join erc-ring erc-networks erc-pcomplete time-date
pcomplete comint ansi-color ring erc-track erc-match erc-button
browse-url wid-edit erc-fill erc-stamp erc-netsplit erc-goodies erc
erc-backend erc-compat format-spec auth-source cl-seq eieio eieio-core
cl-macs eieio-loaddefs cl-loaddefs cl-lib password-cache json subr-x map
seq byte-opt gv bytecomp byte-compile cconv thingatpt pp erc-loaddefs
tooltip eldoc electric uniquify ediff-hook vc-hooks lisp-float-type
mwheel dos-w32 ls-lisp disp-table term/w32-win w32-win w32-vars
term/common-win tool-bar dnd fontset image regexp-opt fringe
tabulated-list replace newcomment text-mode elisp-mode lisp-mode
prog-mode register page tab-bar menu-bar rfn-eshadow isearch timer
select scroll-bar mouse jit-lock font-lock syntax facemenu font-core
term/tty-colors frame minibuffer cl-generic cham georgian utf-8-lang
misc-lang vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms
cp51932 hebrew greek romanian slovak czech european ethiopic indian
cyrillic chinese composite charscript charprop case-table epa-hook
jka-cmpr-hook help simple abbrev obarray cl-preloaded nadvice loaddefs
button faces cus-face macroexp files text-properties overlay sha1 md5
base64 format env code-pages mule custom widget hashtable-print-readable
backquote threads w32notify w32 lcms2 multi-tty make-network-process
emacs)

Memory information:
((conses 16 87033 18275)
 (symbols 48 9967 1)
 (strings 32 28608 1896)
 (string-bytes 1 880312)
 (vectors 16 15638)
 (vector-slots 8 185817 12702)
 (floats 8 42 320)
 (intervals 56 876 280)
 (buffers 1000 16))