Function: with-js

with-js is a macro defined in js.el.gz.

Signature

(with-js &rest FORMS)

Documentation

Run FORMS with the Mozilla repl set up for js commands.

Inside the lexical scope of with-js, js?, js!, js-new, js-eval, js-list, js<, js>, js-get-service, js-create-instance, and js-qi are defined.

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/js.el.gz
(defmacro with-js (&rest forms)
  "Run FORMS with the Mozilla repl set up for js commands.
Inside the lexical scope of `with-js', `js?', `js!',
`js-new', `js-eval', `js-list', `js<', `js>', `js-get-service',
`js-create-instance', and `js-qi' are defined."
  (declare (indent 0) (debug t))
  `(progn
     (js--js-enter-repl)
     (unwind-protect
         (cl-macrolet ((js? (&rest body) `(js--js-true ,@body))
                       (js! (function &rest body)
                            `(js--js-funcall
                              ,(if (consp function)
                                   (cons 'list
                                         (js--optimize-arglist function))
                                 function)
                              ,@(js--optimize-arglist body)))

                       (js-new (function &rest body)
                               `(js--js-new
                                 ,(if (consp function)
                                      (cons 'list
                                            (js--optimize-arglist function))
                                    function)
                                 ,@body))

                       (js-eval (thisobj js)
                                `(js--js-eval
                                  ,@(js--optimize-arglist
                                     (list thisobj js))))

                       (js-list (&rest args)
                                `(js--js-list
                                  ,@(js--optimize-arglist args)))

                       (js-get-service (&rest args)
                                       `(js--js-get-service
                                         ,@(js--optimize-arglist args)))

                       (js-create-instance (&rest args)
                                           `(js--js-create-instance
                                             ,@(js--optimize-arglist args)))

                       (js-qi (&rest args)
                              `(js--js-qi
                                ,@(js--optimize-arglist args)))

                       (js< (&rest body) `(js--js-get
                                           ,@(js--optimize-arglist body)))
                       (js> (props value)
                            `(js--js-funcall
                              '(interactor "_putProp")
                              ,(if (consp props)
                                   (cons 'list
                                         (js--optimize-arglist props))
                                 props)
                              ,@(js--optimize-arglist (list value))
                              ))
                       (js-handle? (arg) `(js--js-handle-p ,arg)))
           ,@forms)
       (js--js-leave-repl))))