From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Xah Lee Newsgroups: gmane.emacs.help Subject: Re: how to use ejacs to eval a file as with command line driven interpreters Date: Sun, 11 Jan 2009 08:20:12 -0800 (PST) Organization: http://groups.google.com Message-ID: <84adaeb7-51b2-4f74-9fa4-f44c181a7ff5@r15g2000prh.googlegroups.com> References: <28fc357b-e4b0-410d-8cc8-3b65cbaf9fc3@z27g2000prd.googlegroups.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1231700038 18769 80.91.229.12 (11 Jan 2009 18:53:58 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 11 Jan 2009 18:53:58 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Sun Jan 11 19:55:09 2009 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.50) id 1LM5Si-0002wr-Tg for geh-help-gnu-emacs@m.gmane.org; Sun, 11 Jan 2009 19:55:05 +0100 Original-Received: from localhost ([127.0.0.1]:54292 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LM5FL-0000nP-0n for geh-help-gnu-emacs@m.gmane.org; Sun, 11 Jan 2009 13:41:15 -0500 Original-Path: news.stanford.edu!newsfeed.stanford.edu!postnews.google.com!r15g2000prh.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help,comp.emacs Original-Lines: 53 Original-NNTP-Posting-Host: 24.6.175.142 Original-X-Trace: posting.google.com 1231690812 11313 127.0.0.1 (11 Jan 2009 16:20:12 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Sun, 11 Jan 2009 16:20:12 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: r15g2000prh.googlegroups.com; posting-host=24.6.175.142; posting-account=bRPKjQoAAACxZsR8_VPXCX27T2YcsyMA User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X 10_4_11; en) AppleWebKit/525.27.1 (KHTML, like Gecko) Version/3.2.1 Safari/525.27.1, gzip(gfe), gzip(gfe) Original-Xref: news.stanford.edu gnu.emacs.help:165919 comp.emacs:97632 X-Mailman-Approved-At: Sun, 11 Jan 2009 13:40:36 -0500 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:61253 Archived-At: On Jan 9, 7:09 pm, Kevin Rodgers wrote: > XahLeewrote: > > there's Stevey Yegge's javascript interpreter written in elisp. > >http://code.google.com/p/ejacs/ > > > by default it runs in emacs as a command line console. > > > my question is, is it possible to run ejacs with a file? > > > e.g. i have a file x.js, which i can run in shell with spidermonkey > > like this: > > js x.js > > > i wish to be able to use ejacs to eval a file. Otherwise it wouldn't > > be useful to me. > > http://code.google.com/p/ejacs/wiki/README > > There is also a console load() function that takes as an argument the > path to a JavaScript source file to load and evaluate. Thanks Kevin. I missed that. ... haven't spend time on this... but =E2=80=9Cload=E2=80=9D is actually ju= st a function of js, much like =E2=80=9Cinclude=E2=80=9D in other lang. i'm hoping to have something like eval-region and eval-buffer for it. Using the =E2=80=9Cload=E2=80=9D function to implement this might mean a bi= t of a hack. ... looking at the source code, looks like js-evaluate in the right thing to call. Just did this: (js-evaluate "print(4);") 4 seems it insert result and consol prompt into the current buffer, as if expecting it is called in a console... a bit more look i found js- eval-buffer: // (js-eval-buffer (current-buffer)) print(3); but got error let: No catch for tag: js-THROW, throw Xah =E2=88=91 http://xahlee.org/ =E2=98=84