branch: externals/auctex commit 65652e8c2d7480fae7d25099630489f5c4728911 Author: Arash Esbati <ar...@gnu.org> Commit: Arash Esbati <ar...@gnu.org>
Simplify implementation of style/breqn.el * style/breqn.el (LaTeX-breqn-key-val-options): New function. (LaTeX-breqn-env): Delete function. ("breqn"): Replace functionality of deleted function with standard ones. Don't use `LaTeX-env-label-as-keyval' for starred environments. --- style/breqn.el | 65 ++++++++++++++++++++++++++++++++-------------------------- 1 file changed, 36 insertions(+), 29 deletions(-) diff --git a/style/breqn.el b/style/breqn.el index 035205565c..bdca52839f 100644 --- a/style/breqn.el +++ b/style/breqn.el @@ -1,6 +1,6 @@ ;;; breqn.el --- AUCTeX style for `breqn.sty' (v0.98j) -*- lexical-binding: t; -*- -;; Copyright (C) 2017--2020 Free Software Foundation, Inc. +;; Copyright (C) 2017--2022 Free Software Foundation, Inc. ;; Author: Arash Esbati <ar...@gnu.org> ;; Maintainer: auctex-devel@gnu.org @@ -64,6 +64,17 @@ "Key=value options for breqn environments. The keys \"label\" and \"labelprefix\" are omitted.") +(defun LaTeX-breqn-key-val-options () + "Return updated key=val's based on the current \"breqn\" environment." + (let ((currenv (LaTeX-current-environment))) + (cond ((string-match-p "\\`dgroup" currenv) + (append '(("noalign") ("brace")) + LaTeX-breqn-key-val-options)) + ((string-match-p "\\`darray" currenv) + (append '(("noalign") ("brace") ("cols" ("{}"))) + LaTeX-breqn-key-val-options)) + (t LaTeX-breqn-key-val-options)))) + (defvar LaTeX-breqn-key-val-label-regexp `(,(concat "\\\\begin{" @@ -73,26 +84,6 @@ The keys \"label\" and \"labelprefix\" are omitted.") 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)) - ((or (string= env "darray") - (string= env "darray*")) - (append '(("noalign") ("brace") ("cols" ("{}"))) - LaTeX-breqn-key-val-options)) - (t LaTeX-breqn-key-val-options))))) - (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))) - (add-hook 'TeX-update-style-hook #'TeX-auto-parse t) (TeX-add-style-hook @@ -119,14 +110,30 @@ Keys offered for key=val query depend on ENV. \"label\" and (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) + '("dmath" LaTeX-env-args + [TeX-arg-key-val (LaTeX-breqn-key-val-options)] + LaTeX-env-label-as-keyval) + '("dmath*" LaTeX-env-args + [TeX-arg-key-val (LaTeX-breqn-key-val-options)]) + + '("dseries" LaTeX-env-args + [TeX-arg-key-val (LaTeX-breqn-key-val-options)] + LaTeX-env-label-as-keyval) + '("dseries*" LaTeX-env-args + [TeX-arg-key-val (LaTeX-breqn-key-val-options)]) + + '("dgroup" LaTeX-env-args + [TeX-arg-key-val (LaTeX-breqn-key-val-options)] + LaTeX-env-label-as-keyval) + '("dgroup*" LaTeX-env-args + [TeX-arg-key-val (LaTeX-breqn-key-val-options)]) + + '("darray" LaTeX-env-args + [TeX-arg-key-val (LaTeX-breqn-key-val-options)] + LaTeX-env-label-as-keyval) + '("darray*" LaTeX-env-args + [TeX-arg-key-val (LaTeX-breqn-key-val-options)]) + '("dsuspend")) (TeX-add-symbols