🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.unix.shell
10 messages
10 total messages Started by Adam Funk Tue, 02 Feb 2010 20:22
Why can't I use xargs emacs?
#4091
Author: Adam Funk
Date: Tue, 02 Feb 2010 20:22
14 lines
1330 bytes
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


-- 
Steve: Now, okay.  I did say that monkeys could program Visual Basic.
Leo:   But not that all Visual Basic programmers are monkeys.
Steve: Exactly.                                    [Security Now 194]
Re: Why can't I use xargs emacs?
#4092
Author: Bit Twister
Date: Tue, 02 Feb 2010 21:14
13 lines
1521 bytes
On Tue, 02 Feb 2010 20:22:17 +0000, Adam Funk wrote:
> 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


Maybe it's the -nw switch. Try
      find -name '*.txt' |xargs emacs
Re: Why can't I use xargs emacs?
#4093
Author: Bill Marcum
Date: Tue, 02 Feb 2010 21:35
14 lines
1393 bytes
["Followup-To:" header set to comp.unix.shell.]
On 2010-02-02, Adam Funk <a24061@ducksburg.com> wrote:
> 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
>
It says: standard input is not a tty. I don't normally use emacs, so there
may be a better way to do this, but you could write a function:
my_emacs () { emacs "$@" </dev/tty >&0 2>&0 ; }
Re: Why can't I use xargs emacs?
#4094
Author: Pascal J. Bourguignon
Date: Tue, 02 Feb 2010 22:40
45 lines
2756 bytes
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?
#4095
Author: Pascal J. Bourguignon
Date: Tue, 02 Feb 2010 22:56
45 lines
2756 bytes
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?
#4096
Author: Harald Hanche-Olsen
Date: Tue, 02 Feb 2010 23:51
17 lines
1500 bytes
+ Adam Funk <a24061@ducksburg.com>:

> 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

$ find -name '*.txt' |xargs sh -c 'emacs -nw "$@" </dev/tty' -

(untested)

-- 
* Harald Hanche-Olsen     <URL:http://www.math.ntnu.no/~hanche/>
- It is undesirable to believe a proposition
  when there is no ground whatsoever for supposing it is true.
  -- Bertrand Russell
Re: Why can't I use xargs emacs?
#4097
Author: Ivan Shmakov
Date: Wed, 03 Feb 2010 03:40
61 lines
2777 bytes
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

>>>>> "PJB" == Pascal J Bourguignon <pjb@informatimago.com> writes:
>>>>> "AF" == Adam Funk <a24061@ducksburg.com> writes:

 AF> The emacs command can take a list of filename arguments, so why
 AF> can't I get xargs to work with it?

 > $ find -name '*.txt' |xargs emacs -nw
 > emacs: standard input is not a tty

[...]

 PJB> emacs is an interactive program.  It expects its stdin and stdout
 PJB> to be hooked to the terminal, where it can display a character
 PJB> matrix, and from which it can read user input.

[...]

 PJB> To open several files in emacs, you could either use emacsclient,
 PJB> or an emacs lisp script.

 PJB> Launch emacs in a separate terminal: xterm -e emacs -nw &

 PJB> In emacs, start the server: M-x server-start RET

 PJB> In a shell, you can then type: find -name '*.txt' | xargs
 PJB> emacsclient -n

	Note that a separate terminal is not necessary, as one can call
	Shell commands from Emacs, like:

$ emacs -nw 
...
M-x server-start RET
...
M-! find -name '*.txt' | xargs emacsclient -n & RET

	But one has to use an “asynchronous” (i. e., “background”)
	command, as indicated by an ampersand after the command line.

 PJB> Simplier would be to just open the file in emacs:

 PJB> Launch emacs: emacs -nw Then type: C-x C-f *.txt RET

	Though that will not recurse into the directories, as the plain
	find will.

[...]

- -- 
FSF associate member #7257
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)

iEYEARECAAYFAkto8B8ACgkQMBO2oCMOM0oHhACgrkJftA4oYTWHscebcCtUvVj2
YroAn2Yg0f8GXeGQoeYzKQcm90waYytw
=hJo3
-----END PGP SIGNATURE-----
Re: Why can't I use xargs emacs?
#4098
Author: hymie!
Date: Wed, 03 Feb 2010 14:12
18 lines
1445 bytes
In our last episode, the evil Dr. Lacto had captured our hero,
  Adam Funk <a24061@ducksburg.com>, who said:
>
>
>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

Are you missing the . in your find command on purpose?

What's wrong with
emacs -nw `find  . -name '*.txt'`
?

--hymie!    http://lactose.homelinux.net/~hymie    hymie@lactose.homelinux.net
-------------------------------------------------------------------------------
Re: Why can't I use xargs emacs?
#4099
Author: Adam Funk
Date: Wed, 03 Feb 2010 14:18
32 lines
1904 bytes
On 2010-02-02, Bit Twister wrote:

> On Tue, 02 Feb 2010 20:22:17 +0000, Adam Funk wrote:
>> 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
>
>
> Maybe it's the -nw switch. Try
>       find -name '*.txt' |xargs emacs

Yes, it works without -nw, but I'm often logged into an ssh server so
it's faster to open emacs in the xterm.

Anyway, the solution (posted by Thierry in gnu.emacs.help) turns out
to be this:

emacs -nw $(find . -name '*.txt')

Thanks.


-- 
...the reason why so many professional artists drink a lot is not
necessarily very much to do with the artistic temperament, etc.  It is
simply that they can afford to, because they can normally take a large
part of a day off to deal with the ravages.          [Amis _On Drink_]
Re: Why can't I use xargs emacs?
#4100
Author: Adam Funk
Date: Wed, 03 Feb 2010 14:20
25 lines
1513 bytes
On 2010-02-03, hymie! wrote:

> In our last episode, the evil Dr. Lacto had captured our hero,
>   Adam Funk <a24061@ducksburg.com>, who said:

>>$ find -name '*.txt' |xargs emacs -nw
>>emacs: standard input is not a tty
>
> Are you missing the . in your find command on purpose?

It's optional in GNU find.


> What's wrong with
> emacs -nw `find  . -name '*.txt'`
> ?

Nothing, thanks!  What's the difference between these two?

emacs -nw `find  . -name '*.txt'`
emacs -nw $(find  . -name '*.txt')


-- 
Usenet is a cesspool, a dung heap.  [Patrick A. Townson]
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads