From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stephen Berman Newsgroups: gmane.emacs.bugs Subject: bug#15419: 24.3.50; file name as directory completion problem Date: Wed, 07 May 2014 22:46:40 +0200 Message-ID: <87r445mi4v.fsf@rosalinde.fritz.box> References: <87pps44z2a.fsf@rosalinde.fritz.box> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1399495708 9612 80.91.229.3 (7 May 2014 20:48:28 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 7 May 2014 20:48:28 +0000 (UTC) To: 15419@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed May 07 22:48:21 2014 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 1Wi8lH-0002bk-Su for geb-bug-gnu-emacs@m.gmane.org; Wed, 07 May 2014 22:48:20 +0200 Original-Received: from localhost ([::1]:43607 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wi8lH-0005NU-Gd for geb-bug-gnu-emacs@m.gmane.org; Wed, 07 May 2014 16:48:19 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:33076) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wi8l8-0005NG-1F for bug-gnu-emacs@gnu.org; Wed, 07 May 2014 16:48:17 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Wi8l0-0005Wj-Cl for bug-gnu-emacs@gnu.org; Wed, 07 May 2014 16:48:09 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:37534) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wi8l0-0005Wc-9R for bug-gnu-emacs@gnu.org; Wed, 07 May 2014 16:48:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1Wi8kz-0000jN-Md for bug-gnu-emacs@gnu.org; Wed, 07 May 2014 16:48:01 -0400 X-Loop: help-debbugs@gnu.org In-Reply-To: <87pps44z2a.fsf@rosalinde.fritz.box> Resent-From: Stephen Berman Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 07 May 2014 20:48:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 15419 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 15419-submit@debbugs.gnu.org id=B15419.13994956392748 (code B ref 15419); Wed, 07 May 2014 20:48:01 +0000 Original-Received: (at 15419) by debbugs.gnu.org; 7 May 2014 20:47:19 +0000 Original-Received: from localhost ([127.0.0.1]:54885 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Wi8kI-0000iF-SW for submit@debbugs.gnu.org; Wed, 07 May 2014 16:47:19 -0400 Original-Received: from mout.gmx.net ([212.227.15.18]:57068) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Wi8kF-0000i0-Nb for 15419@debbugs.gnu.org; Wed, 07 May 2014 16:47:17 -0400 Original-Received: from rosalinde.fritz.box ([89.245.78.238]) by mail.gmx.com (mrgmx002) with ESMTPSA (Nemesis) id 0LmbVT-1XGvCI1hSN-00aDji for <15419@debbugs.gnu.org>; Wed, 07 May 2014 22:47:09 +0200 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.90 (gnu/linux) X-Provags-ID: V03:K0:UxafcBzWE/5/9tz2BdkJVYZhzl/9i3Ig2E0aGwsdS1A5jksa/Rd 6vnPRD0jef0AUi3rR0F53Xcdq0C2+q6NXb1tNqRQfRZT2EynFXf3tGv8eR9QtC7m2lxyYMU 48/SCxMAArnl4wBAmM9kQjsMNYpXdNkpXhZK2NAbSyRqTkOfXiVNmD+tbXJalvJ3Ir6trg0 CLreRYeR1YMPwdcHzwi1A== X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.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:88759 Archived-At: On Thu, 19 Sep 2013 17:21:33 +0200 Stephen Berman wrote: > By default, file name completion adds `/' only if needed, e.g. given the > file name "~/test/bla/abc", if I type `C-x C-f ~/test/bla/abc' and in > the minibuffer delete either "a" or "a/" after "bl", in both case TAB > correctly completes to "~/test/bla/abc" -- unless you do the following: > > 1. emacs -Q > 2. M-c customize-option RET completion-category-overrides RET, press INS > to add a new category, choose "file" from the Value Menu. check > Completion Styles, press INS and choose "substring" from the Value > Menu, press State and choose "Set for Current Session". > 3. Now if I type `C-x C-f ~/test/bla/abc' and in the minibuffer delete > "a/" after "bl", TAB again correctly completes to "~/test/bla/abc", > but if I delete just "a" after "bl", TAB incorrectly completes to > "~/test/bla//abc". > > I think what is happening is that when completion-category-overrides is > set as above, this makes completion-file-name-table call > file-name-all-completions, which calls file_name_completion (dired.c), > which, if the file is a directory, calls Ffile_name_as_directory > (fileio.c), which unconditionally adds `/' to the file name. (Without > the file override, completion-file-name-table does not call > file-name-all-completions in the above test case, but completes when (eq > action 'lambda).) It looks like this could be fixed by adding a > condition to the following code from file_name_completion to the effect > that in the absolute file name containing `name', the next character > after the last character in `name' is not `/'; but I don't know how to > do this in Emacs C. > > if (directoryp) > /* This completion is a directory; make it end with '/'. */ > name = Ffile_name_as_directory (name); I finally took another look at this bug and, while I don't know if my above proposal would be a suitable fix (and anyway still don't know how to implement it), I did come up with the following workaround; but it seems too ad hoc to be a real fix, so I hope someone familiar with the completion code will look at this bug. It would be nice to have it fixed in the next release. Steve Berman === modified file 'lisp/minibuffer.el' *** lisp/minibuffer.el 2014-05-04 19:37:56 +0000 --- lisp/minibuffer.el 2014-05-07 20:06:19 +0000 *************** *** 3197,3203 **** (merged (completion-pcm--pattern->string (nreverse mergedpat)))) (setq suffix (completion--merge-suffix merged newpos suffix)) ! (cons (concat prefix merged suffix) (+ newpos (length prefix))))))) (defun completion-pcm-try-completion (string table pred point) (pcase-let ((`(,pattern ,all ,prefix ,suffix) --- 3197,3208 ---- (merged (completion-pcm--pattern->string (nreverse mergedpat)))) (setq suffix (completion--merge-suffix merged newpos suffix)) ! ;; If we're using the substring style for file name completion ! ;; and completing a directory name, this ends up tacking "/" ! ;; onto the name, resulting in "//" if the suffix begins with ! ;; "/". So drop one "/" (bug#15419). ! (cons (replace-regexp-in-string "//" "/" (concat prefix merged suffix)) ! (+ newpos (length prefix))))))) (defun completion-pcm-try-completion (string table pred point) (pcase-let ((`(,pattern ,all ,prefix ,suffix)