1

使用我的自定义版本的 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 line--”)...

知道那里出了什么问题吗?

4

1 回答 1

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

于 2014-03-04T18:03:17.617 回答