From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#22169: 25.0.50; File name compiletion doesn't work with non-ASCII characters on OS X Date: Sun, 20 Dec 2015 19:56:17 +0200 Message-ID: <83fuyxt35q.fsf@gnu.org> References: <83y4cw3kie.fsf@gnu.org> <83twnk3fg1.fsf@gnu.org> <83oads2x99.fsf@gnu.org> <83io3z3drh.fsf@gnu.org> <831tan32q2.fsf@gnu.org> <83r3ikxmis.fsf@gnu.org> Reply-To: Eli Zaretskii NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1450634183 9040 80.91.229.3 (20 Dec 2015 17:56:23 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 20 Dec 2015 17:56:23 +0000 (UTC) Cc: 22169@debbugs.gnu.org To: andlind@gmail.com, random832@fastmail.com Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Dec 20 18:56:12 2015 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1aAiDI-0007eV-TS for geb-bug-gnu-emacs@m.gmane.org; Sun, 20 Dec 2015 18:56:09 +0100 Original-Received: from localhost ([::1]:41527 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aAiDI-0008GP-D3 for geb-bug-gnu-emacs@m.gmane.org; Sun, 20 Dec 2015 12:56:08 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:50521) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aAiDE-0008GH-An for bug-gnu-emacs@gnu.org; Sun, 20 Dec 2015 12:56:05 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aAiDD-0005tI-4N for bug-gnu-emacs@gnu.org; Sun, 20 Dec 2015 12:56:04 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:50594) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aAiDD-0005tE-1B for bug-gnu-emacs@gnu.org; Sun, 20 Dec 2015 12:56:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84) (envelope-from ) id 1aAiDC-00015P-T7 for bug-gnu-emacs@gnu.org; Sun, 20 Dec 2015 12:56:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 20 Dec 2015 17:56:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 22169 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 22169-submit@debbugs.gnu.org id=B22169.14506341624169 (code B ref 22169); Sun, 20 Dec 2015 17:56:02 +0000 Original-Received: (at 22169) by debbugs.gnu.org; 20 Dec 2015 17:56:02 +0000 Original-Received: from localhost ([127.0.0.1]:58195 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aAiDC-000158-0v for submit@debbugs.gnu.org; Sun, 20 Dec 2015 12:56:02 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:59452) by debbugs.gnu.org with esmtp (Exim 4.84) (envelope-from ) id 1aAiD9-00014q-P8 for 22169@debbugs.gnu.org; Sun, 20 Dec 2015 12:56:00 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aAiD0-0005oN-Fq for 22169@debbugs.gnu.org; Sun, 20 Dec 2015 12:55:54 -0500 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:42290) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aAiD0-0005oI-Cf; Sun, 20 Dec 2015 12:55:50 -0500 Original-Received: from 84.94.185.246.cable.012.net.il ([84.94.185.246]:4597 helo=HOME-C4E4A596F7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_128_CBC_SHA1:128) (Exim 4.82) (envelope-from ) id 1aAiCz-0003z4-KU; Sun, 20 Dec 2015 12:55:50 -0500 In-reply-to: <83r3ikxmis.fsf@gnu.org> (message from Eli Zaretskii on Fri, 18 Dec 2015 09:07:39 +0200) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:110210 Archived-At: > Date: Fri, 18 Dec 2015 09:07:39 +0200 > From: Eli Zaretskii > 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