[Top][All Lists]

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

Re: Question: Is there any way to use the bash completion feature from E

From: Bob Proulx
Subject: Re: Question: Is there any way to use the bash completion feature from Emacs shell mode.
Date: Mon, 10 Oct 2016 18:59:05 -0600
User-agent: NeoMutt/20160916 (1.7.0)

Dan Hitt wrote:
> Tab completion certainly works, but it's the emacs completion, not the
> bash completion.

Right.  There are really (at least) three types of completion.

1) bash completion using bash only
2) bash-completion using the bash-completion 3rd party addon to bash
3) emacs shell-mode completion

All three of those do completion.  The second extends onto the first.
They all have slightly different behavior with pluses and minues to
each of them.  Personally I only use 1 and 3 and don't miss not having
2 but I can understand people wanting it inside emacs.

> Unfortunately, i don't have a good example of the difference right
> now, but i'll bet Chiaki does.

  bash (1) does this:

     complete (TAB)
            Attempt to perform completion on the text before point.  Bash
            attempts completion treating the text as a variable (if the text
            begins with $), username (if the text begins with ~), hostname
            (if the text begins with @), or command (including aliases and
            functions) in turn.  If none of these produces a match, filename
            completion is attempted.

    touch foo bar
    ls f<TAB> will complete foo

  bash-completion (2) has many additional completions including
  completing options for commands that support --help.

    ls --so<TAB> will complete to --sort

> I never used term mode since trying it out a few decades ago, because
> i would get stuck in a buffer and not be able to get out --- unless it
> was a graphical emacs and i could use the mouse to choose another
> buffer --- but that would defeat the whole power of parking the mouse
> and controlling everything by the keyboard.

That was specifically why I mentioned that C-x is mapped to C-c! :-)
Because if that isn't known then you are trapped.  But knowing that
allows you to switch buffers away or other commands.

> However, Bob said that you substitute Control X with Control C, and
> man that works.
> So you can switch buffers using, e.g., Control-C o.

Or kill the buffer with C-c k RET which I usually do when done in
order to clean up and free up memory.

Also as Oleksandr Gavenko wrote the following keys are very useful:

 C-c C-j  switch to term-line-mode (effectively similar to shell mode)
 C-c C-k  switch to term-char-mode

When in term mode I switch back and forth between those modes *a lot*
as needed to deal with the immediate task.  Some things are easier one
way.  Some the other way.  Relevant to this discussion with C-c C-k
you get bash completion.  With C-c C-j you get emacs completion.


reply via email to

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