[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/auctex d27e773 21/28: Add new style environ.el.
From: |
Tassilo Horn |
Subject: |
[elpa] externals/auctex d27e773 21/28: Add new style environ.el. |
Date: |
Fri, 07 Aug 2015 15:59:25 +0000 |
branch: externals/auctex
commit d27e77316a03c8f1fab9ad403ad349724c2d7b6c
Author: Arash Esbati <address@hidden>
Commit: Mosè Giordano <address@hidden>
Add new style environ.el.
Signed-off-by: Mosè Giordano <address@hidden>
---
ChangeLog | 4 ++
Makefile.in | 2 +-
style/environ.el | 127 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 132 insertions(+), 1 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 6eca23d..13d1120 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
2015-07-18 Arash Esbati <address@hidden>
+ * Makefile.in (STYLESRC): Add new style.
+
+ * style/environ.el: New file.
+
* style/tabulary.el ("tabulary"): Add `LCRJ' to
`LaTeX-array-column-letters'.
diff --git a/Makefile.in b/Makefile.in
index 290462c..0552e52 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -149,7 +149,7 @@ STYLESRC = style/prosper.el \
style/geometry.el style/ltablex.el style/ltxtable.el \
style/mn2e.el style/colortbl.el style/attachfile.el \
style/newpxtext.el style/newpxmath.el style/pdfpages.el \
- style/mnras.el
+ style/mnras.el style/environ.el
STYLEELC = $(STYLESRC:.el=.elc)
diff --git a/style/environ.el b/style/environ.el
new file mode 100644
index 0000000..bac82fc
--- /dev/null
+++ b/style/environ.el
@@ -0,0 +1,127 @@
+;;; environ.el --- AUCTeX style for `environ.sty' version v0.3
+
+;; Copyright (C) 2015 Free Software Foundation, Inc.
+
+;; Author: Arash Esbati <esbati'at'gmx.de>
+;; 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 `environ.sty' version v0.3 from
+;; 2014/05/04. `environ.sty' is part of TeXLive.
+
+;; Name of new env's defined with `\NewEnviron' are automatically
+;; added to list of known env's, e.g.:
+;;
+;; \NewEnviron{test}{<macro code>}
+;;
+;; `test' will be in completion list upon `C-c C-e'.
+
+;; More sophisticated definions must go through AUCTeX's parser, e.g.:
+;;
+;; \NewEnviron{test}[2][]{<macro code>}
+;;
+;; After a definition like this, you have to invoke `C-c C-n' to get
+;; the correct completion.
+
+;;; Code:
+
+(defvar LaTeX-auto-environ-NewEnviron nil
+ "Temporary for parsing the arguments of `\\NewEnviron'
+from `environ' package.")
+
+(defvar LaTeX-environ-NewEnviron-regexp
+ `(,(concat "\\\\\\(?:Ren\\|N\\)ewEnviron"
+ "[ \t\n\r]*{\\([A-Za-z0-9]+\\)}%?"
+ "[ \t\n\r]*\\[?\\([0-9]?\\)\\]?%?"
+ "[ \t\n\r]*\\(\\[\\)?")
+ (1 2 3) LaTeX-auto-environ-NewEnviron)
+ "Matches the argument of `\\NewEnviron' and `\\RenewEnviron'
+from `environ.sty'.")
+
+(defun LaTeX-environ-auto-prepare ()
+ "Clear temporary variable from `environ.sty' before parsing."
+ (setq LaTeX-auto-environ-NewEnviron nil))
+
+(defun LaTeX-environ-auto-cleanup ()
+ "Process the parsed results of `\\NewEnviron'."
+ (dolist (env-args LaTeX-auto-environ-NewEnviron)
+ (let ((env (car env-args))
+ (args (cadr env-args))
+ (opt (nth 2 env-args)))
+ (cond (;; opt. 1st argument and mandatory argument(s)
+ (and args (not (string-equal args ""))
+ opt (not (string-equal opt "")))
+ (add-to-list 'LaTeX-auto-environment
+ (list env 'LaTeX-env-args (vector "argument")
+ (1- (string-to-number args)))))
+ (;; mandatory argument(s) only
+ (and args (not (string-equal args ""))
+ (string-equal opt ""))
+ (add-to-list 'LaTeX-auto-environment
+ (list env (string-to-number args))))
+ (t ; No args
+ (add-to-list 'LaTeX-auto-environment (list env)))))))
+
+(add-hook 'TeX-auto-prepare-hook #'LaTeX-environ-auto-prepare t)
+(add-hook 'TeX-auto-cleanup-hook #'LaTeX-environ-auto-cleanup t)
+(add-hook 'TeX-update-style-hook #'TeX-auto-parse t)
+
+(defun TeX-arg-environ-final-code (_optional)
+ "Query for the presence of optional `final code' as argument to
+`\\NewEnviron' and insert the appropriate brackets."
+ (let ((fincode (y-or-n-p "With optional final code?")))
+ (when fincode
+ (insert "[]"))))
+
+(TeX-add-style-hook
+ "environ"
+ (lambda ()
+
+ ;; Add it to the parser
+ (TeX-auto-add-regexp LaTeX-environ-NewEnviron-regexp)
+
+ (TeX-add-symbols
+
+ ;; \NewEnviron{<name>}[<No.args>][<Opt.arg.>]{<Macro code>}[<Final code>]
+ '("NewEnviron"
+ (TeX-arg-define-environment "Environment")
+ [ "Number of arguments" ] [ "argument" ] t TeX-arg-environ-final-code)
+
+ '("RenewEnviron"
+ (TeX-arg-environment "Environment")
+ [ "Number of arguments" ] [ "argument" ] t TeX-arg-environ-final-code)
+
+ ;; Insert a pair of braces and we're done
+ '("environfinalcode" t)
+
+ ;; Pre-defined
+ '("BODY")
+
+ ;; Define another macro instead of \BODY
+ '("environbodyname" TeX-arg-define-macro)))
+ LaTeX-dialect)
+
+(defvar LaTeX-environ-package-options nil
+ "Package options for the environ package.")
+
+;;; environ.el ends here
- [elpa] externals/auctex 8426ca5 12/28: Missing ConTeXt-(un)numbered-section-list-nl variables., (continued)
- [elpa] externals/auctex 8426ca5 12/28: Missing ConTeXt-(un)numbered-section-list-nl variables., Tassilo Horn, 2015/08/07
- [elpa] externals/auctex 0efe678 14/28: Improve completion of includepdf macro., Tassilo Horn, 2015/08/07
- [elpa] externals/auctex 8052cd5 13/28: Find warnings emitted by a package with digits in its name., Tassilo Horn, 2015/08/07
- [elpa] externals/auctex 24a2a9d 20/28: Add `LCRJ' to `LaTeX-array-column-letters'., Tassilo Horn, 2015/08/07
- [elpa] externals/auctex b9eddc9 11/28: Really ignore dbus errors, Tassilo Horn, 2015/08/07
- [elpa] externals/auctex 1202f83 19/28: Add `X' to `LaTeX-array-column-letters'., Tassilo Horn, 2015/08/07
- [elpa] externals/auctex 5178ba6 16/28: Parse hf-tikz messages suggesting to rerun LaTeX., Tassilo Horn, 2015/08/07
- [elpa] externals/auctex bb195ae 15/28: Add new style file for mnras class., Tassilo Horn, 2015/08/07
- [elpa] externals/auctex c2c7dd9 18/28: Parse user-defined new column types., Tassilo Horn, 2015/08/07
- [elpa] externals/auctex e301b71 22/28: Add new style textpos.el., Tassilo Horn, 2015/08/07
- [elpa] externals/auctex d27e773 21/28: Add new style environ.el.,
Tassilo Horn <=
- [elpa] externals/auctex 482dddb 24/28: Query for default first arg when (re-)defining env's., Tassilo Horn, 2015/08/07
- [elpa] externals/auctex 107f106 23/28: Add new style vwcol.el., Tassilo Horn, 2015/08/07
- [elpa] externals/auctex e351a3a 26/28: Add missing commands `\nameref*' and `\Nameref'., Tassilo Horn, 2015/08/07
- [elpa] externals/auctex 6094700 17/28: Restore deleted preview README., Tassilo Horn, 2015/08/07
- [elpa] externals/auctex 166e14b 25/28: Fix a typo in the name of provided env's., Tassilo Horn, 2015/08/07
- [elpa] externals/auctex 3fdeb4b 27/28: Setup preview differently; fixes bug#21188, Tassilo Horn, 2015/08/07
- [elpa] externals/auctex 1fc2c7a 28/28: Merge branch 'master' into elpa, Tassilo Horn, 2015/08/07