Initial Commit
[packages] / xemacs-packages / auctex / style / xparse.el
1 ;;; xparse.el --- AUCTeX style for `xparse.sty' version 4467.
2
3 ;; Copyright (C) 2013 Free Software Foundation, Inc.
4
5 ;; Maintainer: auctex-devel@gnu.org
6 ;; Author: Mosè Giordano <giordano.mose@libero.it>
7 ;; Keywords: tex
8
9 ;; This file is part of AUCTeX.
10
11 ;; AUCTeX is free software; you can redistribute it and/or modify it
12 ;; under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 3, or (at your option)
14 ;; any later version.
15
16 ;; AUCTeX is distributed in the hope that it will be useful, but
17 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19 ;; General Public License for more details.
20
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with AUCTeX; see the file COPYING.  If not, write to the Free
23 ;; Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
24 ;; 02110-1301, USA.
25
26 ;;; Commentary:
27
28 ;; This file adds basic support for `xparse.sty' version 4467.  It
29 ;; doesn't parse argument specification of macros and environments.
30
31 ;;; Code:
32
33 (defvar LaTeX-xparse-macro-regexp
34   (concat "\\\\\\(?:Declare\\|New\\|Renew\\|Provide\\|DeclareExpandable\\)"
35           "DocumentCommand[ \t\n\r]*{?[ \t\n\r]*\\\\\\([A-Za-z]+\\)[ \t\n\r]*}?"
36           ;; The following is the opening brace of argument specification and is
37           ;; needed to skip internal macros containing `:' or `_'.
38           "[ \t\n\r]*{")
39   "Matches macros by xparse package.")
40
41 (defvar LaTeX-xparse-environment-regexp
42   (concat "\\\\\\(?:Declare\\|New\\|Renew\\|Provide\\)DocumentEnvironment"
43           "[ \t\n\r]*{[ \t\n\r]*\\([A-Za-z]+\\)[ \t\n\r]*}")
44   "Matches environments by xparse package.")
45
46 (TeX-add-style-hook
47  "xparse"
48  (lambda ()
49    (TeX-auto-add-regexp `(,LaTeX-xparse-macro-regexp 1 TeX-auto-symbol))
50    (TeX-auto-add-regexp
51     `(,LaTeX-xparse-environment-regexp 1 LaTeX-auto-environment))
52    (TeX-run-style-hooks
53     "expl3")
54    (TeX-add-symbols
55     ;; Declaring commands and environments
56     '("DeclareDocumentCommand" TeX-arg-define-macro "Argument specification" t)
57     '("NewDocumentCommand" TeX-arg-define-macro "Argument specification" t)
58     '("RenewDocumentCommand" TeX-arg-macro "Argument specification" t)
59     '("ProvideDocumentCommand" TeX-arg-define-macro "Argument specification" t)
60     '("DeclareDocumentEnvironment" TeX-arg-define-environment
61       "Argument specification" t t)
62     '("NewDocumentEnvironment" TeX-arg-define-environment
63       "Argument specification" t t)
64     '("RenewDocumentEnvironment" TeX-arg-environment
65       "Argument specification" t t)
66     '("ProvideDocumentEnvironment" TeX-arg-define-environment
67       "Argument specification" t t)
68     ;; Fully-expandable document commands
69     '("DeclareExpandableDocumentCommand"
70       TeX-arg-define-macro "Argument specification" t)
71     ;; Testing special values
72     '("IfBooleanTF" 3)
73     '("IfBooleanT" 3)
74     '("IfBooleanF" 3)
75     '("IfNoValueTF" 3)
76     '("IfNoValueT" 3)
77     '("IfNoValueF" 3)
78     '("IfValueTF" 3)
79     '("IfValueT" 3)
80     '("IfValueF" 3)
81     "BooleanTrue"
82     "BooleanFalse"
83     ;; Argument processors
84     "ProcessedArgument"
85     "ReverseBoolean"
86     '("SplitArgument" "Number" "Token")
87     "SplitList"
88     "TrimSpaces"
89     '("ProcessList" "List" "Functiom")
90     ;; Access to the argument specification
91     '("GetDocumentCommandArgSpec" TeX-arg-macro)
92     '("GetDocumentEnvironmmentArgSpec" TeX-arg-environment)
93     '("ShowDocumentCommandArgSpec" TeX-arg-macro)
94     '("ShowDocumentEnvironmentArgSpec" TeX-arg-environment))
95    ;; Fontification
96    (when (and (featurep 'font-latex)
97               (eq TeX-install-font-lock 'font-latex-setup))
98      (font-latex-add-keywords '(("DeclareDocumentCommand" "|{{{")
99                                 ("NewDocumentCommand" "|{{{")
100                                 ("RenewDocumentCommand" "|{{{")
101                                 ("ProvideDocumentCommand" "|{{{")
102                                 ("DeclareExpandableDocumentCommand" "|{{{")
103                                 ("DeclareDocumentEnvironment" "{{{{")
104                                 ("NewDocumentEnvironment" "{{{{")
105                                 ("RenewDocumentEnvironment" "{{{{")
106                                 ("ProvideDocumentEnvironment" "{{{{"))
107                               'function)))
108  LaTeX-dialect)
109
110 (defun LaTeX-xparse-package-options ()
111   "Read the xparse package options from the user."
112   (TeX-read-key-val t '(("log-declarations" ("true" "false")))))
113
114 ;;; xparse.el ends here