Subject: Re: bug#11348: 24.0.95; TAB-completion in shell-command produces d:\/foo on MS-Windows

From: Stefan Monnier <[email-masked]>
Date: Fri, 04 May 2012 13:59:43 -0400

>  M-! cd d:\gnu TAB
> (A directory 'd:/gnu' exists on my disk.)
> After pressing the TAB key, the minibuffer displays this:
>   cd d:\/gnu/

Duh, I somehow assumed it was on the trunk (seeing how it was reported
soon after I modified code on the trunk in this area).

IIUC from the rest of the thread, the problem is in the pcomplete code
(it affects `cd' but not `toto').  That's bad because the pcomplete code
is even trickier than the rest.

This said, based on your description, the problem may simply come from
shell.el's setting of pcomplete-arg-quote-list which tells pcomplete
that \ is an escape char.

I.e. does the patch below fix the problem?

> This works better, it produces "cd d:\gnu/ ", which is ugly, but
> correct.

Which part is ugly?  The \, the /, or the use of a mix of them?

> Perhaps Stefan could at some point add some documentation about the
> internals, that would allow mere mortals such as myself debug the
> completion code.

I'd love to, but I'm much too deeply in it to know what needs more
documentation, so fire away your questions and I'll reply with
comments&docstrings.

        Stefan

=== modified file 'lisp/shell.el'
--- lisp/shell.el	2012-02-28 08:17:21 +0000
+++ lisp/shell.el	2012-05-04 17:57:59 +0000
@@ -429,7 +429,7 @@
   (set (make-local-variable 'pcomplete-parse-arguments-function)
        #'shell-parse-pcomplete-arguments)
   (set (make-local-variable 'pcomplete-arg-quote-list)
-       (append "\\ \t\n\r\"'`$|&;(){}[]<>#" nil))
+       shell-delimiter-argument-list)
   (set (make-local-variable 'pcomplete-termination-string)
        (cond ((not comint-completion-addsuffix) "")
              ((stringp comint-completion-addsuffix)