Subject: 24.0.92; The variable `erc-channel-users' can be invalid after reconnection

From: Deniz Dogan <[email-masked]>
Date: Mon, 05 Mar 2012 17:31:35 +0100

I noticed this when I disconnected the Internet cable from my machine
and then plugged it back in a while later to reconnect.  When I hit C-c
C-n to list the users, a bot of mine was listed among the users.  I did
/whois the_nickname and got "No such nick/channel".

After some investigation, I found that ERC doesn't clear
erc-channel-users when an unexpected disconnection occurs.  I've
attached a patch which addresses this problem.

=== modified file 'lisp/erc/ChangeLog'
--- lisp/erc/ChangeLog	2012-02-09 07:48:22 +0000
+++ lisp/erc/ChangeLog	2012-03-05 16:26:23 +0000
@@ -1,3 +1,9 @@
+2012-03-05  Deniz Dogan  <[email-masked]>
+
+	* erc-backend.el (erc-process-sentinel): Clear channel user lists
+	upon disconnection.  This prevents invalid channel user lists when
+	reconnecting.
+
 2012-02-08  Glenn Morris  <[email-masked]>

 	* erc-backend.el (erc-coding-system-precedence):
@@ -277,4 +283,3 @@
 ;; coding: utf-8
 ;; add-log-time-zone-rule: t
 ;; End:
-

=== modified file 'lisp/erc/erc-backend.el'
--- lisp/erc/erc-backend.el	2012-02-08 08:07:24 +0000
+++ lisp/erc/erc-backend.el	2012-03-02 15:22:22 +0000
@@ -680,6 +680,9 @@
                    (setq erc-server-ping-handler nil)))
           (run-hook-with-args 'erc-disconnected-hook
                               (erc-current-nick) (system-name) "")
+          (dolist (buf (erc-buffer-filter (lambda () (boundp 'erc-channel-users)) cproc))
+            (with-current-buffer buf
+              (setq erc-channel-users (make-hash-table :test 'equal))))
           ;; Remove the prompt
           (goto-char (or (marker-position erc-input-marker) (point-max)))
           (forward-line 0)

In GNU Emacs 24.0.92.1 (i386-mingw-nt6.1.7601)
 of 2012-01-17 on MARVIN
Windowing system distributor `Microsoft Corp.', version 6.1.7601
configured using `configure --with-gcc (4.6) --no-opt --cflags -ID:/devel/emacs/libs/libXpm-3.5.8/include -ID:/devel/emacs/libs/libXpm-3.5.8/src -ID:/devel/emacs/libs/libpng-dev_1.4.3-1/include -ID:/devel/emacs/libs/zlib-dev_1.2.5-2/include -ID:/devel/emacs/libs/giflib-4.1.4-1/include -ID:/devel/emacs/libs/jpeg-6b-4/include -ID:/devel/emacs/libs/tiff-3.8.2-1/include -ID:/devel/emacs/libs/gnutls-3.0.9/include --ldflags -LD:/devel/emacs/libs/gnutls-3.0.9/lib'

Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: SVE
  value of $XMODIFIERS: nil
  locale-coding-system: cp1252
  default enable-multibyte-characters: t

Major mode: Help

Minor modes in effect:
  diff-auto-refine-mode: t
  erc-truncate-mode: t
  erc-services-mode: t
  erc-ring-mode: t
  erc-networks-mode: t
  erc-netsplit-mode: t
  erc-menu-mode: t
  erc-list-mode: t
  erc-pcomplete-mode: t
  erc-button-mode: t
  erc-fill-mode: t
  erc-stamp-mode: t
  erc-autojoin-mode: t
  popcmp-group-alternatives: t
  popcmp-short-help-beside-alts: t
  erc-track-mode: t
  erc-track-minor-mode: t
  erc-match-mode: t
  erc-irccontrols-mode: t
  erc-noncommands-mode: t
  erc-move-to-prompt-mode: t
  erc-readonly-mode: t
  erc-scrolltobottom-mode: t
  electric-indent-mode: t
  nxhtml-menu-mode: t
  rcirc-track-minor-mode: t
  tooltip-mode: t
  mouse-wheel-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  size-indication-mode: t
  column-number-mode: t
  line-number-mode: t
  transient-mark-mode: t

Recent messages:
Wrote d:/repos/emacs/trunk/lisp/erc/ChangeLog
Finding changes in d:/repos/emacs/trunk/lisp/erc/...done
Mark set [2 times]
Quit
Saving file d:/erc-channel-users.patch...
Wrote d:/erc-channel-users.patch
Quit
Making completion list...
Type "q" in help window to restore its previous buffer.
Mark activated

Load-path shadows:
d:/repos/nxhtml/related/django hides ~/.emacs.d/django
d:/repos/nima/json hides c:/misc/emacs/lisp/json
d:/repos/nxhtml/util/org-odt hides c:/misc/emacs/lisp/org/org-odt

Features:
(shadow sort mail-extr message rfc822 mml mml-sec mm-decode mm-bodies
mm-encode mail-parse rfc2231 rfc2047 rfc2045 ietf-drums mailabbrev
mail-utils gmm-utils mailheader emacsbug smerge-mode newcomment
whitespace vc-sccs vc-svn vc-cvs vc-rcs vc-dir ewoc vc ediff-merg
ediff-diff ediff-wind ediff-help ediff-util ediff-mult ediff-init ediff
vc-dispatcher magit diff-mode log-edit pcvs-util add-log magit-key-mode
dired-aux apropos debug help-mode view multi-isearch browse-url iswitchb
vc-git network-stream auth-source eieio byte-opt bytecomp byte-compile
cconv macroexp assoc gnus-util mm-util mail-prsvr password-cache
starttls tls magit-autoloads package tabulated-list uniquify
erc-truncate erc-services erc-ring erc-networks erc-netsplit erc-menu
erc-pcomplete pcomplete comint erc-button erc-fill erc-stamp wid-edit
erc-join nathalie-theme popcmp erc-track erc-match erc-goodies erc
erc-backend erc-compat format-spec thingatpt pp electric cus-start
cus-load flymake-files advice help-fns advice-preload flymakemsg
nxhtml-autostart nxhtml-autoload majmodpri vc-bzr nxhtml-menu
web-autoload nxhtml-base dired-x easymenu dired regexp-opt filmtipset
sgml-mode helo derived nginx-mode notepad rcirc easy-mmode edmacro
kmacro cl ring ido time-date tooltip ediff-hook vc-hooks lisp-float-type
mwheel dos-w32 disp-table ls-lisp w32-win w32-vars tool-bar dnd fontset
image fringe lisp-mode register page menu-bar rfn-eshadow timer select
scroll-bar mouse jit-lock font-lock syntax facemenu font-core frame cham
georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao
korean japanese hebrew greek romanian slovak czech european ethiopic
indian cyrillic chinese case-table epa-hook jka-cmpr-hook help simple
abbrev minibuffer button faces cus-face files text-properties overlay
sha1 md5 base64 format env code-pages mule custom widget
hashtable-print-readable backquote make-network-process multi-tty emacs)