branch: externals/guess-language commit cc11ec643e77e8e0d5604f2c991c2fff3131a334 Author: Titus von der Malsburg <malsb...@posteo.de> Commit: Titus von der Malsburg <malsb...@posteo.de>
README: More details about configuration. --- README.org | 59 +++++++++++++++++++++++++++++++++++++------------------ guess-language.el | 44 ++++++++++++++++++++++++----------------- 2 files changed, 66 insertions(+), 37 deletions(-) diff --git a/README.org b/README.org index d2441f2..2905e67 100644 --- a/README.org +++ b/README.org @@ -36,27 +36,48 @@ Guess-language-mode is available through [[https://melpa.org/#/guess-language][M (setq guess-language-min-paragraph-length 35) #+END_SRC +~guess-language-languages~ defines the candidate languages that should be considered. Only include languages that you actually use to improve performance. Languages are identified using ISO 639-1 codes (see table below). + +~guess-language-min-paragraph-length~ specifies the minimal length that a paragraph needs to have before guess-language-mode starts guessing. + +For each language, there is a default Ispell dictionary that guess-language-mode tries to use. However, for some languages there are several dictionaries available and guess-language can’t know which one you’d like to use. For example, there are several different dictionaries for German and for English. If the dictionary that guess-language-mode uses by default is not present, you will get an error message like the following: + +#+BEGIN_SRC elisp +Error in post-command-hook (flyspell-post-command-hook): (error "Undefined dictionary: en") +#+END_SRC + +In this case, use the variable ~guess-language-langcodes~ to tell guess-language-mode which dictionary should be used instead. For example, use the following definition if you want to use British English and Swiss German: + +#+BEGIN_SRC elisp +(setq guess-language-langcodes + '((en . ("en_GB" "English")) + (de . ("de_CH" "German")))) +#+END_SRC + + + Available languages at this time: -| IDO 639-1 code | Language | -|----------------+------------| -| ~ar~ | Arabic | -| ~cs~ | Czech | -| ~da~ | Danish | -| ~nl~ | Dutch | -| ~en~ | English | -| ~es~ | Spanish | -| ~fi~ | Finnish | -| ~fr~ | French | -| ~de~ | German | -| ~it~ | Italian | -| ~nb~ | Norwegian | -| ~pl~ | Polish | -| ~pt~ | Portuguese | -| ~ru~ | Russian | -| ~sk~ | Slovak | -| ~sl~ | Slovenian | -| ~sv~ | Swedish | +| Language | IDO 639-1 code | Ispell dictionary | Typo-mode setting | +|------------+----------------+-------------------+-------------------| +| Arabic | ~ar~ | ar | | +| Czech | ~cs~ | czech | Czech | +| Danish | ~da~ | dansk | | +| Dutch | ~nl~ | de | | +| English | ~en~ | en | English | +| Finnish | ~fi~ | finnish | Finnish | +| French | ~fr~ | francais | French | +| German | ~de~ | de | German | +| Italian | ~it~ | italiano | Italian | +| Norwegian | ~nb~ | norsk | | +| Polish | ~pl~ | polish | | +| Portuguese | ~pt~ | portuguese | | +| Russian | ~ru~ | russian | Russian | +| Slovak | ~sk~ | slovak | | +| Slovenian | ~sl~ | slovenian | | +| Spanish | ~es~ | spanish | | +| Swedish | ~sv~ | svenska | | + ** Usage diff --git a/guess-language.el b/guess-language.el index b7bab34..347fc7d 100644 --- a/guess-language.el +++ b/guess-language.el @@ -80,26 +80,34 @@ little material to reliably guess the language." (defvar guess-language-regexps nil "The regular expressions that are used to count trigrams.") -(defvar guess-language-langcodes - '( - (ar . ("ar" nil)) - (cs . ("czech" "Czech")) - (da . ("dansk" nil)) - (de . ("de" "German")) - (en . ("en" "English")) - (es . ("spanish" nil)) - (fi . ("finnish" "Finnish")) - (fr . ("francais" "French")) - (it . ("italiano" "Italian")) - (nb . ("norsk" nil)) +(defcustom guess-language-langcodes + '((ar . ("ar" nil)) + (cs . ("czech" "Czech")) + (da . ("dansk" nil)) + (de . ("de" "German")) + (en . ("en" "English")) + (es . ("spanish" nil)) + (fi . ("finnish" "Finnish")) + (fr . ("francais" "French")) + (it . ("italiano" "Italian")) + (nb . ("norsk" nil)) (nl . ("nederlands" nil)) - (pl . ("polish" nil)) + (pl . ("polish" nil)) (pt . ("portuguese" nil)) - (ru . ("russian" "Russian")) - (sk . ("slovak" nil)) - (sl . ("slovenian" nil)) - (sv . ("svenska" nil))) - "Language codes for Ispell and typo-mode.") + (ru . ("russian" "Russian")) + (sk . ("slovak" nil)) + (sl . ("slovenian" nil)) + (sv . ("svenska" nil))) + "Language codes for Ispell and typo-mode. The key is a symbol +giving the ISO 639-1 code of the language. The values is a list +with two elements. The first is the name of the Ispell +dictionary that should be used (i.e., what you would enter when +setting the language with `ispell-change-dictionary'. The second +element is the name of the language setting that should be used +with typo-mode. If a language is not supported by typo-mode, +enter `nil'." + :type '(alist :key-type symbol :value-type list) + :group 'guess-language) (defun guess-language-load-trigrams () "Load language statistics."