auctex-diffs
[Top][All Lists]
Advanced

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

[AUCTeX-diffs] GNU AUCTeX branch, master, updated. 6cac3e59a1d9eaccc52cd


From: Arash Esbati
Subject: [AUCTeX-diffs] GNU AUCTeX branch, master, updated. 6cac3e59a1d9eaccc52cd9116aa28a91cff95760
Date: Thu, 27 Apr 2017 10:14:30 -0400 (EDT)

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU AUCTeX".

The branch, master has been updated
       via  6cac3e59a1d9eaccc52cd9116aa28a91cff95760 (commit)
      from  ef7e48b499461aa53c4099675daeb3a19da4ea1b (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 6cac3e59a1d9eaccc52cd9116aa28a91cff95760
Author: Arash Esbati <address@hidden>
Date:   Thu Apr 27 16:13:26 2017 +0200

    Update style/fontspec.el to package version 2.6a
    
    * style/fontspec.el (LaTeX-fontspec-font-features): Update
    variable to package version 2.6a.
    (LaTeX-fontspec-auto-cleanup): New function for parsing support
    for \newfontfamily and \newfontface macros.
    ("fontspec"): Add missing macros and environment.
    (LaTeX-fontspec-package-options): Update with new options.

diff --git a/style/fontspec.el b/style/fontspec.el
index 5ec7bb4..58f4e48 100644
--- a/style/fontspec.el
+++ b/style/fontspec.el
@@ -1,9 +1,9 @@
-;;; fontspec.el --- AUCTeX style for `fontspec.sty' version 2.3c.
+;;; fontspec.el --- AUCTeX style for `fontspec.sty' version 2.6a.
 
-;; Copyright (C) 2013 Free Software Foundation, Inc.
+;; Copyright (C) 2013, 2017 Free Software Foundation, Inc.
 
 ;; Maintainer: address@hidden
-;; Author: Mosè Giordano <address@hidden>
+;; Author: Mosè Giordano <address@hidden>
 ;; Keywords: tex
 
 ;; This file is part of AUCTeX.
@@ -25,94 +25,119 @@
 
 ;;; Commentary:
 
-;; This file adds support for `fontspec.sty' version 2.3c.
+;; This file adds support for `fontspec.sty' version 2.6a.  Starting
+;; with `fontspec.sty' v2.4, the order of mandatory font names and
+;; optional font features in related macros has changed, i.e. optional
+;; argument comes after the mandatory one.  This change is now (April
+;; 2017) implemented in this file.  Fontification support retains
+;; backward compatibilty.
 
 ;;; Code:
 
 (defvar LaTeX-fontspec-font-features
-  '(;; More control over font shape selection
+  '(;; 5 Font selection
+    ("Extension" (".otf" ".ttf" ".ttc" ".dfont"))
+    ("Path")
+    ;; 6.1 More control over font shape selection
     ("BoldFont")
     ("ItalicFont")
     ("BoldItalicFont")
     ("SlantedFont")
     ("BoldSlantedFont")
     ("SmallCapsFont")
-    ;; Different features for different font shapes
+    ;; 6.2 Specifically choosing the NFSS family
+    ("NFSSFamily")
+    ("FontFace")
+    ;; 11 Different features for different font shapes
+    ("UprightFeatures")
     ("BoldFeatures")
     ("ItalicFeatures")
     ("BoldItalicFeatures")
     ("SlantedFeatures")
     ("BoldSlantedFeatures")
     ("SmallCapsFeatures")
-    ;; Different features for different font sizes
+    ;; 13 Different features for different font sizes
     ("SizeFeatures")
-    ;; Font independent options
+    ;; 14 Font independent options
     ("Color")
     ("Scale" ("MatchLowercase" "MatchUppercase"))
     ("WordSpace")
     ("PunctuationSpace")
     ("HyphenChar")
     ("OpticalSize")
-    ;; OpenType options
-    ("Ligatures" ("Required"
-                 "NoRequired"
-                 "Common"
-                 "NoCommon"
-                 "Contextual"
-                 "NoContextual"
-                 "Rare"
-                 "Historic"
-                 "TeX"))
-    ("Letters" ("Uppercase"
-               "SmallCaps"
-               "PetiteCaps"
-               "UppercaseSmallCaps"
-               "UppercasePetiteCaps"
-               "Unicase"))
-    ("Numbers" ("Lining"
-               "OldStyle"
-               "Proportional"
-               "Monospaced"
-               "SlashedZero"
-               "Arabic"))
-    ("Contextuals" ("Swash"
-                   "Alternate"
-                   "WordInitial"
-                   "WordFinal"
-                   "LineFinal"
-                   "Inner"))
-    ("VerticalPosition" ("Superior"
-                        "Inferior"
-                        "Numerator"
-                        "Denominator"
-                        "ScientificInferior"
-                        "Ordinal"))
-    ("Fraction" ("On" "Alternate"))
-    ("StylisticSet")
-    ("CharacterVariants")
-    ("Alternate")
-    ("Style" ("Alternate"
-             "Italic"
-             "Ruby"
-             "Swash"
-             "Historic"
-             "TitlingCaps"
-             "HorizontalKana"
-             "VerticalKana"))
-    ("Diacritics" ("MarkToBase"
-                  "NoMarkToBase"
-                  "MarkToMark"
-                  "NoMarkToMark"
-                  "AboveBase"
-                  "NoAboveBase"
-                  "BelowBase"
-                  "NoBelowBase"))
-    ("Kerning" ("Uppercase" "On" "Off"))
     ("AutoFakeBold")
     ("AutoFakeSlant")
     ("FakeSlant")
     ("FakeStretch")
     ("FakeBold")
+    ("LetterSpace")
+    ;; 16 OpenType options
+    ("Ligatures" ("Required"      "RequiredOff"
+                 "Common"        "CommonOff"
+                 "Contextual"    "ContextualOff"
+                 "Rare"          "RareOff"
+                 "Discretionary" "DiscretionaryOff"
+                 "Historic"      "HistoricOff"
+                 "TeX"
+                 "ResetAll"))
+    ("Letters" ("Uppercase"           "UppercaseOff"
+               "SmallCaps"           "SmallCapsOff"
+               "PetiteCaps"          "PetiteCapsOff"
+               "UppercaseSmallCaps"  "UppercaseSmallCapsOff"
+               "UppercasePetiteCaps" "UppercasePetiteCapsOff"
+               "Unicase"             "UnicaseOff"
+               "ResetAll"))
+    ("Numbers" ("Uppercase"    "UppercaseOff"
+               "Lowercase"    "LowercaseOff"
+               "Lining"       "LiningOff"
+               "OldStyle"     "OldStyleOff"
+               "Proportional" "ProportionalOff"
+               "Monospaced"   "MonospacedOff"
+               "SlashedZero"  "SlashedZeroOff"
+               "Arabic"       "ArabicOff"
+               "ResetAll"))
+    ("Contextuals" ("Swash"       "SwashOff"
+                   "Alternate"   "AlternateOff"
+                   "WordInitial" "WordInitialOff"
+                   "WordFinal"   "WordFinalOff"
+                   "LineFinal"   "LineFinalOff"
+                   "Inner"       "InnerOff"
+                   "ResetAll"))
+    ("VerticalPosition" ("Superior"           "SuperiorOff"
+                        "Inferior"           "InferiorOff"
+                        "Numerator"          "NumeratorOff"
+                        "Denominator"        "DenominatorOff"
+                        "ScientificInferior" "ScientificInferiorOff"
+                        "Ordinal"            "OrdinalOff"
+                        "ResetAll"))
+    ("Fraction" ("On" "Off" "Reset" "Alternate" "AlternateOff" "ResetAll"))
+    ("StylisticSet")
+    ("CharacterVariant")
+    ("Alternate" ("Random"))
+    ("Style" ("Alternate"      "AlternateOff"
+             "Italic"         "ItalicOff"
+             "Ruby"           "RubyOff"
+             "Swash"          "SwashOff"
+             "Cursive"        "CursiveOff"
+             "Historic"       "HistoricOff"
+             "TitlingCaps"    "TitlingCapsOff"
+             "HorizontalKana" "HorizontalKanaOff"
+             "VerticalKana"   "VerticalKanaOff"
+             "ResetAll"))
+    ("Diacritics" ("MarkToBase" "MarkToBaseOff"
+                  "MarkToMark" "MarkToMarkOff"
+                  "AboveBase"  "AboveBaseOff"
+                  "BelowBase"  "BelowBaseOff"
+                  "ResetAll"))
+    ("Kerning" ("Uppercase" "UppercaseOff" "On" "Off" "Reset" "ResetAll"))
+    ("CharacterWidth" ("Proportional"          "ProportionalOff"
+                      "Full"                  "FullOff"
+                      "Half"                  "HalfOff"
+                      "Third"                 "ThirdOff"
+                      "Quarter"               "QuarterOff"
+                      "AlternateProportional" "AlternateProportionalOff"
+                      "AlternateHalf"         "AlternateHalfOff"
+                      "ResetAll"))
     ("Annotation")
     ("CJKShape" ("Traditional"
                 "Simplified"
@@ -121,16 +146,24 @@
                 "JIS1990"
                 "Expert"
                 "NLC"))
-    ("CharacterWidth" ("Proportional"
-                      "Full"
-                      "Half"
-                      "Third"
-                      "Quarter"
-                      "AlternateProportional"
-                      "AlternateHalf"))
-    ("Vertical" ("RotatedGlyphs")))
+    ("Vertical" ("RotatedGlyphs"         "RotatedGlyphsOff"
+                "AlternatesForRotation" "AlternatesForRotationOff"
+                "Alternates"            "AlternatesOff"
+                "KanaAlternates"        "KanaAlternatesOff"
+                "Kerning"               "KerningOff"
+                "AlternateMetrics"      "AlternateMetricsOff"
+                "HalfMetrics"           "HalfMetricsOff"
+                "ProportionalMetrics"   "ProportionalMetricsOff"
+                "ResetAll"))
+    ;; 25 Going behind fontspec's back: Offer only an excerpt of all
+    ;; possible tags:
+    ("RawFeature" ("frac" "lnum" "onum" "pnum" "smcp" "tnum" "zero")))
   "Font features options for macros of the fontspec package.")
 
+(defvar LaTeX-fontspec-font-features-local nil
+  "Buffer-local font features options for macros of the fontspec package.")
+(make-variable-buffer-local 'LaTeX-fontspec-font-features-local)
+
 (defvar LaTeX-fontspec-font-list nil
   "List of the fonts accessible to fontspec.")
 
@@ -163,74 +196,205 @@ to retrieve the list of fonts."
     (or LaTeX-fontspec-font-list LaTeX-fontspec-font-list-default))
    optional))
 
+(defun LaTeX-fontspec-update-font-features ()
+  "Update Color key=values in `LaTeX-fontspec-font-features-local'."
+  ;; Check if any color defininig package is loaded and update the
+  ;; key=values for coloring.  Prefer xcolor.sty if both packages are
+  ;; loaded.
+  (when (or (member "xcolor" (TeX-style-list))
+           (member "color" (TeX-style-list)))
+    (let* ((colorcmd (if (member "xcolor" (TeX-style-list))
+                        #'LaTeX-xcolor-definecolor-list
+                      #'LaTeX-color-definecolor-list))
+          (tmp (copy-alist LaTeX-fontspec-font-features-local)))
+      (setq tmp (assq-delete-all (car (assoc "Color" tmp)) tmp))
+      (push (list "Color" (mapcar #'car (funcall colorcmd))) tmp)
+      (setq LaTeX-fontspec-font-features-local
+           (copy-alist tmp)))))
+
+;; Setup for \newfontfamily and \newfontface:
+(TeX-auto-add-type "fontspec-newfontcmd" "LaTeX")
+
+(defvar LaTeX-fontspec-newfontcmd-regexp
+  '("\\\\newfontfa\\(?:ce\\|mily\\)[ \t\n\r%]*\\\\\\([a-zA-Z]+\\)"
+    1 LaTeX-auto-fontspec-newfontcmd)
+  "Matches new macros defined with \\newfontface and \\newfontfamily.")
+
+(defun LaTeX-fontspec-auto-prepare ()
+  "Clear `LaTeX-auto-fontspec-newfontcmd' before parsing."
+  (setq LaTeX-auto-fontspec-newfontcmd nil))
+
+(defun LaTeX-fontspec-auto-cleanup ()
+  "Process parsed elements for fontspec package."
+  (dolist (mac (mapcar #'car (LaTeX-fontspec-newfontcmd-list)))
+    ;; Add macro to list of known macros
+    (TeX-add-symbols mac)
+    ;; Cater for fontification
+    (when (and (featurep 'font-latex)
+              (eq TeX-install-font-lock 'font-latex-setup))
+      (font-latex-add-keywords `((,mac ""))
+                              'type-declaration)))
+  ;; Update values of Color key:
+  (LaTeX-fontspec-update-font-features))
+
+(add-hook 'TeX-auto-prepare-hook #'LaTeX-fontspec-auto-prepare t)
+(add-hook 'TeX-auto-cleanup-hook #'LaTeX-fontspec-auto-cleanup t)
+(add-hook 'TeX-update-style-hook #'TeX-auto-parse t)
+
 (TeX-add-style-hook
  "fontspec"
  (lambda ()
    (TeX-check-engine-add-engines 'luatex 'xetex)
    (TeX-run-style-hooks "expl3" "xparse")
+
+   ;; Add fontspec to the parser.
+   (TeX-auto-add-regexp LaTeX-fontspec-newfontcmd-regexp)
+
+   ;; Activate the buffer local version of font features:
+   (setq LaTeX-fontspec-font-features-local
+        (copy-alist LaTeX-fontspec-font-features))
+
    (TeX-add-symbols
-    ;; Font selection
-    '("fontspec" [TeX-arg-key-val LaTeX-fontspec-font-features "Font features"]
-      LaTeX-fontspec-arg-font)
+    ;; 4.3 Commands for old-style and lining numbers: \oldstylenums is
+    ;; already provided by LaTeX, so just add \liningnums here
+    '("liningnums" "Numbers")
+
+    ;; 4.5 Emphasis and nested emphasis
+    ;; \emshape seems to be an internal macro
+    "emshape"
+    '("emfontdeclare" t)
+    "emreset"
+
+    ;; 4.6 Strong emphasis
+    '("strong" t)
+    '("strongfontdeclare" t)
+    "strongreset"
+
+    ;; 5 Font selection
+    '("fontspec"
+      LaTeX-fontspec-arg-font
+      [TeX-arg-key-val LaTeX-fontspec-font-features-local "Font features"])
+
     ;; Default font families
     '("setmainfont"
-      [TeX-arg-key-val LaTeX-fontspec-font-features "Font features"]
-      (LaTeX-fontspec-arg-font "Main font name"))
+      (LaTeX-fontspec-arg-font "Main font name")
+      [TeX-arg-key-val LaTeX-fontspec-font-features-local "Font features"])
     '("setsansfont"
-      [TeX-arg-key-val LaTeX-fontspec-font-features "Font features"]
-      (LaTeX-fontspec-arg-font "Sans font name"))
+      (LaTeX-fontspec-arg-font "Sans font name")
+      [TeX-arg-key-val LaTeX-fontspec-font-features-local "Font features"])
     '("setmonofont"
-      [TeX-arg-key-val LaTeX-fontspec-font-features "Font features"]
-      (LaTeX-fontspec-arg-font "Mono font name"))
-    ;; New commands to select font families
+      (LaTeX-fontspec-arg-font "Mono font name")
+      [TeX-arg-key-val LaTeX-fontspec-font-features-local "Font features"])
+
+    ;; 5.3 Querying whether a font exists
+    '("IfFontExistsTF" LaTeX-fontspec-arg-font 2)
+
+    ;; 6 commands to select font families
     '("newfontfamily" TeX-arg-define-macro
-      [TeX-arg-key-val LaTeX-fontspec-font-features "Font features"]
-      LaTeX-fontspec-arg-font)
+      LaTeX-fontspec-arg-font
+      [TeX-arg-key-val LaTeX-fontspec-font-features-local "Font features"])
+
     '("newfontface" TeX-arg-define-macro
-      [TeX-arg-key-val LaTeX-fontspec-font-features "Font features"]
-      LaTeX-fontspec-arg-font)
-    ;; Math(s) fonts
-    '("setmathrm" [ "Font features" ] "Font name")
-    '("setmathsf" [ "Font features" ] "Font name")
-    '("setmathtt" [ "Font features" ] "Font name")
-    '("setboldmathrm" [ "Font features" ] "Font name")
-    ;; Emphasis and nested emphasis
-    "emshape"
-    "eminnershape"
-    ;; Default settings
+      LaTeX-fontspec-arg-font
+      [TeX-arg-key-val LaTeX-fontspec-font-features-local "Font features"])
+
+    ;; 6.4 Math(s) fonts
+    '("setmathrm" "Font name" [ "Font features" ])
+    '("setmathsf" "Font name" [ "Font features" ])
+    '("setmathtt" "Font name" [ "Font features" ])
+    '("setboldmathrm" "Font name" [ "Font features" ])
+
+    ;; 8 Default settings
     '("defaultfontfeatures" [ LaTeX-fontspec-arg-font ]
-      (TeX-arg-key-val LaTeX-fontspec-font-features "Font features"))
+      (TeX-arg-key-val LaTeX-fontspec-font-features-local "Font features"))
+    '("defaultfontfeatures+" [ LaTeX-fontspec-arg-font ]
+      (TeX-arg-key-val LaTeX-fontspec-font-features-local "Font features"))
+
+    ;; 10 Working with the currently selected features
+    '("IfFontFeatureActiveTF"
+      [TeX-arg-key-val LaTeX-fontspec-font-features-local "Font feature"] 2)
+
     ;; Changing the currently selected features
     '("addfontfeatures"
-      (TeX-arg-key-val LaTeX-fontspec-font-features "Font features"))
-    ;; Defining new scripts and languages
+      (TeX-arg-key-val LaTeX-fontspec-font-features-local "Font features"))
+
+    ;; 23 Defining new features
+    '("newAATfeature"
+      (TeX-arg-eval completing-read
+                   (TeX-argument-prompt optional nil "Existing feature")
+                   LaTeX-fontspec-font-features-local)
+      "New option" 2)
+
+    '("newopentypefeature"
+      (TeX-arg-eval completing-read
+                   (TeX-argument-prompt optional nil "Existing feature")
+                   LaTeX-fontspec-font-features-local)
+      "New option" t)
+
+    '("newfontfeature" "New feature" t)
+
+    ;; 24 Defining new scripts and languages
     '("newfontscript" "Script name" "OpenType tag")
-    '("newfontlanguage" "Language name" "OpenType tag"))
+    '("newfontlanguage" "Language name" "OpenType tag")
+
+    ;; 26 Renaming existing features & options
+    '("aliasfontfeature"
+      (TeX-arg-eval completing-read
+                   (TeX-argument-prompt optional nil "Existing feature")
+                   LaTeX-fontspec-font-features-local)
+      "New name")
+
+    '("aliasfontfeatureoption"
+      (TeX-arg-eval
+       (lambda ()
+        (let* ((key (completing-read
+                     (TeX-argument-prompt optional nil "Feature")
+                     LaTeX-fontspec-font-features-local))
+               (val (completing-read
+                     (TeX-argument-prompt optional nil "Existing name")
+                     (cadr (assoc key LaTeX-fontspec-font-features-local)))))
+          (TeX-argument-insert key optional)
+          (format "%s" val))))
+      "New name") )
+
+   (LaTeX-add-environments
+    ;; 4.6 Strong emphasis
+    '("strong"))
 
    ;; Fontification
    (when (and (featurep 'font-latex)
              (eq TeX-install-font-lock 'font-latex-setup))
-     (font-latex-add-keywords '(("fontspec"    "[{")
-                               ("setmainfont" "[{")
-                               ("setsansfont" "[{")
-                               ("setmonofont" "[{")
-                               ("newfontfamily" "\\[{")
-                               ("newfontface" "\\[{")
-                               ("setmathrm" "[{")
-                               ("setmathsf" "[{")
-                               ("setmathtt" "[{")
-                               ("setboldmathrm" "[{")
-                               ("emshape")
-                               ("eminnershape")
-                               ("defaultfontfeatures" "[{")
-                               ("addfontfeature" "{")
-                               ("newfontscript" "{{")
-                               ("newfontlanguage" "{{"))
-                             'function)))
+     (font-latex-add-keywords '(("fontspec"    "[{[")
+                               ("setmainfont" "[{[")
+                               ("setsansfont" "[{[")
+                               ("setmonofont" "[{[")
+                               ("newfontfamily" "\\[{[")
+                               ("newfontface"   "\\[{[")
+                               ("setmathrm" "[{[")
+                               ("setmathsf" "[{[")
+                               ("setmathtt" "[{[")
+                               ("setboldmathrm" "[{[")
+                               ("defaultfontfeatures" "+[{")
+                               ("addfontfeature"  "{")
+                               ("addfontfeatures" "{")
+                               ("newfontscript"   "{{")
+                               ("newfontlanguage" "{{")
+                               ("emfontdeclare"   "{")
+                               ("strongfontdeclare"  "{")
+                               ("newAATfeature"      "{{{{")
+                               ("newopentypefeature" "{{{")
+                               ("newfontfeature"     "{{")
+                               ("aliasfontfeature"   "{{")
+                               ("aliasfontfeatureoption" "{{{"))
+                             'function)
+     (font-latex-add-keywords '(("liningnums"    "{"))
+                             'type-command)
+     (font-latex-add-keywords '(("strong"    "{"))
+                             'bold-command)))
  LaTeX-dialect)
 
 (defvar LaTeX-fontspec-package-options
-  '("math" "no-math" "config" "no-config" "quiet" "silent")
+  '("tuenc" "euenc" "math" "no-math" "config" "no-config" "quiet" "silent")
   "Package options for the fontspec package.")
 
 ;;; fontspec.el ends here

-----------------------------------------------------------------------

Summary of changes:
 style/fontspec.el | 396 ++++++++++++++++++++++++++++++++++++++----------------
 1 file changed, 280 insertions(+), 116 deletions(-)


hooks/post-receive
-- 
GNU AUCTeX



reply via email to

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