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: Tue, 13 Jan 2009 09:00:03 -0800 (PST) Organization: http://groups.google.com Message-ID: <9990ecd5-b463-4a21-bbb4-6c3c63cc0575@r15g2000prh.googlegroups.com> References: <28fc357b-e4b0-410d-8cc8-3b65cbaf9fc3@z27g2000prd.googlegroups.com> <84adaeb7-51b2-4f74-9fa4-f44c181a7ff5@r15g2000prh.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 1231874691 17970 80.91.229.12 (13 Jan 2009 19:24:51 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 13 Jan 2009 19:24:51 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Jan 13 20:26:03 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 1LMotm-0001w2-De for geh-help-gnu-emacs@m.gmane.org; Tue, 13 Jan 2009 20:26:02 +0100 Original-Received: from localhost ([127.0.0.1]:58314 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LMosV-0002ny-Vf for geh-help-gnu-emacs@m.gmane.org; Tue, 13 Jan 2009 14:24:44 -0500 Original-Path: news.stanford.edu!headwall.stanford.edu!news.glorb.com!postnews.google.com!r15g2000prh.googlegroups.com!not-for-mail Original-Newsgroups: gnu.emacs.help,comp.emacs Original-Lines: 69 Original-NNTP-Posting-Host: 24.6.175.142 Original-X-Trace: posting.google.com 1231866004 28096 127.0.0.1 (13 Jan 2009 17:00:04 GMT) Original-X-Complaints-To: groups-abuse@google.com Original-NNTP-Posting-Date: Tue, 13 Jan 2009 17:00:04 +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:165979 comp.emacs:97642 X-Mailman-Approved-At: Tue, 13 Jan 2009 14:18:10 -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:61308 Archived-At: On Jan 12, 6:18 pm, Kevin Rodgers wrote: > XahLeewrote: > > On Jan 9, 7:09 pm, Kevin Rodgers wrote: > >>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 actuall= y just 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 bit 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 > > So you need to establish the js-THROW tag before calling js-eval-buffer: > > (catch 'js-THROW > (js-eval-buffer (current-buffer))) > > If you search the ejacs source code for js-THROW and js-eval-buffer, you > should be able to find out how to do it properly. i think i'm too lazy. I already have spidermonkey on command line... was just hoping to toy up with ejacs... Maybe someone should tell Stevey to brush it up for this... it might increase its toy value a bit and make use of it ... (am updating my js tutorial ( http://xahlee.org/js/javascript_basics.html ) For the examples there, ejacs would be perfect if i can just run it as file.) he wanted to add DOM to ejacs so that people can script emacs with js. (which would be great cause i think js is much better than elisp (not in some fundamental sense, but in pratice, cause lisp is really aged and in my opinion practically inferior to js or say ruby even just considering the language)) According to his blog, he's todo is piled up to next 2 or more years... but as with most todos and projects that became successful, maybe someone just need to give him a jolt. i thought of taking it up myself but designing a DOM for emacs and implement it in js is not trivial, and am no js expert. Xah =E2=88=91 http://xahlee.org/ =E2=98=84