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

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

Re: "more", "ls -l", and column 80 in shell


From: Tim X
Subject: Re: "more", "ls -l", and column 80 in shell
Date: Sun, 25 Jun 2006 12:39:53 +1000
User-agent: Gnus/5.110006 (No Gnus v0.6) Emacs/22.0.50 (gnu/linux)

dkcombs@panix.com (David Combs) writes:

> In article <87slm4p8sx.fsf@tiger.rapttech.com.au>,
> Tim X  <timx@nospam.dev.null> wrote:
>>...
>
>>Some basic rules of thumb and advice which I hope will help
>>
>>1. Don't try to use emacs as if it was equivalent to one of the
>>   standard shells like bash, tcsh or (gasp) csh. While emacs provides
>
> M-x shell
>    (then, in *shell*):
> tcsh
>
> Works *absolutely* fine -- ie the same as in a dtterm (no emacs).
>
No, its not the same as in a term because it is initialised as a dumb
terminal - i.e. it does not have any concept of a "screen" (rows,
columns). This was the OPs initial problem and why programs like less
don't operate correctly. Also, on most Linux systems, the shell used
will be bash, which has most of the features of tcsh these days, so
little will be gained IMO by running a second shell inside the
original one.



> (of course, no "more", etc, but grep, find, etc all work
>       exactly as expected.  Likewise pushd, popd, dirs, etc.
>     (Although from time to time it gets confused, at which
>       point you simply do  M-x dirs )

This is no different to just M-x shell unless your default shell is a
very old or basic sh or similar. Even then, these commands should
still work fine.

If the shell constantly loses track of directory locations etc, it
might be worth looking at the various variables which are used to
match the commands and which the inferior shell process uses to keep
track of the directory. i.e.

Variables `shell-cd-regexp', `shell-chdrive-regexp', `shell-pushd-regexp'
and `shell-popd-regexp' are used to match their respective commands,
while `shell-pushd-tohome', `shell-pushd-dextract' and `shell-pushd-dunique'
control the behavior of the relevant command.


>>   various ways of doing interaction at this level, you are much
>>   better off using equivalent emacs features when possible i.e.
>>   dired, 
>       of course (plus with dired-x, too).
>
> M-x locate, M-x grep, M-x cd etc. 
> Huh?
>
Not sure what the Huh? refers to. 

> About M-x grep, I find it very useful to use normal
>    grep/egrep/etc, *with -n*, and on *at least 2 files*
>     (eg if just one to be grepped, then append /dev/null to
>       get to the 2-or-more-files -- so as to get file-names
>       at the left of the grep-output)
>    and then, if desired, hack that file to remove lines,
>      add marks to certain lines, etc,
>    and THEN do M-x grep, and change the offered args to
>     "`cat mygrep.out`"

I find using direds facilities makes this very easy.

>
>>
>>2. When using one of emacs' shell interfaces, keep in mind that it is
>>   often necessary to have some escape key sequence to either access
>>   shell commands that conflict with normal emacs interpreted commands
>
> I don't understand, so: Please expain, ie show examples where necessary.
>
>
>>   or you need to use an escape sequence within the shell buffer to
>                            HUH?  Explain?
>

Think about it for a second. Your in M-x shell and you want to
interrupt a process you have started in that shell. Normally, when in
a terminal, you could send a C-c, but within emacs M-x shell, emacs
will grab the first C-c, so you need to send it again. However, in M-x
term, the situation is reversed. You need to send a different prefix
(escape) to access emacs commands that are not part of term mode. 

>>   access emacs commands. Also, note that some shell interfaces, like
>>   M-x term have different operating modes - a line mode and a
>>   terminal mode.
>>
Actually, I should have said a line mode and a character mode.


What I was trying to point out tot he OP is that emacs has at least
three different shell interfaces and they all have their strengths and
weaknesses. Therefore, it is important to know what does what in order
to select the best shell for the job you want to do. For example, the
problem the OP was having with a screen oriented program indicated M-x
term would probably be a better choice than M-x shell, which is good
for simple line oriented programs than don't need the concept of a
screen. Likewise, M-x eshell offers other strengths, such as being
able to execute elisp from the command line and call emacs functions
to operate on the place/directory where you are etc.

Tim
-- 
tcross (at) rapttech dot com dot au


reply via email to

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