根据收件人自动在Gnus中切换语言

时间:2014-03-04 14:51:04

标签: emacs message gnus

使用我的自定义版本的th-message-switch-ispell-dictionary(参见http://lists.gnu.org/archive/html/info-gnus-english/2007-08/msg00062.html)时:

(defun my-message-switch-ispell-dictionary ()
  (save-excursion
    (message-narrow-to-headers-or-head)
    (let ((newsgroups (message-fetch-field "Newsgroups"))
          (to         (message-fetch-field "To")))
      (message "Newsgroup or To = %s." (or newsgroups to))
      (if newsgroups
          (cond ((string-match (rx bol "fr.") newsgroups)
                 (ispell-change-dictionary "francais"))
                (t
                 (ispell-change-dictionary "american")))
        ;; email
        (ispell-change-dictionary "francais")))))

(add-hook 'message-setup-hook 'my-message-switch-ispell-dictionary)

我遇到错误:

message-position-on-field: Search failed: "^--text follows this line--$"

创建邮件或帖子时(不再出现“ - text follow this lines--”)...

有关于那里出了什么问题的想法吗?

1 个答案:

答案 0 :(得分:0)

我不确定为什么--text follows this line--没有插入。作为替代方案,尝试修改上述功能如下

(require 'sendmail)
(defun my-message-switch-ispell-dictionary ()
  (save-excursion
    (narrow-to-region (point-min) (mail-header-end))            ;; changed this line
    (let ((newsgroups (message-fetch-field "Newsgroups"))
          (to         (message-fetch-field "To")))
      (message "Newsgroup or To = %s." (or newsgroups to))
      (if newsgroups
          (cond ((string-match (rx bol "fr.") newsgroups)
                 (ispell-change-dictionary "francais"))
                (t
                 (ispell-change-dictionary "american")))
        ;; email
        (ispell-change-dictionary "francais")))))

(add-hook 'message-setup-hook 'my-message-switch-ispell-dictionary)

添加的行执行相同的操作(message-narrow-to-headers-or-head),但不依赖于插入的(“ - text follow this line--”)mail-header-separator