如何在包含UTF-8字符的HTML邮件中使用Emacs Gnus,并将Lynx作为HTML渲染器进行核心处理?

时间:2013-11-18 12:46:59

标签: emacs utf-8 lynx gnus

我使用Gnus v5.13使用GNU Emacs 24.2.1(但从来没有Emacs它也不起作用),并使用Lynx格式化HTML邮件进行如下配置:

(setq 'mm-text-html-renderer 'lynx)
(setcdr (assoc 'lynx mm-text-html-renderer-alist)
        '(mm-inline-render-with-stdin
          nil "lynx" "-dump" "-force_html" "-stdin" "-display_charset=UTF-8"))

但是UTF-8字符显示不正确,例如我看到类似的东西:

Es gibt \303\274ber 700 neue Top-Level-Domains.

使用以下命令可以轻松解决:

(toggle-read-only)
(recode-region (point-min) (point-max) 'utf-8 'utf-8)

但是有可能让Gnus将Lynx输出解释为UTF-8吗?

(这个问题在这里也没有回答: http://lists.gnu.org/archive/html/info-gnus-english/2010-06/msg00006.html

1 个答案:

答案 0 :(得分:0)

我自己找到了一个答案,这里有完整的代码用UTF-8激活Gnus中的Lynx:

(require 'mm-view)
(setq mm-text-html-renderer 'lynx)
(setcdr (assoc 'lynx mm-text-html-renderer-alist)
        '(mm-inline-render-with-stdin
          nil "lynx" "-dump" "-force_html" "-stdin" "-display_charset=UTF-8"))

(defvar mm-insert-inline-use-utf-8 nil)

(defadvice mm-insert-inline (around mm-insert-inline-utf-8)
  (let ((x (point)))
    (prog1 (progn ad-do-it)
      (when mm-insert-inline-use-utf-8
        (decode-coding-region x (point-max) 'utf-8)))))
(ad-activate 'mm-insert-inline)

(defadvice mm-inline-text-html (around mm-inline-text-html-utf-8)
  (let ((mm-insert-inline-use-utf-8 t))
    ad-do-it))
(ad-activate 'mm-inline-text-html)