Discussion:
Automatic selection of ispell dictionaries
Erik Frisk
2005-01-14 13:09:36 UTC
Permalink
What is the easiest way to automatically select the correct ispell
dictionary for a Latex document?

I normally write documents in english or swedish and would like ispell
to default to english, but if I have option 'swedish' to babel or the
class I would like ispell to change to the swedish dictionary.
I guess some hooks in Auctex can be used for this purpose.

/Erik

---------------------------------------------------------------------
Erik Frisk email: ***@isy.liu.se
Dept. of Electrical Engineering tel: +46 13 285714
Linköping University fax: +46 13 282035
S-581 83 Linköping
SWEDEN http://www.fs.isy.liu.se/~frisk/
---------------------------------------------------------------------
Reiner Steib
2005-01-14 13:44:37 UTC
Permalink
I normally write documents in english or swedish and would like ispell to
default to english, but if I have option 'swedish' to babel or the class I
would like ispell to change to the swedish dictionary.
I guess some hooks in Auctex can be used for this purpose.
,----[ (info "(auctex)European") ]
| AUCTeX supports style files for several languages. Each style file
| may modify some AUCTeX to better support the language, and will run a
| language specific hook that will allow you to for example change ispell
| dictionary, or run code to change the keyboard remapping. The
| following will for example choose a Danish dictionary for documents
| including the `dk.sty' file. This requires parsing to be enabled,
| *note Parsing Files::.
|
| (add-hook 'TeX-language-dk-hook
| (function (lambda () (ispell-change-dictionary "danish"))))
|
| The following style files are recognized.
| `dk'
| Runs style hook `TeX-language-dk-hook'.
`----

The same pattern should hold for Swedish, though it is missing in the
manual. The hook is called `TeX-language-sv-hook' (see
`style/swedish.el').

Does it work?

Probably we should add the other missing languages in (info
"(auctex)European") too:

,----[ grep -nH TeX-language-.*-hook *.el ]
| czech.el:9: (run-hooks 'TeX-language-cz-hook))))
| danish.el:13: (run-hooks 'TeX-language-dk-hook))))
| dk.el:9: (run-hooks 'TeX-language-dk-hook))))
| dutch.el:9: (run-hooks 'TeX-language-nl-hook))))
| german.el:36: (run-hooks 'TeX-language-de-hook))))
| italian.el:38:(defvar TeX-language-it-hook nil
| italian.el:50: (run-hooks 'TeX-language-it-hook)))
| ngerman.el:36: (run-hooks 'TeX-language-de-hook))))
| plfonts.el:29: (run-hooks 'TeX-language-pl-hook))))
| plhb.el:29: (run-hooks 'TeX-language-pl-hook))))
| slovak.el:9: (run-hooks 'TeX-language-sk-hook))))
| swedish.el:13: (run-hooks 'TeX-language-sv-hook))))
`----

Maybe in form of a table. Any volunteers?

Bye, Reiner.
--
,,,
(o o)
---ooO-(_)-Ooo--- | PGP key available | http://rsteib.home.pages.de/
Reiner Steib
2005-01-14 17:05:26 UTC
Permalink
Post by Reiner Steib
The same pattern should hold for Swedish, though it is missing in the
manual. The hook is called `TeX-language-sv-hook' (see
`style/swedish.el').
[...]
Post by Reiner Steib
Probably we should add the other missing languages in (info
"(auctex)European") too: [...]
Done. It would be nice if people who are using those languages could
check this and suggest improvements. E.g. I don't understand the
difference between `danish.el' and `dk.el'.

,----[ (info "(auctex)European") ]
| The following style files are recognized.
| `czech'
| Runs style hook `TeX-language-cz-hook'. Pressing <"> will insert
| `\uv{' and `}' depending on context.
|
| `danish'
| Runs style hook `TeX-language-dk-hook'. Pressing <"> will insert
| `"`' and `"'' depending on context.
|
| `dk'
| Runs style hook `TeX-language-dk-hook'.
|
| `dutch'
| Runs style hook `TeX-language-nl-hook'.
|
| `german'
| `ngerman'
| Runs style hook `TeX-language-de-hook'. Gives `"' word syntax,
| makes the <"> key insert a literal `"', and pressing it twice will
| give you opening or closing german quotes (`"`' or `"''), if you
| have configured `TeX-open-quote' and `TeX-close-quote'
| accordingly. *Note Quotes::.
|
| `italian'
| Runs style hook `TeX-language-it-hook'. Pressing <"> will insert
| `"<' (`LaTeX-italian-open-quote') and `">'
| (`LaTeX-italian-close-quote') depending on context.
|
| `plfonts'
| `plhb'
| Runs style hook `TeX-language-pl-hook'. Gives `"' word syntax
| and makes the <"> key insert a literal `"'. Pressing <"> twice
| will insert `"<' or `">' depending on context.
|
| `slovak'
| Runs style hook `TeX-language-sk-hook'. Pressing <"> will insert
| `\uv{' and `}' depending on context.
|
| `swedish'
| Runs style hook `TeX-language-sv-hook'. Pressing <"> will insert
| `'''.
`----

Bye, Reiner.
--
,,,
(o o)
---ooO-(_)-Ooo--- | PGP key available | http://rsteib.home.pages.de/
Arne Jørgensen
2005-01-14 18:41:24 UTC
Permalink
Done. It would be nice if people who are using those languages could
check this and suggest improvements.
The danish entries are fine.
E.g. I don't understand the difference between `danish.el' and
`dk.el'.
I think the difference is that danish.el is read if you use the danish
option to Babel. Babel defines the quotes for the danish laguage.

And I think dk.el is from the old days before Babel where we where
probabably using some dk.sty (I don't really remember anymore) that
didn't define quotes.

Kind regards,
--
Arne Jørgensen <http://arnested.dk>
DK-TUG / Danish TeX Users Group <http://www.tug.dk/>
Reiner Steib
2005-01-14 19:51:48 UTC
Permalink
[...]
Post by Arne Jørgensen
E.g. I don't understand the difference between `danish.el' and
`dk.el'.
I think the difference is that danish.el is read if you use the danish
option to Babel. Babel defines the quotes for the danish laguage.
And I think dk.el is from the old days before Babel where we where
probabably using some dk.sty (I don't really remember anymore) that
didn't define quotes.
The we should probably don't mention `dk' in the manual. WDYT?
(It might encourage users to use obsolete stuff.)

Bye, Reiner.
--
,,,
(o o)
---ooO-(_)-Ooo--- | PGP key available | http://rsteib.home.pages.de/
Arne Jørgensen
2005-01-14 21:18:50 UTC
Permalink
Post by Reiner Steib
[...]
Post by Arne Jørgensen
E.g. I don't understand the difference between `danish.el' and
`dk.el'.
I think the difference is that danish.el is read if you use the danish
option to Babel. Babel defines the quotes for the danish laguage.
And I think dk.el is from the old days before Babel where we where
probabably using some dk.sty (I don't really remember anymore) that
didn't define quotes.
The we should probably don't mention `dk' in the manual. WDYT?
(It might encourage users to use obsolete stuff.)
Bye, Reiner.
You are right.

Kind regards,
--
Arne Jørgensen <http://arnested.dk>
DK-TUG / Danish TeX Users Group <http://www.tug.dk/>
Reiner Steib
2005-01-14 22:08:56 UTC
Permalink
[...]
Post by Arne Jørgensen
Post by Reiner Steib
The we should probably don't mention `dk' in the manual. WDYT?
(It might encourage users to use obsolete stuff.)
[ s/The/Then/ ]
Post by Arne Jørgensen
You are right.
Okay, how about this:

,----[ (info "(auctex)European") ]
| AUCTeX supports style files for several languages. Each style file
| may modify AUCTeX to better support the language, and will run a
| language specific hook that will allow you to for example change ispell
| dictionary, or run code to change the keyboard remapping. The
| following will for example choose a Danish dictionary for documents
| including `\usepackage[danish]{babel}'. This requires parsing to be
| enabled, *note Parsing Files::.
|
| (add-hook 'TeX-language-dk-hook
| (function (lambda () (ispell-change-dictionary "danish"))))
|
| The following style files are recognized.
| [...]
| `danish'
| Runs style hook `TeX-language-dk-hook'. Pressing <"> will insert
| `"`' and `"'' depending on context.
|
| `dutch' [...]
`----

Beside eliminating dk.sty, I also changed this:

,----
| @AUCTeX{} supports style files for several languages. Each style file
| -may modify some @AUCTeX{} to better support the language, and will run
| +may modify @AUCTeX{} to better support the language, and will run
| a language specific hook that will allow you to for example change
`----

The "some" is nonsense or there is something else missing.

Bye, Reiner.
--
,,,
(o o)
---ooO-(_)-Ooo--- | PGP key available | http://rsteib.home.pages.de/
Arne Jørgensen
2005-01-17 23:45:59 UTC
Permalink
Post by Reiner Steib
[...]
Post by Arne Jørgensen
Post by Reiner Steib
The we should probably don't mention `dk' in the manual. WDYT?
(It might encourage users to use obsolete stuff.)
[ s/The/Then/ ]
Post by Arne Jørgensen
You are right.
Fine.
Post by Reiner Steib
,----[ (info "(auctex)European") ]
| AUCTeX supports style files for several languages. Each style file
| may modify AUCTeX to better support the language, and will run a
| language specific hook that will allow you to for example change ispell
| dictionary, or run code to change the keyboard remapping. The
| following will for example choose a Danish dictionary for documents
| including `\usepackage[danish]{babel}'. This requires parsing to be
| enabled, *note Parsing Files::.
|
| (add-hook 'TeX-language-dk-hook
| (function (lambda () (ispell-change-dictionary "danish"))))
|
| The following style files are recognized.
| [...]
| `danish'
| Runs style hook `TeX-language-dk-hook'. Pressing <"> will insert
| `"`' and `"'' depending on context.
|
| `dutch' [...]
`----
Kind regards,
--
Arne Jørgensen <http://arnested.dk>
DK-TUG / Danish TeX Users Group <http://www.tug.dk/>
Jan-Ake Larsson
2005-01-19 08:21:55 UTC
Permalink
Post by Reiner Steib
,----[ (info "(auctex)European") ]
| AUCTeX supports style files for several languages. Each style file
| may modify AUCTeX to better support the language, and will run a
| language specific hook that will allow you to for example change ispell
| dictionary, or run code to change the keyboard remapping. The
| following will for example choose a Danish dictionary for documents
| including `\usepackage[danish]{babel}'. This requires parsing to be
| enabled, *note Parsing Files::.
|
| (add-hook 'TeX-language-dk-hook
| (function (lambda () (ispell-change-dictionary "danish"))))
|
| The following style files are recognized.
| [...]
| `danish'
| Runs style hook `TeX-language-dk-hook'. Pressing <"> will insert
| `"`' and `"'' depending on context.
|
| `dutch' [...]
`----
Just a quick note: the one swedish dictionary I seem to have installed
goes under the name "svenska". Could someone verify that
(ispell-change-dictionary "danish") is OK above, or if we need to use
"dansk".

/JÅ
--
Linux: The choice of a GNU generation.
Frank Küster
2005-01-19 08:50:30 UTC
Permalink
Post by Jan-Ake Larsson
Post by Reiner Steib
,----[ (info "(auctex)European") ]
| AUCTeX supports style files for several languages. Each style file
| may modify AUCTeX to better support the language, and will run a
| language specific hook that will allow you to for example change ispell
| dictionary, or run code to change the keyboard remapping. The
| following will for example choose a Danish dictionary for documents
| including `\usepackage[danish]{babel}'. This requires parsing to be
| enabled, *note Parsing Files::.
|
| (add-hook 'TeX-language-dk-hook
| (function (lambda () (ispell-change-dictionary "danish"))))
|
| The following style files are recognized.
| [...]
| `danish'
| Runs style hook `TeX-language-dk-hook'. Pressing <"> will insert
| `"`' and `"'' depending on context.
|
| `dutch' [...]
`----
Just a quick note: the one swedish dictionary I seem to have installed
goes under the name "svenska". Could someone verify that
(ispell-change-dictionary "danish") is OK above, or if we need to use
"dansk".
Debian ships the following files in the idanish dictionary package:

usr/lib/ispell/danish.aff text/idanish
usr/lib/ispell/danish.hash text/idanish
usr/lib/ispell/dansk.aff text/idanish
usr/lib/ispell/dansk.hash text/idanish
usr/share/doc/idanish/README text/idanish
usr/share/doc/idanish/README.Debian text/idanish
usr/share/doc/idanish/changelog.Debian.gz text/idanish
usr/share/doc/idanish/contributors.gz text/idanish
usr/share/doc/idanish/copyright text/idanish

I guess danish is a symlink to dans, or vice versa, and it doesn't matter.

Regards, Frank
--
Frank Küster
Inst. f. Biochemie der Univ. Zürich
Debian Developer
Reiner Steib
2005-01-20 20:08:08 UTC
Permalink
[...]
Post by Jan-Ake Larsson
Post by Reiner Steib
| (add-hook 'TeX-language-dk-hook
| (function (lambda () (ispell-change-dictionary "danish"))))
[...]
Post by Jan-Ake Larsson
Just a quick note: the one swedish dictionary I seem to have installed
goes under the name "svenska". Could someone verify that
(ispell-change-dictionary "danish") is OK above, or if we need to use
"dansk".
I think this depends on your distributor and configuration, so we
cannot give the exact name.

Bye, Reiner.
--
,,,
(o o)
---ooO-(_)-Ooo--- | PGP key available | http://rsteib.home.pages.de/
Loading...