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. 8e0fb6559974d8bc1920b


From: Arash Esbati
Subject: [AUCTeX-diffs] GNU AUCTeX branch, master, updated. 8e0fb6559974d8bc1920b5abe1a142ad71d045de
Date: Wed, 17 Nov 2021 04:04:00 -0500 (EST)

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  8e0fb6559974d8bc1920b5abe1a142ad71d045de (commit)
      from  43f6398028d1d14e4ee5a9538e2dba4ef791ea53 (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 8e0fb6559974d8bc1920b5abe1a142ad71d045de
Author: Arash Esbati <arash@gnu.org>
Date:   Wed Nov 17 10:03:03 2021 +0100

    Improve handling of key=vals in style/listings.el
    
    * style/listings.el (LaTeX-listings-key-val-options): Fix a typo.
    (LaTeX-listings-key-val-options-local)
    (LaTeX-listings-update-style-key): Remove now unused variable and
    function.
    (LaTeX-listings-key-val-options): New function returning key=vals.
    (LaTeX-listings-lstnewenvironment-regexp): Adjust matching of
    first optional argument.
    ("listings"): Call the function `LaTeX-listings-key-val-options'
    instead of the variable `LaTeX-listings-key-val-options-local'.
    Various docstring fixes.

diff --git a/style/listings.el b/style/listings.el
index 50f0907..cfd4968 100644
--- a/style/listings.el
+++ b/style/listings.el
@@ -1,6 +1,6 @@
 ;;; listings.el --- AUCTeX style for `listings.sty'  -*- lexical-binding: t; 
-*-
 
-;; Copyright (C) 2004, 2005, 2009, 2013-2020 Free Software Foundation, Inc.
+;; Copyright (C) 2004, 2005, 2009, 2013-2021 Free Software Foundation, Inc.
 
 ;; Author: Ralf Angeli <angeli@iwi.uni-sb.de>
 ;; Maintainer: auctex-devel@gnu.org
@@ -58,6 +58,9 @@
 (declare-function font-latex-set-syntactic-keywords
                   "font-latex")
 
+(declare-function LaTeX-color-definecolor-list "color" ())
+(declare-function LaTeX-xcolor-definecolor-list "xcolor" ())
+
 ;; The following are options taken from chapter 4 of the listings
 ;; manual (2007/02/22 Version 1.4).
 (defvar LaTeX-listings-key-val-options
@@ -162,7 +165,7 @@
     ("backgroundcolor")
     ("rulecolor")
     ("fillcolor")
-    ("fulesepcolor")
+    ("rulesepcolor")
     ("frameshape")
     ;; Indexing
     ("index")
@@ -246,22 +249,45 @@
     ("multicolumn"))
   "Key=value options for listings macros and environments.")
 
-(defvar LaTeX-listings-key-val-options-local nil
-  "Buffer-local Key=value options for listings macros and environments.")
-(make-variable-buffer-local 'LaTeX-listings-key-val-options-local)
+(defun LaTeX-listings-key-val-options ()
+  "Return an updated list of key=vals from listings package."
+  (append
+   ;; Check for x?color package.  Note that listings requires a \color
+   ;; command, e.g., 'rulecolor=\color{blue}':
+   (when (and (or (member "xcolor" (TeX-style-list))
+                  (member "color" TeX-active-styles)))
+     (let* ((colorcmd (if (member "xcolor" TeX-active-styles)
+                          #'LaTeX-xcolor-definecolor-list
+                        #'LaTeX-color-definecolor-list))
+            (colors (mapcar (lambda (x)
+                              (concat TeX-esc "color" TeX-grop x TeX-grcl))
+                            (mapcar #'car (funcall colorcmd))))
+            (keys '("backgroundcolor"
+                    "fillcolor"
+                    "rulecolor"
+                    "rulesepcolor"))
+            result)
+       (dolist (key keys result)
+         (push (list key colors) result))))
+   ;; Cater for user defined styles:
+   (when (LaTeX-listings-lstdefinestyle-list)
+     `(("style" ,(mapcar #'car (LaTeX-listings-lstdefinestyle-list)))))
+   ;; Standard key=vals:
+   LaTeX-listings-key-val-options))
 
 ;; Setup for \lstnewenvironment:
 (defvar LaTeX-auto-listings-lstnewenvironment nil
-  "Temporary for parsing the arguments of `\\lstnewenvironment'
-from `listings' package.")
+  "Temporary for parsing the arguments of '\\lstnewenvironment'.")
 
 (defvar LaTeX-listings-lstnewenvironment-regexp
   `(,(concat "\\\\lstnewenvironment"
-             "[ \t\n\r]*{\\([A-Za-z0-9]+\\)}%?"
-             "[ \t\n\r]*\\[?\\([0-9]?\\)\\]?%?"
+             "[ \t\n\r]*{\\([A-Za-z0-9]+\\)}"
+             "%?"
+             "[ \t\n\r]*\\(?:\\[\\([0-9]\\)\\]\\)?"
+             "%?"
              "[ \t\n\r]*\\(\\[\\)?")
     (1 2 3) LaTeX-auto-listings-lstnewenvironment)
-  "Matches the argument of `\\lstnewenvironment' from `listings.sty'.")
+  "Matches the argument of '\\lstnewenvironment'.")
 
 ;; Setup for \lstdefinestyle:
 (TeX-auto-add-type "listings-lstdefinestyle" "LaTeX")
@@ -269,8 +295,7 @@ from `listings' package.")
 (defvar LaTeX-listings-lstdefinestyle-regexp
   '("\\\\lstdefinestyle{\\([^}]+\\)}"
     1 LaTeX-auto-listings-lstdefinestyle)
-  "Matches the argument of \"\\lstdefinestyle\" from
-\"listings\" package.")
+  "Matches the argument of '\\lstdefinestyle' from 'listings' package.")
 
 ;; Setup for parsing the labels inside optional arguments:
 
@@ -280,27 +305,13 @@ from `listings' package.")
     1 LaTeX-auto-label)
   "Matches the label inside an optional argument after \\begin{lstlisting}.")
 
-(defun LaTeX-listings-update-style-key ()
-  "Update the \"style\" key from `LaTeX-listings-key-val-options-local'
-with user-defined values via the \"lstdefinestyle\" macro."
-  (let* ((elt (assoc "style" LaTeX-listings-key-val-options-local))
-         (key (car elt))
-         (temp (copy-alist LaTeX-listings-key-val-options-local))
-         (opts (assq-delete-all (car (assoc key temp)) temp)))
-    (cl-pushnew (list key (TeX-delete-duplicate-strings
-                           (mapcar #'car 
(LaTeX-listings-lstdefinestyle-list))))
-                opts :test #'equal)
-    (setq LaTeX-listings-key-val-options-local
-          (copy-alist opts))))
-
 (defun LaTeX-listings-auto-prepare ()
-  "Clear temporary variable from `listings.sty' before parsing."
+  "Clear temporary variable from 'listings' package before parsing."
   (setq LaTeX-auto-listings-lstnewenvironment nil)
   (setq LaTeX-auto-listings-lstdefinestyle    nil))
 
 (defun LaTeX-listings-auto-cleanup ()
-  "Process the parsed results of \"\\lstnewenvironment\" and
-\"\\lstdefinestyle\"."
+  "Process the parsed results of 'listings' package."
   (dolist (env-args LaTeX-auto-listings-lstnewenvironment)
     (let ((env  (car   env-args))
           (args (cadr  env-args))
@@ -311,7 +322,7 @@ with user-defined values via the \"lstdefinestyle\" macro."
              (LaTeX-add-environments
               `(,env
                 LaTeX-env-args
-                [TeX-arg-key-val LaTeX-listings-key-val-options-local]
+                [TeX-arg-key-val (LaTeX-listings-key-val-options)]
                 (LaTeX-env-label-as-keyval "caption")
                 ,(1- (string-to-number args)))))
             (;; mandatory argument(s) only
@@ -340,9 +351,7 @@ with user-defined values via the \"lstdefinestyle\" macro."
         ;; Tell font-lock about the update.
         (font-latex-set-syntactic-keywords))
       ;; Add new env's to `ispell-tex-skip-alist': skip the entire env
-      (TeX-ispell-skip-setcdr `(,(cons env (concat "\\\\end{" env "}"))))))
-  (when (LaTeX-listings-lstdefinestyle-list)
-    (LaTeX-listings-update-style-key)))
+      (TeX-ispell-skip-setcdr `(,(cons env (concat "\\\\end{" env "}")))))))
 
 (add-hook 'TeX-auto-prepare-hook #'LaTeX-listings-auto-prepare t)
 (add-hook 'TeX-auto-cleanup-hook #'LaTeX-listings-auto-cleanup t)
@@ -390,10 +399,6 @@ caption key is found, an error is issued."
    (TeX-auto-add-regexp LaTeX-listings-lstdefinestyle-regexp)
    (TeX-auto-add-regexp LaTeX-listings-key-val-label-regexp)
 
-   ;; Local version of key-val options:
-   (setq LaTeX-listings-key-val-options-local
-         (copy-alist LaTeX-listings-key-val-options))
-
    ;; New symbols
    (TeX-add-symbols
     '("lstalias" ["Alias dialect"] "Alias" ["Dialect"] "Language")
@@ -402,17 +407,16 @@ caption key is found, an error is issued."
        (lambda ()
          (let ((name (TeX-read-string "Style name: ")))
            (LaTeX-add-listings-lstdefinestyles name)
-           (LaTeX-listings-update-style-key)
            (format "%s" name))))
-      (TeX-arg-key-val LaTeX-listings-key-val-options-local))
-    '("lstinline" [TeX-arg-key-val LaTeX-listings-key-val-options-local]
+      (TeX-arg-key-val (LaTeX-listings-key-val-options)))
+    '("lstinline" [TeX-arg-key-val (LaTeX-listings-key-val-options)]
       TeX-arg-verb-delim-or-brace)
-    '("lstinputlisting" [TeX-arg-key-val LaTeX-listings-key-val-options-local]
+    '("lstinputlisting" [TeX-arg-key-val (LaTeX-listings-key-val-options)]
       TeX-arg-file)
     "lstlistoflistings"
     '("lstnewenvironment" "Name" ["Number or arguments"] ["Default argument"]
       "Starting code" "Ending code")
-    '("lstset" (TeX-arg-key-val LaTeX-listings-key-val-options-local))
+    '("lstset" (TeX-arg-key-val (LaTeX-listings-key-val-options)))
     '("lstloadlanguages" t)
     ;; 4.17 Short Inline Listing Commands
     '("lstMakeShortInline" [ "Options" ] "Character")
@@ -425,7 +429,7 @@ caption key is found, an error is issued."
    ;; New environments
    (LaTeX-add-environments
     '("lstlisting" LaTeX-env-args
-      [TeX-arg-key-val LaTeX-listings-key-val-options-local]
+      [TeX-arg-key-val (LaTeX-listings-key-val-options)]
       (LaTeX-env-label-as-keyval "caption")))
 
    ;; Append "lstlisting" to `LaTeX-label-alist':

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

Summary of changes:
 style/listings.el | 88 +++++++++++++++++++++++++++++--------------------------
 1 file changed, 46 insertions(+), 42 deletions(-)


hooks/post-receive
-- 
GNU AUCTeX



reply via email to

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