[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[AUCTeX-diffs] [elpa] externals/auctex ab57cb0 21/80: Add new function `
From: |
Tassilo Horn |
Subject: |
[AUCTeX-diffs] [elpa] externals/auctex ab57cb0 21/80: Add new function `LaTeX-extract-key-value-label' |
Date: |
Wed, 16 Oct 2019 11:07:09 -0400 (EDT) |
branch: externals/auctex
commit ab57cb076d148321ef859422dd1b158fc7652c74
Author: Arash Esbati <address@hidden>
Commit: Arash Esbati <address@hidden>
Add new function `LaTeX-extract-key-value-label'
* latex.el (LaTeX-extract-key-value-label): Add new utility
function to return a regexp string to extract label value in an
optional key=val argument.
* style/breqn.el (LaTeX-breqn-key-val-label-regexp):
* style/listings.el (LaTeX-listings-key-val-label-regexp)
(LaTeX-listings-auto-cleanup): Use
`LaTeX-extract-key-value-label'.
Delete now unused variable `LaTeX-listings-key-val-label-extract'.
---
latex.el | 36 ++++++++++++++++++++++++++++++++++++
style/breqn.el | 14 ++++----------
style/listings.el | 20 ++++----------------
3 files changed, 44 insertions(+), 26 deletions(-)
diff --git a/latex.el b/latex.el
index 6a96cb4..f5f186d 100644
--- a/latex.el
+++ b/latex.el
@@ -6664,6 +6664,42 @@ functions `TeX-arg-color' (style/color.el) or
last-optional-rejected))
,@body))
+(defun LaTeX-extract-key-value-label (&optional key)
+ "Return a regexp string to match a label in an optional argument.
+The optional KEY is a string which is the name of the key in the
+key=value, default is \"label\".
+
+As an extra feature, the key can be the symbol none where the
+entire matching for the key=value is skipped. The regexp then is
+useful for skipping complex optional arguments. It should be
+wrapped in \(?:...\)? then."
+ ;; The regexp produced here is ideally in sync with the complex one
+ ;; in `reftex-label-regexps'.
+ (concat
+ ;; Match the opening [ and the following chars
+ "\[[^][]*"
+ ;; Allow nested levels of chars enclosed in braces
+ "\(?:{[^}{]*"
+ "\(?:{[^}{]*"
+ "\(?:{[^}{]*}[^}{]*\)*"
+ "}[^}{]*\)*"
+ "}[^][]*\)*"
+ ;; If KEY is the symbol none, don't look for any key=val:
+ (unless (eq key 'none)
+ (concat "\<"
+ ;; Match the key, default is label
+ (or key "label")
+ ;; Optional spaces
+ "[[:space:]]*=[[:space:]]*"
+ ;; Match the value; braces around the value are optional
+ "{?\("
+ ;; One of these chars terminates the value
+ "[^] ,}
%]+"
+ ;; Close the group
+ "\)}?"))
+ ;; We are done. Just search until the next closing bracket
+ "[^]]*\]"))
+
(provide 'latex)
;;; latex.el ends here
diff --git a/style/breqn.el b/style/breqn.el
index 63821f2..f22696c 100644
--- a/style/breqn.el
+++ b/style/breqn.el
@@ -1,6 +1,6 @@
;;; breqn.el --- AUCTeX style for `breqn.sty' (v0.98e)
-;; Copyright (C) 2017 Free Software Foundation, Inc.
+;; Copyright (C) 2017--2019 Free Software Foundation, Inc.
;; Author: Arash Esbati <address@hidden>
;; Maintainer: address@hidden
@@ -48,6 +48,8 @@
;;; Code:
+(require 'latex)
+
;; Silence the compiler:
(declare-function LaTeX-color-definecolor-list "color" ())
(declare-function LaTeX-xcolor-definecolor-list "xcolor" ())
@@ -77,15 +79,7 @@ The keys \"label\" and \"labelprefix\" are omitted.")
"\\begin{"
(regexp-opt '("dmath" "dseries" "dgroup" "darray"))
"}"
- "\(?:\[[^][]*"
- "\(?:{[^}{]*"
- "\(?:{[^}{]*"
- "\(?:{[^}{]*}[^}{]*\)*"
- "}[^}{]*\)*"
- "}[^][]*\)*"
- "label[ ]*=[ ]*{\([^}]+\)}"
- "\(?:[^]]*\)*"
- "\]\)")
+ (LaTeX-extract-key-value-label))
1 LaTeX-auto-label)
"Matches the label inside an optional argument after \begin{<breqn-env's>}.")
diff --git a/style/listings.el b/style/listings.el
index 598574c..5c20308 100644
--- a/style/listings.el
+++ b/style/listings.el
@@ -1,6 +1,6 @@
;;; listings.el --- AUCTeX style for `listings.sty'
-;; Copyright (C) 2004, 2005, 2009, 2013-2018 Free Software Foundation, Inc.
+;; Copyright (C) 2004, 2005, 2009, 2013--2019 Free Software Foundation, Inc.
;; Author: Ralf Angeli <address@hidden>
;; Maintainer: address@hidden
@@ -48,6 +48,7 @@
;; Needed for auto-parsing:
(require 'tex)
+(require 'latex)
;; Silence the compiler:
(declare-function font-latex-add-keywords
@@ -273,22 +274,9 @@ from `listings' package.")
;; Setup for parsing the labels inside optional arguments:
-(defvar LaTeX-listings-key-val-label-extract
- (concat
- "\(?:\[[^][]*"
- "\(?:{[^}{]*"
- "\(?:{[^}{]*"
- "\(?:{[^}{]*}[^}{]*\)*"
- "}[^}{]*\)*"
- "}[^][]*\)*"
- "label[ ]*=[ ]*{\([^}]+\)}"
- "\(?:[^]]*\)*"
- "\]\)")
- "Helper regexp to extract the label out of optional argument.")
-
(defvar LaTeX-listings-key-val-label-regexp
`(,(concat
- "\\begin{lstlisting}" LaTeX-listings-key-val-label-extract)
+ "\\begin{lstlisting}" (LaTeX-extract-key-value-label))
1 LaTeX-auto-label)
"Matches the label inside an optional argument after \begin{lstlisting}.")
@@ -338,7 +326,7 @@ with user-defined values via the \"lstdefinestyle\" macro."
(add-to-list 'LaTeX-label-alist `(,env . LaTeX-listing-label) t)
;; Add new env to parser for labels in opt. argument:
(TeX-auto-add-regexp `(,(concat "\\begin{" env "}"
- LaTeX-listings-key-val-label-extract)
+ (LaTeX-extract-key-value-label))
1 LaTeX-auto-label))
;; Tell RefTeX
(when (fboundp 'reftex-add-label-environments)
- [AUCTeX-diffs] [elpa] externals/auctex 3543e45 06/80: New styles for beamerarticle & beamerswitch triggering beamer, (continued)
- [AUCTeX-diffs] [elpa] externals/auctex 3543e45 06/80: New styles for beamerarticle & beamerswitch triggering beamer, Tassilo Horn, 2019/10/16
- [AUCTeX-diffs] [elpa] externals/auctex 7872796 15/80: * tex-info.el (TeX-texinfo-mode): Set `add-log-current-defun-function' locally., Tassilo Horn, 2019/10/16
- [AUCTeX-diffs] [elpa] externals/auctex 4d0cf0f 10/80: ; Silence the compiler, Tassilo Horn, 2019/10/16
- [AUCTeX-diffs] [elpa] externals/auctex d4660dd 18/80: * style/xparse.el ("xparse"): Fix fontification of alternatives., Tassilo Horn, 2019/10/16
- [AUCTeX-diffs] [elpa] externals/auctex cd39966 14/80: ; Fix typos, Tassilo Horn, 2019/10/16
- [AUCTeX-diffs] [elpa] externals/auctex 1a83f1b 09/80: ; Remove `eval-when-compile' for latex.el, Tassilo Horn, 2019/10/16
- [AUCTeX-diffs] [elpa] externals/auctex 2a642a4 19/80: Add support for ChangeLog entries for LaTeX files, Tassilo Horn, 2019/10/16
- [AUCTeX-diffs] [elpa] externals/auctex 5592f7d 17/80: Reset `TeX-PDF-from-DVI' if xetex engine is in use, Tassilo Horn, 2019/10/16
- [AUCTeX-diffs] [elpa] externals/auctex 18a09f0 03/80: * auctex.el: Add requireds, keywords, and trailer, Tassilo Horn, 2019/10/16
- [AUCTeX-diffs] [elpa] externals/auctex 1b6e513 22/80: ; Use `LaTeX-extract-key-value-label', Tassilo Horn, 2019/10/16
- [AUCTeX-diffs] [elpa] externals/auctex ab57cb0 21/80: Add new function `LaTeX-extract-key-value-label',
Tassilo Horn <=
- [AUCTeX-diffs] [elpa] externals/auctex ddd7894 20/80: ; Fix last commit, Tassilo Horn, 2019/10/16
- [AUCTeX-diffs] [elpa] externals/auctex af15814 42/80: ; * style/babel.el: Fix typo, remove code remainder., Tassilo Horn, 2019/10/16
- [AUCTeX-diffs] [elpa] externals/auctex 8530cd0 45/80: Support cleveref labels, Tassilo Horn, 2019/10/16
- [AUCTeX-diffs] [elpa] externals/auctex 4611580 32/80: * tex-jp.el (AUCTeX-jp): Add keyword :link to info node., Tassilo Horn, 2019/10/16
- [AUCTeX-diffs] [elpa] externals/auctex a9eb155 37/80: Fix regression, Tassilo Horn, 2019/10/16
- [AUCTeX-diffs] [elpa] externals/auctex 4776fd0 25/80: ; Remove compatibility code for older emacsen, Tassilo Horn, 2019/10/16
- [AUCTeX-diffs] [elpa] externals/auctex 400b002 28/80: Remove obsolete codes, Tassilo Horn, 2019/10/16
- [AUCTeX-diffs] [elpa] externals/auctex a8bbd1f 31/80: ; Fix document, Tassilo Horn, 2019/10/16
- [AUCTeX-diffs] [elpa] externals/auctex ff688b9 33/80: Stop depreciated usage of undeclared dynamic variable, Tassilo Horn, 2019/10/16
- [AUCTeX-diffs] [elpa] externals/auctex 945ffaf 40/80: Update style/babel.el to package version 3.31, Tassilo Horn, 2019/10/16