emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Why Emacs should have a good web-browser


From: Daniel Colascione
Subject: Re: Why Emacs should have a good web-browser
Date: Thu, 13 Aug 2009 18:54:33 -0400

On Jul 8, 2009, at 6:42 PM, Lennart Borgman wrote:
BTW, I have heard that espresso offers even better interaction than
MozRepl but I am not sure. Is there anyone who knows more about this?
Some examples of how to interact from Espresso/MozRepl?


Here is an example of some code from espresso (after the rename to js- mode). I hope the JS interaction is self-explanatory, at least for the purpose of discussion.

(FWIW, maybe the elisp<->js bridge really should be moved to moz.el?)

(defun js--get-tabs ()
  "Enumerate all the contexts available. Each one is a list:

   The list is (TITLE URL BROWSER TAB TABBROWSER) for content documents
   The list is (TITLE URL WINDOW) for windows

   All tabs of a given window are grouped together. The most
   recent window is first. Within each window, the tabs are
   returned left-to-right.
"
  (with-js
   (let (windows)

     (loop with window-mediator = (js! ("Components" "classes"
"@mozilla.org/appshell/window- mediator;1"
                                        "getService")
                                       (js< "Components" "interfaces"
                                            "nsIWindowMediator"))
with enumerator = (js! (window-mediator "getEnumerator") nil)

           while (js? (js! (enumerator "hasMoreElements")))
           for window = (js! (enumerator "getNext"))
           for window-info = (js-list window
                                      (js< window "document" "title")
(js! (window "location" "toString"))
                                      (js< window "closed")
                                      (js< window "windowState"))

           unless (or (js? (fourth window-info))
                      (eq (fifth window-info) 2))
           do (push window-info windows))

     (loop for window-info in windows
           for window = (first window-info)
           collect (list (second window-info)
                         (third window-info)
                         window)

           for gbrowser = (js< window "gBrowser")
           if (js-handle? gbrowser)
           nconc (loop
                  for x below (js< gbrowser "browsers" "length")
                  collect (js-list (js< gbrowser
                                        "browsers"
                                        x
                                        "contentDocument"
                                        "title")

                                   (js! (gbrowser
                                         "browsers"
                                         x
                                         "contentWindow"
                                         "location"
                                         "toString"))
                                   (js< gbrowser
                                        "browsers"
                                        x)

                                   (js! (gbrowser
                                         "tabContainer"
                                         "childNodes"
                                         "item")
                                        x)

                                   gbrowser))))))





reply via email to

[Prev in Thread] Current Thread [Next in Thread]