unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: 11339@debbugs.gnu.org, stephen.berman@gmx.net, stefan@marxist.se
Subject: bug#11339: 24.1.50; read-{buffer,file-name}-completion-ignore-case fails on non-ascii
Date: Sat, 09 Nov 2019 11:20:12 +0200	[thread overview]
Message-ID: <83eeyh9zjn.fsf@gnu.org> (raw)
In-Reply-To: <jwvftiydmki.fsf-monnier+emacs@gnu.org> (message from Stefan Monnier on Fri, 08 Nov 2019 17:36:08 -0500)

> From: Stefan Monnier <monnier@iro.umontreal.ca>
> Cc: stephen.berman@gmx.net,  11339@debbugs.gnu.org,  stefan@marxist.se
> Date: Fri, 08 Nov 2019 17:36:08 -0500
> 
> > The patch below fixes Stefan's simplified test case, but the original
> > problem is still unsolved: "C-x b ba TAB TAB" says "Sole completion".
> >
> > What did I miss?
> 
> It still fails when you swap the two elements in the list :-(
> I don't have time to dig into the code now, tho,

What about the below?  It passes all the tests, and also fixes the
original use case.

diff --git a/src/minibuf.c b/src/minibuf.c
index f6cf47f..1e87c50 100644
--- a/src/minibuf.c
+++ b/src/minibuf.c
@@ -1323,13 +1323,13 @@ DEFUN ("try-completion", Ftry_completion, Stry_completion, 2, 3, 0,
 	  else
 	    {
 	      compare = min (bestmatchsize, SCHARS (eltstring));
-	      tem = Fcompare_strings (bestmatch, zero,
-				      make_fixnum (compare),
-				      eltstring, zero,
-				      make_fixnum (compare),
+	      Lisp_Object lcompare = make_fixnum (compare);
+	      tem = Fcompare_strings (bestmatch, zero, lcompare,
+				      eltstring, zero, lcompare,
 				      completion_ignore_case ? Qt : Qnil);
 	      matchsize = EQ (tem, Qt) ? compare : eabs (XFIXNUM (tem)) - 1;
 
+	      Lisp_Object old_bestmatch = bestmatch;
 	      if (completion_ignore_case)
 		{
 		  /* If this is an exact match except for case,
@@ -1363,7 +1363,12 @@ DEFUN ("try-completion", Ftry_completion, Stry_completion, 2, 3, 0,
 		    bestmatch = eltstring;
 		}
 	      if (bestmatchsize != SCHARS (eltstring)
-		  || bestmatchsize != matchsize)
+		  || bestmatchsize != matchsize
+		  || (completion_ignore_case
+		      && !EQ (Fcompare_strings (old_bestmatch, zero, lcompare,
+						eltstring, zero, lcompare,
+						Qnil),
+			      Qt)))
 		/* Don't count the same string multiple times.  */
 		matchcount += matchcount <= 1;
 	      bestmatchsize = matchsize;





  reply	other threads:[~2019-11-09  9:20 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-25 15:37 bug#11339: 24.1.50; read-{buffer,file-name}-completion-ignore-case fails on non-ascii Stephen Berman
2013-07-08 22:08 ` Stephen Berman
2019-11-01 19:57 ` Stefan Kangas
2019-11-01 20:20   ` Eli Zaretskii
2019-11-01 22:37     ` Stephen Berman
2019-11-02  7:11       ` Eli Zaretskii
2019-11-02 15:09         ` Stephen Berman
2019-11-03 16:16           ` Eli Zaretskii
2019-11-04 13:39             ` Stephen Berman
2019-11-04 16:21               ` Eli Zaretskii
2019-11-04 16:22               ` Stephen Berman
2019-11-04 17:12                 ` Eli Zaretskii
2019-11-04 18:02                   ` Stephen Berman
2019-11-06 16:58                     ` Eli Zaretskii
2019-11-07 14:34                       ` Stephen Berman
2019-11-07 14:49                         ` Eli Zaretskii
2019-11-07 16:01                         ` Stefan Monnier
2019-11-07 16:08                           ` Eli Zaretskii
2019-11-07 16:27                             ` Stefan Monnier
2019-11-07 18:12                               ` Eli Zaretskii
2019-11-08 22:36                                 ` Stefan Monnier
2019-11-09  9:20                                   ` Eli Zaretskii [this message]
2019-11-09 17:56                                     ` Stephen Berman
2019-11-09 18:24                                     ` Stefan Monnier
2019-11-09 19:57                                       ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=83eeyh9zjn.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=11339@debbugs.gnu.org \
    --cc=monnier@iro.umontreal.ca \
    --cc=stefan@marxist.se \
    --cc=stephen.berman@gmx.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).