From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: pjb@informatimago.com (Pascal J. Bourguignon) Newsgroups: gmane.emacs.help Subject: Re: Why can't I use xargs emacs? Date: Tue, 02 Feb 2010 23:56:51 +0100 Organization: Informatimago Message-ID: <87sk9jw8jw.fsf@informatimago.com> References: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1265154109 7767 80.91.229.12 (2 Feb 2010 23:41:49 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 2 Feb 2010 23:41:49 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Feb 03 00:41:45 2010 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1NcSNK-00026b-KY for geh-help-gnu-emacs@m.gmane.org; Wed, 03 Feb 2010 00:41:43 +0100 Original-Received: from localhost ([127.0.0.1]:50334 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NcSNJ-0003ZU-V7 for geh-help-gnu-emacs@m.gmane.org; Tue, 02 Feb 2010 18:41:42 -0500 Original-Path: news.stanford.edu!usenet.stanford.edu!news.glorb.com!news2.glorb.com!news.glorb.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail Original-Newsgroups: comp.unix.shell,gnu.emacs.help Original-Lines: 45 Original-X-Trace: individual.net 59jfVzfjP1/Lhg20ywZaegLpQwL0OB3cJOL+F54/9DrnRLFGQw Cancel-Lock: sha1:NTZjMWNhNTcxZjg0YWU0Y2Y2N2M2ZDViMzFlYzllOGFlZjZmMGQ2MA== sha1:kmZ1Hl/GZ446VYRX2Ptd3hSwtDg= Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwAQMAAABtzGvEAAAABlBMVEUAAAD///+l2Z/dAAAA oElEQVR4nK3OsRHCMAwF0O8YQufUNIQRGIAja9CxSA55AxZgFO4coMgYrEDDQZWPIlNAjwq9 033pbOBPtbXuB6PKNBn5gZkhGa86Z4x2wE67O+06WxGD/HCOGR0deY3f9Ijwwt7rNGNf6Oac l/GuZTF1wFGKiYYHKSFAkjIo1b6sCYS1sVmFhhhahKQssRjRT90ITWUk6vvK3RsPGs+M1RuR mV+hO/VvFAAAAABJRU5ErkJggg== X-Accept-Language: fr, es, en X-Disabled: X-No-Archive: no User-Agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/22.3 (darwin) Original-Xref: news.stanford.edu comp.unix.shell:233695 gnu.emacs.help:176564 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:71630 Archived-At: Adam Funk 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__