all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* how to use ejacs to eval a file as with command line driven  interpreters
@ 2009-01-08 15:12 Xah Lee
  2009-01-10  3:09 ` Kevin Rodgers
       [not found] ` <mailman.4473.1231557011.26697.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 5+ messages in thread
From: Xah Lee @ 2009-01-08 15:12 UTC (permalink / raw
  To: help-gnu-emacs

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.

Thanks.

  Xah
∑ http://xahlee.org/^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: how to use ejacs to eval a file as with command line driven  interpreters
  2009-01-08 15:12 how to use ejacs to eval a file as with command line driven interpreters Xah Lee
@ 2009-01-10  3:09 ` Kevin Rodgers
       [not found] ` <mailman.4473.1231557011.26697.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 5+ messages in thread
From: Kevin Rodgers @ 2009-01-10  3:09 UTC (permalink / raw
  To: help-gnu-emacs

Xah Lee wrote:
> 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. It cannot have 
any dependencies on browser DOM or other non-Ecma-262 host objects.


-- 
Kevin Rodgers
Denver, Colorado, USA





^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: how to use ejacs to eval a file as with command line driven  interpreters
       [not found] ` <mailman.4473.1231557011.26697.help-gnu-emacs@gnu.org>
@ 2009-01-11 16:20   ` Xah Lee
  2009-01-13  2:18     ` Kevin Rodgers
       [not found]     ` <mailman.4694.1231813093.26697.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 5+ messages in thread
From: Xah Lee @ 2009-01-11 16:20 UTC (permalink / raw
  To: help-gnu-emacs

On Jan 9, 7:09 pm, Kevin Rodgers <kevin.d.rodg...@gmail.com> 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 “load” is actually just a
function of js, much like “include” in other lang.

i'm hoping to have something like eval-region and eval-buffer for it.
Using the “load” 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

  Xah
∑ http://xahlee.org/^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: how to use ejacs to eval a file as with command line driven  interpreters
  2009-01-11 16:20   ` Xah Lee
@ 2009-01-13  2:18     ` Kevin Rodgers
       [not found]     ` <mailman.4694.1231813093.26697.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 5+ messages in thread
From: Kevin Rodgers @ 2009-01-13  2:18 UTC (permalink / raw
  To: help-gnu-emacs

Xah Lee wrote:
> On Jan 9, 7:09 pm, Kevin Rodgers <kevin.d.rodg...@gmail.com> 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 “load” is actually just a
> function of js, much like “include” in other lang.
> 
> i'm hoping to have something like eval-region and eval-buffer for it.
> Using the “load” 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.

-- 
Kevin Rodgers
Denver, Colorado, USA





^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: how to use ejacs to eval a file as with command line driven  interpreters
       [not found]     ` <mailman.4694.1231813093.26697.help-gnu-emacs@gnu.org>
@ 2009-01-13 17:00       ` Xah Lee
  0 siblings, 0 replies; 5+ messages in thread
From: Xah Lee @ 2009-01-13 17:00 UTC (permalink / raw
  To: help-gnu-emacs

On Jan 12, 6:18 pm, Kevin Rodgers <kevin.d.rodg...@gmail.com> wrote:
> XahLeewrote:
> > On Jan 9, 7:09 pm, Kevin Rodgers <kevin.d.rodg...@gmail.com> 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 “load” is actually just a
> > function of js, much like “include” in other lang.
>
> > i'm hoping to have something like eval-region and eval-buffer for it.
> > Using the “load” 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
∑ http://xahlee.org/^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2009-01-13 17:00 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-01-08 15:12 how to use ejacs to eval a file as with command line driven interpreters Xah Lee
2009-01-10  3:09 ` Kevin Rodgers
     [not found] ` <mailman.4473.1231557011.26697.help-gnu-emacs@gnu.org>
2009-01-11 16:20   ` Xah Lee
2009-01-13  2:18     ` Kevin Rodgers
     [not found]     ` <mailman.4694.1231813093.26697.help-gnu-emacs@gnu.org>
2009-01-13 17:00       ` Xah Lee

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.