branch: master
commit 38a883d37c43f4841342ed3ef8d95040d7cfc010
Author: Arash Esbati
Commit: Arash Esbati
Save regexp groups in style/minted.el
* style/minted.el (LaTeX-minted-pygmentize-program): Add
docstring.
(LaTeX-minted-language-list, LaTeX-minted-style-list): Add
variables to `TeX-normal-mode-reset-list' so the variables aren't
reset upon regular re-parsing.
(LaTeX-minted-newmint-regexp): Extend regexp to cover all
\newmint* variations. Delete other regexp additions to the
parser.
(LaTeX-minted-auto-prepare, LaTeX-minted-auto-cleanup): Adjust
functions to the above regexp change.
(LaTeX-minted-add-syntactic-keywords-extra): Improve docstring.
("minted"): Don't add deleted regexp's to the parser.
Accept also braces as delimiters for \mint macro.
---
style/minted.el | 172
1 file changed, 86 insertions(+), 86 deletions(-)
diff --git a/style/minted.el b/style/minted.el
index 2f39b782..10bc0b35 100644
--- a/style/minted.el
+++ b/style/minted.el
@@ -176,10 +176,16 @@ prepends them to variable `LaTeX-minted-key-val-options'."
(push (list key colors) result
LaTeX-minted-key-val-options))
-(defvar LaTeX-minted-pygmentize-program (executable-find "pygmentize"))
+(defvar LaTeX-minted-pygmentize-program (executable-find "pygmentize")
+ "Absolute file name to pygmentize program.")
(defvar LaTeX-minted-language-list nil
- "List containing languages provided by pymentize program.")
+ "List containing languages provided by pymentize program.
+Initialized once at the first prompt for a Pygments language.
+May be reset with `\\[universal-argument] \\[TeX-normal-mode]'.")
+
+;; Add the variable to `TeX-normal-mode-reset-list':
+(add-to-list 'TeX-normal-mode-reset-list 'LaTeX-minted-language-list)
(defun LaTeX-minted-language-list ( _ignored)
"Return a list of languages provided by pymentize program.
@@ -198,7 +204,12 @@ Update the variable `LaTeX-minted-language-list' if still
nil."
LaTeX-minted-language-list
(defvar LaTeX-minted-style-list nil
- "List containing styles provided by pymentize program.")
+ "List containing styles provided by pymentize program.
+Initialized once at the first prompt for a Pygments style.
+May be reset with `\\[universal-argument] \\[TeX-normal-mode]'.")
+
+;; Add the variable to `TeX-normal-mode-reset-list':
+(add-to-list 'TeX-normal-mode-reset-list 'LaTeX-minted-style-list)
(defun LaTeX-minted-style-list ( _ignored)
"Return a list of styles provided by pymentize program.
@@ -216,91 +227,83 @@ Update the variable `LaTeX-minted-style-list' if still
nil."
(setq LaTeX-minted-style-list styles))
LaTeX-minted-style-list
-(defvar LaTeX-minted-auto-newminted nil)
-(defvar LaTeX-minted-newminted-regexp
- '("newminted\\(?:\\[\\([^]]+\\)\\]\\)?{\\([^}]+\\)}{[^}]*}"
-(1 2) LaTeX-minted-auto-newminted))
+(TeX-auto-add-type "minted-newmint" "LaTeX")
-(defvar LaTeX-minted-auto-newmint nil)
(defvar LaTeX-minted-newmint-regexp
- '("newmint\\(?:\\[\\([^]]+\\)\\]\\)?{\\([^}]+\\)}{[^}]*}"
-(1 2) LaTeX-minted-auto-newmint))
-
-(defvar LaTeX-minted-auto-newmintinline nil)
-(defvar LaTeX-minted-newmintinline-regexp
- '("newmintinline\\(?:\\[\\([^]]+\\)\\]\\)?{\\([^}]+\\)}{[^}]*}"
-(1 2) LaTeX-minted-auto-newmintinline))
-
-(defvar LaTeX-minted-auto-newmintedfile nil)
-(defvar LaTeX-minted-newmintedfile-regexp
- '("newmintedfile\\(?:\\[\\([^]]+\\)\\]\\)?{\\([^}]+\\)}{[^}]*}"
-(1 2) LaTeX-minted-auto-newmintedfile))
+
'("newmint\\(edfile\\|inline\\|ed\\)?\\(?:\\[\\([^]]+\\)\\]\\)?{\\([^}]+\\)}"
+(2 3 1) LaTeX-auto-minted-newmint)
+ "Match the arguments of \\newmint* macros from minted package.")
(defun LaTeX-minted-auto-prepare ()
- (setq LaTeX-minted-auto-newminted nil
-LaTeX-minted-auto-newmint nil
-LaTeX-minted-auto-newmintinline nil
-LaTeX-minted-auto-newmintedfile nil
-LaTeX-minted-language-list nil
-LaTeX-minted-style-list nil))
+ "Reset `LaTeX-auto-minted-newmint' before parsing."
+ (setq LaTeX-auto-minted-newmint nil))
(defun LaTeX-minted-auto-cleanup ()
- ;; \newminted{lang}{opts} => new langcode and langcode* envs.
- ;; \newminted[envname]{lang}{opts} => new envname/envname* envs.
- (dolist (name-lang LaTeX-minted-auto-newminted)
-(let* ((env (if (> (length (car name-lang)) 0)
-(car name-lang)
- (concat (cadr name-lang) "code")))
- (env* (concat env "*")))
- (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
- (add-to-list 'LaTeX-indent-environment-list `(,env current-indentation)
t)
- (add-to-list 'LaTeX-indent-environment-list `(,env*