]> code.delx.au - gnu-emacs-elpa/blob - auctex-11.86/style/babel.el
Initial repository contents
[gnu-emacs-elpa] / auctex-11.86 / style / babel.el
1 ;;; babel.el --- AUCTeX style for `babel.sty'
2
3 ;; Copyright (C) 2005 Free Software Foundation, Inc.
4
5 ;; Author: Ralf Angeli <angeli@iwi.uni-sb.de>
6 ;; Maintainer: auctex-devel@gnu.org
7 ;; Created: 2005-05-29
8 ;; Keywords: tex
9
10 ;; This file is part of AUCTeX.
11
12 ;; AUCTeX is free software; you can redistribute it and/or modify it
13 ;; under the terms of the GNU General Public License as published by
14 ;; the Free Software Foundation; either version 3, or (at your option)
15 ;; any later version.
16
17 ;; AUCTeX is distributed in the hope that it will be useful, but
18 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 ;; General Public License for more details.
21
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with AUCTeX; see the file COPYING. If not, write to the Free
24 ;; Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
25 ;; 02110-1301, USA.
26
27 ;;; Commentary:
28
29 ;; This file adds support for `babel.sty'.
30
31 ;;; Code:
32
33 (defvar LaTeX-babel-language-list
34 '("acadian" "afrikaans" "american" "austrian""bahasa" "basque" "brazil"
35 "brazilian" "breton" "british" "bulgarian" "canadian" "canadien"
36 "catalan" "croatian" "czech" "danish" "dutch" "english" "esperanto"
37 "estonian" "finnish" "francais" "frenchb" "french" "galician"
38 "german" "germanb" "greek" "polutonikogreek" "hebrew" "hungarian"
39 "icelandic" "irish" "italian" "latin" "lowersorbian" "magyar"
40 "naustrian" "ngerman" "norsk" "samin" "nynorsk" "polish" "portuges"
41 "portuguese" "romanian" "russian" "scottish" "serbian" "slovak"
42 "slovene" "spanish" "swedish" "turkish" "ukrainian" "uppersorbian"
43 "welsh" "UKenglish" "USenglish")
44 "List of languages supported by the babel LaTeX package.")
45
46 (if (fboundp 'defvaralias)
47 (defvaralias 'LaTeX-babel-package-options 'LaTeX-babel-language-list)
48 (defvar LaTeX-babel-package-options LaTeX-babel-language-list
49 "Package options for the babel package."))
50
51 (defun LaTeX-babel-active-languages ()
52 "Return a list of languages used in the document."
53 (let (active-languages)
54 (dolist (elt LaTeX-babel-language-list)
55 (when (member elt TeX-active-styles)
56 (add-to-list 'active-languages (list elt))))
57 active-languages))
58
59 (defun TeX-arg-babel-lang (optional &optional prompt)
60 "Prompt for a language with completion and insert it as an argument."
61 (TeX-argument-insert
62 (completing-read "Language: " (LaTeX-babel-active-languages)) nil))
63
64 (defun LaTeX-env-babel-lang (env)
65 "Prompt for a language and insert it as an argument of ENV."
66 (LaTeX-insert-environment
67 env (format "{%s}" (completing-read "Language: "
68 (LaTeX-babel-active-languages)))))
69
70 (TeX-add-style-hook
71 "babel"
72 (lambda ()
73 ;; New symbols
74 (TeX-add-symbols
75 '("selectlanguage" TeX-arg-babel-lang)
76 '("foreignlanguage" TeX-arg-babel-lang t)
77 "languagename"
78 '("iflanguage" TeX-arg-babel-lang t nil)
79 '("useshorthands" t)
80 '("defineshorthand" t nil)
81 '("aliasshorthand" t nil)
82 '("languageshorthands" TeX-arg-babel-lang)
83 '("shorthandon" t)
84 '("shorthandoff" t)
85 '("languageattribute" TeX-arg-babel-lang t))
86 ;; New environments
87 (LaTeX-add-environments
88 '("otherlanguage" LaTeX-env-babel-lang)
89 '("otherlanguage*" LaTeX-env-babel-lang)
90 '("hyphenrules" LaTeX-env-babel-lang))
91 ;; Fontification
92 (when (and (featurep 'font-latex)
93 (eq TeX-install-font-lock 'font-latex-setup))
94 (font-latex-add-keywords '(("selectlanguage" "{")
95 ("foreignlanguage" "{{")
96 ("iflanguage" "{{{")
97 ("languagename" "")
98 ("useshorthands" "{")
99 ("languageshorthands" "{")
100 ("shorthandon" "{")
101 ("shorthandoff" "{"))
102 'function)
103 (font-latex-add-keywords '(("defineshorthand" "{{")
104 ("aliasshorthand" "{{")
105 ("languageattribute" "{{"))
106 'variable))))
107
108 ;;; babel.el ends here