2014-03-04 25 views
1

当使用TH-消息开关的ispell词典我的定制版本(见http://lists.gnu.org/archive/html/info-gnus-english/2007-08/msg00062.html):自动切换在Gnus的语言,这取决于接受者

(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--$" 

当创建一个邮件或一个职位(并没有“ - 文本遵循此行 - ”存在了)...

任何有关哪里出错的想法吗?

回答

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遵循此line--”)功能mail-header-separator被插入。

+0

它没有帮助。尽管如此,如果我评论以下gnus别名: – user3341592

+0

;;以上做得很好。 (add-hook'message-setup-hook'gnus-alias-determine-identity) – user3341592

+0

我试过寻找'gnus-alias-determin-identity',它不包含在vanilla emacs中,也许你将不得不单独安装它在(https://github.com/emacsmirror/gnus-alias)找到了一份副本。顺便说一句,如果评论该行的作品(你不需要它)考虑完全删除它。 – 2014-03-05 14:29:12