Subject: bug#10457: (Broken?) programmable completion in shell buffers

From: Oleksandr Manzyuk <[email-masked]>
Date: Sun, 8 Jan 2012 19:40:48 +0000

Dear all,

I've decided to give Emacs 24 a try, primarily because I've read that
in Emacs 24 completion in `shell-mode' is performed using `pcomplete',
which is effectively broken in 23.2 and which I have always wanted to
try out.  I am on Ubuntu, so I've chosen to install emacs-snapshot
package from emacs-snapshot PPA (ppa:cassou/emacs).  The version I'm
running is

GNU Emacs 24.0.92.1 (x86_64-pc-linux-gnu, GTK+ Version 2.20.1) of
2012-01-05 on papaya, modified by Debian

I started a shell and tried to play with completion for various shell
commands defined in pcmpl-{gnu,unix,linux}.el, and it feels...
frustrating.  Let me explain what I mean by that.  Note: everything
below refers to emacs-snapshot run with -Q flag.

First, I'm unable to complete options to commands.  Take, for example,
"ssh".  If I'm in my home directory, type "ssh -", and hit TAB, the
command line changes to "ssh .-", and when I hit TAB again, a
completions buffer pops up showing only the file and directory names
starting with a dot and containing a dash.  I assume that instead of
offering the options available for ssh, Emacs performs some sort of
"fuzzy" matching against file and directory names.  Is this the
intended behavior, and if so, how can I disable this fuzzy matching?
Note that I do get completions for host names if I type "ssh " and hit
TAB.  When I am in a directory that doesn't contain files with a dash
in the name, typing "ssh -" and hitting TAB produces only "No match"
message in the minibuffer.

Second, more disturbingly, trying to complete options to "tar" locks
Emacs.  Here is how to reproduce it:

emacs -Q
M-x shell
cd <some directory without dashes in file and directory names>
tar - TAB SPC

(the last line means type "tar -" and hit TAB followed by SPC).  On my
machine this reliably locks Emacs: it becomes completely unresponsive,
I cannot close its window and have to open a terminal and kill it.
While it is locked, the system monitor shows that Emacs is using
almost 100% CPU.  As far as I can tell, this doesn't happen with the
other commands (pressing TAB followed by SPC simply inserts a space
into the shell buffer).

Is it only me or is it a bug?  I've had high hopes for `pcomplete',
but I am put off by its weirdness.  Am I missing something?  Please
let me know if I can provide more information.  I would submit a bug
report from within Emacs if it did not hang up.

Thanks,
Sasha
-- 
Oleksandr Manzyuk
http://oleksandrmanzyuk.wordpress.com