Subject: Re: bug#11339: 24.1.50; read-{buffer,file-name}-completion-ignore-case fails on non-ascii

From: Stephen Berman <[email-masked]>
Date: Tue, 09 Jul 2013 00:08:29 +0200

On Wed, 25 Apr 2012 17:37:38 +0200 Stephen Berman <[email-masked]> wrote:

> -1. cd /tmp; touch bäh bÄh bla
> 0. emacs -Q
> 1. M-x customize-option RET read-buffer-completion-ignore-case RET.
>    Toggle to "on", set for the current session.
>    M-x customize-option RET read-file-name-completion-ignore-case RET.
>    Toggle to "on", set for the current session.
> 2. C-x C-f b TAB => *Completions* buffer contains, as expected: bla bÄh bäh.         
> 3. Visit files `bla', `bäh' and `bÄh', switch to buffer *scratch* and
>    repeat step 2, replacing `C-x C-f' with `C-x b' => same results.
> 4. C-x C-f bä TAB => Emacs completes the input to "bäh".               
> 5. TAB => Emacs incorrectly reports: "[Sole completion]".                 
> 6. C-x C-f bÄ TAB => Emacs completes the input to "bÄh".
> 7. TAB => Emacs incorrectly reports: "[Sole completion]".                 
> 8. Switch to buffer *scratch* and repeat step 4-7, replacing `C-x C-f'
>    with `C-x b' => same results.

This bug still exists in the current trunk.  I have an additional
observation, which I don't know if I just overlooked in my OP or if
there's been a code change since then that's responsible for this
observation: if only one of the files `bäh' and `bÄh' is being visited,
then `C-x b' completes correctly regardless of the case of the input;
i.e., if only `bÄh' is in a buffer `C-x b bä TAB' completes to it, and
likewise, if only `bäh' is in a buffer `C-x b bÄ TAB' completes to it.
But if only one of the files `bäh' and `bÄh' exists, `C-x C-f' still
only completes if the case of the input matches the case of the file
name, as above.

Here is part of the call chain of find-file:

find-file (files.el) -> find-file-read-args -> read-file-name
(minibuffer.el) -> read-file-name-default -> completing-read ->
read-file-name-internal -> completion-table-in-turn ->
completion--file-name-table -> completion-file-name-table ->
file-name-completion (dired.c) -> file_name_completion ->
fast_string_match_ignore_case (search.c) -> compile_pattern with argument
Vascii_canon_table

The argument Vascii_canon_table looks suspicious, but maybe it's already
been overridden earlier, though I don't see where; or maybe I just don't
understand its import here.  Anyway, the call chain of switch-to-buffer
is quite different:

switch-to-buffer (window.el) -> read-buffer-to-switch ->
internal-complete-buffer-except (minibuffer.el) -> internal-complete-buffer
(minibuf.c) -> (try-completion | all-completions | test-completion) ->
Fcompare_strings

(file_name_completion also calls Fcompare_strings later, but there's no
use of Vascii_canon_table there.)

I don't know how to debug this.

Steve Berman