Select flyspell via a variable in a file

885 views Asked by At
  1. Question:

How can i select flyspell automatically by an EMACS Variable in my file (not via the .emacs configuration file!), just for that file, similar like I select the ispell dictionary just for that file

EXAMPLE abc.tex:

---SNIP---

text text ..

text text ..

<!-- LocalXIspellDict: de -->
<!-- HERE SHOULD GO THE SOLUTION -->

---SNIP---

Second Question:

How can I achieve that -- whenever I open a TeX-File, i. e., XXX.tex -- flyspell is automatically selected by configuring my init.el file? Meaning, flyspell is selected depending on the filename extension.

3

There are 3 answers

0
phils On

An alternative to the first-line file variables statement is a commented local variables block like this:

% Local Variables:
% eval: (flyspell-mode 1)
% ispell-local-dictionary: "german"
% End:

(n.b. As of Emacs 24, while still applicable to major modes, the mode: MINOR-MODE syntax is deprecated, and eval should be used instead).

See the manual for details:
M-: (info "(emacs) Specifying File Variables") RET

Also: http://www.emacswiki.org/emacs/FileLocalVariables

2
pmr On

The second part is rather simple: Just add flyspell-mode to the mode-hook for every mode that you want to use with flyspell.

This enables flyspell whenever text-mode is enabled (which is basically always):

(add-hook 'text-mode-hook (lambda ()  (flyspell-mode 1)))

You probably want to use tex-mode-hook.

For the file: Put this on the beginning of the file and flyspell should be entered whenever you find that file.

-*- mode: flyspell; -*-
1
david villa On

Using file-local-variables: http://www.gnu.org/software/emacs/manual/html_node/emacs/File-Variables.html

% Local Variables:
%   ispell-local-dictionary: "american"
% End: