[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/auctex 8e0fb65 47/71: Improve handling of key=vals in s
From: |
Tassilo Horn |
Subject: |
[elpa] externals/auctex 8e0fb65 47/71: Improve handling of key=vals in style/listings.el |
Date: |
Fri, 17 Dec 2021 15:00:34 -0500 (EST) |
branch: externals/auctex
commit 8e0fb6559974d8bc1920b5abe1a142ad71d045de
Author: Arash Esbati <arash@gnu.org>
Commit: Arash Esbati <arash@gnu.org>
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.
---
style/listings.el | 88 +++++++++++++++++++++++++++++--------------------------
1 file changed, 46 insertions(+), 42 deletions(-)
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':
- [elpa] externals/auctex df0d719 52/71: Improve handling of key=vals in style/hologo.el, (continued)
- [elpa] externals/auctex df0d719 52/71: Improve handling of key=vals in style/hologo.el, Tassilo Horn, 2021/12/17
- [elpa] externals/auctex 08f5c9e 51/71: Improve handling of key=vals in style/floatrow.el, Tassilo Horn, 2021/12/17
- [elpa] externals/auctex 9fa3859 38/71: ; Remove duplicates, Tassilo Horn, 2021/12/17
- [elpa] externals/auctex 7b632c6 43/71: * doc/todo.texi (Mid-term Goals): Add TODO about tool bar., Tassilo Horn, 2021/12/17
- [elpa] externals/auctex b379da7 18/71: Don't indent begin/end of comment env, Tassilo Horn, 2021/12/17
- [elpa] externals/auctex 483f6e9 05/71: ; * style/hyperref.el ("hyperref"): Fix other link to testform.tex., Tassilo Horn, 2021/12/17
- [elpa] externals/auctex 380bc4a 06/71: Handle optional embellishment arguments correctly, Tassilo Horn, 2021/12/17
- [elpa] externals/auctex bd723c7 24/71: Cater for corner case when dealing with TeX error, Tassilo Horn, 2021/12/17
- [elpa] externals/auctex 6433dc3 30/71: Extend `TeX-read-key-val' to accept a function call, Tassilo Horn, 2021/12/17
- [elpa] externals/auctex df69443 26/71: ; Silence the compiler, Tassilo Horn, 2021/12/17
- [elpa] externals/auctex 8e0fb65 47/71: Improve handling of key=vals in style/listings.el,
Tassilo Horn <=
- [elpa] externals/auctex 0419539 37/71: Improve style/babel.el, Tassilo Horn, 2021/12/17
- [elpa] externals/auctex d62d8f3 34/71: Update style/fontspec.el to package version 2.7i, Tassilo Horn, 2021/12/17
- [elpa] externals/auctex b9545c8 45/71: Improve handling of key=vals in style/fancyvrb.el, Tassilo Horn, 2021/12/17
- [elpa] externals/auctex 9e97edc 49/71: Fix wrong logic of the previous commit, Tassilo Horn, 2021/12/17
- [elpa] externals/auctex 8c50665 62/71: Add new style/unicodefonttable.el, Tassilo Horn, 2021/12/17
- [elpa] externals/auctex 8e13306 66/71: Update style/url.el to package version 3.4, Tassilo Horn, 2021/12/17
- [elpa] externals/auctex 25c8d0f 12/71: Add NEWS for two commands available in Texinfo mode, Tassilo Horn, 2021/12/17
- [elpa] externals/auctex 2e26d49 61/71: Update style/siunitx.el to package version 3, Tassilo Horn, 2021/12/17
- [elpa] externals/auctex ee37db3 33/71: Supplement doc string, Tassilo Horn, 2021/12/17
- [elpa] externals/auctex d77f49e 54/71: Fontify \tabularnewline macro, Tassilo Horn, 2021/12/17