在 Emacs 中显示远程 HTML 的内容 [英] Display contents of remote HTML in Emacs

查看:23
本文介绍了在 Emacs 中显示远程 HTML 的内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道 w3m 与 Emacs 的集成,但我已经筋疲力尽了让它在我的 W7/x64 上运行:这里有 w3m 二进制文件的永久分段错误.

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.

我想知道是否有一种替代方法可以在 Emacs 中显示远程 HTML,可能会按照 Readability/GetPocket 等服务完成的方式进行初步过滤?我不需要那里的导航,所以清除内容就完美了.

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.

谢谢,

推荐答案

trunk/Emacs 24.4:

trunk / Emacs 24.4:

  • M-x eww RET (URL) RET

Emacs 24.1 - 24.3:

Emacs 24.1 - 24.3:

  • Mx browse-url-emacs RET (URL) RET
  • M-x load-library RET shr​​ RET
  • M-x shr​​-render-buffer RET
  • 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: 或 this,它绝对没有错误处理,但速度要快得多(我将其归因于使用 url-retrieve-synchronously 的 browse-url-emacs,因为这是异步的).随意改进:)

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)))))

这篇关于在 Emacs 中显示远程 HTML 的内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆