[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/auctex 945ffaf 40/80: Update style/babel.el to package
From: |
Tassilo Horn |
Subject: |
[elpa] externals/auctex 945ffaf 40/80: Update style/babel.el to package version 3.31 |
Date: |
Wed, 16 Oct 2019 11:07:13 -0400 (EDT) |
branch: externals/auctex
commit 945ffaf985884b768acaeb1c05086a4f69d3a63a
Author: Arash Esbati <address@hidden>
Commit: Arash Esbati <address@hidden>
Update style/babel.el to package version 3.31
* style/babel.el (LaTeX-babel-language-list): Add azerbaijani and
remove frenchb.
(LaTeX-babel-babelprovide-key-val-options): New variable.
(LaTeX-babel-babeltags-regexp, LaTeX-babel-cleanup-babeltags): Add
parsing support for \babeltags macro.
(LaTeX-babel-babelfont-regexp, LaTeX-babel-cleanup-babelfont): Add
parsing support for \babelfont macro.
(TeX-arg-babel-lang): Use the arguments optional and prompt
properly.
("babel"): Add missing macros incl. fontification.
(LaTeX-babel-package-options): Add missing package options.
---
style/babel.el | 287 +++++++++++++++++++++++++++++++++++++++++++++++++++------
1 file changed, 258 insertions(+), 29 deletions(-)
diff --git a/style/babel.el b/style/babel.el
index 52ee8ee..38a51ab 100644
--- a/style/babel.el
+++ b/style/babel.el
@@ -1,6 +1,6 @@
-;;; babel.el --- AUCTeX style for `babel.sty' version 3.9h.
+;;; babel.el --- AUCTeX style for `babel.sty' version 3.31.
-;; Copyright (C) 2005, 2007, 2013-2014, 2018 Free Software Foundation, Inc.
+;; Copyright (C) 2005, 2007, 2013-2019 Free Software Foundation, Inc.
;; Author: Ralf Angeli <address@hidden>
;; Maintainer: address@hidden
@@ -26,13 +26,16 @@
;;; Commentary:
-;; This file adds support for `babel.sty' version 3.9h.
+;; This file adds support for `babel.sty' version 3.31 from 2019/05/04.
;;; Code:
(eval-when-compile
(require 'cl-lib))
+;; Needed for auto-parsing.
+(require 'tex)
+
;; Silence the compiler:
(declare-function font-latex-add-keywords
"font-latex"
@@ -40,6 +43,7 @@
(defvar LaTeX-babel-language-list
'("afrikaans"
+ "azerbaijani"
"bahasa" "indonesian" "indon" "bahasai" "bahasam" "malay" "meyalu"
"basque"
"breton"
@@ -85,9 +89,21 @@
"albanian" "hindi" "thai" "thaicjk" "latvian" "turkmen" "hungarian"
"magyar"
"mongolian" "romansh" "lithuanian" "spanglish" "vietnamese" "japanese"
"pinyin" "arabinc" "farsi" "ibygreek" "bgreek" "serbianic" "frenchle"
- "ethiop" "friulan" "frenchb")
+ "ethiop" "friulan")
"List of languages supported by the babel LaTeX package.")
+(defvar LaTeX-babel-babelprovide-key-val-options
+ `(("import")
+ ("captions")
+ ("hyphenrules" ,(append '("+") LaTeX-babel-language-list))
+ ("main")
+ ("script")
+ ("language")
+ ("mapfont")
+ ("intraspace")
+ ("intrapenalty"))
+ "Key=value options for `\\babelprovide' macro from `babel' package.")
+
(defun LaTeX-babel-active-languages ()
"Return a list of languages used in the document."
(let (main-language active-languages)
@@ -117,13 +133,109 @@
;; except if it is set with the `main' option.
(cl-pushnew elt active-languages :test #'equal))))
(if main-language
- (cl-pushnew main-language active-languages :test #'equal))
+ (cl-pushnew main-language active-languages :test #'equal))
(nreverse active-languages)))
-(defun TeX-arg-babel-lang (_optional &optional _prompt)
+;; Setup for \babeltags: Note that the macros is \babeltags, we use
+;; the version without `s' in order to reduce the hassle with AUCTeX
+;; auto-generating the plural form:
+(TeX-auto-add-type "babel-babeltag" "LaTeX")
+
+(defvar LaTeX-babel-babeltags-regexp
+ '("\\\\babeltags{\\([^}]+\\)}" 1 LaTeX-auto-babel-babeltag)
+ "Matches the argument of `\\babeltags' from `babel' package.")
+
+(defun LaTeX-babel-cleanup-babeltags ()
+ "Parse defined babel tags and add them to AUCTeX."
+ ;; Check if we parsed something at all
+ (when (LaTeX-babel-babeltag-list)
+ (let (results tag tags cmds)
+ ;; Clean up the parsed results from characters we don't want;
+ ;; also remove possible comment lines
+ (setq results
+ (replace-regexp-in-string
+ "\\(%.*$\\|[ \n\r\t]\\)" ""
+ (mapconcat #'car (LaTeX-babel-babeltag-list) ",")))
+ ;; Look if \babeltags was issued once with multiple entries or
+ ;; more than once in the document:
+ (if (string-match-p "," results)
+ (progn
+ (dolist (elt (split-string results "," t))
+ (setq tag (car (split-string elt "=" t)))
+ (push tag tags)
+ (push (list (concat "text" tag) t) cmds)
+ (push (list tag -1) cmds)))
+ ;; One \babeltags with one entry only
+ (setq tag (car (split-string results "=" t)))
+ (push tag tags)
+ (push (list (concat "text" tag) t) cmds)
+ (push (list tag -1) cmds))
+ (mapc #'TeX-add-symbols cmds)
+ (mapc #'LaTeX-add-environments tags)
+ ;; Fontification
+ (when (and (featurep 'font-latex)
+ (eq TeX-install-font-lock 'font-latex-setup))
+ (font-latex-add-keywords (mapcar (lambda (x)
+ (list (concat "text" x) "{"))
+ tags)
+ 'textual)
+ (font-latex-add-keywords (mapcar (lambda (x)
+ (list x ""))
+ tags)
+ 'type-declaration)))))
+
+;; Setup for \babelfont:
+(TeX-auto-add-type "babel-babelfont" "LaTeX")
+
+(defvar LaTeX-babel-babelfont-regexp
+ '("\\\\babelfont\\(?:\\[[^]]*\\]\\)?[ \t\n\r%]*{\\([^}]+\\)}"
+ 1 LaTeX-auto-babel-babelfont)
+ "Matches the <font-family> argument of `\\babelfont' from `babel' package.")
+
+(defun LaTeX-babel-cleanup-babelfont ()
+ "Parse defined font-families and add them to AUCTeX."
+ (when (LaTeX-babel-babelfont-list)
+ (dolist (elt (mapcar #'car (LaTeX-babel-babelfont-list)))
+ ;; Don't do anything for standard font-families:
+ (unless (member elt '("rm" "sf" "tt"))
+ ;; Define \<font>family, \<font>default and \text<font>:
+ (let ((fam (concat elt "family"))
+ (def (concat elt "default"))
+ (mac (concat "text" elt)))
+ (apply #'TeX-add-symbols
+ `((,fam -1)
+ (,def -1)
+ (,mac t)))
+ ;; Cater for fontification:
+ (when (and (featurep 'font-latex)
+ (eq TeX-install-font-lock 'font-latex-setup))
+ (font-latex-add-keywords `((,fam "")
+ (,def ""))
+ 'type-declaration)
+ (font-latex-add-keywords `((,mac "{"))
+ 'type-command)))))))
+
+(defun LaTeX-babel-auto-prepare ()
+ "Clear `LaTeX-auto-babel-babel*' before parsing."
+ (setq LaTeX-auto-babel-babeltag nil
+ LaTeX-auto-babel-babelfont nil))
+
+(defun LaTeX-babel-auto-cleanup ()
+ "Process parsed elements."
+ (LaTeX-babel-cleanup-babeltags)
+ (LaTeX-babel-cleanup-babelfont))
+
+(add-hook 'TeX-auto-prepare-hook #'LaTeX-babel-auto-prepare t)
+(add-hook 'TeX-auto-cleanup-hook #'LaTeX-babel-auto-cleanup t)
+(add-hook 'TeX-update-style-hook #'TeX-auto-parse t)
+
+(defun TeX-arg-babel-lang (optional &optional prompt)
"Prompt for a language with completion and insert it as an argument."
(TeX-argument-insert
- (completing-read "Language: " (LaTeX-babel-active-languages)) nil))
+ (completing-read
+ (TeX-argument-prompt optional prompt "Language")
+ (LaTeX-babel-active-languages))
+ optional))
(defun LaTeX-env-babel-lang (env)
"Prompt for a language and insert it as an argument of ENV."
@@ -135,46 +247,153 @@
"Load style files of babel active languages."
;; Run style hooks for every active language in loading order, so
;; `TeX-quote-language' will be correctly set.
- (mapc 'TeX-run-style-hooks (LaTeX-babel-active-languages)))
+ (mapc #'TeX-run-style-hooks (LaTeX-babel-active-languages)))
(TeX-add-style-hook
"babel"
(lambda ()
(LaTeX-babel-load-languages)
(add-hook 'LaTeX-after-usepackage-hook 'LaTeX-babel-load-languages nil t)
+
+ ;; Add babel to the parser.
+ (TeX-auto-add-regexp LaTeX-babel-babeltags-regexp)
+ (TeX-auto-add-regexp LaTeX-babel-babelfont-regexp)
+
;; New symbols
(TeX-add-symbols
+
+ ;; 1.7 Basic language selectors
'("selectlanguage" TeX-arg-babel-lang)
'("foreignlanguage" TeX-arg-babel-lang t)
- "languagename"
- '("iflanguage" TeX-arg-babel-lang t nil)
- '("useshorthands" t)
- '("defineshorthand" t nil)
- '("aliasshorthand" t nil)
+
+ ;; 1.9 More on selection
+ '("babeltags" t)
+ '("babelensure" (TeX-arg-key-val
+ (("include") ("exclude")
+ ("fontenc" (;; 128+ glyph encodings (text)
+ "OT1" "OT2" "OT3" "OT4" "OT6"
+ ;; 256 glyph encodings (text)
+ "T1" "T2A" "T2B" "T2C" "T3" "T4" "T5"
+ ;; 256 glyph encodings (text extended)
+ "X2"
+ ;; Other encodings
+ "LY1" "LV1" "LGR"))))
+ TeX-arg-babel-lang)
+ ;; 1.10 Shorthands
+ '("shorthandon" "Shorthands list")
+ '("shorthandoff" "Shorthands list")
+ '("shorthandoff*" "Shorthands list")
+ '("useshorthands" "Character")
+ '("useshorthands*" "Character")
+ '("defineshorthand"
+ [ TeX-arg-eval mapconcat #'identity
+ (TeX-completing-read-multiple
+ (TeX-argument-prompt optional nil "Language(s)")
+ (LaTeX-babel-active-languages)) ""]
+ t nil)
+ '("aliasshorthand" "Original" "Alias")
'("languageshorthands" TeX-arg-babel-lang)
- '("shorthandon" t)
- '("shorthandoff" t)
+ '("babelshorthand" "Short hand")
+ '("ifbabelshorthand" "Character" t nil)
+
+ ;; 1.12 The base option
+ '("AfterBabelLanguage"
+ (TeX-arg-eval completing-read
+ (TeX-argument-prompt optional nil "Language")
+ LaTeX-babel-language-list)
+ t)
+
+ ;; 1.14 Selecting fonts
+ '("babelfont"
+ [ TeX-arg-eval mapconcat #'identity
+ (TeX-completing-read-multiple
+ (TeX-argument-prompt optional nil "Language(s)")
+ LaTeX-babel-language-list)
+ "," ]
+ ;; LaTeX-arg-babel-babelfont
+ (TeX-arg-eval let ((fontfam (completing-read
+ (TeX-argument-prompt optional nil "font
family")
+ '("rm" "sf" "tt"))))
+ ;; Make sure `tex-buf.el' is also loaded otherwise
+ ;; `TeX-check-engine-add-engines' is not defined.
+ ;; Then load `fontspec.el' and make sure the
+ ;; key-vals are up to date.
+ (unless (member "fontspec" (TeX-style-list))
+ (require 'tex-buf)
+ (TeX-check-engine-add-engines 'luatex 'xetex)
+ (TeX-run-style-hooks "fontspec")
+ (LaTeX-fontspec-auto-cleanup))
+ (LaTeX-add-babel-babelfonts fontfam)
+ (LaTeX-babel-cleanup-babelfont)
+ (format "%s" fontfam))
+ [ TeX-arg-key-val LaTeX-fontspec-font-features-local]
+ LaTeX-fontspec-arg-font)
+
+ ;; 1.16 Creating a language
+ '("babelprovide"
+ [ TeX-arg-key-val LaTeX-babel-babelprovide-key-val-options ]
+ (TeX-arg-eval completing-read
+ (TeX-argument-prompt optional nil "Language")
+ LaTeX-babel-language-list))
+
+ ;; 1.18 Getting the current language name
+ '("languagename" 0)
+ '("iflanguage" TeX-arg-babel-lang t nil)
+
+ ;; 1.19 Hyphenation and line breaking
+ '("babelhyphen"
+ (TeX-arg-eval completing-read
+ (TeX-argument-prompt optional nil "Type/Text")
+ '("soft" "hard" "repeat" "empty")))
+ '("babelhyphen*"
+ (TeX-arg-eval completing-read
+ (TeX-argument-prompt optional nil "Type/Text")
+ '("soft" "hard" "repeat" "empty")))
+
+ '("babelhyphenation"
+ [ TeX-arg-eval mapconcat #'identity
+ (TeX-completing-read-multiple
+ (TeX-argument-prompt optional nil "Language(s)")
+ LaTeX-babel-language-list)
+ "," ]
+ t)
+
+ ;; 1.20 Selecting scripts
+ '("ensureascii" "Text")
+
+ ;; 1.22 Language attributes
'("languageattribute" TeX-arg-babel-lang t))
- ;; New environments
+
+ ;; New environments: 1.8 Auxiliary language selectors
(LaTeX-add-environments
'("otherlanguage" LaTeX-env-babel-lang)
'("otherlanguage*" LaTeX-env-babel-lang)
'("hyphenrules" LaTeX-env-babel-lang))
+
;; Fontification
(when (and (featurep 'font-latex)
(eq TeX-install-font-lock 'font-latex-setup))
- (font-latex-add-keywords '(("selectlanguage" "{")
- ("foreignlanguage" "{{")
- ("iflanguage" "{{{")
- ("languagename" "")
- ("useshorthands" "{")
+ (font-latex-add-keywords '(("selectlanguage" "{")
+ ("foreignlanguage" "{{")
+ ("babeltags" "{")
+ ("babelensure" "{{")
+ ("shorthandon" "{")
+ ("shorthandoff" "*{")
+ ("useshorthands" "*{")
("languageshorthands" "{")
- ("shorthandon" "{")
- ("shorthandoff" "{"))
+ ("babelshorthand" "{")
+ ("AfterBabelLanguage" "{")
+ ("babelfont" "[{[{")
+ ("babelprovide" "[{")
+ ("languagename" "")
+ ("iflanguage" "{{{")
+ ("babelhyphen" "*{")
+ ("babelhyphenation" "[{")
+ ("ensureascii" "{"))
'function)
- (font-latex-add-keywords '(("defineshorthand" "{{")
- ("aliasshorthand" "{{")
- ("languageattribute" "{{"))
+ (font-latex-add-keywords '(("defineshorthand" "[{{")
+ ("aliasshorthand" "{{")
+ ("languageattribute" "{{"))
'variable)))
LaTeX-dialect)
@@ -186,17 +405,27 @@
'(("KeepShorthandsActive")
("activeacute")
("activegrave")
- ("shorthands")
+ ("shorthands" ("off"))
("safe" ("none" "ref" "bib"))
("math" ("active" "normal"))
("config")
("main" LaTeX-babel-language-list)
("headfoot" LaTeX-babel-language-list)
("noconfigs")
+ ("nocase")
+ ("silent")
("showlanguages")
- ("strings" ("generic" "unicode" "encoded"))
+ ("nocase")
+ ("silent")
+ ("strings" ("generic" "unicode" "encoded"
+ "OT1" "OT2" "OT3" "OT4" "OT6"
+ "T1" "T2A" "T2B" "T2C" "T3" "T4" "T5"
+ "X2" "LY1" "LV1" "LGR"))
("hyphenmap" ("off" "main" "select" "other" "other*"))
+ ("bidi" ("default" "basic" "basic-r" "bidi-l" "bidi-r"))
+ ("layout" ("sectioning" "counters" "lists" "captions"
+ "contents" "footnotes" "columns" "extras"))
("base"))
- (mapcar 'list LaTeX-babel-language-list))))
+ (mapcar #'list LaTeX-babel-language-list))))
;;; babel.el ends here
- [elpa] externals/auctex a9eb155 37/80: Fix regression, (continued)
- [elpa] externals/auctex a9eb155 37/80: Fix regression, Tassilo Horn, 2019/10/16
- [elpa] externals/auctex af15814 42/80: ; * style/babel.el: Fix typo, remove code remainder., Tassilo Horn, 2019/10/16
- [elpa] externals/auctex 5208d91 50/80: Enhance support for file names with spaces, Tassilo Horn, 2019/10/16
- [elpa] externals/auctex 1a83f1b 09/80: ; Remove `eval-when-compile' for latex.el, Tassilo Horn, 2019/10/16
- [elpa] externals/auctex ddd7894 20/80: ; Fix last commit, Tassilo Horn, 2019/10/16
- [elpa] externals/auctex c92251c 36/80: Load hyperref.el in `LaTeX-beamer-class-options', Tassilo Horn, 2019/10/16
- [elpa] externals/auctex d4660dd 18/80: * style/xparse.el ("xparse"): Fix fontification of alternatives., Tassilo Horn, 2019/10/16
- [elpa] externals/auctex b62181c 29/80: ; Remove unused code fragment, Tassilo Horn, 2019/10/16
- [elpa] externals/auctex 400b002 28/80: Remove obsolete codes, Tassilo Horn, 2019/10/16
- [elpa] externals/auctex 0cc2578 39/80: ; Use the correct variable `LaTeX-fontspec-font-features', Tassilo Horn, 2019/10/16
- [elpa] externals/auctex 945ffaf 40/80: Update style/babel.el to package version 3.31,
Tassilo Horn <=
- [elpa] externals/auctex 36d06e2 44/80: ; * tests/latex/preview-latex-test.el: Fix typo., Tassilo Horn, 2019/10/16
- [elpa] externals/auctex 686366e 48/80: ; Add Emacs 24 compatibility to the previous commit, Tassilo Horn, 2019/10/16
- [elpa] externals/auctex 0a9407c 47/80: Conform to `delete-selection-mode' (bug#36385), Tassilo Horn, 2019/10/16
- [elpa] externals/auctex 8530cd0 45/80: Support cleveref labels, Tassilo Horn, 2019/10/16
- [elpa] externals/auctex 4a56103 56/80: Reduce unnecessary local variable safety inquiry, Tassilo Horn, 2019/10/16
- [elpa] externals/auctex b7083ee 51/80: Change color adjustment method (bug#35571, bug#35696, bug#36039), Tassilo Horn, 2019/10/16
- [elpa] externals/auctex 43e98f1 55/80: Update style/titlesec.el to package version 2.11, Tassilo Horn, 2019/10/16
- [elpa] externals/auctex f477383 54/80: Update style/thmtools.el to package version 67, Tassilo Horn, 2019/10/16
- [elpa] externals/auctex ccfd3d9 57/80: Restore syntax fontify in Texinfo mode, Tassilo Horn, 2019/10/16
- [elpa] externals/auctex f127145 60/80: * context.el (ConTeXt-environment): Fix docstring., Tassilo Horn, 2019/10/16