htmlemacsw3m

Display contents of remote HTML in Emacs


I am aware about w3m integration with Emacs but I am exhausted to make it run on my W7/x64: there is a permanent segmentation fault of w3m binary here.

I wonder if there is an alternative way to display remote HTML in Emacs possibly preliminary filtered in the way it is done by Readability/GetPocket etc. services? I do not need a navigation there so cleared contents would be perfect.

Thanks,


Solution

  • trunk / Emacs 24.4:

    Emacs 24.1 - 24.3:

    (defun my-render-url (url)
      "Render URL as HTML."
      (interactive "sURL: ")
      (require 'shr)
      (let ((buf (save-window-excursion (browse-url-emacs url))))
        (shr-render-buffer buf)))
    

    Edit: or this, which has absolutely no error handling, but is considerably faster (which I attribute to browse-url-emacs using url-retrieve-synchronously, where as this is asynchronous). Feel free to make improvements :)

    (defun my-render-url (url)
      "Render URL as HTML."
      (declare (obsolete eww "24.4"))
      (interactive "sURL: ")
      (require 'shr)
      (url-retrieve
       url
       (lambda (&optional status cbargs)
         (let ((markup (current-buffer)))
           (delete-region (point-min) (1+ url-http-end-of-headers))
           (shr-render-buffer markup)
           (kill-buffer markup)))))