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. a9ec6ba8cc86b22d97da6


From: Arash Esbati
Subject: [AUCTeX-diffs] GNU AUCTeX branch, master, updated. a9ec6ba8cc86b22d97da6ca4946aa6690cc059ad
Date: Thu, 22 Dec 2016 14:20:03 +0000 (UTC)

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  a9ec6ba8cc86b22d97da6ca4946aa6690cc059ad (commit)
      from  b44d52469fb7b3dc7743881e9927a01999b6fef1 (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 a9ec6ba8cc86b22d97da6ca4946aa6690cc059ad
Author: Arash Esbati <address@hidden>
Date:   Thu Dec 22 15:19:11 2016 +0100

    Update style/minted.el to package version 2.4.1.
    
    * style/minted.el (LaTeX-minted-key-val-options): Add new key=vals
    from package version 2.4.1.
    (LaTeX-minted-key-val-options-local): New variable.
    (LaTeX-minted-language-list): Set the variable
    `LaTeX-minted-language-list' after the first call of function.
    (LaTeX-minted-style-list): New variable.
    (LaTeX-minted-style-list): New function analogous to
    `LaTeX-minted-language-list' returning styles provided by
    pymentize program.
    (LaTeX-arg-minted-style): New function to insert styles provided
    by pymentize program into buffer.
    (LaTeX-minted-update-key-vals): New function to update key=vals in
    `LaTeX-minted-key-val-options-local'.
    (LaTeX-minted-auto-cleanup): Call `LaTeX-minted-update-key-vals'.
    ("minted"): Use `LaTeX-minted-key-val-options-local' for all
    key=val queries.  Update macros incl. fontification.  Run style
    hook for `newfloat' when package option is given.

diff --git a/style/minted.el b/style/minted.el
index b4bc572..914ee66 100644
--- a/style/minted.el
+++ b/style/minted.el
@@ -1,4 +1,4 @@
-;;; minted.el --- AUCTeX style for `minted.sty'
+;;; minted.el --- AUCTeX style for `minted.sty' (v2.4.1)
 
 ;; Copyright (C) 2014-2016 Free Software Foundation, Inc.
 
@@ -26,7 +26,7 @@
 
 ;;; Commentary:
 
-;; This file adds support for `minted.sty'.
+;; This file adds support for `minted.sty' (v2.4.1) from 2016/10/31.
 
 ;;; Code:
 
@@ -35,12 +35,31 @@
 (defvar LaTeX-minted-key-val-options
   '(("autogobble" ("true" "false"))
     ("baselinestretch" ("auto"))
+    ("breakafter")
+    ("breakaftergroup" ("true" "false"))
+    ("breakaftersymbolpre")
+    ("breakaftersymbolpost")
+    ("breakbytoken" ("true" "false"))
+    ("breakbytokenanywhere" ("true" "false"))
+    ("breakindent")
+    ("breaklines" ("true" "false"))
+    ("breaksymbol")
+    ("breaksymbolleft")
+    ("breaksymbolright")
+    ("breaksymbolindent")
+    ("breaksymbolindentleft")
+    ("breaksymbolindentright")
+    ("breaksymbolsep")
+    ("breaksymbolsepleft")
+    ("breaksymbolsepright")
     ("bgcolor")
     ("codetagify")
+    ("curlyquotes" ("true" "false"))
     ("encoding")
     ("outencoding")
+    ("escapeinside")
     ("firstline")
-    ("firstnumber" ("auto"))
+    ("firstnumber" ("auto" "last" "integer"))
     ("fontfamily" ("tt" "courier" "helvetica"))
     ("fontseries" ("auto"))
     ("fontsize" ("auto" "\\tiny" "\\large" "\\scriptsize" "\\Large"
@@ -53,12 +72,15 @@
     ("framesep")
     ("funcnamehighlighting" ("true" "false"))
     ("gobble")
+    ("highlightcolor")
+    ("highlightlines")
     ("keywordcase" ("lower" "upper" "capitalize"))
     ("label")
     ("labelposition" ("none" "topline" "bottomline" "all"))
     ("lastline")
     ("linenos" ("true" "false"))
-    ("numbers" ("left" "right"))
+    ("numberfirstline" ("true" "false"))
+    ("numbers" ("left" "right" "both" "none"))
     ("mathescape" ("true" "false"))
     ("numberblanklines" ("true" "false"))
     ("numbersep")
@@ -69,10 +91,27 @@
     ("samepage" ("true" "false"))
     ("showspaces" ("true" "false"))
     ("showtabs" ("true" "false"))
+    ("space")
+    ("spacecolor")
     ("startinline" ("true" "false"))
-    ("style")
+    ;; FIXME: It would be nice to use the function
+    ;; `LaTeX-minted-style-list' here, but with a file local var like:
+    ;;     %%% TeX-command-extra-options: "-shell-escape"
+    ;; in a .tex file, Emacs asks to apply a variable which is not
+    ;; safe and does not restore the frame; the splitted frame
+    ;; remains.  I couldn't figure out why, so for now, I add the
+    ;; styles from Pygments version 2.1.3 here.
+    ("style" ("colorful" "default" "emacs" "friendly" "fruity" "igor"
+             "lovelace" "manni" "monokai" "murphy" "native"
+             "paraiso-dark" "paraiso-light" "pastie" "perldoc"
+             "rrt" "tango" "trac" "vim" "vs" "xcode"))
     ("stepnumber")
+    ("stepnumberfromfirst")
+    ("stepnumberoffsetvalues" ("true" "false"))
+    ("stripall" ("true" "false"))
     ("stripnl")
+    ("tab")
+    ("tabcolor")
     ("tabsize")
     ("texcl" ("true" "false"))
     ("texcomments" ("true" "false"))
@@ -80,11 +119,18 @@
     ("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)
+
 (defvar LaTeX-minted-pygmentize-program (executable-find "pygmentize"))
 
-(defvar LaTeX-minted-language-list nil)
+(defvar LaTeX-minted-language-list nil
+  "List containing languages provided by pymentize program.")
 
 (defun LaTeX-minted-language-list (&rest _ignored)
+  "Return a list of languages provided by pymentize program.
+Update the variable `LaTeX-minted-language-list' if still nil."
   (or LaTeX-minted-language-list
       (when LaTeX-minted-pygmentize-program
        (with-temp-buffer
@@ -95,14 +141,67 @@
            (while (re-search-forward "^\\*[[:space:]]\\([^:]+\\):" nil t)
              (dolist (lang (split-string (match-string 1) "[[:space:],]" t))
                (push lang languages)))
-           languages)))))
+           (setq LaTeX-minted-language-list languages))
+         LaTeX-minted-language-list))))
 
 (defun LaTeX-arg-minted-language (optional &optional prompt)
+    "Insert a selected pygmentize language as argument for macros from 
minted.sty.
+If OPTIONAL is non-nil, insert it as optional argument in
+brackets.  PROMPT replaces the standard one."
   (TeX-argument-insert
    (completing-read (TeX-argument-prompt optional prompt "Language")
                    (LaTeX-minted-language-list))
    optional))
 
+(defvar LaTeX-minted-style-list nil
+  "List containing styles provided by pymentize program.")
+
+(defun LaTeX-minted-style-list (&rest _ignored)
+  "Return a list of styles provided by pymentize program.
+Update the variable `LaTeX-minted-style-list' if still nil."
+  (or LaTeX-minted-style-list
+      (when LaTeX-minted-pygmentize-program
+       (with-temp-buffer
+         (shell-command (concat LaTeX-minted-pygmentize-program " -L styles")
+                        (current-buffer))
+         (goto-char (point-min))
+         (let (styles)
+           (while (re-search-forward "^\\*[[:space:]]\\([^:]+\\):" nil t)
+             (dolist (style (split-string (match-string 1) "[[:space:],]" t))
+               (push style styles)))
+           (setq LaTeX-minted-style-list styles))
+         LaTeX-minted-style-list))))
+
+(defun LaTeX-arg-minted-style (optional &optional prompt)
+  "Insert a selected pygmentize style as argument for macros from minted.sty.
+If OPTIONAL is non-nil, insert it as optional argument in
+brackets.  PROMPT replaces the standard one."
+  (TeX-argument-insert
+   (completing-read (TeX-argument-prompt optional prompt "Style")
+                   (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)
+       (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\\(?:\\[\\([^]]+\\)\\]\\)?{\\([^}]+\\)}{[^}]*}"
@@ -127,7 +226,9 @@
   (setq LaTeX-minted-auto-newminted     nil
        LaTeX-minted-auto-newmint       nil
        LaTeX-minted-auto-newmintinline nil
-       LaTeX-minted-auto-newmintedfile nil))
+       LaTeX-minted-auto-newmintedfile nil
+       LaTeX-minted-language-list      nil
+       LaTeX-minted-style-list         nil))
 
 (defun LaTeX-minted-auto-cleanup ()
   ;; \newminted{lang}{opts} => new langcode and langcode* envs.
@@ -140,7 +241,7 @@
       (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)))
+                        '(TeX-arg-key-val LaTeX-minted-key-val-options-local)))
       (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)
@@ -171,7 +272,9 @@
   (when (and (fboundp 'font-latex-update-font-lock)
             (eq TeX-install-font-lock 'font-latex-setup))
     ;; Refresh font-locking so that the verbatim envs take effect.
-    (font-latex-update-font-lock t)))
+    (font-latex-update-font-lock t))
+  ;; Also update the key=vals
+  (LaTeX-minted-update-key-vals))
 
 (add-hook 'TeX-auto-prepare-hook #'LaTeX-minted-auto-prepare t)
 (add-hook 'TeX-auto-cleanup-hook #'LaTeX-minted-auto-cleanup t)
@@ -180,25 +283,63 @@
 (TeX-add-style-hook
  "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" LaTeX-arg-minted-language TeX-arg-verb)
     '("mintinline" LaTeX-arg-minted-language TeX-arg-verb)
-    '("listoflistings")
     '("newminted" ["Environment Name"] LaTeX-arg-minted-language
-      (TeX-arg-key-val LaTeX-minted-key-val-options))
+      (TeX-arg-key-val LaTeX-minted-key-val-options-local))
     '("newmint" ["Macro Name"] LaTeX-arg-minted-language
-      (TeX-arg-key-val LaTeX-minted-key-val-options))
+      (TeX-arg-key-val LaTeX-minted-key-val-options-local))
     '("newmintinline" ["Macro Name"] LaTeX-arg-minted-language
-      (TeX-arg-key-val LaTeX-minted-key-val-options))
+      (TeX-arg-key-val LaTeX-minted-key-val-options-local))
     '("newmintedfile" ["Macro Name"] LaTeX-arg-minted-language
-      (TeX-arg-key-val LaTeX-minted-key-val-options)))
+      (TeX-arg-key-val LaTeX-minted-key-val-options-local))
+    ;; 3.3 Formatting source code
+    '("inputminted"
+      [ TeX-arg-key-val LaTeX-minted-key-val-options-local ]
+      (LaTeX-arg-minted-language)
+      TeX-arg-file)
+    ;; 3.4 Using different styles
+    '("usemintedstyle"
+      [ LaTeX-arg-minted-language ] LaTeX-arg-minted-style)
+    ;; 5.2 Macro option usage
+    '("setminted"
+      [ LaTeX-arg-minted-language ]
+      (TeX-arg-key-val LaTeX-minted-key-val-options-local))
+    '("setmintedinline"
+      [ LaTeX-arg-minted-language ]
+      (TeX-arg-key-val LaTeX-minted-key-val-options-local)))
 
    ;; New environments
    (LaTeX-add-environments
-    '("minted" LaTeX-env-args [TeX-arg-key-val LaTeX-minted-key-val-options]
-      LaTeX-arg-minted-language)
-    '("listing" ["Float Position"]))
+    '("minted" LaTeX-env-args [TeX-arg-key-val 
LaTeX-minted-key-val-options-local]
+      LaTeX-arg-minted-language))
+
+   ;; 4 Floating listings: If option "newfloat" is given, run the
+   ;; style hook and use the interface provided by the style,
+   ;; otherwise add "listing" manually
+   (if (or (LaTeX-provided-package-options-member "minted" "newfloat")
+          (LaTeX-provided-package-options-member "minted" "newfloat=true"))
+       (progn
+        (TeX-run-style-hooks "newfloat")
+        (LaTeX-add-newfloat-DeclareFloatingEnvironments
+         '("listing" "verbatim")))
+     (LaTeX-add-environments '("listing" ["Float Position"]))
+     (TeX-add-symbols '("listoflistings")
+                     '("listingscaption")
+                     '("listoflistingscaption"))
+     (add-to-list (make-local-variable 'LaTeX-indent-environment-list)
+                 '("listing" current-indentation) t)
+     (add-to-list 'LaTeX-label-alist '("listing" . "lst:") t)
+     (when (fboundp 'reftex-add-label-environments)
+       (reftex-add-label-environments
+       '(("listing" ?l "lst:" "~\\ref{%s}" caption nil nil)))))
 
    ;; Add to the auto parser
    (TeX-auto-add-regexp LaTeX-minted-newminted-regexp)
@@ -218,18 +359,30 @@
    (when (and (fboundp 'font-latex-add-keywords)
              (fboundp 'font-latex-update-font-lock)
              (eq TeX-install-font-lock 'font-latex-setup))
-     (font-latex-add-keywords '(;; FIXME: Those have the form \mint{lang}|code|
+     (font-latex-add-keywords '(("usemintedstyle"  "[{")
+                               ("setminted"       "[{")
+                               ("setmintedinline" "[{")
+                               ("newminted"       "[{{")
+                               ("newmint"         "[{{")
+                               ("newmintedinline" "[{{")
+                               ("newmintedfile"   "[{{")
+                               ;; FIXME: Those have the form \mint{lang}|code|
                                ;; so ideally the verbatim arg should be
                                ;; recognized.
                                "mint" "mintinline")
                              'function)
+     (font-latex-add-keywords '(("inputminted" "[{{"))
+                             'textual)
      ;; Tell font-lock about the update.
      (font-latex-update-font-lock t)))
  LaTeX-dialect)
 
-(defvar LaTeX-minted-package-options '("section" "chapter" "cache"
-                                      "outputdir" "cachedir"
-                                      "langlinenos")
+(defvar LaTeX-minted-package-options '("chapter"     "cache"
+                                      "cachedir"    "finalizecache"
+                                      "frozencache" "draft"
+                                      "final"       "kpsewhich"
+                                      "langlinenos" "newfloat"
+                                      "outputdir"   "section")
   "Package options for the minted package.")
 
 ;;; minted.el ends here

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

Summary of changes:
 style/minted.el |  197 ++++++++++++++++++++++++++++++++++++++++++++++++-------
 1 file changed, 175 insertions(+), 22 deletions(-)


hooks/post-receive
-- 
GNU AUCTeX



reply via email to

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