[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Why can't I use xargs emacs?
From: |
Pascal J. Bourguignon |
Subject: |
Re: Why can't I use xargs emacs? |
Date: |
Tue, 02 Feb 2010 23:56:51 +0100 |
User-agent: |
Gnus/5.1008 (Gnus v5.10.8) Emacs/22.3 (darwin) |
Adam Funk <a24061@ducksburg.com> writes:
> The emacs command can take a list of filename arguments, so why can't
> I get xargs to work with it?
>
> $ find -name '*.txt' |xargs emacs -nw
> emacs: standard input is not a tty
>
> $ grep -rl 'foo' some/path |xargs emacs -nw
> emacs: standard input is not a tty
emacs is an interactive program. It expects its stdin and stdout to
be hooked to the terminal, where it can display a character matrix,
and from which it can read user input.
When you use a pipe to send paths to xargs, you disconnect the
terminal from the stdin, and replace it with a pipe. When xargs forks
and exec emacs, emacs inherit this pipe as stdin, and cannot get user
input, but will get instead further path from grep.
% echo hello > file ; ( echo -b ; echo file ) | xargs -L 1 cat
hello
To open several files in emacs, you could either use emacsclient, or
an emacs lisp script.
Launch emacs in a separate terminal: xterm -e emacs -nw &
In emacs, start the server: M-x server-start RET
In a shell, you can then type: find -name '*.txt' | xargs emacsclient -n
Simplier would be to just open the file in emacs:
Launch emacs: emacs -nw
Then type: C-x C-f *.txt RET
For the second case, you could type:
M-: (map nil 'find-file (split-string (shell-command-to-string "grep -rl 'foo'
some/path") "\n")) RET
--
__Pascal Bourguignon__
Re: Why can't I use xargs emacs?, Bit Twister, 2010/02/03
Re: Why can't I use xargs emacs?, hymie!, 2010/02/04