emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] 211/299: Adapt style/babel.el to babel 3.9.


From: Stefan Monnier
Subject: [elpa] 211/299: Adapt style/babel.el to babel 3.9.
Date: Sun, 02 Nov 2014 03:11:30 +0000

monnier pushed a commit to branch externals/auctex
in repository elpa.

commit 59c80eb0431a76b732fe2e2cfadcbd75da33a2d7
Author: Mosè Giordano <address@hidden>
Date:   Wed Jan 15 16:19:13 2014 +0100

    Adapt style/babel.el to babel 3.9.
    
    * style/babel.el: Update copyright years and specify last `babel'
    version supported.
    (LaTeX-babel-language-list): Expand language list to all languages
    mentioned in the last version of the manual.
    (LaTeX-babel-active-languages): Update in order to parse the
    `main' option and ignore the modifiers.
    (LaTeX-babel-package-options): Turn the variable into a function
    because now requires `TeX-read-key-val'.
---
 ChangeLog      |   11 +++++
 style/babel.el |  114 ++++++++++++++++++++++++++++++++++++++++++++-----------
 2 files changed, 102 insertions(+), 23 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 1bac4ee..cc6ec9c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2014-01-15  Mos� Giordano  <address@hidden>
+
+       * style/babel.el: Update copyright years and specify last `babel'
+       version supported.
+       (LaTeX-babel-language-list): Expand language list to all languages
+       mentioned in the last version of the manual.
+       (LaTeX-babel-active-languages): Update in order to parse the
+       `main' option and ignore the modifiers.
+       (LaTeX-babel-package-options): Turn the variable into a function
+       because now requires `TeX-read-key-val'.
+
 2014-01-11  Mos� Giordano  <address@hidden>
 
        * latex.el (LaTeX-current-environment): Make search for `\begin'
diff --git a/style/babel.el b/style/babel.el
index 784732d..36c93be 100755
--- a/style/babel.el
+++ b/style/babel.el
@@ -1,6 +1,6 @@
-;;; babel.el --- AUCTeX style for `babel.sty'
+;;; babel.el --- AUCTeX style for `babel.sty' version 3.9h.
 
-;; Copyright (C) 2005, 2007, 2013 Free Software Foundation, Inc.
+;; Copyright (C) 2005, 2007, 2013-2014 Free Software Foundation, Inc.
 
 ;; Author: Ralf Angeli <address@hidden>
 ;; Maintainer: address@hidden
@@ -26,31 +26,63 @@
 
 ;;; Commentary:
 
-;; This file adds support for `babel.sty'.
+;; This file adds support for `babel.sty' version 3.9h.
 
 ;;; Code:
 
 (defvar LaTeX-babel-language-list
-  '("acadian" "albanian" "afrikaans" "american" "australian" "austrian" 
"bahasa"
-    "indonesian" "indon" "bahasai" "malay" "meyalu" "bahasam" "basque" "brazil"
-    "brazilian" "breton" "british" "bulgarian" "canadian" "canadien" "catalan"
-    "croatian" "czech" "danish" "dutch" "english" "esperanto" "estonian" 
"finnish"
-    "francais" "frenchb" "french" "galician" "german" "germanb" "greek"
-    "polutonikogreek" "hebrew" "hungarian" "icelandic" "interlingua" "irish"
-    "italian" "latin" "lowersorbian" "magyar" "naustrian" "newzealand" 
"ngerman"
-    "norsk" "samin" "nynorsk" "polish" "portuges" "portuguese" "romanian"
-    "russian" "scottish" "serbian" "slovak" "slovene" "spanish" "swedish" 
"turkish"
-    "ukrainian" "uppersorbian" "welsh" "UKenglish" "USenglish")
+  '("afrikaans"
+    "bahasa" "indonesian" "indon" "bahasai" "bahasam" "malay" "meyalu"
+    "basque"
+    "breton"
+    "bulgarian"
+    "catalan"
+    "croatian"
+    "czech"
+    "danish"
+    "dutch"
+    "english" "USenglish" "american" "UKenglish" "british"  "canadian"
+    "australian" "newzealand"
+    "esperanto"
+    "estonian"
+    "finnish"
+    "french" "francais" "canadien" "acadian"
+    "galician"
+    "austrian" "german" "germanb" "ngerman" "naustrian"
+    "greek" "polutonikogreek"
+    "hebrew"
+    "icelandic"
+    "interlingua"
+    "irish"
+    "italian"
+    "latin"
+    "lowersorbian"
+    "samin"
+    "norsk" "nynorsk"
+    "polish"
+    "portuges" "portuguese" "brazilian" "brazil"
+    "romanian"
+    "russian"
+    "scottish"
+    "spanish"
+    "slovak"
+    "slovene"
+    "swedish"
+    "serbian"
+    "turkish"
+    "ukrainian"
+    "uppersorbian"
+    "welsh"
+    ;; Extra languages mentioned in the `babel' manual.
+    "albanian" "hindi" "thai" "thaicjk" "latvian" "turkmen" "hungarian" 
"magyar"
+    "mongolian" "romansh" "lithuanian" "spanglish" "vietnamese" "japanese"
+    "pinyin" "arabinc" "farsi" "ibygreek" "bgreek" "serbianic" "frenchle"
+    "ethiop" "friulan" "frenchb")
   "List of languages supported by the babel LaTeX package.")
 
-(defvar LaTeX-babel-package-options
-  (append LaTeX-babel-language-list '("activeacute" "activegrave"
-                                     "KeepShorthandsActive"))
-  "Package options for the babel package.")
-
 (defun LaTeX-babel-active-languages ()
   "Return a list of languages used in the document."
-  (let (active-languages)
+  (let (main-language active-languages)
     ;; Loop over options provided to class and `babel' package at load time.
     (dolist (elt (append
                  ;; In most cases there is only one element in the alist, if
@@ -59,10 +91,25 @@
                  ;; take the car of `LaTeX-provided-class-options'.
                  (cdr (car LaTeX-provided-class-options))
                  (cdr (assoc "babel" LaTeX-provided-package-options))))
-      (when (member elt LaTeX-babel-language-list)
-       ;; Append element to `active-languages' to respect loading order.
-       ;; `babel' package uses as default language the last loaded one.
-       (add-to-list 'active-languages elt t)))
+      (setq elt (TeX-split-string "=" elt))
+      (if (equal (car elt) "main")
+         ;; Starting from version 3.9 of `babel' package, languages can be set
+         ;; with the following syntax:
+         ;;   \usepackage[latin.medieval,main=danish,spanish.notilde]{babel}
+         ;; with `danish' being the default language.  When the default
+         ;; language is set with the `main' option, we record it and append to
+         ;; the list at the end.
+         (setq main-language (car (cdr elt)))
+       ;; Get rid of the modifiers (`medieval' and `notilde' in the above
+       ;; example).
+       (setq elt (car (TeX-split-string "\\." (car elt))))
+       (if (member elt LaTeX-babel-language-list)
+           ;; Append element to `active-languages' to respect loading order.
+           ;; `babel' package uses as default language the last loaded one,
+           ;; except if it is set with the `main' option.
+           (add-to-list 'active-languages elt t))))
+    (if main-language
+       (add-to-list 'active-languages main-language t))
     active-languages))
 
 (defun TeX-arg-babel-lang (optional &optional prompt)
@@ -122,4 +169,25 @@
                                ("languageattribute" "{{"))
                              'variable))))
 
+(defun LaTeX-babel-package-options ()
+  "Prompt for package options for the babel package."
+  (TeX-read-key-val
+   t
+   (append
+    '(("KeepShorthandsActive")
+      ("activeacute")
+      ("activegrave")
+      ("shorthands")
+      ("safe" ("none" "ref" "bib"))
+      ("math" ("active" "normal"))
+      ("config")
+      ("main" LaTeX-babel-language-list)
+      ("headfoot" LaTeX-babel-language-list)
+      ("noconfigs")
+      ("showlanguages")
+      ("strings" ("generic" "unicode" "encoded"))
+      ("hyphenmap" ("off" "main" "select" "other" "other*"))
+      ("base"))
+    (mapcar 'list LaTeX-babel-language-list))))
+
 ;;; babel.el ends here



reply via email to

[Prev in Thread] Current Thread [Next in Thread]