1

When using my custom version of th-message-switch-ispell-dictionary (see 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)

I experience the error:

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

when creating a mail or a post (and no "--text follows this line--" is present anymore)...

Any idea about what goes wrong there?

user3341592
  • 1,419
  • 1
  • 17
  • 36

1 Answers1

0

I am not sure why the --text follows this line-- is not getting inserted. As alternative try modifying the function above as follows

(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)

The line added does the same thing (message-narrow-to-headers-or-head) but does not rely on the ("--text follows this line--") mail-header-separator being inserted.

  • It did not help. Though, the above does well work if I comment the following line of gnus-alias: – user3341592 Mar 05 '14 at 14:15
  • ;; (add-hook 'message-setup-hook 'gnus-alias-determine-identity) – user3341592 Mar 05 '14 at 14:16
  • I tried searching for `gnus-alias-determine-identity`, it is NOT included in vanilla emacs perhaps you will have to install it separately I found a copy at (https://github.com/emacsmirror/gnus-alias). BTW if commenting the line works (and you do not need it) consider removing it altogether. –  Mar 05 '14 at 14:29
  • I do need it... as I have different "personalities" (for work, for friends, etc.) and you can change it on the fly, unlike gnus-posting-style... Thanks for helping! – user3341592 Mar 05 '14 at 16:44