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

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

Re: editing output in shell mode


From: David Kastrup
Subject: Re: editing output in shell mode
Date: Fri, 09 Jan 2009 22:39:25 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux)

"Samuel Wales" <samologist@gmail.com> writes:

> Let's say you do something in shell mode that produces a lot of
> output.  Normally, you'd use less(1), but that is not possible in
> shell mode.
>
> Ideally, you'd view the output in an emacs buffer, perhaps in text
> mode, so that you can edit it and navigate it.
>
> Is there a way to pipe this output to, say, emacsclient?
>
> Or -- more sophisticatedly -- is there another solution that uses
> shell mode, e.g. to grab the output once it detects that it is a lot
> of output, and redirect it into a text mode buffer?
>
> Obviously if it's an infinite amount of output, it should do what less
> does and not use up all memory.
>
> Google was not my friend.  :)
>
> Thanks.

I have something I call emacs-pager, but it will probably not work with
infinite output satisfactorily.

#!/bin/sh
TMP=`mktemp -t emacs-pager.XXXXXX`
trap "rm $TMP* 2>/dev/null" 0
echo '-*- mode: view; auto-revert-interval: 1; mode: auto-revert-tail; 
view-exit-action: kill-buffer -*-' >"$TMP"
exec 5<&0 <&-
cat "$@" <&5 >>"$TMP" &
eval "${VISUAL:-${EDITOR}}" '"$TMP"'

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum

reply via email to

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