emacs_batch_mode_ques

This is part of The Pile, a partial archive of some open source mailing lists and newsgroups.



From: doom@kzsu.stanford.edu (Joe Brenner)
Subject: using emacs non-interactively
Date: 17 Dec 2000 14:03:11 GMT

Can someone point me at some information on how to use 
the emacs '-batch' feature? 

There are examples in the texinfo docs on how to use it to
edit files, but I'd also like to get it to read stdin and
output to stdout.

And for that matter, even my attempts at using it to modify 
files is running into trouble, e.g. this:

  emacs some.txt -batch -f mark-whole-buffer -f fill-region -f save-buffer 

Produces some strange error messages: 

   Mark set
   Mark set
   Wrong number of arguments: #[(from to &optional justify nosqueeze to-eop) >

[followed by a lot of high-byte junk].


Path: nntp.stanford.edu!newsfeed.stanford.edu!xfer10.netnews.com!netnews.com!newspeer.monmouth.com!newsgate.duke.edu!usenet
From: Dan Mills <dm@cs.duke.edu>
Newsgroups: comp.emacs
Subject: Re: using emacs non-interactively
Date: 17 Dec 2000 13:46:09 -0500
Organization: Duke University
Lines: 21
Message-ID: <8666kiubri.fsf@wojo.dulug.duke.edu>
References: <91ih2v$a5$1@nntp.Stanford.EDU>
NNTP-Posting-Host: wojo.dulug.duke.edu
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
X-Face: *A{%->08frcej]'gm;C(iI>,gA^(wV.7lN.*QR(?p)z[Ea]ay5$%7}^<oy(T\
	PsC$9Oq5GO_Bcl'pq%J:)5:^FR"*0!{+J5@=tY(V?\C|"F
X-Home-Page: http://www.dulug.duke.edu/~thunder/
User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.0.93
Xref: nntp.stanford.edu comp.emacs:53501

* "Joe" == Joe Brenner <doom@kzsu.stanford.edu> writes:

  Joe>  emacs some.txt -batch -f mark-whole-buffer -f fill-region -f
  Joe>  save-buffer

Shouldn't that be:

emacs -batch -f [...] file.txt

?

Also, is it possible to give several '-f' arguments?  You may have to
define a function and call that instead.

-Dan

-- 
Dan Mills, Duke Class of 2000         -o)
email: danmills(at)sandmill(dot)org   /\\
-----------------------------------\ _\_v
Damn Sill.. Sand Mill?  All Minds! |_____

Path: nntp.stanford.edu!newsfeed.stanford.edu!uchinews!logbridge.uoregon.edu!xmission!nnrp.xmission!not-for-mail
From: Benjamin Rutt <brutt@bloomington.in.us>
Newsgroups: comp.emacs
Subject: Re: using emacs non-interactively
Date: 18 Dec 2000 09:20:43 -0700
Organization: XMission http://www.xmission.com/
Lines: 11
Message-ID: <m3n1dtem5g.fsf@brutt.dsl.xmission.com>
References: <91ih2v$a5$1@nntp.Stanford.EDU> <8666kiubri.fsf@wojo.dulug.duke.edu>
NNTP-Posting-Host: brutt.dsl.xmission.com
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
X-Trace: news.xmission.com 977156444 17977 166.70.87.126 (18 Dec 2000 16:20:44 GMT)
X-Complaints-To: abuse@xmission.com
NNTP-Posting-Date: 18 Dec 2000 16:20:44 GMT
User-Agent: Gnus/5.0807 (Gnus v5.8.7) Emacs/20.7
Xref: nntp.stanford.edu comp.emacs:53565

Dan Mills <dm@cs.duke.edu> writes:

> Also, is it possible to give several '-f' arguments? 

yes this is possible.

what i haven't figured out is how to give the command itself
arguments.  I always get defeated by shell+elisp quoting if I try the
form --eval "(func arg1 arg2)".

Benjamin

Path: nntp.stanford.edu!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newspeer.monmouth.com!newsgate.duke.edu!usenet
From: Dan Mills <dm@cs.duke.edu>
Newsgroups: comp.emacs
Subject: Re: using emacs non-interactively
Date: 18 Dec 2000 11:36:51 -0500
Organization: Duke University
Lines: 25
Message-ID: <86u281r8ik.fsf@wojo.dulug.duke.edu>
References: <91ih2v$a5$1@nntp.Stanford.EDU> <8666kiubri.fsf@wojo.dulug.duke.edu> <m3n1dtem5g.fsf@brutt.dsl.xmission.com>
NNTP-Posting-Host: wojo.dulug.duke.edu
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
X-Face: *A{%->08frcej]'gm;C(iI>,gA^(wV.7lN.*QR(?p)z[Ea]ay5$%7}^<oy(T\
	PsC$9Oq5GO_Bcl'pq%J:)5:^FR"*0!{+J5@=tY(V?\C|"F
X-Home-Page: http://www.dulug.duke.edu/~thunder/
User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.0.93
Xref: nntp.stanford.edu comp.emacs:53569

* "Benjamin" == Benjamin Rutt <brutt@bloomington.in.us> writes:

  Benjamin>  form --eval "(func arg1 arg2)".

I do something like this for popping up new windows with gnuserv.
Like:

gnudoit "(make-frame-on-display \"$DISPLAY\")"

(got that line from someone in here).

If you don't care about variable substitution, you can do:

gnudoit '(make-frame-on-display "localhost:0")'

Which is a little nicer.  One of those two examples should work for
you..

-Dan

-- 
Dan Mills, Duke Class of 2000         -o)
email: danmills(at)sandmill(dot)org   /\\
-----------------------------------\ _\_v
Damn Sill.. Sand Mill?  All Minds! |_____

Path: nntp.stanford.edu!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!sunqbc.risq.qc.ca!xmission!nnrp.xmission!not-for-mail
From: Benjamin Rutt <brutt@bloomington.in.us>
Newsgroups: comp.emacs
Subject: Re: using emacs non-interactively
Date: 18 Dec 2000 09:59:55 -0700
Organization: XMission http://www.xmission.com/
Lines: 12
Message-ID: <m3elz5ekc4.fsf@brutt.dsl.xmission.com>
References: <91ih2v$a5$1@nntp.Stanford.EDU> <8666kiubri.fsf@wojo.dulug.duke.edu> <m3n1dtem5g.fsf@brutt.dsl.xmission.com> <86u281r8ik.fsf@wojo.dulug.duke.edu>
NNTP-Posting-Host: brutt.dsl.xmission.com
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
X-Trace: news.xmission.com 977158795 18636 166.70.87.126 (18 Dec 2000 16:59:55 GMT)
X-Complaints-To: abuse@xmission.com
NNTP-Posting-Date: 18 Dec 2000 16:59:55 GMT
User-Agent: Gnus/5.0807 (Gnus v5.8.7) Emacs/20.7
Xref: nntp.stanford.edu comp.emacs:53572

Dan Mills <dm@cs.duke.edu> writes:

> gnudoit "(make-frame-on-display \"$DISPLAY\")"

Hmm...I don't have the gnuserv package.  Anyone get the --eval quoting
to work with something like

emacs --eval '(message "did the command line eval thing")'

I always get "End of file during parsing"

Benjamin

Path: nntp.stanford.edu!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!cpk-news-hub1.bbnplanet.com!news.gtei.net!newsfeed.cs.utexas.edu!news.cs.utexas.edu!not-for-mail
From: Suvrit Sra <suvrit@cs.utexas.edu>
Newsgroups: comp.emacs
Subject: Re: using emacs non-interactively
Date: Mon, 18 Dec 2000 17:28:57 +0000 (UTC)
Organization: Computer Sciences, University of Texas
Lines: 10

===






From: Benjamin Rutt <brutt@bloomington.in.us>
Subject: Re: using emacs non-interactively
Date: 18 Dec 2000 11:29:59 -0700

Suvrit Sra <suvrit@cs.utexas.edu> writes:

> >>>>> "Benjamin" == Benjamin Rutt <brutt@bloomington.in.us> writes:
> 
>     Benjamin> emacs --eval '(message "did the command line eval thing")'
> 
>     Benjamin> I always get "End of file during parsing"
> 
> I guess your .emacs might be missing some quote mark or some
> parenthesis...because this works for me.

Interesting.  Running it with

emacs -q --no-site-file --eval '(message "blah blah")

works on Gnu Emacs for AIX, Linux, solaris, etc. but chokes on
NTEmacs.  So it must be an NTEmacs port thing.  Thanks for helping me
narrow it down.  Off to NTEmacs mailing list archives, and possibly
NTEmacs bug reports....

Benjamin

Path: nntp.stanford.edu!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!news1.best.com!nntp1.ba.best.com!not-for-mail
From: thi <ttn@glug.org>
Newsgroups: comp.emacs
Subject: Re: using emacs non-interactively
Date: 18 Dec 2000 10:51:32 -0800
Organization: sometimes
Lines: 12
Message-ID: <y16bsu9o957.fsf@glug.org>
References: <91ih2v$a5$1@nntp.Stanford.EDU>
	<8666kiubri.fsf@wojo.dulug.duke.edu>
	<m3n1dtem5g.fsf@brutt.dsl.xmission.com>
	<86u281r8ik.fsf@wojo.dulug.duke.edu>
	<m3elz5ekc4.fsf@brutt.dsl.xmission.com>
NNTP-Posting-Host: shell4.ba.best.com
X-Trace: nntp1.ba.best.com 977165493 69136 206.184.139.135 (18 Dec 2000 18:51:33 GMT)
X-Complaints-To: abuse@best.com
NNTP-Posting-Date: 18 Dec 2000 18:51:33 GMT
X-Newsreader: Gnus v5.3/Emacs 19.34
Xref: nntp.stanford.edu comp.emacs:53583

Benjamin Rutt <brutt@bloomington.in.us> writes:

> emacs --eval '(message "did the command line eval thing")'
> 
> I always get "End of file during parsing"

if that is the complete command line, most likely your site init file is
fubar.  try w/

  emacs --batch --no-site-file --eval

thi

Path: nntp.stanford.edu!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.cwix.com!news.ycc.yale.edu!tequila.cs.yale.edu!rum.cs.yale.edu
From: "Stefan Monnier <foo@acm.com>" <monnier+comp.emacs/news/@flint.cs.yale.edu>
Newsgroups: comp.emacs
Subject: Re: using emacs non-interactively
Date: 18 Dec 2000 14:32:19 -0500
Organization: Yale University
Lines: 18

===








From: Edric M Ellis <eellis@mathworks.co.uk>
Subject: Re: using emacs non-interactively
Date: 19 Dec 2000 08:15:13 +0000

Benjamin Rutt <brutt@bloomington.in.us> writes:

> Suvrit Sra <suvrit@cs.utexas.edu> writes:
> 
> emacs -q --no-site-file --eval '(message "blah blah")
> 
> works on Gnu Emacs for AIX, Linux, solaris, etc. but chokes on
> NTEmacs.  So it must be an NTEmacs port thing.

Actually, I think it's a NT shell quoting rules thing. The following
line works fine from a cygwin shell:
$ gnudoit '(message "Hello from Cygwin")'
But, this fails from a standard NT command window. To get it to work
there, you need this:
C:\>gnudoit "(message \"Hello from NT\")"

Edric.

-- 
Edric M Ellis
The MathWorks, Ltd.
Tel: +44 (0) 1223 423 200    Ext: 218
Fax: +44 (0) 1223 423 289

Path: nntp.stanford.edu!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!xmission!nnrp.xmission!not-for-mail
From: Benjamin Rutt <brutt@bloomington.in.us>
Newsgroups: comp.emacs
Subject: Re: using emacs non-interactively
Date: 19 Dec 2000 09:00:41 -0700
Organization: XMission http://www.xmission.com/
Lines: 7
Message-ID: <m3ofy8v1sm.fsf@brutt.dsl.xmission.com>
References: <91ih2v$a5$1@nntp.Stanford.EDU> <8666kiubri.fsf@wojo.dulug.duke.edu> <m3n1dtem5g.fsf@brutt.dsl.xmission.com> <86u281r8ik.fsf@wojo.dulug.duke.edu> <m3elz5ekc4.fsf@brutt.dsl.xmission.com> <91lhgp$qrd$1@news.cs.utexas.edu> <m37l4xy448.fsf@brutt.dsl.xmission.com> <5lbsu9r0e4.fsf@rum.cs.yale.edu>
NNTP-Posting-Host: brutt.dsl.xmission.com
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
X-Trace: news.xmission.com 977241641 15004 166.70.87.126 (19 Dec 2000 16:00:41 GMT)
X-Complaints-To: abuse@xmission.com
NNTP-Posting-Date: 19 Dec 2000 16:00:41 GMT
User-Agent: Gnus/5.0807 (Gnus v5.8.7) Emacs/20.7
Xref: nntp.stanford.edu comp.emacs:53649

"Stefan Monnier <foo@acm.com>" <monnier+comp.emacs/news/@flint.cs.yale.edu> writes:

> and of course, the '(message is just nonsensical.

can you elaborate?  I don't understand what you mean by this.  

Benjamin

Path: nntp.stanford.edu!newsfeed.stanford.edu!news.tele.dk!193.174.75.178!news-fra1.dfn.de!news-koe1.dfn.de!news.uni-dortmund.de!Informatik.Uni-Dortmund.DE!news
From: Kai.Grossjohann@CS.Uni-Dortmund.DE (Kai =?iso-8859-1?q?Gro=DFjohann?=)
Newsgroups: comp.emacs
Subject: Re: using emacs non-interactively
Date: 19 Dec 2000 21:21:09 +0100
Organization: University of Dortmund, Germany
Lines: 37

===












From: Benjamin Rutt <brutt@bloomington.in.us>
Subject: Re: using emacs non-interactively
Date: 19 Dec 2000 14:10:44 -0700

Kai.Grossjohann@CS.Uni-Dortmund.DE (Kai Gro

the rest of The Pile (a partial mailing list archive)

doom@kzsu.stanford.edu