Subject: Re: bug#63396: \foreignlanguage in babel style file

From: Arash Esbati <[email-masked]>
Date: Wed, 10 May 2023 09:45:43 +0200

Hi Gustavo,

Gustavo Barros <[email-masked]> writes:

> just a quick and simple one.
>
> `\foreignlanguage' specs in `babel.el' are missing the optional
> argument it takes, both in `TeX-add-symbol` and in
> `font-latex-add-keywords`.
>
> Also, `\foreignlanguage' is included in the `function' font-lock
> class. Arguably `textual' would be a much better fit for it.

Thanks for the report.  You were thinking about a change like this?

--8<---------------cut here---------------start------------->8---
diff --git a/style/babel.el b/style/babel.el
index 2483b73b..2110289b 100644
--- a/style/babel.el
+++ b/style/babel.el
@@ -256,6 +256,7 @@
       (TeX-arg-completing-read (LaTeX-babel-active-languages)
                                "Language"))
     '("foreignlanguage"
+      [TeX-arg-completing-read-multiple ("date" "captions")]
       (TeX-arg-completing-read (LaTeX-babel-active-languages)
                                "Language")
       t)
@@ -374,7 +375,6 @@
    (when (and (featurep 'font-latex)
               (eq TeX-install-font-lock 'font-latex-setup))
      (font-latex-add-keywords '(("selectlanguage"     "{")
-                                ("foreignlanguage"    "{{")
                                 ("babeltags"          "{")
                                 ("babelensure"        "{{")
                                 ("shorthandon"        "{")
@@ -394,7 +394,9 @@
      (font-latex-add-keywords '(("defineshorthand"    "[{{")
                                 ("aliasshorthand"     "{{")
                                 ("languageattribute"  "{{"))
-                              'variable)))
+                              'variable)
+     (font-latex-add-keywords '(("foreignlanguage"    "[{{"))
+                              'textual)))
  TeX-dialect)

 (defvar LaTeX-babel-package-options-list
--8<---------------cut here---------------end--------------->8---

Best, Arash