From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.bugs Subject: bug#10085: 24.0.91; completion-pcm--find-all-completions returns wrong remote file names Date: Tue, 22 Nov 2011 14:05:42 -0500 Message-ID: References: <87ty5yu6or.fsf@gmx.de> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1321988816 5614 80.91.229.12 (22 Nov 2011 19:06:56 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 22 Nov 2011 19:06:56 +0000 (UTC) Cc: 10085@debbugs.gnu.org To: Michael Albinus Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Nov 22 20:06:50 2011 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1RSvg6-0002za-Ns for geb-bug-gnu-emacs@m.gmane.org; Tue, 22 Nov 2011 20:06:46 +0100 Original-Received: from localhost ([::1]:39343 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RSvg5-0003HT-D5 for geb-bug-gnu-emacs@m.gmane.org; Tue, 22 Nov 2011 14:06:45 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]:54772) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RSvg2-0003HA-IG for bug-gnu-emacs@gnu.org; Tue, 22 Nov 2011 14:06:43 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RSvg1-0003zM-DY for bug-gnu-emacs@gnu.org; Tue, 22 Nov 2011 14:06:42 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:33169) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RSvg1-0003zC-By for bug-gnu-emacs@gnu.org; Tue, 22 Nov 2011 14:06:41 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1RSvhK-0001Kr-5m for bug-gnu-emacs@gnu.org; Tue, 22 Nov 2011 14:08:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 22 Nov 2011 19:08:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 10085 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 10085-submit@debbugs.gnu.org id=B10085.13219888305062 (code B ref 10085); Tue, 22 Nov 2011 19:08:02 +0000 Original-Received: (at 10085) by debbugs.gnu.org; 22 Nov 2011 19:07:10 +0000 Original-Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RSvgT-0001Ja-N5 for submit@debbugs.gnu.org; Tue, 22 Nov 2011 14:07:09 -0500 Original-Received: from chene.dit.umontreal.ca ([132.204.246.20]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1RSvgP-0001JR-Kj for 10085@debbugs.gnu.org; Tue, 22 Nov 2011 14:07:08 -0500 Original-Received: from faina.iro.umontreal.ca (lechon.iro.umontreal.ca [132.204.27.242]) by chene.dit.umontreal.ca (8.14.1/8.14.1) with ESMTP id pAMJ5gjP008526; Tue, 22 Nov 2011 14:05:42 -0500 Original-Received: by faina.iro.umontreal.ca (Postfix, from userid 20848) id 908EDB4043; Tue, 22 Nov 2011 14:05:42 -0500 (EST) In-Reply-To: <87ty5yu6or.fsf@gmx.de> (Michael Albinus's message of "Sun, 20 Nov 2011 16:58:28 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.91 (gnu/linux) X-NAI-Spam-Flag: NO X-NAI-Spam-Threshold: 5 X-NAI-Spam-Score: 0 X-NAI-Spam-Rules: 1 Rules triggered RV4049=0 X-NAI-Spam-Version: 2.2.0.9286 : core <4049> : streams <703860> : uri <1013339> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Tue, 22 Nov 2011 14:08:02 -0500 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) 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:54179 Archived-At: > Start "emacs -Q". Apply "C-x C-f /sudo:: TAB". This results in > "/sudo:sudo:root@". A correct expansion would be "/sudo:root@". > As far as I can see, Tramp's completion functions work properly. > The problem seems to be `completion-pcm--find-all-completions'. I think the patch below fixes it. The problem is that PCM assumes that a field separator cannot appear within a field. In "/sudo::" the first / is a field separator, and the last ":" is also a field separator, but the first ":" isn't. Sadly the fix could have some detrimental impact on performance, and I think that the overall problem is linked to an oddity of Tramp's completion: If you do "C-x C-f /sudo ?" you get "/sudo:" but if you do "C-x C-f /sudo: ?" you get "sudo:root@". So fundamentally, the : of "/sudo:" acts a field separator, so (completion-boundaries "/sudo:") should probably return (6 . 0) rather than (1 . 0), and then "C-x C-f /sudo: ?" should list '("root@" ":") rather than '("sudo:root@"). Related inconsistency from a trace of C-x C-f /sud: TAB: 1 -> completion-file-name-table: string="/sud:" pred=file-exists-p action=(boundaries . "") 1 <- completion-file-name-table: (boundaries 5) [...] ====================================================================== 1 -> completion-file-name-table: string="/sudo:" pred=file-exists-p action=(boundaries . "") 1 <- completion-file-name-table: (boundaries 1) Stefan === modified file 'lisp/minibuffer.el' *** lisp/minibuffer.el 2011-11-19 09:18:31 +0000 --- lisp/minibuffer.el 2011-11-22 18:45:38 +0000 *************** *** 2458,2464 **** (between nil)) ;; Eliminate submatches that don't end with the separator. (dolist (submatch (prog1 suball (setq suball ()))) ! (when (eq sep (aref submatch (1- (length submatch)))) (push submatch suball))) (when suball ;; Update the boundaries and corresponding pattern. --- 2458,2474 ---- (between nil)) ;; Eliminate submatches that don't end with the separator. (dolist (submatch (prog1 suball (setq suball ()))) ! (when (and (eq sep (aref submatch (1- (length submatch)))) ! ;; The `sep' check is an optimization, but we need ! ;; to check that submatch really introduces ! ;; a new field. E.g. When completing "/sudo::", ! ;; prefix="/sudo:" and submatch is "sudo:" which ! ;; matches `sep' but is not sufficient (we'd need ! ;; "sudo::" or "sudo:foo@bar:" to get back to the ! ;; field that we're trying to complete). ! (let ((match (concat subprefix submatch))) ! (eq (length match) ! (completion-boundaries match table pred "")))) (push submatch suball))) (when suball ;; Update the boundaries and corresponding pattern.