[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[AUCTeX-diffs] [elpa] externals/auctex 5cf46ff8e2 52/60: Improve parsing
From: |
Tassilo Horn |
Subject: |
[AUCTeX-diffs] [elpa] externals/auctex 5cf46ff8e2 52/60: Improve parsing of re-definitions |
Date: |
Fri, 8 Apr 2022 11:52:56 -0400 (EDT) |
branch: externals/auctex
commit 5cf46ff8e20bb890cdbc53c2a516baa7388687b2
Author: Arash Esbati <arash@gnu.org>
Commit: Arash Esbati <arash@gnu.org>
Improve parsing of re-definitions
* latex.el (LaTeX-auto-regexp-list): Extend regexp's for defining
commands and environments to match also their re-defining
counterparts.
Improve matching of environment names.
Delete space after the `,' marker.
(LaTeX-auto-cleanup): Add checks for re-definition of macros and
environments in order to remove already defined entries from
`TeX-auto-symbol' and `LaTeX-auto-environment'.
---
latex.el | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++--------------
1 file changed, 50 insertions(+), 14 deletions(-)
diff --git a/latex.el b/latex.el
index a8696f39c2..8bb01c4905 100644
--- a/latex.el
+++ b/latex.el
@@ -1764,27 +1764,29 @@ This is necessary since index entries may contain
commands and stuff.")
(defvar LaTeX-auto-regexp-list
(append
(let ((token TeX-token-char))
- `((,(concat "\\\\\\(?:new\\|provide\\)command\\*?{?\\\\\\(" token
"+\\)}?\\[\\([0-9]+\\)\\]\\[\\([^\n\r]*\\)\\]")
- (1 2 3) LaTeX-auto-optional)
- (,(concat "\\\\\\(?:new\\|provide\\)command\\*?{?\\\\\\(" token
"+\\)}?\\[\\([0-9]+\\)\\]")
- (1 2) LaTeX-auto-arguments)
+ `((,(concat "\\\\\\(re\\)?\\(?:new\\|provide\\)command\\*?"
+ "{?\\\\\\(" token
"+\\)}?\\[\\([0-9]+\\)\\]\\[\\([^\n\r]*\\)\\]")
+ (2 3 4 1) LaTeX-auto-optional)
+ (,(concat "\\\\\\(re\\)?\\(?:new\\|provide\\)command\\*?"
+ "{?\\\\\\(" token "+\\)}?\\[\\([0-9]+\\)\\]")
+ (2 3 1) LaTeX-auto-arguments)
(,(concat "\\\\\\(?:new\\|provide\\)command\\*?{?\\\\\\(" token
"+\\)}?")
1 TeX-auto-symbol)
- (,(concat "\\\\newenvironment\\*?{?\\(" token
"+\\)\\*?}?\\[\\([0-9]+\\)\\]\\[")
- (1 2) LaTeX-auto-env-args-with-opt)
- (,(concat "\\\\newenvironment\\*?{?\\(" token
"+\\)\\*?}?\\[\\([0-9]+\\)\\]")
- (1 2) LaTeX-auto-env-args)
- (,(concat "\\\\newenvironment\\*?{?\\(" token "+\\)\\*?}?")
+ ("\\\\\\(re\\)?newenvironment\\*?{\\([^}]+\\)}\\[\\([0-9]+\\)\\]\\["
+ (2 3 1) LaTeX-auto-env-args-with-opt)
+ ("\\\\\\(re\\)?newenvironment\\*?{\\([^}]+\\)}\\[\\([0-9]+\\)\\]"
+ (2 3 1) LaTeX-auto-env-args)
+ ("\\\\newenvironment\\*?{\\([^}]+\\)}"
1 LaTeX-auto-environment)
(,(concat "\\\\newtheorem{\\(" token "+\\)}") 1 LaTeX-auto-environment)
("\\\\input{\\(\\.*[^#}%\\\\\\.\n\r]+\\)\\(\\.[^#}%\\\\\\.\n\r]+\\)?}"
1 TeX-auto-file)
("\\\\include{\\(\\.*[^#}%\\\\\\.\n\r]+\\)\\(\\.[^#}%\\\\\\.\n\r]+\\)?}"
1 TeX-auto-file)
- (, (concat "\\\\bibitem{\\(" token "[^, \n\r\t%\"#'()={}]*\\)}")
- 1 LaTeX-auto-bibitem)
- (, (concat "\\\\bibitem\\[[^][\n\r]+\\]{\\(" token "[^,
\n\r\t%\"#'()={}]*\\)}")
- 1 LaTeX-auto-bibitem)
+ (,(concat "\\\\bibitem{\\(" token "[^, \n\r\t%\"#'()={}]*\\)}")
+ 1 LaTeX-auto-bibitem)
+ (,(concat "\\\\bibitem\\[[^][\n\r]+\\]{\\(" token "[^,
\n\r\t%\"#'()={}]*\\)}")
+ 1 LaTeX-auto-bibitem)
("\\\\bibliography{\\([^#}\\\\\n\r]+\\)}" 1 LaTeX-auto-bibliography)
("\\\\addbibresource\\(?:\\[[^]]+\\]\\)?{\\([^#}\\\\\n\r]+\\)\\..+}"
1 LaTeX-auto-bibliography)
@@ -1973,7 +1975,8 @@ The value is actually the tail of the list of options
given to PACKAGE."
((member "12pt" options)
"12")
(t
- "10"))) t)
+ "10")))
+ t)
(unless (equal options '(""))
(TeX-add-to-alist 'LaTeX-provided-class-options
(list (cons style options)))))
@@ -1987,6 +1990,14 @@ The value is actually the tail of the list of options
given to PACKAGE."
;; Cleanup optional arguments
(mapc (lambda (entry)
+ ;; If we're renewcommand-ing and there is already an entry
+ ;; in `TeX-auto-symbol', delete it first:
+ (when (and (string= (nth 2 entry) "re")
+ (assoc (car entry) TeX-auto-symbol))
+ (setq TeX-auto-symbol
+ (assq-delete-all (car (assoc (car entry)
+ TeX-auto-symbol))
+ TeX-auto-symbol)))
(add-to-list 'TeX-auto-symbol
(list (nth 0 entry)
(string-to-number (nth 1 entry)))))
@@ -1994,6 +2005,14 @@ The value is actually the tail of the list of options
given to PACKAGE."
;; Cleanup default optional arguments
(mapc (lambda (entry)
+ ;; If we're renewcommand-ing and there is already an entry
+ ;; in `TeX-auto-symbol', delete it first:
+ (when (and (string= (nth 3 entry) "re")
+ (assoc (car entry) TeX-auto-symbol))
+ (setq TeX-auto-symbol
+ (assq-delete-all (car (assoc (car entry)
+ TeX-auto-symbol))
+ TeX-auto-symbol)))
(add-to-list 'TeX-auto-symbol
(list (nth 0 entry)
(vector "argument")
@@ -2002,12 +2021,29 @@ The value is actually the tail of the list of options
given to PACKAGE."
;; Cleanup environments arguments
(mapc (lambda (entry)
+ ;; If we're renewenvironment-ing and there is already an
+ ;; entry in `LaTeX-auto-environment', delete it first:
+ (when (and (string= (nth 2 entry) "re")
+ (assoc (car entry) LaTeX-auto-environment))
+ (setq LaTeX-auto-environment
+ (assq-delete-all (car (assoc (car entry)
+ LaTeX-auto-environment))
+ LaTeX-auto-environment)))
(add-to-list 'LaTeX-auto-environment
(list (nth 0 entry)
(string-to-number (nth 1 entry)))))
LaTeX-auto-env-args)
+
;; Ditto for environments with an optional arg
(mapc (lambda (entry)
+ ;; If we're renewenvironment-ing and there is already an
+ ;; entry in `LaTeX-auto-environment', delete it first:
+ (when (and (string= (nth 2 entry) "re")
+ (assoc (car entry) LaTeX-auto-environment))
+ (setq LaTeX-auto-environment
+ (assq-delete-all (car (assoc (car entry)
+ LaTeX-auto-environment))
+ LaTeX-auto-environment)))
(add-to-list 'LaTeX-auto-environment
(list (nth 0 entry) 'LaTeX-env-args (vector "argument")
(1- (string-to-number (nth 1 entry))))))
- [AUCTeX-diffs] [elpa] externals/auctex 238dad67f9 04/60: Introduce DEFAULT argument in `TeX-arg-length', (continued)
- [AUCTeX-diffs] [elpa] externals/auctex 238dad67f9 04/60: Introduce DEFAULT argument in `TeX-arg-length', Tassilo Horn, 2022/04/08
- [AUCTeX-diffs] [elpa] externals/auctex 7b0cbbb465 38/60: Document feature of []-induced indent, Tassilo Horn, 2022/04/08
- [AUCTeX-diffs] [elpa] externals/auctex 4b1c7015ae 45/60: Move contents of tex-buf.el into tex.el, Tassilo Horn, 2022/04/08
- [AUCTeX-diffs] [elpa] externals/auctex e032df90e7 05/60: Fix simultaneity, Tassilo Horn, 2022/04/08
- [AUCTeX-diffs] [elpa] externals/auctex a078fda16b 06/60: ; * doc/auctex.texi (Starting a Command): Delete obosolete comment., Tassilo Horn, 2022/04/08
- [AUCTeX-diffs] [elpa] externals/auctex b1a0d5df74 36/60: ; * style/algpseudocode.el: Fix position of TeX-dialect., Tassilo Horn, 2022/04/08
- [AUCTeX-diffs] [elpa] externals/auctex 1bc2630275 20/60: Don't change syntax of ^^A comments in doctex mode (bug#35140), Tassilo Horn, 2022/04/08
- [AUCTeX-diffs] [elpa] externals/auctex fa8842c626 26/60: Recognize macrocode*? environments in doctex-mode, Tassilo Horn, 2022/04/08
- [AUCTeX-diffs] [elpa] externals/auctex 45aff50ff3 48/60: Support \mathcolor in style/x?color.el, Tassilo Horn, 2022/04/08
- [AUCTeX-diffs] [elpa] externals/auctex 5d2829aed4 49/60: Remove old defadvices (patch by Stefan Monnier), Tassilo Horn, 2022/04/08
- [AUCTeX-diffs] [elpa] externals/auctex 5cf46ff8e2 52/60: Improve parsing of re-definitions,
Tassilo Horn <=
- [AUCTeX-diffs] [elpa] externals/auctex 03ed9004cd 60/60: Merge remote-tracking branch 'origin/master' into externals/auctex, Tassilo Horn, 2022/04/08
- [AUCTeX-diffs] [elpa] externals/auctex c050335dd8 21/60: ; Fix typo, Tassilo Horn, 2022/04/08
- [AUCTeX-diffs] [elpa] externals/auctex 69b78fcc26 54/60: Don't change indentation when defining a conditional, Tassilo Horn, 2022/04/08
- [AUCTeX-diffs] [elpa] externals/auctex 323eb08ca6 46/60: Assign reasonable sentinel in AmS-TeX mode, Tassilo Horn, 2022/04/08
- [AUCTeX-diffs] [elpa] externals/auctex 2af3c1bcbd 33/60: Add new style/ifthen.el, Tassilo Horn, 2022/04/08
- [AUCTeX-diffs] [elpa] externals/auctex e1c3e37e0c 56/60: ; Update copyright year, Tassilo Horn, 2022/04/08
- [AUCTeX-diffs] [elpa] externals/auctex 3df1e313ea 25/60: Adapt TeX-region-hook for lexical-binding, Tassilo Horn, 2022/04/08
- [AUCTeX-diffs] [elpa] externals/auctex fded69c292 59/60: Let \Describe<foo> macros stay on their own lines, Tassilo Horn, 2022/04/08
- [AUCTeX-diffs] [elpa] externals/auctex 806100f29a 27/60: Delete obsoleted variables (bug#54339), Tassilo Horn, 2022/04/08
- [AUCTeX-diffs] [elpa] externals/auctex 9554d1e8a2 40/60: * doc/changes.texi: Announce the indentation improvement., Tassilo Horn, 2022/04/08