Subject: bug#18509: 24.3.93; [patch] erc completion case inconsistency

From: Carlos Pita <[email-masked]>
Date: Fri, 19 Sep 2014 11:01:58 -0300

(The following was a follow up to bug #11360, but I decided to report it
separately as they're not quite the same issues and, also, because I
know how to fix this one but not the other.)

When using the bitlbee channel (this is the example I have, the issue is
not specific to bitlbee at all), tab completion on an empty line gives:

FirstName
SecondName
....

But tab completion after /query gives:

firstname
secondname
....

This is not only visually inconsistent but, as the completion is case
sensitive, then that a given prefix successfully completes depends on
where the completion was triggered.

The case inconsistency is due to the fact that users are hashed into
erc-server-users using (erc-downcase nick). But then
pcomplete-erc-all-nicks builds the completion list from the hash
keys. This is wrong because the keys are the downcased nicks, not the
real nicks themselves. This is also inconsistent with the way
pcomplete-erc-nicks works (this one does use the real nick).

Changing (erc-server-user-nickname user) for nick in
pcomplete-erc-all-nicks will fix this issue. I'm not attaching an
explicit patch as the fix is quite trivial, but the resulting
pcomplete-erc-all-nicks should look like:

(defun pcomplete-erc-all-nicks (&optional postfix)
  "Returns a list of all nicks on the current server."
  (let (nicks)
    (erc-with-server-buffer
      (maphash (lambda (nick user)
                 (setq nicks (cons
                              ;; change this -----.
                              ;;                  v
                              (concat (erc-server-user-nickname user) postfix)
                              nicks)))
               erc-server-users))
      nicks))

Best regards
--
Carlos

------------------------------------------------------------

In GNU Emacs 24.3.93.1 (x86_64-unknown-linux-gnu, GTK+ Version 3.12.2)
 of 2014-09-11 on archiso
Windowing system distributor `The X.Org Foundation', version 11.0.11600000
Configured using:
 `configure --prefix=/usr --sysconfdir=/etc --libexecdir=/usr/lib
 --localstatedir=/var --with-x-toolkit=gtk3 --with-xft
 'CFLAGS=-march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong
 --param=ssp-buffer-size=4' CPPFLAGS=-D_FORTIFY_SOURCE=2
 LDFLAGS=-Wl,-O1,--sort-common,--as-needed,-z,relro'