emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/auctex 1341b2c 09/28: Query for optional env arg define


From: Tassilo Horn
Subject: [elpa] externals/auctex 1341b2c 09/28: Query for optional env arg defined with \lstnewenvironment.
Date: Fri, 07 Aug 2015 15:59:19 +0000

branch: externals/auctex
commit 1341b2c2e302a92e9afeb050004b3b2e9cb49a8d
Author: Arash Esbati <address@hidden>
Commit: Mosè Giordano <address@hidden>

    Query for optional env arg defined with \lstnewenvironment.
    
    * style/listings.el (LaTeX-listings-auto-cleanup): Add support for
    the optional argument of env's defined with `\lstnewenvironment'.
    (LaTeX-listing-lstnewenvironment-regexp): Ditto.
    
    Signed-off-by: Mosè Giordano <address@hidden>
---
 ChangeLog         |    6 ++++++
 style/listings.el |   43 +++++++++++++++++++++++++++----------------
 2 files changed, 33 insertions(+), 16 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index d2e1a09..539a008 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2015-06-05  Arash Esbati  <address@hidden>
+
+       * style/listings.el (LaTeX-listings-auto-cleanup): Add support for
+       the optional argument of env's defined with `\lstnewenvironment'.
+       (LaTeX-listing-lstnewenvironment-regexp): Ditto.
+
 2015-06-05  Ikumi Keita  <address@hidden>
 
        * tex.el (featurep): Restore compatibility with emacs versions
diff --git a/style/listings.el b/style/listings.el
index aa91b77..f9aee45 100644
--- a/style/listings.el
+++ b/style/listings.el
@@ -145,8 +145,8 @@
     ("indexstyle")
     ;; Column alignment
     ("columns" ("fixed" "flexible" "fullflexible" "spaceflexible")) ;
-                                        ; Also supports an optional
-                                        ; argument with {c,l,r}.
+                                       ; Also supports an optional
+                                       ; argument with {c,l,r}.
     ("flexiblecolumns" ("true" "false"))
     ("keepspaces" ("true" "false"))
     ("basewidth")
@@ -227,8 +227,9 @@ from `listings' package.")
 (defvar LaTeX-listing-lstnewenvironment-regexp
   `(,(concat "\\\\lstnewenvironment"
             "[ \t\n\r]*{\\([A-Za-z0-9]+\\)}%?"
-            "[ \t\n\r]*\\[?\\([0-9]?\\)\\]?")
-    (1 2) LaTeX-auto-listings-lstnewenvironment)
+            "[ \t\n\r]*\\[?\\([0-9]?\\)\\]?%?"
+            "[ \t\n\r]*\\(\\[\\)?")
+    (1 2 3) LaTeX-auto-listings-lstnewenvironment)
   "Matches the argument of `\\lstnewenvironment' from `listings.sty'.")
 
 (defun LaTeX-listings-auto-prepare ()
@@ -238,12 +239,22 @@ from `listings' package.")
 (defun LaTeX-listings-auto-cleanup ()
   "Process the parsed results of `\\lstnewenvironment'."
   (dolist (env-args LaTeX-auto-listings-lstnewenvironment)
-    (let ((env  (car env-args))
-         (args (cadr env-args)))
-      (if (string-equal args "")
-         (add-to-list 'LaTeX-auto-environment (list env))
-       (add-to-list 'LaTeX-auto-environment
-                    (list env (string-to-number args))))
+    (let ((env  (car   env-args))
+         (args (cadr  env-args))
+         (opt  (nth 2 env-args)))
+      (cond (;; opt. 1st argument and mandatory argument(s)
+            (and args (not (string-equal args ""))
+                 opt  (not (string-equal opt  "")))
+            (add-to-list 'LaTeX-auto-environment
+                         (list env 'LaTeX-env-args (vector "argument")
+                               (1- (string-to-number args)))))
+           (;; mandatory argument(s) only
+            (and args (not (string-equal args ""))
+                 (string-equal opt ""))
+            (add-to-list 'LaTeX-auto-environment
+                         (list env (string-to-number args))))
+           (t ; No args
+            (add-to-list 'LaTeX-auto-environment (list env))))
       (add-to-list 'LaTeX-indent-environment-list `(,env current-indentation))
       (add-to-list 'LaTeX-verbatim-environments-local env))))
 
@@ -274,10 +285,10 @@ from `listings' package.")
     ;; 4.17 Short Inline Listing Commands
     '("lstMakeShortInline" [ "Options" ] "Character")
     '("lstDeleteShortInline" "Character")
-    
+
     "lstgrinddeffile" "lstaspectfiles" "lstlanguagefiles"
     "lstlistingname" "lstlistlistingname")
-   
+
    ;; New environments
    (LaTeX-add-environments
     '("lstlisting" LaTeX-env-args
@@ -310,11 +321,11 @@ from `listings' package.")
      (font-lock-set-defaults)))
  LaTeX-dialect)
 
-(defvar LaTeX-listings-package-options '("draft" "final" "savemem" 
+(defvar LaTeX-listings-package-options '("draft" "final" "savemem"
                                         "noaspects"
-                                         ;; procnames is mentioned in
-                                         ;; Section 5.2 
-                                         "procnames")
+                                        ;; procnames is mentioned in
+                                        ;; Section 5.2
+                                        "procnames")
   "Package options for the listings package.")
 
 ;;; listings.el ends here



reply via email to

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