auctex-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[AUCTeX-diffs] GNU AUCTeX branch, master, updated. ab57cb076d148321ef859


From: Arash Esbati
Subject: [AUCTeX-diffs] GNU AUCTeX branch, master, updated. ab57cb076d148321ef859422dd1b158fc7652c74
Date: Tue, 23 Apr 2019 15:33:59 -0400 (EDT)

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU AUCTeX".

The branch, master has been updated
       via  ab57cb076d148321ef859422dd1b158fc7652c74 (commit)
      from  ddd78945c0c82b4601e55b0bea100d095106403b (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit ab57cb076d148321ef859422dd1b158fc7652c74
Author: Arash Esbati <address@hidden>
Date:   Tue Apr 23 21:32:59 2019 +0200

    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'.

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)

-----------------------------------------------------------------------

Summary of changes:
 latex.el          | 36 ++++++++++++++++++++++++++++++++++++
 style/breqn.el    | 14 ++++----------
 style/listings.el | 20 ++++----------------
 3 files changed, 44 insertions(+), 26 deletions(-)


hooks/post-receive
-- 
GNU AUCTeX



reply via email to

[Prev in Thread] Current Thread [Next in Thread]