>From f6ab845a1d0ea6ce7b62111d870964f44b0b4035 Mon Sep 17 00:00:00 2001
From: Arash Esbati
Date: Tue, 17 May 2016 13:38:03 +0200
Subject: [PATCH 1/5] Add new style/xcolor.el
* Makefile.in (STYLESRC): Add new style xcolor.el.
* style/xcolor.el: Add new file.
---
Makefile.in | 2 +-
style/xcolor.el | 628 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 629 insertions(+), 1 deletion(-)
create mode 100644 style/xcolor.el
diff --git a/Makefile.in b/Makefile.in
index b390c66..23bf4a5 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -154,7 +154,7 @@ STYLESRC = style/prosper.el \
style/fontenc.el style/Alegreya.el style/gloss-italian.el \
style/newfloat.el style/subcaption.el style/AlegreyaSans.el \
style/hologo.el style/theorem.el style/ntheorem.el \
- style/splitidx.el style/tikz.el
+ style/splitidx.el style/tikz.el style/xcolor.el
STYLEELC = $(STYLESRC:.el=.elc)
diff --git a/style/xcolor.el b/style/xcolor.el
new file mode 100644
index 0000000..2466b12
--- /dev/null
+++ b/style/xcolor.el
@@ -0,0 +1,628 @@
+;; xcolor.el --- AUCTeX style for `xcolor.sty' (v2.12)
+
+;; Copyright (C) 2016 Free Software Foundation, Inc.
+
+;; Author: Arash Esbati
+;; Maintainer: address@hidden
+;; Created: 2015-07-04
+;; Keywords: tex
+
+;; This file is part of AUCTeX.
+
+;; AUCTeX is free software; you can redistribute it and/or modify it
+;; under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 3, or (at your option)
+;; any later version.
+
+;; AUCTeX is distributed in the hope that it will be useful, but
+;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+;; General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with AUCTeX; see the file COPYING. If not, write to the Free
+;; Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+;; 02110-1301, USA.
+
+;;; Commentary:
+
+;; This file adds support for `xcolor.sty' (v2.12) from 2016/05/11.
+;; `xcolor.sty' is part of TeXLive.
+
+;; `xcolor.sty' and `color.sty' share many command namens, but the
+;; number of arguments is not always identical -- `xcolor.sty'
+;; commands take more arguments. In order to make the commands and
+;; font-locking work correctly, we follow this strategy: If
+;; `xcolor.sty' is loaded after `color.sty', everything works fine.
+;; For the way around, we guard the definitions in `color.sty' with:
+;;
+;; (unless (member "xcolor" (TeX-TeX-style-list))
+;; (]{}{}{}
+ (let* ((xcoltype (completing-read
+ (TeX-argument-prompt t nil "Type")
+ LaTeX-xcolor-type-color-models))
+ (xcolname (TeX-read-string
+ (TeX-argument-prompt optional nil "Color name")))
+ (xcolmodel (completing-read
+ (TeX-argument-prompt optional nil "Model (list)")
+ (if (string= xcoltype "named")
+ (LaTeX-xcolor-color-models t)
+ LaTeX-xcolor-color-models)))
+ (xcolspec (if (string= xcolmodel "named")
+ (completing-read
+ (TeX-argument-prompt optional nil "Color")
+ (LaTeX-xcolor-definecolor-list))
+ (TeX-read-string
+ (TeX-argument-prompt optional nil (concat xcolmodel " spec (list)"))))))
+ (when (and xcoltype (not (string= xcoltype "")))
+ (insert (format "[%s]" xcoltype)))
+ (TeX-argument-insert xcolname optional)
+ (LaTeX-add-xcolor-definecolors xcolname)
+ (TeX-argument-insert xcolmodel optional)
+ (TeX-argument-insert xcolspec optional)))
+
+(defun TeX-arg-xcolor-definecolorset (optional)
+ "Insert arguments of \\definecolorset and similar macros from
+xcolor.sty."
+ (let ((xcoltype (completing-read
+ (TeX-argument-prompt t nil "Type")
+ LaTeX-xcolor-type-color-models))
+ (xcolmodel (completing-read
+ (TeX-argument-prompt optional nil "Model")
+ (LaTeX-xcolor-color-models t))))
+ (when (and xcoltype (not (string= xcoltype "")))
+ (insert (format "[%s]" xcoltype)))
+ (TeX-argument-insert xcolmodel optional)))
+
+(defun TeX-arg-xcolor (optional)
+ "Insert arguments of various color commands from xcolor.sty."
+ ;; \color{} or \color[]{}
+ (let* ((xcolmodel (completing-read
+ (TeX-argument-prompt t nil "Model (list)")
+ (LaTeX-xcolor-color-models t)))
+ (xcolor (if (and xcolmodel (not (string= xcolmodel "")))
+ (TeX-read-string
+ (TeX-argument-prompt optional nil (concat xcolmodel " spec (list)")))
+ (completing-read
+ (TeX-argument-prompt optional nil "Color")
+ (LaTeX-xcolor-definecolor-list)))))
+ (when (and xcolmodel (not (string= xcolmodel "")))
+ (insert (format "[%s]" xcolmodel)))
+ (TeX-argument-insert xcolor optional)))
+
+(defun TeX-arg-xcolor-fcolorbox (optional)
+ "Insert arguments of \\fcolorbox from xcolor.sty."
+ ;;\fcolorbox[]{}[]{}{}
+ (let* ((xfrmodel (completing-read
+ (TeX-argument-prompt t nil "(Frame) Color model")
+ LaTeX-xcolor-color-models))
+ (xfrspec (if (or (string= xfrmodel "")
+ (string= xfrmodel "named"))
+ (completing-read
+ (TeX-argument-prompt optional nil "Frame color spec")
+ (LaTeX-xcolor-definecolor-list))
+ (TeX-read-string
+ (TeX-argument-prompt optional nil "Frame color spec"))))
+ (xbgmodel (completing-read
+ (TeX-argument-prompt t nil "Background Color model")
+ LaTeX-xcolor-color-models))
+ (xbgspec (if (or (string= xfrmodel "")
+ (string= xfrmodel "named")
+ (string= xbgmodel "")
+ (string= xbgmodel "named"))
+ (completing-read
+ (TeX-argument-prompt optional nil "Background color spec")
+ (LaTeX-xcolor-definecolor-list))
+ (TeX-read-string
+ (TeX-argument-prompt optional nil "Background color spec")))))
+ (when (and xfrmodel (not (string= xfrmodel "")))
+ (insert (format "[%s]" xfrmodel)))
+ (TeX-argument-insert xfrspec optional)
+ (when (and xbgmodel (not (string= xbgmodel "")))
+ (insert (format "[%s]" xbgmodel)))
+ (TeX-argument-insert xbgspec optional)))
+
+
+(TeX-add-style-hook
+ "xcolor"
+ (lambda ()
+ ;; Add color to the parser.
+ (TeX-auto-add-regexp LaTeX-xcolor-definecolor-regexp)
+ (TeX-auto-add-regexp LaTeX-xcolor-definecolorset-regexp)
+
+ ;; Add list of colors which are always available.
+ (apply #'LaTeX-add-xcolor-definecolors LaTeX-xcolor-base-colors)
+
+ ;; Add dvips colors in conjunction with `dvipsnames*?'.
+ (when (or (LaTeX-provided-package-options-member "xcolor" "dvipsnames")
+ (LaTeX-provided-package-options-member "xcolor" "dvipsnames*"))
+ (apply #'LaTeX-add-xcolor-definecolors LaTeX-xcolor-dvipsnames-colors))
+
+ ;; For `svgnames*?'
+ (when (or (LaTeX-provided-package-options-member "xcolor" "svgnames")
+ (LaTeX-provided-package-options-member "xcolor" "svgnames*"))
+ (apply #'LaTeX-add-xcolor-definecolors LaTeX-xcolor-svgnames-colors))
+
+ ;; For `x11ames*?'
+ (when (or (LaTeX-provided-package-options-member "xcolor" "x11names")
+ (LaTeX-provided-package-options-member "xcolor" "x11names*"))
+ (apply #'LaTeX-add-xcolor-definecolors LaTeX-xcolor-x11names-colors))
+
+ (TeX-add-symbols
+ ;; 2.5.2 Color definition in xcolor
+ ;; \definecolor[]{}{}{}
+ '("definecolor" TeX-arg-xcolor-definecolor)
+
+ ;; \providecolor[]{}{}{}
+ '("providecolor" TeX-arg-xcolor-definecolor)
+
+ ;; \colorlet[]{}{}{}
+ '("colorlet"
+ [ TeX-arg-eval completing-read
+ (TeX-argument-prompt optional nil "Type")
+ LaTeX-xcolor-type-color-models ]
+ (TeX-arg-eval
+ (lambda ()
+ (let ((xcolor (TeX-read-string
+ (TeX-argument-prompt optional nil "Color"))))
+ (LaTeX-add-xcolor-definecolors xcolor)
+ (format "%s" xcolor))))
+ [ TeX-arg-eval completing-read
+ (TeX-argument-prompt optional nil "Model")
+ (LaTeX-xcolor-color-models t) ]
+ (TeX-arg-eval completing-read
+ (TeX-argument-prompt optional nil "Color")
+ (LaTeX-xcolor-definecolor-list)))
+
+ ;; 2.5.3 Defining sets of colors
+ ;; \definecolorset[]{}{}{}{}
+ '("definecolorset" TeX-arg-xcolor-definecolorset "Head" "Tail" t)
+
+ ;; \providecolorset[]{}{}{}{}
+ '("providecolorset" TeX-arg-xcolor-definecolorset "Head" "Tail" t)
+
+ ;; 2.5.4 Immediate and deferred definitions
+ ;; \preparecolor[]{}{}{}
+ '("preparecolor" TeX-arg-xcolor-definecolor)
+
+ ;; \preparecolorset[]{}{}{}{}
+ '("preparecolorset" TeX-arg-xcolor-definecolorset "Head" "Tail" t)
+
+ ;; \definecolors{}
+ '("definecolors" t)
+
+ ;; \providecolors{}
+ '("providecolors" t)
+
+ ;; 2.6 Color application
+ ;; 2.6.1 Standard color commands
+
+ ;; \color{} or \color[]{}
+ '("color" TeX-arg-xcolor)
+
+ ;; \textcolor{}{} or
+ ;; \textcolor[]{}{}
+ '("textcolor" TeX-arg-xcolor "Text")
+
+ ;; \pagecolor{} or
+ ;; \pagecolor[]{}
+ '("pagecolor" TeX-arg-xcolor)
+
+ ;; \nopagecolor
+ '("nopagecolor" 0)
+
+ ;; 2.6.2 Colored boxes
+ ;; \colorbox{}{} or
+ ;; \colorbox[]{}{}
+ '("colorbox" TeX-arg-xcolor "Text")
+
+ ;; \fcolorbox{}{}{} or
+ ;; \fcolorbox[]{}{}{} or
+ ;; \fcolorbox[]{}[]{}{}
+ '("fcolorbox" TeX-arg-xcolor-fcolorbox "Text")
+
+ ;; 2.6.4 Color testing
+ ;; \testcolor{} or
+ ;; \testcolor[]{}
+ '("testcolor" TeX-arg-xcolor)
+
+ ;; 2.7 Color blending
+ '("blendcolors"
+ (TeX-arg-eval completing-read
+ (TeX-argument-prompt optional nil "Mix expr")
+ (LaTeX-xcolor-definecolor-list)))
+ '("blendcolors*"
+ (TeX-arg-eval completing-read
+ (TeX-argument-prompt optional nil "Mix expr")
+ (LaTeX-xcolor-definecolor-list)))
+
+ ;; 2.8 Color masks and separation
+ '("maskcolors"
+ [ TeX-arg-eval completing-read
+ (TeX-argument-prompt optional nil "Model")
+ (LaTeX-xcolor-color-models t) ]
+ (TeX-arg-eval completing-read
+ (TeX-argument-prompt optional nil "Color")
+ (LaTeX-xcolor-definecolor-list)))
+
+ ;; 2.9 Color series
+ '("definecolorseries"
+ "Name"
+ (TeX-arg-eval completing-read
+ (TeX-argument-prompt optional nil "Core model")
+ LaTeX-xcolor-core-color-models)
+ (TeX-arg-eval completing-read
+ (TeX-argument-prompt optional nil "Method")
+ '("step" "grad" "last"))
+ [ t ] nil [ nil ] nil)
+
+ '("resetcolorseries" [ "Div." ] "Name")
+
+ ;; 2.13 Color information
+ ;; \extractcolorspec{}{}
+ '("extractcolorspec"
+ (TeX-arg-eval completing-read
+ (TeX-argument-prompt optional nil "Color")
+ (LaTeX-xcolor-definecolor-list))
+ (TeX-arg-define-macro "Command: \\"))
+
+ ;; \extractcolorspecs{}{{}
+ '("extractcolorspecs"
+ (TeX-arg-eval completing-read
+ (TeX-argument-prompt optional nil "Color")
+ (LaTeX-xcolor-definecolor-list))
+ (TeX-arg-define-macro "Model command: \\")
+ (TeX-arg-define-macro "Color command: \\"))
+
+ ;; \tracingcolors =
+ '("tracingcolors"
+ (TeX-arg-literal "="))
+
+ ;; 2.14 Color conversion
+ ;; \convertcolorspec{}{}{}{cmd>}
+ '("convertcolorspec"
+ (TeX-arg-eval completing-read
+ (TeX-argument-prompt optional nil "Model")
+ (LaTeX-xcolor-color-models))
+ (TeX-arg-eval TeX-read-string
+ (TeX-argument-prompt optional nil "Spec"))
+ (TeX-arg-eval completing-read
+ (TeX-argument-prompt optional nil "Model")
+ (LaTeX-xcolor-color-models t))
+ (TeX-arg-define-macro "Macro: \\")) ) ; close TeX-add-symbols
+
+ ;; 2.12 Color in tables
+ ;; These commands are available with `table' package option
+ (when (LaTeX-provided-package-options-member "xcolor" "table")
+ ;; Run style hook to colortbl.sty
+ (TeX-run-style-hooks "colortbl")
+
+ ;; Add additional commands:
+ (TeX-add-symbols
+ ;; \rowcolors[]{}{}{}
+ '("rowcolors"
+ (TeX-arg-conditional (y-or-n-p "With optional commands? ")
+ ( [ t ] )
+ (ignore))
+ "Row"
+ (TeX-arg-eval completing-read
+ (TeX-argument-prompt optional nil "Odd-row color")
+ (LaTeX-xcolor-definecolor-list))
+ (TeX-arg-eval completing-read
+ (TeX-argument-prompt optional nil "Even-row color")
+ (LaTeX-xcolor-definecolor-list)))
+ '("rowcolors*"
+ (TeX-arg-conditional (y-or-n-p "With optional commands? ")
+ ( [ t ] )
+ (ignore))
+ "Row"
+ (TeX-arg-eval completing-read
+ (TeX-argument-prompt optional nil "Odd-row color")
+ (LaTeX-xcolor-definecolor-list))
+ (TeX-arg-eval completing-read
+ (TeX-argument-prompt optional nil "Even-row color")
+ (LaTeX-xcolor-definecolor-list)))
+ '("showrowcolors" 0)
+ '("hiderowcolors" 0))
+ (LaTeX-add-counters "rownum"))
+
+ ;; 2.6.4 Color testing
+ (LaTeX-add-environments
+ '("testcolors" LaTeX-env-args
+ [ TeX-arg-eval mapconcat #'identity
+ (TeX-completing-read-multiple
+ (TeX-argument-prompt optional nil "Color models")
+ (LaTeX-xcolor-color-models t))
+ "," ] ))
+
+ ;; Fontification
+ (when (and (featurep 'font-latex)
+ (eq TeX-install-font-lock 'font-latex-setup))
+ (font-latex-add-keywords '(("color" "[{")
+ ("pagecolor" "[{"))
+ 'type-declaration)
+ (font-latex-add-keywords '(("textcolor" "[{{")
+ ("colorbox" "[{{" )
+ ("fcolorbox" "[{[{{"))
+ 'type-command)
+ (font-latex-add-keywords '(("definecolor" "[{{{")
+ ("providecolor" "[{{{")
+ ("colorlet" "[{[{")
+ ("definecolorset" "[{{{{")
+ ("providecolorset" "[{{{{")
+ ("preparecolor" "[{{{")
+ ("preparecolorset" "[{{{{")
+ ("definecolors" "{")
+ ("providecolors" "{")
+ ("testcolor" "[{")
+ ("blendcolors" "*{")
+ ("maskcolors" "[{")
+ ("definecolorseries" "{{{[{[{")
+ ("resetcolorseries" "[{")
+ ("extractcolorspec" "{{")
+ ("extractcolorspecs" "{{{")
+ ("convertcolorspec" "{{{{")
+ ("rowcolors" "*[{{{"))
+ 'function)))
+ LaTeX-dialect)
+
+(defvar LaTeX-xcolor-package-options
+ '(;; options that determine the color driver
+ "dvips" "xdvi" "dvipdf" "dvipdfm" "dvipdfmx" "pdftex" "dvipsone"
+ "dviwindo" "emtex" "dviwin" "oztex" "textures" "pctexps" "pctexwin"
+ "pctexhp" "pctex32" "truetex" "tcidvi" "vtex" "xetex"
+
+ ;; options that determine the target color model
+ "natural" "rgb" "cmy" "cmyk" "hsb" "gray" "RGB" "HTML"
+ "HSB" "Gray" "monochrome"
+
+ ;; options that control predefined colors loading
+ "dvipsnames" "dvipsnames*" "svgnames" "svgnames*" "x11names" "x11names*"
+
+ ;; options that determine which other packages to load
+ "table" "fixpdftex" "hyperref"
+
+ ;; options that influence the behaviour of other commands
+ "prologue" "kernelfbox" "xcdraw" "noxcdraw" "fixinclude"
+ "showerrors" "hideerrors")
+ "Package options for the xcolor package.")
+
+;;; xcolor.el ends here
--
2.8.1