bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#16197: 24.3.50; no completion on commands following "sudo" in shell


From: Thierry Volpiatto
Subject: bug#16197: 24.3.50; no completion on commands following "sudo" in shell and eshell
Date: Sun, 05 Jan 2014 08:35:57 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux)

Stefan Monnier <monnier@iro.umontreal.ca> writes:

>> Don't know what */rsh does, but */xargs is actually not working.
>
> Aha!
>
>> Well I didn't read */xargs, but here are the problems:
>
>> - `pcomplete-command-name' actually is always returning the first arg of
>>   command line e.g for "sudo apt-get" it is returning "sudo".
>
>> - `shell-command-completion' is trying to complete after what
>>   `shell-backward-command' returns, which is actually the first command
>>   near prompt or "[&;|]+ ", so when you try to complete after sudo or
>>   xargs, you call the completion against "sudo" or "xargs" which returns
>>   nothing of course.
>
> Can you describe those problems in terms of user-visible behavior
> (i.e. a recipe) so I can better understand what the code does (and
> should do instead)?
(! is the cursor)

emacs -Q
M-x shell
$ find . -name '*.el' | xargs et!
Press TAB, nothing, no completion against "et".
M-: (shell-backward-command)
I have now the cursor at xargs:
$ find . -name '*.el' | !xargs et
To provide completion against "et" I should have the cursor at:
$ find . -name '*.el' | xargs !et
after evaling (shell-backward-command).

Now download and load:
https://github.com/thierryvolpiatto/emacs-tv-config/blob/master/pcomplete-extension.el
And repeat the same recipe.

For `pcomplete-command-name' it is harder to give a recipe, the best is
to edebug it to have an idea (be careful the actual version is crashing
emacs sometimes).

>> Actually the fix made to these two functions is affecting only sudo, but
>> I can easily fix it to handle also 'xargs'.
>
> That would be nice.

Done in pcomplete-extension.el.

>> Don't think so, I think the problem should be fixed at another level as
>> descripted above.
>
> I missed the description, I'm afraid.
>
>> https://github.com/thierryvolpiatto/emacs-tv-config/blob/master/pcomplete-extension.el
>
> Not sure what I should look at there.

- pcomplete/sudo
- shell-backward-command
- pcomplete-command-name

> Can you send it as a patch against pcmpl-unix.el to fix pcomplete/xargs
> (and add pcomplete/sudo at the same time)?

Not only against pcmpl-unix.el I think:

* pcmpl-unix.el: Add `pcomplete/sudo'.
* pcomplete.el: Redefine `pcomplete-command-name'.
* shell.el: Redefine `shell-backward-command'.

Not urgent:

I would be happy to give also pcomplete/find,hg,ls,apt-get.
Not sure where they would go in this case, pcmpl-linux? unix? gnu?

Also more things to fix are `pcomplete/tar', `pcomplete/ssh' and maybe
others (allow completion on more than one arg), but I haven't worked on
this already.

-- 
Thierry
Get my Gnupg key:
gpg --keyserver pgp.mit.edu --recv-keys 59F29997 





reply via email to

[Prev in Thread] Current Thread [Next in Thread]