[Top][All Lists]

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

Re: Optimal emacs shell for coding

From: Tim X
Subject: Re: Optimal emacs shell for coding
Date: Tue, 12 Aug 2008 18:02:48 +1000
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux)

Xah <address@hidden> writes:

> On Aug 11, 4:38 am, Jonathan Groll <address@hidden> wrote:
>> I know of only three ways to get an emacs shell:
>> M-x terminal-emulator
>> M-x shell
>> M-x eshell
>> (There is also M-x shell-command RET)
>> Question is, which one is best for coding? Lately I've found myself
>> opening up an xterm session to do miscellaneous coding support tasks -
>> and am mostly struggling with different readline history keybindings
>> (eg. I'm used to entering C-r at a shell to get (reverse-i-search) -
>> obviously in an emacs shell this will have a dfferent outcome to what
>> I desire!

It depends on what you want to do. If I'm writing shell scripts, I will
open an emacs buffer to put the script in and then run the script in
whichever other shell is most appropriate (depending on things such as
whether I plan to use redirection (don't use eshell), run with little
interaction (probably just use run-shell) or if I require ansi, ncurses or
other screen/terminal support, M-x term. 

>> Any recommendations?
> They really all have different purposs.
> • M-x shell-command
> lets you run a single shell cammand.
> • M-x shell
> command line interface to OS.
> • M-x terminal-emulator
> This is actually a terminal emulator.
> For example, you can start a telnet or ssh or top in it.
> You can also start a vi, or even emacs itself within.
> You cannot run these problems with M-x shell, for example.
> • M-x eshell
> This is just like shell, except it's written in elisp.
> The purpose is so that you can have access to the familiar unix shell
> in different OSes such as MS Windows.
> In general, the shell-command and shell is most useful. Run eshell if
> you are in Windows and don't have cygwin installed and want to run
> unix commands such as ls, cd, mkdir, etc. If you need to run telnet,
> ssh, top, or any program that fills a screen, you'll need to run term.
> I don't particular recommend it because once in term, many default
> keybindings of emacs won't work because it pretends to be a term emu.
> If you want to run ssh etc, best to start in a real term emulator.

M-x term does re-define some key sequences so that they don't conflict
with, in particular, shell control sequences such as Ctrl C. However, yu
also have line mode and character mode, which enables you to switch from
keyboard input being sent as characters to the command line to being
able to move around in the buffer and do things like cut and paste etc,
which you can then use in another buffer. 

Eshell can cause confusion because it cannot handle redirection
correctly. This can give some unexpected results and you don't
necessarily get any eror message warning you. I once ran a simple shell
script that grabbed some xml using wget and then displayed it on the
screen. When I ran it under eshell, I thought the service I was trying
to access was not working because nothing was being displayed to the
screen. I then realised that the data was being returned, but eshell
wasn't handling the redirection to stdout correctly. However, if you
keep this in mind, eshell is very useful and you can execute emacs lisp
directly from the command line, plus all the key-bindings are as you
wold expect them to be. 

Note also that with reference to running programs like telnet, rlogin
ssh and top, there are facilities available to do this from within
emacs. Emacs has M-x telnet, M-x rlogin and there are at least two
ssh.el packages out there. You can also set the rlogin-program variable
to use ssh rather than rlogini. For top, their is view-process.el (quite
old) and in the CVS version of emacs proced, which is like a top for

and of course, there is tramp, which can allow you to edit files and run
remote processes from inside emacs. 

to provide more specific help on what would be most useful, we would
need more details regarding what it is you want to do and what platform
your running on.



tcross (at) rapttech dot com dot au

reply via email to

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