[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[AUCTeX-diffs] [elpa] externals/auctex 8e0fb65 47/71: Improve handling o
From: |
Tassilo Horn |
Subject: |
[AUCTeX-diffs] [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':
- [AUCTeX-diffs] [elpa] externals/auctex bc5f7bc 60/71: Add new style/cancel.el, (continued)
- [AUCTeX-diffs] [elpa] externals/auctex bc5f7bc 60/71: Add new style/cancel.el, Tassilo Horn, 2021/12/17
- [AUCTeX-diffs] [elpa] externals/auctex 380bc4a 06/71: Handle optional embellishment arguments correctly, Tassilo Horn, 2021/12/17
- [AUCTeX-diffs] [elpa] externals/auctex db45d9e 41/71: Improve handling of key=vals in style/mdframed.el, Tassilo Horn, 2021/12/17
- [AUCTeX-diffs] [elpa] externals/auctex 9f3e760 10/71: Recognize L3 \msg_line_context: on warning parsing, Tassilo Horn, 2021/12/17
- [AUCTeX-diffs] [elpa] externals/auctex 3684fde 17/71: Explain how to support option completion, Tassilo Horn, 2021/12/17
- [AUCTeX-diffs] [elpa] externals/auctex 44a8a42 09/71: ; Don't use `assoc-delete-all', Tassilo Horn, 2021/12/17
- [AUCTeX-diffs] [elpa] externals/auctex 22e4415 68/71: Add styles for packages from sttools collection, Tassilo Horn, 2021/12/17
- [AUCTeX-diffs] [elpa] externals/auctex ae2d7ef 23/71: Silence compiler warning, Tassilo Horn, 2021/12/17
- [AUCTeX-diffs] [elpa] externals/auctex 6433dc3 30/71: Extend `TeX-read-key-val' to accept a function call, Tassilo Horn, 2021/12/17
- [AUCTeX-diffs] [elpa] externals/auctex c6350aa 07/71: Track standardized generic hook names in LaTeX kernel, Tassilo Horn, 2021/12/17
- [AUCTeX-diffs] [elpa] externals/auctex 8e0fb65 47/71: Improve handling of key=vals in style/listings.el,
Tassilo Horn <=
- [AUCTeX-diffs] [elpa] externals/auctex accfe51 58/71: Add new style/xr-hyper.el, Tassilo Horn, 2021/12/17
- [AUCTeX-diffs] [elpa] externals/auctex 483f6e9 05/71: ; * style/hyperref.el ("hyperref"): Fix other link to testform.tex., Tassilo Horn, 2021/12/17
- [AUCTeX-diffs] [elpa] externals/auctex 0c01b75 13/71: ; * doc/changes.texi: Fix a markup., Tassilo Horn, 2021/12/17
- [AUCTeX-diffs] [elpa] externals/auctex ee37db3 33/71: Supplement doc string, Tassilo Horn, 2021/12/17
- [AUCTeX-diffs] [elpa] externals/auctex bd723c7 24/71: Cater for corner case when dealing with TeX error, Tassilo Horn, 2021/12/17
- [AUCTeX-diffs] [elpa] externals/auctex 2e968b6 36/71: ; Fix escapings, Tassilo Horn, 2021/12/17
- [AUCTeX-diffs] [elpa] externals/auctex b379da7 18/71: Don't indent begin/end of comment env, Tassilo Horn, 2021/12/17
- [AUCTeX-diffs] [elpa] externals/auctex 08f5c9e 51/71: Improve handling of key=vals in style/floatrow.el, Tassilo Horn, 2021/12/17
- [AUCTeX-diffs] [elpa] externals/auctex df69443 26/71: ; Silence the compiler, Tassilo Horn, 2021/12/17
- [AUCTeX-diffs] [elpa] externals/auctex 0419539 37/71: Improve style/babel.el, Tassilo Horn, 2021/12/17