eww

I couple of years ago I wrote an HTML rendering library for Emacs so that I could read blogs in Gnus. And because I thought that Emacs should have a built-in method to display HTML. I mean, it was only about 20 years over-due.

Simple HTML Renderer (or shr, as the cool kids call it) was included in Emacs 24, and is based on the HTML capabilities of libxml2.  So it parses HTML very quickly.  The rendering, however, is in Emacs Lisp, so there’s a constant struggle between the impulse to IMPLEMENT IT ALL and not having it be so slow that you wouldn’t want to use it.

shr is fast enough to be usable on short, un-complicated pages.  But point it to a page containing tables nested ten-deep, and it’s a dog.  Mostly because I couldn’t come up with a table rendering algorithm that isn’t exponential.  Or something. 

Anyway, after doing that, implementing an Emacs web browser seemed like the obvious next step.  It would be useful for doing, say, lookups in the Common Lisp Hyperspec, or look up the documentation for PHP functions, and stuff like that.  Since shr doesn’t do JavaScript, you can’t really do Gmail.

So this Monday, I came up with the name of the browser while half-asleep: eww!  I don’t quite know what the second w is supposed to stand for (Emacs Web Wowser?), but now that I had a name I just had to start programming.

It was only a couple day’s work (mostly implementing support), and here’s how eww renders the Wikipedia page on kittens, which we all consult daily.  Probably.

It’s alive!

Emacs has other, non-built-in browsers.  I think the reason they haven’t been included are for copyright assignment reasons.  But let’s compare.

Here’s emacs-w3m, which uses the external w3m program do generate a parse tree:
 

emacs-w3m is quite fast (much faster than shr on nested tables) and renders stuff nicely.  The

  • list is better in emacs-w3m than in shr, for instance.  And shr “lifts” the [1] elements, making the lines uneven.  On the other hand, shr displays the images in-line, which surely must be the most important thing on pages with kittens!

    Then there’s the venerable w3, which I only have for XEmacs.  Let’s see how it does:

    Oops.  Perhaps it doesn’t like https links?  Yup, the http version is better:

    w3 is more fond of changing font size than both eww and emacs-w3m.  My reasoning for disallowing font size changes is that Emacs has a pretty basic rendering model.  If you have characters with different widths, lining stuff up is almost impossible.  And since so many pages are table-based, it’s more important to make stuff readable than to vary text sizes and use different fonts.  But perhaps shr could do font stuff outside of tables?  There wouldn’t be much of an issue of lining stuff up outside of table contexts.

    Anyway, there you go.  There’s lots of stuff that could and possibly should be tweaked in eww (and shr), but I think it’s basically usable. 

    If you want to give it a twirl, the easiest (ahem) thing is probably to pull down the Emacs 24 bzr tree.  Or, if you’re using Emacs 24, pull down the Gnus git tree.  (I put it in the Gnus git repository, where it kinda doesn’t belong, but since shr is in there already, and they’re developed synchronously, it was easier to put it there.  It’ll probably be removed from there after a while.)

  • This entry was posted in Uncategorized. Bookmark the permalink.

    14 Responses to eww

    1. Nic says:

      Package it and put it on GNU's ELPA. I think it's interesting at least.

    2. ivant says:

      FYI, emacs-w3m can show images in-line, but it's not “on” by default.

    3. dida says:

      For heaven's sake, please go on!

      Build in WWW browsing capabilities are the only thing missing in Emacs. And thanks for Gnus, Gwene and Eww…

    4. dida says:

      Built-in, I meant…

    5. Warbo says:

      Indeed. Press “T” to toggle inline images on/off for the current tab, or press “t” to toggle the image at the point.

      I generally browse with inline images off, and enable images when necessary (eg. diagrams). That prevents most obnoxious advertising.

      One thing to note is that emacs-w3m always seems to display images at their native size.

    6. I get,

      Symbol's function definition is void: libxml-parse-html-region

      Does that mean my emacs24 is compiled wrong?

    7. Yes. You have to compile your emacs with libxml2 support.

    8. Zebulon says:

      This post is a bit old now, but when I try and go to a url, i get this:
      symbol’s function definition is void: setq-local

      Any ideas?

    9. larsmagne23 says:

      You need the latest bzr Emacs to use eww.

    10. Pingback: Emacs Cloud | Random Thoughts

    11. Joe Corneli says:

      Hi Lars: I’m using Eww for a lot of my web things, thanks! It’s great and adds a lot of motivation for “living in emacs”.

      One thing that I must say it’s not very good at is text areas. For example, if I try to edit any Wikipedia page, I just see a big blank. (I’m posting this comment using Firefox.) Would be nice to copy the emacs/w3m or emacs-w3 behavior for text areas… and even with emacs/w3m couldn’t I post a comment, presumably b/c of some javascript issue.

      Maybe I can help out sometime…

      One of the things I worked on in the past was called nero.el, which was a sort of browser-shell that used lynx -dump as the backend. If I remember correctly it did some interesting tricks with multilinear history…

      Joe – holtzermann17@gmail.com

    12. Brian says:

      A couple of questions. First, is there a better place other than these comments to ask questions (or file bugs or feature requests)?

      Second, is there a reason why only one eww process is allowed? Even if I rename the buffer to try and open two eww buffers, both buffers get updated to display the url I requested in the second buffer. Essentially, multiple tabs/pages don’t seem possible.

      Third, going on on a limb here, but how hard would it be to have eww support the Gopher protocol? Currently, I use lynx, which works great, but it’d be pretty sweet if eww could handle Gopher. However, I’d really want the ability to have multiple eww’s running first (i.e. my second question, above).

      Finally, not a question, but great work on eww. I look forward to seeing it grow and mature even more than it already has!

    13. Richard M. Stallman says:

      Nothing new. W3, W3M, Elinks inside Emacs, all of these have been around for years and none of them is usefull. Also, nice to see all buffers hanging while eww loads the page.

    14. Yuanqi says:

      Hi, Great to find eww but I found that most theme are not good for that on Mac, Space or return are marked by red which made the search result on google is so ugly and in w3m I don’t have this problem, any solutions?

      Why not give more option for search engine although we could change that , duckduckgo is good but I have to give it up because I could not hardly press next link.

    Leave a Reply

    Fill in your details below or click an icon to log in:

    WordPress.com Logo

    You are commenting using your WordPress.com account. Log Out / Change )

    Twitter picture

    You are commenting using your Twitter account. Log Out / Change )

    Facebook photo

    You are commenting using your Facebook account. Log Out / Change )

    Google+ photo

    You are commenting using your Google+ account. Log Out / Change )

    Connecting to %s