Subject: bug#227: partial-completion-mode and completion-ignore-case combine to make 'read-file-name return a subdirectory when user enters the parent

From: Trey Jackson <[email-masked]>
Date: Mon, 12 May 2008 11:23:25 -0700

scenario:  you have a directory (/scratch2/rfn-bug) that contains some number of files, and one sub-directory (/scratch2/rfn-bug/frog).
You are prompted for a file name via 'read-file-name, you enter "/scratch2/rfn-bug" and that is properly returned, you enter "/scratch2/rfn-bug/" and what is returned is "/scratch2/rfn-bug/frog"

To reproduce:

in a shell:
  mkdir /scratch2/rfn-bug
  touch /scratch2/rfn-bug/a
  touch /scratch2/rfn-bug/b
  mkdir /scratch2/rfn-bug/frog

Run emacs, and then evaluate:

   (setq read-file-name-completion-ignore-case t)
   (require 'complete)
   (partial-completion-mode t)
   (read-file-name prompt dir dir 'must-match nil 'file-directory-p)

When you enter "/scratch2/rfn-bug", you'll get back "/scratch2/rfn-bug"
When you enter "/scratch2/rfn-bug/", you'll get back "/scratch2/rfn-bug/frog"

If read-file-name-completion-ignore-case is nil, this problem does not happen.
If there are more than one subdirectory, this problem does not happen.
If the single subdirectory is a link, you get the same behavior.
Running on linux (as seen below).

I built this version of Emacs myself, but did nothing custom, just the
standard ./configure, gmake, gmake install.  This bug was reproduced running 
emacs w/out an initialization file.

thanks,

TJ

In GNU Emacs 22.1.1 (x86_64-unknown-linux-gnu, X toolkit, Xaw3d scroll bars)
 of 2007-06-13 on quartzville
Windowing system distributor `The X.Org Foundation', version 11.0.60802000
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: en_US.UTF-8
  locale-coding-system: utf-8
  default-enable-multibyte-characters: t

Major mode: Lisp Interaction

Minor modes in effect:
  partial-completion-mode: t
  tooltip-mode: t
  tool-bar-mode: t
  mouse-wheel-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  unify-8859-on-encoding-mode: t
  utf-translate-cjk-mode: t
  auto-compression-mode: t
  line-number-mode: t

Recent input:
<down-mouse-2> <mouse-2> <down-mouse-2> <mouse-2> C-p 
C-p C-p C-p C-p C-p C-p C-p C-p C-e C-b <backspace> 
<backspace> <backspace> t C-e C-j C-n C-n C-n C-n C-n 
C-n C-n C-n C-n C-e C-p C-e C-j / <return> <help-echo> 
( r e q u i r e SPC ' c o m p l e t e ) C-j C-p C-p 
C-p C-p C-e C-j / <return> C-n C-n C-n C-n ( p a r 
t i a l - c o m p l e t i o n - m o d e SPC t ) C-j 
C-p C-p C-p C-p C-p C-p C-p C-p C-e C-j / <return> 
<help-echo> M-x e m a <backspace> <backspace> <backspace> 
r e p o <tab> <backspace> o r <tab> <return>

Recent messages:
("emacs" "-q")
For information about the GNU Project and its goals, type C-h C-p. [2 times]
Mark set
prompt here after complete/scratch2/rfn-bug/
Loading advice...done
prompt here after complete/scratch2/rfn-bug/
prompt here after complete/scratch2/rfn-bug/frog/
Loading emacsbug...
Loading regexp-opt...done
Loading emacsbug...done