> Date: Fri, 18 Dec 2015 09:07:39 +0200
> From: Eli Zaretskii <eliz@gnu.org>
> Cc: random832@fastmail.com, 22169@debbugs.gnu.org
>
> > After reading through Random832:s comments, I also see the problem with "åäö"
> > and "aao" not being handled correctly. Typing "a TAB" makes Emacs delete the
> > "a", which seems very confusing. Typing "å TAB" or "aa TAB" works, though.
> > (Here `(file-name-all-completions "a" ".")' returns `("åäöfirst.txt"
> > "aaosecond.txt")'.
> >
> > In other words, Emcas is in better shape with my than it was before, but there
> > is still some work to be done.
> >
> > When it comes to "lax" matching -- I really don't think we should use it for
> > file names. I don't want to match "å" when I type "a" etc.
>
> I have an idea for a change that could solve this. I will post it in
> a day or two and ask you to try it.
Could you please try the patch below, and see if it avoids the "lax"
matches and the confusing effect of deleting "a" in the scenario above
is avoided on OS X?
(This is not the full patch, since we need to add this code only for
some file-name encodings, such as utf-8-hfs. If this works for you, I
will add the missing bits. If it doesn't work, please tell where I
goofed.)
Thanks.
diff --git a/src/dired.c b/src/dired.c
index 84bf247..4ff85f1 100644
--- a/src/dired.c
+++ b/src/dired.c
@@ -641,16 +641,30 @@ file_name_completion (Lisp_Object file, Lisp_Object dirname, bool all_flag,
matchcount += matchcount <= 1;
+ Lisp_Object zero = make_number (0);
if (all_flag)
- bestmatch = Fcons (name, bestmatch);
+ {
+ Lisp_Object cmp1
+ = Fcompare_strings (name, zero, make_number (SCHARS (name)),
+ file, zero, make_number (SCHARS (file)),
+ completion_ignore_case ? Qt : Qnil);
+ if (EQ (cmp1, Qt) || XINT (cmp1) != -1)
+ bestmatch = Fcons (name, bestmatch);
+ }
else if (NILP (bestmatch))
{
- bestmatch = name;
- bestmatchsize = SCHARS (name);
+ Lisp_Object cmp2
+ = Fcompare_strings (name, zero, make_number (SCHARS (name)),
+ file, zero, make_number (SCHARS (file)),
+ completion_ignore_case ? Qt : Qnil);
+ if (EQ (cmp2, Qt) || XINT (cmp2) != -1)
+ {
+ bestmatch = name;
+ bestmatchsize = SCHARS (name);
+ }
}
else
{
- Lisp_Object zero = make_number (0);
/* FIXME: This is a copy of the code in Ftry_completion. */
ptrdiff_t compare = min (bestmatchsize, SCHARS (name));
Lisp_Object cmp