Subject: bug#49761: file-cache-minibuffer-complete has become unusable for duplicate file names in MacOSX 27.x emacs

From: Juri Linkov <[email-masked]>
Date: Sun, 01 Aug 2021 11:40:50 +0300

tags 49761 fixed
close 49761 28.0.50
thanks

> Well, it's now the default behavior.  It wasn't previously.  :-)

And new is not always better ;-)

So now the new behavior (that became old now) was fixed
in the master branch for Emacs 28, and all test cases
that you presented work completely as expected.
Thanks for helping to understand where the problem was.

BTW, after the fix, the following additional information
is not necessary, but I discovered that in old versions
you can use the prefix argument to force C-TAB cycling.

An excerpt from etc/NEWS.20:

  ** file-cache-minibuffer-complete now accepts a prefix argument.
  With a prefix argument, it does not try to do completion of
  the file name within its directory; it only checks for other
  directories that contain the same file name.
  Thus, given the file name Makefile, and assuming that a file
  Makefile.in exists in the same directory, ordinary
  file-cache-minibuffer-complete will try to complete Makefile to
  Makefile.in and will therefore never look for other directories that
  have Makefile.  A prefix argument tells it not to look for longer
  names such as Makefile.in, so that instead it will look for other
  directories--just as if the name were already complete in its present
  directory.

and a comment from bindings.el:

  ;; The prefix argument works around a bug in the minibuffer completion.
  ;; The completion function doesn't distinguish between the states:
  ;;
  ;;   "Multiple completions of name" (eg, Makefile, Makefile.in)
  ;;   "Name available in multiple directories" (/tmp/Makefile, ~me/Makefile)
  ;;
  ;; The default is to do the former; a prefix arg forces the latter.