* Proposal for shell completion in M-x shell RET
@ 2007-09-10 12:44 David Kastrup
2007-09-10 13:21 ` Andreas Schwab
2007-09-10 14:19 ` Stefan Monnier
0 siblings, 2 replies; 11+ messages in thread
From: David Kastrup @ 2007-09-10 12:44 UTC (permalink / raw)
To: emacs-devel
Hi,
it turns out that when using bash's programmable completion, the
results are typically much better than Emacs' completion. Since it is
unfeasible to mimic or interpret the wealth of shell-completion
scripts in Emacs, I would propose making it configurable to use the
shell completion instead.
The way this would work would be when TAB is pressed to send the
partial line up to the cursor as input to the shell, followed by TAB,
then capture the output from bash and interpret it (either inserting
completed output, or offering a completion menu). When committing a
line (or pressing TAB), when the partial line already submitted does
not correspond with the one in the shell command line, the line is
erased and committed fresh, otherwise only the rest of the line is
submitted.
This approach would have the advantage of leaving no trace of the
completion in the shell history unless a command is actually sent to
the shell.
It should also work with other shells.
--
David Kastrup
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Proposal for shell completion in M-x shell RET
2007-09-10 12:44 Proposal for shell completion in M-x shell RET David Kastrup
@ 2007-09-10 13:21 ` Andreas Schwab
2007-09-10 13:56 ` David Kastrup
2007-09-10 14:19 ` Stefan Monnier
1 sibling, 1 reply; 11+ messages in thread
From: Andreas Schwab @ 2007-09-10 13:21 UTC (permalink / raw)
To: David Kastrup; +Cc: emacs-devel
David Kastrup <dak@gnu.org> writes:
> The way this would work would be when TAB is pressed to send the
> partial line up to the cursor as input to the shell, followed by TAB,
> then capture the output from bash and interpret it (either inserting
> completed output, or offering a completion menu).
Command line editing is disabled in the inferior shell. If you want to
enable it you'll have to make sure all literal control characters are
preceded by the quote character before sending the line to the shell.
You'll also have to enable echoing to be able to capture anything.
Andreas.
--
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
PGP key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Proposal for shell completion in M-x shell RET
2007-09-10 13:21 ` Andreas Schwab
@ 2007-09-10 13:56 ` David Kastrup
2007-09-10 14:03 ` Andreas Schwab
0 siblings, 1 reply; 11+ messages in thread
From: David Kastrup @ 2007-09-10 13:56 UTC (permalink / raw)
To: Andreas Schwab; +Cc: emacs-devel
Andreas Schwab <schwab@suse.de> writes:
> David Kastrup <dak@gnu.org> writes:
>
>> The way this would work would be when TAB is pressed to send the
>> partial line up to the cursor as input to the shell, followed by TAB,
>> then capture the output from bash and interpret it (either inserting
>> completed output, or offering a completion menu).
>
> Command line editing is disabled in the inferior shell. If you want to
> enable it you'll have to make sure all literal control characters are
> preceded by the quote character before sending the line to the
> shell.
Should be doable. Command line editing is necessary for completion?
> You'll also have to enable echoing to be able to capture anything.
Hm. Completion is not really echoing. Worth an experiment, but
probably one could expect this to work on more shells if one did not
rely on a nice combination of non-echo/complete.
--
David Kastrup
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Proposal for shell completion in M-x shell RET
2007-09-10 13:56 ` David Kastrup
@ 2007-09-10 14:03 ` Andreas Schwab
2007-09-10 14:10 ` David Kastrup
0 siblings, 1 reply; 11+ messages in thread
From: Andreas Schwab @ 2007-09-10 14:03 UTC (permalink / raw)
To: David Kastrup; +Cc: emacs-devel
David Kastrup <dak@gnu.org> writes:
> Should be doable. Command line editing is necessary for completion?
TAB completion is part of line editing.
>> You'll also have to enable echoing to be able to capture anything.
>
> Hm. Completion is not really echoing.
If the terminal is on -echo state then readline does not echo anything
besides the initial prompt.
Andreas.
--
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
PGP key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Proposal for shell completion in M-x shell RET
2007-09-10 14:03 ` Andreas Schwab
@ 2007-09-10 14:10 ` David Kastrup
0 siblings, 0 replies; 11+ messages in thread
From: David Kastrup @ 2007-09-10 14:10 UTC (permalink / raw)
To: Andreas Schwab; +Cc: emacs-devel
Andreas Schwab <schwab@suse.de> writes:
> David Kastrup <dak@gnu.org> writes:
>
>> Should be doable. Command line editing is necessary for completion?
>
> TAB completion is part of line editing.
>
>>> You'll also have to enable echoing to be able to capture anything.
>>
>> Hm. Completion is not really echoing.
>
> If the terminal is on -echo state then readline does not echo anything
> besides the initial prompt.
Checked it. If there is no unique completion, the completion list
appears, but if a unique completion is performed, no echoing happens.
At least with the version of bash I am using. So you are right: one
would have to turn on echoing on the tty at least while one is fishing
for completions.
--
David Kastrup
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Proposal for shell completion in M-x shell RET
2007-09-10 12:44 Proposal for shell completion in M-x shell RET David Kastrup
2007-09-10 13:21 ` Andreas Schwab
@ 2007-09-10 14:19 ` Stefan Monnier
2007-09-10 14:29 ` Stefan Monnier
2007-09-10 14:30 ` David Kastrup
1 sibling, 2 replies; 11+ messages in thread
From: Stefan Monnier @ 2007-09-10 14:19 UTC (permalink / raw)
To: David Kastrup; +Cc: emacs-devel
> The way this would work would be when TAB is pressed to send the
> partial line up to the cursor as input to the shell, followed by TAB,
It would most likely have to be another key, because shell.el cannot know if
the command is sent to bash or to some other application, so it could only
be the user's choice to either get local completion or to send "prefix string
plus TAB" to the application.
Stefan
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Proposal for shell completion in M-x shell RET
2007-09-10 14:19 ` Stefan Monnier
@ 2007-09-10 14:29 ` Stefan Monnier
2007-09-10 14:52 ` David Kastrup
2007-09-10 14:30 ` David Kastrup
1 sibling, 1 reply; 11+ messages in thread
From: Stefan Monnier @ 2007-09-10 14:29 UTC (permalink / raw)
To: David Kastrup; +Cc: emacs-devel
>> The way this would work would be when TAB is pressed to send the
>> partial line up to the cursor as input to the shell, followed by TAB,
> It would most likely have to be another key, because shell.el cannot know if
> the command is sent to bash or to some other application, so it could only
> be the user's choice to either get local completion or to send "prefix string
> plus TAB" to the application.
BTW, maybe we can do it the way `gdb' does it: instead of sending TAB, we
send a "list_all_completions" command, presuming that bash offers such
a function.
Stefan
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Proposal for shell completion in M-x shell RET
2007-09-10 14:19 ` Stefan Monnier
2007-09-10 14:29 ` Stefan Monnier
@ 2007-09-10 14:30 ` David Kastrup
1 sibling, 0 replies; 11+ messages in thread
From: David Kastrup @ 2007-09-10 14:30 UTC (permalink / raw)
To: Stefan Monnier; +Cc: emacs-devel
Stefan Monnier <monnier@iro.umontreal.ca> writes:
>> The way this would work would be when TAB is pressed to send the
>> partial line up to the cursor as input to the shell, followed by TAB,
>
> It would most likely have to be another key, because shell.el cannot know if
> the command is sent to bash or to some other application, so it could only
> be the user's choice to either get local completion or to send "prefix string
> plus TAB" to the application.
Maybe this can help on some platforms?
process-running-child-p is a built-in function in `C source code'.
(process-running-child-p &optional PROCESS)
Return t if PROCESS has given the terminal to a child.
If the operating system does not make it possible to find out,
return t unconditionally.
[back]
Anyway, one could just send the partial line plus TAB to the other
application, anyway. If it just echoes it, no harm is done. The
behavior should work for most applications that use either a normal
stty setting or readline.
--
David Kastrup
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Proposal for shell completion in M-x shell RET
2007-09-10 14:29 ` Stefan Monnier
@ 2007-09-10 14:52 ` David Kastrup
2007-09-10 15:51 ` Andreas Schwab
2007-09-10 23:55 ` Richard Stallman
0 siblings, 2 replies; 11+ messages in thread
From: David Kastrup @ 2007-09-10 14:52 UTC (permalink / raw)
To: Stefan Monnier; +Cc: emacs-devel
Stefan Monnier <monnier@iro.umontreal.ca> writes:
>>> The way this would work would be when TAB is pressed to send the
>>> partial line up to the cursor as input to the shell, followed by TAB,
>
>> It would most likely have to be another key, because shell.el cannot know if
>> the command is sent to bash or to some other application, so it could only
>> be the user's choice to either get local completion or to send "prefix string
>> plus TAB" to the application.
>
> BTW, maybe we can do it the way `gdb' does it: instead of sending TAB, we
> send a "list_all_completions" command, presuming that bash offers such
> a function.
programmable completion is extensively context-sensitive (which is
pretty much its whole point: it does not just complete file names, but
also CVS revisions, options and other stuff).
And sending such a command would clobber the command history, too.
--
David Kastrup
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Proposal for shell completion in M-x shell RET
2007-09-10 14:52 ` David Kastrup
@ 2007-09-10 15:51 ` Andreas Schwab
2007-09-10 23:55 ` Richard Stallman
1 sibling, 0 replies; 11+ messages in thread
From: Andreas Schwab @ 2007-09-10 15:51 UTC (permalink / raw)
To: David Kastrup; +Cc: Stefan Monnier, emacs-devel
David Kastrup <dak@gnu.org> writes:
> programmable completion is extensively context-sensitive (which is
> pretty much its whole point: it does not just complete file names, but
> also CVS revisions, options and other stuff).
The gdb completions are context sentive as well. The implementation
uses the complete command that gets the current command line as argument
and lists all completions thereof. That does not handle all cases
though, there is no trailing context.
> And sending such a command would clobber the command history, too.
In gdb this is solved by defining a special prefix that suppresses
putting the command in the history. Of course, this is much easier
implemented in gdb since there is a fixed set of commands.
Andreas.
--
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
PGP key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: Proposal for shell completion in M-x shell RET
2007-09-10 14:52 ` David Kastrup
2007-09-10 15:51 ` Andreas Schwab
@ 2007-09-10 23:55 ` Richard Stallman
1 sibling, 0 replies; 11+ messages in thread
From: Richard Stallman @ 2007-09-10 23:55 UTC (permalink / raw)
To: David Kastrup; +Cc: monnier, emacs-devel
Maybe this can help on some platforms?
process-running-child-p is a built-in function in `C source code'.
(process-running-child-p &optional PROCESS)
I think it is not reliable to use this, because input is ansynchronous.
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2007-09-10 23:55 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-09-10 12:44 Proposal for shell completion in M-x shell RET David Kastrup
2007-09-10 13:21 ` Andreas Schwab
2007-09-10 13:56 ` David Kastrup
2007-09-10 14:03 ` Andreas Schwab
2007-09-10 14:10 ` David Kastrup
2007-09-10 14:19 ` Stefan Monnier
2007-09-10 14:29 ` Stefan Monnier
2007-09-10 14:52 ` David Kastrup
2007-09-10 15:51 ` Andreas Schwab
2007-09-10 23:55 ` Richard Stallman
2007-09-10 14:30 ` David Kastrup
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.