[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/auctex ec7caff 14/95: Add new style/breqn.el
From: |
Tassilo Horn |
Subject: |
[elpa] externals/auctex ec7caff 14/95: Add new style/breqn.el |
Date: |
Sun, 16 Apr 2017 01:26:46 -0400 (EDT) |
branch: externals/auctex
commit ec7caff5fa3a31c39e21244a118cf59f6194f390
Author: Arash Esbati <address@hidden>
Commit: Arash Esbati <address@hidden>
Add new style/breqn.el
* Makefile.in (STYLESRC): Add new style.
* style/breqn.el: New file.
---
Makefile.in | 2 +-
style/breqn.el | 185 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 186 insertions(+), 1 deletion(-)
diff --git a/Makefile.in b/Makefile.in
index e650ddc..19ef2ab 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -163,7 +163,7 @@ STYLESRC = style/prosper.el \
style/bicaption.el style/amsfonts.el style/subfiles.el \
style/dcolumn.el style/mdframed.el style/tcolorboxlib-raster.el \
style/titleps.el style/titlesec.el style/titletoc.el \
- style/exam.el
+ style/exam.el style/breqn.el
STYLEELC = $(STYLESRC:.el=.elc)
diff --git a/style/breqn.el b/style/breqn.el
new file mode 100644
index 0000000..0c75fac
--- /dev/null
+++ b/style/breqn.el
@@ -0,0 +1,185 @@
+;;; breqn.el --- AUCTeX style for `breqn.sty' (v0.98e)
+
+;; Copyright (C) 2017 Free Software Foundation, Inc.
+
+;; Author: Arash Esbati <address@hidden>
+;; Maintainer: address@hidden
+;; Created: 2017-01-06
+;; 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 `breqn.sty' (v0.98e) from 2017/01/27.
+;; `breqn.sty' is part of TeXLive.
+
+;; In breqn documentation, there is the following statement:
+;;
+;; 9 Various environment options
+;;
+;; Use of the normal \label command instead of the label option
+;; works, I think, most of the time (untested).
+;;
+;; To be on the safe side, a label should be written in the optional
+;; argument of an environment as value to the `label' key, e.g.:
+;;
+;; \begin{dmath}[label={eq:42}]
+;; ...
+;; \end{dmath}
+;;
+;; This style achieves this requirement by using the function
+;; `LaTeX-env-label-as-keyval'.
+
+;;; Code:
+
+(defvar LaTeX-breqn-key-val-options
+ '(("style" ("\\tiny" "\\scriptsize" "\\footnotesize" "\\small"
+ "\\normalsize" "\\large" "\\Large" "\\LARGE"
+ "\\huge" "\\Huge"))
+ ("number")
+ ("indentstep")
+ ("compact")
+ ("spread")
+ ("frame")
+ ("framesep")
+ ("background")
+ ("color")
+ ("breakdepth"))
+ "Key=value options for breqn environments.
+The keys \"label\" and \"labelprefix\" are omitted.")
+
+(defvar LaTeX-breqn-key-val-options-local nil
+ "Buffer-local key=value options for breqn environments.")
+(make-variable-buffer-local 'LaTeX-breqn-key-val-options-local)
+
+(defvar LaTeX-breqn-key-val-label-regexp
+ `(,(concat
+ "\\\\begin{"
+ (regexp-opt '("dmath" "dseries" "dgroup" "darray"))
+ "}"
+ "\\(?:\\[[^][]*"
+ "\\(?:{[^}{]*"
+ "\\(?:{[^}{]*"
+ "\\(?:{[^}{]*}[^}{]*\\)*"
+ "}[^}{]*\\)*"
+ "}[^][]*\\)*"
+ "label[ \t]*=[ \t]*{\\([^}]+\\)}"
+ "\\(?:[^]]*\\)*"
+ "\\]\\)")
+ 1 LaTeX-auto-label)
+ "Matches the label inside an optional argument after
\\begin{<breqn-env's>}.")
+
+(defun LaTeX-breqn-env (env)
+ "Insert ENV from breqn package incl. optional key=val argument.
+Keys offered for key=val query depend on ENV. \"label\" and
+\"labelprefix\" are omitted."
+ (let ((keyvals
+ (TeX-read-key-val t
+ (cond ((or (string= env "dgroup")
+ (string= env "dgroup*"))
+ (append '(("noalign") ("brace"))
+ LaTeX-breqn-key-val-options-local))
+ ((or (string= env "darray")
+ (string= env "darray*"))
+ (append '(("noalign") ("brace") ("cols"
("{}")))
+ LaTeX-breqn-key-val-options-local))
+ (t LaTeX-breqn-key-val-options-local)))))
+ (LaTeX-insert-environment env (when (and keyvals
+ (not (string= keyvals "")))
+ (concat LaTeX-optop keyvals LaTeX-optcl)))
+ (LaTeX-env-label-as-keyval nil nil keyvals env)))
+
+(defun LaTeX-breqn-update-color-keys ()
+ "Update color relevant keys from `LaTeX-breqn-key-val-options-local'."
+ (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))
+ (keys '("color" "background"))
+ (tmp (copy-alist LaTeX-breqn-key-val-options-local)))
+ (dolist (x keys)
+ (assq-delete-all (car (assoc x tmp)) tmp)
+ (push (list x (mapcar #'car (funcall colorcmd))) tmp))
+ (setq LaTeX-breqn-key-val-options-local
+ (copy-alist tmp)))))
+
+(add-hook 'TeX-auto-cleanup-hook #'LaTeX-breqn-update-color-keys t)
+(add-hook 'TeX-update-style-hook #'TeX-auto-parse t)
+
+(TeX-add-style-hook
+ "breqn"
+ (lambda ()
+
+ ;; Local version of key-val options
+ (setq LaTeX-breqn-key-val-options-local
+ (copy-alist LaTeX-breqn-key-val-options))
+
+ ;; Add breqn to parser:
+ (TeX-auto-add-regexp LaTeX-breqn-key-val-label-regexp)
+
+ ;; Tell AUCTeX that we want to prefix the labels with
`LaTeX-equation-label':
+ (let ((envs '("dmath" "dseries" "dgroup" "darray")))
+ (dolist (env envs)
+ (add-to-list 'LaTeX-label-alist (cons env LaTeX-equation-label) t)))
+
+ ;; For RefTeX, we must distinguish between equation and eqnarray-like:
+ ;; breqn env == equivalent -- starred
+ ;; dmath == equation -- dmath* == unnumbered
+ ;; dseries == equation -- dseries* == unnumbered
+ ;; dgroup == align -- dgroup* == unnumbered
+ ;; darray == eqnarray -- darray* == unnumbered
+ (when (fboundp 'reftex-add-label-environments)
+ (dolist (env '("dmath" "dseries" "dgroup"))
+ (reftex-add-label-environments `((,env ?e nil nil t))))
+ (reftex-add-label-environments '(("darray" ?e nil nil eqnarray-like))))
+
+ (LaTeX-add-environments
+ '("dmath" LaTeX-breqn-env)
+ '("dmath*" LaTeX-breqn-env)
+ '("dseries" LaTeX-breqn-env)
+ '("dseries*" LaTeX-breqn-env)
+ '("dgroup" LaTeX-breqn-env)
+ '("dgroup*" LaTeX-breqn-env)
+ '("darray" LaTeX-breqn-env)
+ '("darray" LaTeX-breqn-env)
+ '("dsuspend"))
+
+ (TeX-add-symbols
+ '("condition" [ "Punctuation mark (default ,)" ] t)
+ '("condition*" [ "Punctuation mark (default ,)" ] t)
+ '("hiderel" t))
+
+ ;; Fontification
+ (when (and (featurep 'font-latex)
+ (eq TeX-install-font-lock 'font-latex-setup)
+ (boundp 'font-latex-math-environments))
+ (make-local-variable 'font-latex-math-environments)
+ (let ((envs '(;; Do not insert the starred versions here;
+ ;; function `font-latex-match-math-envII' takes
+ ;; care of it
+ "dmath" "dseries" "dgroup" "darray")))
+ (dolist (env envs)
+ (add-to-list 'font-latex-math-environments env t)))))
+ LaTeX-dialect)
+
+(defvar LaTeX-breqn-package-options nil
+ "Package options for the breqn package.")
+
+;;; breqn.el ends here
- [elpa] externals/auctex 74766b4 03/95: Remove also a gitignore, (continued)
- [elpa] externals/auctex 74766b4 03/95: Remove also a gitignore, Tassilo Horn, 2017/04/16
- [elpa] externals/auctex 7230fec 07/95: * latex.el (LaTeX-newline): Make interactive. See bug#24412., Tassilo Horn, 2017/04/16
- [elpa] externals/auctex a77e75a 15/95: ; * doc/changes.texi: Improve wording., Tassilo Horn, 2017/04/16
- [elpa] externals/auctex 76a2b5f 18/95: * tex-ispell.el: Add support for enviroments from breqn.sty., Tassilo Horn, 2017/04/16
- [elpa] externals/auctex 558da5f 24/95: * latex/preview.dtx: Fix example for \PreviewMacro* macro., Tassilo Horn, 2017/04/16
- [elpa] externals/auctex 73ccc38 22/95: Simplify addition of entirely skipped environments, Tassilo Horn, 2017/04/16
- [elpa] externals/auctex 4f2a322 16/95: Fix plain-TeX-auto-regexp-list docstring, Tassilo Horn, 2017/04/16
- [elpa] externals/auctex fbe0782 11/95: Add `NO-INSERT' argument to `LaTeX-label', Tassilo Horn, 2017/04/16
- [elpa] externals/auctex d54e747 19/95: Fix font-latex-after-hacking-local-variables on XEmacs, Tassilo Horn, 2017/04/16
- [elpa] externals/auctex 1b3f6e8 13/95: Update style/listings.el to use `LaTeX-env-label-as-keyval', Tassilo Horn, 2017/04/16
- [elpa] externals/auctex ec7caff 14/95: Add new style/breqn.el,
Tassilo Horn <=
- [elpa] externals/auctex 5708567 26/95: Improve parsing process in style/color.el, Tassilo Horn, 2017/04/16
- [elpa] externals/auctex c21aff6 31/95: ; Add `LaTeX-equation-label' as symbol to `LaTeX-label-alist', Tassilo Horn, 2017/04/16
- [elpa] externals/auctex c0f3659 21/95: Fix TeX-view-predicate-list-builtin predicates wrt class opts, Tassilo Horn, 2017/04/16
- [elpa] externals/auctex 6c91dba 20/95: Fix number of arguments of local-variable-p in XEmacs, Tassilo Horn, 2017/04/16
- [elpa] externals/auctex e18e46e 32/95: * latex.el (LaTeX-label): Eliminate premature returning of label., Tassilo Horn, 2017/04/16
- [elpa] externals/auctex f12dbb2 27/95: Improve parsing process in style/xcolor.el, Tassilo Horn, 2017/04/16
- [elpa] externals/auctex 85c4656 12/95: Add function to put labels in opt. argument of environments, Tassilo Horn, 2017/04/16
- [elpa] externals/auctex c112a9e 34/95: ; * style/empheq.el (LaTeX-empheq-item-equation): Delete unnecessary *., Tassilo Horn, 2017/04/16
- [elpa] externals/auctex f708e1b 29/95: Add new style/preview.el, Tassilo Horn, 2017/04/16
- [elpa] externals/auctex a1091b8 35/95: Improve determination of master file with subfiles class, Tassilo Horn, 2017/04/16