[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[AUCTeX-diffs] [elpa] externals/auctex 6902d05 42/71: Improve handling o
From: |
Tassilo Horn |
Subject: |
[AUCTeX-diffs] [elpa] externals/auctex 6902d05 42/71: Improve handling of key=vals in style/minted.el |
Date: |
Fri, 17 Dec 2021 15:00:33 -0500 (EST) |
branch: externals/auctex
commit 6902d059a10b88a24d97263ce00390226e3eea77
Author: Arash Esbati <arash@gnu.org>
Commit: Arash Esbati <arash@gnu.org>
Improve handling of key=vals in style/minted.el
* style/minted.el (LaTeX-minted-key-val-options-local)
(LaTeX-minted-update-key-vals): Remove now unused variable and
function.
(LaTeX-minted-key-val-options): New function returning key=vals.
(LaTeX-minted-auto-cleanup): Delete call of
`LaTeX-minted-update-key-vals'.
("minted"): Use new function in the style hook.
---
style/minted.el | 77 ++++++++++++++++++++++++---------------------------------
1 file changed, 32 insertions(+), 45 deletions(-)
diff --git a/style/minted.el b/style/minted.el
index 41f63e6..93e8052 100644
--- a/style/minted.el
+++ b/style/minted.el
@@ -155,9 +155,23 @@
("xrightmargin"))
"Key=value options for minted macros and environments.")
-(defvar LaTeX-minted-key-val-options-local nil
- "Buffer-local key=value options for minted macros and environments.")
-(make-variable-buffer-local 'LaTeX-minted-key-val-options-local)
+(defun LaTeX-minted-key-val-options ()
+ "Return an updated list of key=vals from minted package.
+This function retrieves values of (user) defined colors and
+prepends them to variable `LaTeX-minted-key-val-options'."
+ (append
+ (when (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 #'car (funcall colorcmd)))
+ (keys '("bgcolor" "highlightcolor"
+ "rulecolor" "spacecolor" "tabcolor"))
+ result)
+ (dolist (key keys result)
+ (push (list key colors) result))))
+ LaTeX-minted-key-val-options))
(defvar LaTeX-minted-pygmentize-program (executable-find "pygmentize"))
@@ -217,27 +231,6 @@ brackets. PROMPT replaces the standard one."
(LaTeX-minted-style-list))
optional))
-(defun LaTeX-minted-update-key-vals ()
- "Update color related key-vals in `LaTeX-minted-key-val-options-local'.
-This function checks if one of the packages \"xcolor.sty\" or
-\"xcolor.sty\" is loaded and appends defined colors as values to
-color related key. \"xcolor.sty\" is preferred if both packages
-are loaded."
- (when (or (member "xcolor" (TeX-style-list))
- (member "color" (TeX-style-list)))
- (let* ((colorcmd (if (member "xcolor" (TeX-style-list))
- #'LaTeX-xcolor-definecolor-list
- #'LaTeX-color-definecolor-list))
- (colorkeys '("bgcolor" "highlightcolor"
- "rulecolor" "spacecolor" "tabcolor"))
- (opts (copy-alist LaTeX-minted-key-val-options-local)))
- (dolist (key colorkeys)
- (setq opts (assq-delete-all (car (assoc key opts)) opts))
- (push (list key (mapcar #'car (funcall colorcmd)))
- opts))
- (setq LaTeX-minted-key-val-options-local
- (copy-alist opts)))))
-
(defvar LaTeX-minted-auto-newminted nil)
(defvar LaTeX-minted-newminted-regexp
'("\\\\newminted\\(?:\\[\\([^]]+\\)\\]\\)?{\\([^}]+\\)}{[^}]*}"
@@ -277,7 +270,7 @@ are loaded."
(add-to-list 'LaTeX-auto-environment (list env))
(add-to-list 'LaTeX-auto-environment
(list env* #'LaTeX-env-args
- '(TeX-arg-key-val
LaTeX-minted-key-val-options-local)))
+ '(TeX-arg-key-val (LaTeX-minted-key-val-options))))
(add-to-list 'LaTeX-indent-environment-list `(,env current-indentation)
t)
(add-to-list 'LaTeX-indent-environment-list `(,env* current-indentation)
t)
(add-to-list 'LaTeX-verbatim-environments-local env)
@@ -289,7 +282,7 @@ are loaded."
(car name-lang)
(cadr name-lang))))
(add-to-list 'TeX-auto-symbol
- `(,lang [ TeX-arg-key-val
LaTeX-minted-key-val-options-local ]
+ `(,lang [TeX-arg-key-val (LaTeX-minted-key-val-options)]
TeX-arg-verb))
(add-to-list 'LaTeX-verbatim-macros-with-delims-local lang)
(when (and (fboundp 'font-latex-add-keywords)
@@ -304,7 +297,7 @@ are loaded."
(car name-lang)
(concat (cadr name-lang) "inline"))))
(add-to-list 'TeX-auto-symbol
- `(,lang [ TeX-arg-key-val
LaTeX-minted-key-val-options-local ]
+ `(,lang [TeX-arg-key-val (LaTeX-minted-key-val-options)]
TeX-arg-verb-delim-or-brace))
(add-to-list 'LaTeX-verbatim-macros-with-delims-local lang)
(add-to-list 'LaTeX-verbatim-macros-with-braces-local lang)
@@ -318,14 +311,12 @@ are loaded."
(car name-lang)
(concat (cadr name-lang) "file"))))
(add-to-list 'TeX-auto-symbol
- `(,lang [ TeX-arg-key-val
LaTeX-minted-key-val-options-local ]
+ `(,lang [TeX-arg-key-val (LaTeX-minted-key-val-options)]
TeX-arg-file))))
(when (and (fboundp 'font-latex-set-syntactic-keywords)
(eq TeX-install-font-lock 'font-latex-setup))
;; Refresh font-locking so that the verbatim envs take effect.
- (font-latex-set-syntactic-keywords))
- ;; Also update the key=vals
- (LaTeX-minted-update-key-vals))
+ (font-latex-set-syntactic-keywords)))
(add-hook 'TeX-auto-prepare-hook #'LaTeX-minted-auto-prepare t)
(add-hook 'TeX-auto-cleanup-hook #'LaTeX-minted-auto-cleanup t)
@@ -375,29 +366,25 @@ a list of strings."
"minted"
(lambda ()
- ;; Activate local-version of key=vals
- (setq LaTeX-minted-key-val-options-local
- (copy-alist LaTeX-minted-key-val-options))
-
;; New symbols
(TeX-add-symbols
'("mint"
- [ TeX-arg-key-val LaTeX-minted-key-val-options-local ]
+ [TeX-arg-key-val (LaTeX-minted-key-val-options)]
LaTeX-arg-minted-language TeX-arg-verb)
'("mintinline"
- [ TeX-arg-key-val LaTeX-minted-key-val-options-local ]
+ [TeX-arg-key-val (LaTeX-minted-key-val-options)]
LaTeX-arg-minted-language TeX-arg-verb-delim-or-brace)
'("newminted" ["Environment Name"] LaTeX-arg-minted-language
- (TeX-arg-key-val LaTeX-minted-key-val-options-local))
+ (TeX-arg-key-val (LaTeX-minted-key-val-options)))
'("newmint" ["Macro Name"] LaTeX-arg-minted-language
- (TeX-arg-key-val LaTeX-minted-key-val-options-local))
+ (TeX-arg-key-val (LaTeX-minted-key-val-options)))
'("newmintinline" ["Macro Name"] LaTeX-arg-minted-language
- (TeX-arg-key-val LaTeX-minted-key-val-options-local))
+ (TeX-arg-key-val (LaTeX-minted-key-val-options)))
'("newmintedfile" ["Macro Name"] LaTeX-arg-minted-language
- (TeX-arg-key-val LaTeX-minted-key-val-options-local))
+ (TeX-arg-key-val (LaTeX-minted-key-val-options)))
;; 3.3 Formatting source code
'("inputminted"
- [ TeX-arg-key-val LaTeX-minted-key-val-options-local ]
+ [TeX-arg-key-val (LaTeX-minted-key-val-options)]
(LaTeX-arg-minted-language)
TeX-arg-file)
;; 3.4 Using different styles
@@ -406,14 +393,14 @@ a list of strings."
;; 5.2 Macro option usage
'("setminted"
[ LaTeX-arg-minted-language ]
- (TeX-arg-key-val LaTeX-minted-key-val-options-local))
+ (TeX-arg-key-val (LaTeX-minted-key-val-options)))
'("setmintedinline"
[ LaTeX-arg-minted-language ]
- (TeX-arg-key-val LaTeX-minted-key-val-options-local)))
+ (TeX-arg-key-val (LaTeX-minted-key-val-options))))
;; New environments
(LaTeX-add-environments
- '("minted" LaTeX-env-args [TeX-arg-key-val
LaTeX-minted-key-val-options-local]
+ '("minted" LaTeX-env-args [TeX-arg-key-val (LaTeX-minted-key-val-options)]
LaTeX-arg-minted-language))
;; 4 Floating listings: If option "newfloat" is given, run the
- [AUCTeX-diffs] [elpa] externals/auctex c457aab 35/71: * style/babel.el ("babel"): Use `LaTeX-fontspec-font-features'., (continued)
- [AUCTeX-diffs] [elpa] externals/auctex c457aab 35/71: * style/babel.el ("babel"): Use `LaTeX-fontspec-font-features'., Tassilo Horn, 2021/12/17
- [AUCTeX-diffs] [elpa] externals/auctex dfd3369 59/71: Add new style/xr.el, Tassilo Horn, 2021/12/17
- [AUCTeX-diffs] [elpa] externals/auctex cd4a1c9 28/71: * style/graphicx.el (LaTeX-graphicx-key-val-options): Add alt key., Tassilo Horn, 2021/12/17
- [AUCTeX-diffs] [elpa] externals/auctex 0322057 55/71: Fix misc minor issues, Tassilo Horn, 2021/12/17
- [AUCTeX-diffs] [elpa] externals/auctex ec9362d 16/71: ; * doc/todo.texi (Mid-term Goals): Fix spacing., Tassilo Horn, 2021/12/17
- [AUCTeX-diffs] [elpa] externals/auctex fa309c9 02/71: Fix error when tex.el is loaded while default-directory doesn't exist, Tassilo Horn, 2021/12/17
- [AUCTeX-diffs] [elpa] externals/auctex 5f67eac 50/71: Fix logic again, Tassilo Horn, 2021/12/17
- [AUCTeX-diffs] [elpa] externals/auctex b866110 31/71: Autoload `TeX-check-engine-add-engines' in tex.el, Tassilo Horn, 2021/12/17
- [AUCTeX-diffs] [elpa] externals/auctex e118a53 64/71: ; Prepare for upcoming release, Tassilo Horn, 2021/12/17
- [AUCTeX-diffs] [elpa] externals/auctex f6edd15 70/71: Add style/sidecap.el, Tassilo Horn, 2021/12/17
- [AUCTeX-diffs] [elpa] externals/auctex 6902d05 42/71: Improve handling of key=vals in style/minted.el,
Tassilo Horn <=
- [AUCTeX-diffs] [elpa] externals/auctex fd73414 11/71: ; * doc/changes.texi: Add supplementary notice., Tassilo Horn, 2021/12/17
- [AUCTeX-diffs] [elpa] externals/auctex 464fd34 20/71: * tests/latex/latex-test.el (LaTeX-flush-left-indent): New test., Tassilo Horn, 2021/12/17
- [AUCTeX-diffs] [elpa] externals/auctex 16bcc8d 21/71: ; * tex.el (TeX-source-correlate-mode): Quote function name by #'., Tassilo Horn, 2021/12/17
- [AUCTeX-diffs] [elpa] externals/auctex 2af20f4 27/71: ; Silence TeX warnings, Tassilo Horn, 2021/12/17
- [AUCTeX-diffs] [elpa] externals/auctex 363b778 56/71: Update style/multicol.el to package version 1.9b, Tassilo Horn, 2021/12/17
- [AUCTeX-diffs] [elpa] externals/auctex 7fa094f 14/71: ; * style/tabulary.el ("tabulary"): Really append the entry., Tassilo Horn, 2021/12/17
- [AUCTeX-diffs] [elpa] externals/auctex 2ee9a07 71/71: Merge remote-tracking branch 'origin/master' into externals/auctex, Tassilo Horn, 2021/12/17
- [AUCTeX-diffs] [elpa] externals/auctex 0752650 44/71: Don't use obsolete @inforef, Tassilo Horn, 2021/12/17
- [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