Monday, August 24, 2009

It's Alive!!!

Update: With version 0.1.2, opening up a page is much easier, so I have edited the instructions below.

After nearly a month of (very sporadic) work on it, I have finally done the impossible: embedded a fully-featured web browser in Emacs. Behold:



I am calling my creation "Ezbl," pronounced "ease-able." It is a combination of Uzbl and Emacs. Right now, Ezbl is still in the early stages, but it can display a Uzbl window and receive commands from Emacs (over Uzbl's STDIN).

Currently, it requires a patched version of Emacs (available here) which supports embedding widgets and windows, such as Uzbl. It is still in an early state, and any of the drawing-related problems will be caused by the xwidget code. Joakim Verona is the genius behind the xwidget code, so talk to him if you have suggestions about that aspect.

Right now, I'm using the following code to start an instance of Uzbl (which can be called interactively):


(ezbl-open "www.google.com")


You will notice that it creates a buffer called "*ezbl-display-xxxx*", where "xxxx" is the pid of the Uzbl process. To browse to a different page, execute:


(ezbl-command-uri 1234 "www.yahoo.com")


Where "1234" is the pid of the Uzbl process. This will be cleaned up in the future with an "Ezbl" major mode and interactive commands.

Just recently, I've added a live(ish) updating display of the current page title and URL to the mode-line, shown here:



The interface still needs quite a bit of work, and it is not yet possible to type into text areas of the browser window. If you are interested in helping out, I have a GitHub project here to which I regularly push.

Eventually, I plan to have Emacs manage history and cookies, as well as multiple "tabs," which will be done by having one Uzbl window per buffer. It has a long way to go, and is not at all useful for real browsing at this point, so help is greatly appreciated.

Enjoy!

18 comments:

  1. This is fantastic. I can't wait to try it and hack on it - just today I was lamenting that web browsing inside Emacs usually meant not being able to render most of the web.

    ReplyDelete
  2. Great to hear that a graphical browser has finally been embedded in emacs. Do no be discouraged by so few comments - I am sure people will love it once it has matured a bit.

    Speaking of which what is holding back typing into text areas? This, the lack of resizing and the fact that only one xwidget can be visible at a time are of course problems that make it rather pointless to actually use ezbl for anything serious.

    Are this all xwidget problems or are those things that could be solved on the uzbl side?

    ReplyDelete
  3. Thanks for the encouragement! It's nice to know that people know of its existence! :)

    @alex: That exact same feeling was what caused me to jump for joy when I saw the usefulness and extendability of Uzbl.

    @tarsius: I don't expect much attention to it yet, since it is really not anywhere close to being a useful browser yet. Once it is a bit more usable (heh), I'll be sure to let you know.

    The lack of text area support is due to Joakim's xwidget patch. Apparently, getting Emacs to cede keyboard input to an embedded process is non-trivial; I haven't so much as looked at the code for his patch, so you would have to ask him about anything on that front.

    As for resizing, I simply chose the current size of 600x600 pixels as a big enough size for me to be able to see things for testing. The idea would be to have it fill up the whole Emacs window, though I don't know how feasible that is.

    So far, I haven't really run into anything that would need to be handled on the Uzbl side, but I'll be sure to talk to them should anything come up.

    Thanks for the interest!

    ReplyDelete
  4. This is great. Your approach seems very sensible : reuse an existing renderer, because basically nobody can reimplement the web in all its complexity, and reuse uzbl to get rid of the burden of getting something to render.

    Count on a massive amount of people hacking on it once it is in a usable state. I can't even begin to fathom the possibilities this opens :)

    Good luck !

    ReplyDelete
  5. You are my hero. What's the status on the xembed patches making it into mainline Emacs?

    ReplyDelete
  6. go back and work hard, we want this thing!!! : )

    ReplyDelete
  7. This is amazing. This is like my dream project, and you've gone and done it. Emacs, Webkit, embedded, in buffers, god damnit Gary, you're good! Give me a week (to learn how this all works) and I'll try to submit patches to help.

    ReplyDelete
  8. So does the text actually sit inside the buffer à la Emacs/W3 or emacs-w3m, or might it just as well be a picture of a browser as far as Emacs is concerned?

    Mainly, can this be used in a TTY, or only in an X11 Emacs frame?

    ReplyDelete
  9. Wow! Thanks for all the kind words!

    My next priority is getting something that people can actually use, so stay tuned to my GitHub project and Identica timeline for more info. Any help (especially with cookie and history handling) is greatly appreciated!

    @vsync: No, the whole thing is embedded as an xwidget, so Emacs sees it similarly to an image. Emacs has no knowledge (aside from what I add in through the Emacs-Uzbl communication channel) of what's going on inside of the window. It means you lose some of the cool Emacs features for the web pages themselves, but it massively reduces the complexity of the thing.

    It also means that it won't work in a TTY, or anything which cannot embed arbitrary X windows (really GtkSocket). Making it work in a terminal would require a completely different approach, and I wouldn't be able to use Uzbl, unfortunately. I don't think one could ever make this work in a terminal, since it is such a fundamentally different design. I'm bummed about that, but that's how it is.

    ReplyDelete
  10. Wow! Now if emacs only had a decent text editor...

    ReplyDelete
  11. Ah, this might make me give up my w3m+conkeror combination =D

    ReplyDelete
  12. This comment has been removed by a blog administrator.

    ReplyDelete
  13. Wow! This certainly is a great thing.

    Even with the integration limitations of an xwidget (no TTY, no 2 buffers displaying at same time, etc) it's still a must-have, since all the cache/bookmark/mode-line/etc layer build on top of uzbl would be needed anyway if in a distant future there was the remote possibility of a better renderer that could replace uzbl in emacs.

    ReplyDelete
  14. Nice one!
    Keep up the good work on this please to make this possible for all emacs versions and users (if possible).

    ReplyDelete
  15. That is very interesting, kudos to you! :)

    ReplyDelete
  16. Very nice indeed! Congratulations!

    ReplyDelete
  17. Nice !!! Thank's for sharing.

    Links are broken:
    github.com/dhax -> github.com/haxney

    ReplyDelete
    Replies
    1. Wow, good catch. I didn't think anyone was still reading this!

      Delete