Display contents of remote HTML in Emacs

主宰稳场 提交于 2019-12-18 03:43:20

问题


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,


回答1:


trunk / Emacs 24.4:

  • M-x eww RET (URL) RET

Emacs 24.1 - 24.3:

  • M-x browse-url-emacs RET (URL) RET
  • M-x load-library RET shr RET
  • M-x shr-render-buffer RET
(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)))))


来源:https://stackoverflow.com/questions/19632185/display-contents-of-remote-html-in-emacs

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!