[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/auctex ab57cb0 21/80: Add new function `LaTeX-extract-k
From: |
Tassilo Horn |
Subject: |
[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
+ "[^] ,}\r\n\t%]+"
+ ;; 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[ \t]*=[ \t]*{\\([^}]+\\)}"
- "\\(?:[^]]*\\)*"
- "\\]\\)")
+ (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[ \t]*=[ \t]*{\\([^}]+\\)}"
- "\\(?:[^]]*\\)*"
- "\\]\\)")
- "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)
- [elpa] externals/auctex 083964b 02/80: Delete auctex-pkg.el which is not needed for ELPA releases, (continued)
- [elpa] externals/auctex 083964b 02/80: Delete auctex-pkg.el which is not needed for ELPA releases, Tassilo Horn, 2019/10/16
- [elpa] externals/auctex b82ab0c 08/80: Support up to 12 command arguments., Tassilo Horn, 2019/10/16
- [elpa] externals/auctex cd39966 14/80: ; Fix typos, Tassilo Horn, 2019/10/16
- [elpa] externals/auctex 686a8ed 13/80: Elaborate LaTeX math insertion command, Tassilo Horn, 2019/10/16
- [elpa] externals/auctex 8a36595 12/80: Fix handling of function entries in `TeX-complete-list', Tassilo Horn, 2019/10/16
- [elpa] externals/auctex fcaef6b 11/80: Improve fontification of \href macro, Tassilo Horn, 2019/10/16
- [elpa] externals/auctex 23b3405 23/80: ; Fix typos, Tassilo Horn, 2019/10/16
- [elpa] externals/auctex 3b3c224 26/80: Remove compatibility code for xemacs, Tassilo Horn, 2019/10/16
- [elpa] externals/auctex 2a642a4 19/80: Add support for ChangeLog entries for LaTeX files, Tassilo Horn, 2019/10/16
- [elpa] externals/auctex a8bbd1f 31/80: ; Fix document, Tassilo Horn, 2019/10/16
- [elpa] externals/auctex ab57cb0 21/80: Add new function `LaTeX-extract-key-value-label',
Tassilo Horn <=
- [elpa] externals/auctex 4776fd0 25/80: ; Remove compatibility code for older emacsen, Tassilo Horn, 2019/10/16
- [elpa] externals/auctex 92c090d 30/80: Fix treatment of class and package options, Tassilo Horn, 2019/10/16
- [elpa] externals/auctex a30db7c 24/80: Allow the user to customize which TeX commands are available in each mode., Tassilo Horn, 2019/10/16
- [elpa] externals/auctex 4d0cf0f 10/80: ; Silence the compiler, Tassilo Horn, 2019/10/16
- [elpa] externals/auctex 7872796 15/80: * tex-info.el (TeX-texinfo-mode): Set `add-log-current-defun-function' locally., Tassilo Horn, 2019/10/16
- [elpa] externals/auctex 18a09f0 03/80: * auctex.el: Add requireds, keywords, and trailer, Tassilo Horn, 2019/10/16
- [elpa] externals/auctex b141ded 27/80: Remove compatibility code for xemacs, Tassilo Horn, 2019/10/16
- [elpa] externals/auctex 4611580 32/80: * tex-jp.el (AUCTeX-jp): Add keyword :link to info node., Tassilo Horn, 2019/10/16
- [elpa] externals/auctex ca0437d 16/80: Update keywords to biblatex v3.12, Tassilo Horn, 2019/10/16
- [elpa] externals/auctex 1b6e513 22/80: ; Use `LaTeX-extract-key-value-label', Tassilo Horn, 2019/10/16