branch: externals/guess-language
commit 9117deb0e4df2fe515d097cf21b952dce6819429
Author: Titus von der Malsburg <malsb...@posteo.de>
Commit: Titus von der Malsburg <malsb...@posteo.de>

    Made it easier to add new languages.
---
 guess-language.el | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/guess-language.el b/guess-language.el
index afc8170..38e7a28 100644
--- a/guess-language.el
+++ b/guess-language.el
@@ -56,6 +56,12 @@ 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
+  '((de . ("de" "German"))
+    (en . ("en" "English"))
+    (fr . ("francais" "French")))
+  "Language codes for ispell and typo-mode.")
+
 (defun guess-language-load-trigrams ()
   (cl-loop
    for lang in guess-language-languages
@@ -104,16 +110,10 @@ little material to reliably guess the language."
   "Detects language of the current paragraph and sets things like
 ispell dictionaries accordingly."
   (interactive)
-  (pcase (guess-language-paragraph)
-    ('de (progn
-           (ispell-change-dictionary "de")
-           (typo-change-language "German")))
-    ('en (progn
-           (ispell-change-dictionary "en")
-           (typo-change-language "English")))
-    ('fr (progn
-           (ispell-change-dictionary "francais")
-           (typo-change-language "French")))))
+  (let* ((lang (guess-language-paragraph))
+         (codes (cdr (assoc lang guess-language-langcodes))))
+    (ispell-change-dictionary (car codes))
+    (typo-change-language (cadr codes))))
 
 (defun guess-language-autoset-and-spellcheck-maybe (beginning end doublon)
   "Runs `guess-language-autoset' and then the flyspell on the

Reply via email to