2014-03-04 68 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