Hi all,

please find attached 4 patches covering:

* style/longtable.el ("longtable"): Use `LaTeX-add-counters' on
"LTchunksize" and not `TeX-add-symbols'.

* style/enumitem.el (LaTeX-arg-SetEnumitemKey): Remove unused
`prompt' from arguments list.
(LaTeX-arg-SetEnumitemValue): ditto.

* style/listings.el (LaTeX-listings-key-val-options-local): New
variable used for all key-val queries.
("listings-lstdefinestyle"): Add parsing support for
"\lstdefinestyle".
(LaTeX-listings-lstnewenvironment-regexp): Add missing "s" to
"listing".
(LaTeX-listings-update-style-key): New function adding newly
defined values to "style" key in
`LaTeX-listings-key-val-options-local'.
("listings"): Extend "lstdefinestyle".

* style/wrapfig.el ("wrapfig"): Check for new floating
environments definded through "newfloat.el" and offer them as
completion to "wrapfloat" environment.

As always any comments welcome and my apologies for missing the change
in `longtable' last time.

Best, Arash

>From 90bbbfb68f219c0a47314eec6d11c066c2cd22a1 Mon Sep 17 00:00:00 2001
From: Arash Esbati <esb...@gmx.de>
Date: Thu, 8 Oct 2015 21:53:17 +0200
Subject: [PATCH 1/4] Support newfloat.el.

* style/wrapfig.el ("wrapfig"): Check for new floating
environments definded through "newfloat.el" and offer them as
completion to "wrapfloat" environment.
---
 ChangeLog        |  6 ++++++
 style/wrapfig.el | 15 +++++++++++++--
 2 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index b287587..62199eb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2015-10-08  Arash Esbati  <esb...@gmx.de>
+
+	* style/wrapfig.el ("wrapfig"): Check for new floating
+	environments definded through "newfloat.el" and offer them as
+	completion to "wrapfloat" environment.
+
 2015-10-05  Mosè Giordano  <m...@gnu.org>
 
 	* context.el (TeX-ConTeXt-sentinel): Parse ConTeXt Mark IV output.
diff --git a/style/wrapfig.el b/style/wrapfig.el
index 097e5ad..64bb265 100644
--- a/style/wrapfig.el
+++ b/style/wrapfig.el
@@ -1,6 +1,6 @@
 ;;; wrapfig.el --- AUCTeX style for `wrapfig.sty' version v3.6
 
-;; Copyright (C) 2014 Free Software Foundation, Inc.
+;; Copyright (C) 2014, 2015 Free Software Foundation, Inc.
 
 ;; Author: Arash Esbati <esbati'at'gmx.de>
 ;; Maintainer: auctex-devel@gnu.org
@@ -78,11 +78,22 @@
 	    (format "{%s}" width))))))
     ;;
     ;; \begin{wrapfloat}{<Type>}[No.lines]{Placement}[Overhang]{Width} ... \end{wrapfloat}
+    ;;
+    ;; <Type> can be a new floating environment defined with
+    ;; "\DeclareFloatingEnvironment" from newfloat.el.  We check if
+    ;; the function `LaTeX-newfloat-DeclareFloatingEnvironment-list'
+    ;; is bound and returns non-nil before offering environment for
+    ;; completion.  Otherwise, just ask user without completion.
     '("wrapfloat"
       (lambda (env &rest ignore)
 	(LaTeX-insert-environment
 	 env
-	 (let ((floattype (TeX-read-string "Float type: "))
+	 (let ((floattype (if (and (fboundp 'LaTeX-newfloat-DeclareFloatingEnvironment-list)
+				   (LaTeX-newfloat-DeclareFloatingEnvironment-list))
+			      (completing-read
+			       "Float type: "
+			       (mapcar 'car (LaTeX-newfloat-DeclareFloatingEnvironment-list)))
+			    (TeX-read-string "Float type: ")))
 	       (narrow    (TeX-read-string "(Optional) Number of narrow lines: "))
 	       (placement (completing-read
 			   "Placement: " '(("r") ("R")
-- 
2.6.0

>From 45bc65d6adfdfe05c33b1d037e186da9b994af41 Mon Sep 17 00:00:00 2001
From: Arash Esbati <esb...@gmx.de>
Date: Thu, 8 Oct 2015 22:08:03 +0200
Subject: [PATCH 2/4] Add user-defined values to "style" key.

* style/listings.el (LaTeX-listings-key-val-options-local): New
variable used for all key-val queries.
("listings-lstdefinestyle"): Add parsing support for
"\lstdefinestyle".
(LaTeX-listings-lstnewenvironment-regexp): Add missing "s" to
"listing".
(LaTeX-listings-update-style-key): New function adding newly
defined values to "style" key in
`LaTeX-listings-key-val-options-local'.
("listings"): Extend "lstdefinestyle".
---
 ChangeLog         | 11 +++++++++
 style/listings.el | 70 ++++++++++++++++++++++++++++++++++++++++++++++---------
 2 files changed, 70 insertions(+), 11 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 62199eb..f699850 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,16 @@
 2015-10-08  Arash Esbati  <esb...@gmx.de>
 
+	* style/listings.el (LaTeX-listings-key-val-options-local): New
+	variable used for all key-val queries.
+	("listings-lstdefinestyle"): Add parsing support for
+	"\lstdefinestyle".
+	(LaTeX-listings-lstnewenvironment-regexp): Add missing "s" to
+	"listing".
+	(LaTeX-listings-update-style-key): New function adding newly
+	defined values to "style" key in
+	`LaTeX-listings-key-val-options-local'.
+	("listings"): Extend "lstdefinestyle".
+
 	* style/wrapfig.el ("wrapfig"): Check for new floating
 	environments definded through "newfloat.el" and offer them as
 	completion to "wrapfloat" environment.
diff --git a/style/listings.el b/style/listings.el
index f9aee45..0dff6ec 100644
--- a/style/listings.el
+++ b/style/listings.el
@@ -31,10 +31,16 @@
 ;; May 2015: The style detects new environments defined with
 ;; `\lstnewenvironment'.  Users need to invoke `C-c C-n' for this.
 ;;
+;; October 2015: The style detects new "styles" defined with
+;; `\lstdefinestyle' and offers them during key-value query.
+;;
 ;; FIXME: Please make me more sophisticated!
 
 ;;; Code:
 
+;; Needed for compiling `pushnew':
+(eval-when-compile (require 'cl))
+
 ;; The following are options taken from chapter 4 of the listings
 ;; manual (2007/02/22 Version 1.4).
 (defvar LaTeX-listings-key-val-options
@@ -220,11 +226,16 @@
     ("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)
+
+;; Setup for \lstnewenvironment:
 (defvar LaTeX-auto-listings-lstnewenvironment nil
   "Temporary for parsing the arguments of `\\lstnewenvironment'
 from `listings' package.")
 
-(defvar LaTeX-listing-lstnewenvironment-regexp
+(defvar LaTeX-listings-lstnewenvironment-regexp
   `(,(concat "\\\\lstnewenvironment"
 	     "[ \t\n\r]*{\\([A-Za-z0-9]+\\)}%?"
 	     "[ \t\n\r]*\\[?\\([0-9]?\\)\\]?%?"
@@ -232,12 +243,36 @@ from `listings' package.")
     (1 2 3) LaTeX-auto-listings-lstnewenvironment)
   "Matches the argument of `\\lstnewenvironment' from `listings.sty'.")
 
+;; Setup for \lstdefinestyle:
+(TeX-auto-add-type "listings-lstdefinestyle" "LaTeX")
+
+(defvar LaTeX-listings-lstdefinestyle-regexp
+  '("\\\\lstdefinestyle{\\([^}]+\\)}"
+    1 LaTeX-auto-listings-lstdefinestyle)
+  "Matches the argument of \"\\lstdefinestyle\" from
+\"listings\" package.")
+
+(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)))
+    (pushnew (list key (delete-dups
+			(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."
-  (setq LaTeX-auto-listings-lstnewenvironment nil))
+  (setq LaTeX-auto-listings-lstnewenvironment nil)
+  (setq LaTeX-auto-listings-lstdefinestyle    nil))
 
 (defun LaTeX-listings-auto-cleanup ()
-  "Process the parsed results of `\\lstnewenvironment'."
+  "Process the parsed results of \"\\lstnewenvironment\" and
+\"\\lstdefinestyle\"."
   (dolist (env-args LaTeX-auto-listings-lstnewenvironment)
     (let ((env  (car   env-args))
 	  (args (cadr  env-args))
@@ -256,7 +291,9 @@ from `listings' package.")
 	    (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))))
+      (add-to-list 'LaTeX-verbatim-environments-local env)))
+  (when (LaTeX-listings-lstdefinestyle-list)
+    (LaTeX-listings-update-style-key)))
 
 (add-hook 'TeX-auto-prepare-hook #'LaTeX-listings-auto-prepare t)
 (add-hook 'TeX-auto-cleanup-hook #'LaTeX-listings-auto-cleanup t)
@@ -266,21 +303,32 @@ from `listings' package.")
  "listings"
  (lambda ()
 
-   ;; Add it to the parser
-   (TeX-auto-add-regexp LaTeX-listing-lstnewenvironment-regexp)
+   ;; Add to parser:
+   (TeX-auto-add-regexp LaTeX-listings-lstnewenvironment-regexp)
+   (TeX-auto-add-regexp LaTeX-listings-lstdefinestyle-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")
-    '("lstdefinestyle" "Style name"
-      (TeX-arg-key-val LaTeX-listings-key-val-options))
+    '("lstdefinestyle"
+      (TeX-arg-eval
+       (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-verb)
-    '("lstinputlisting" [TeX-arg-key-val LaTeX-listings-key-val-options]
+    '("lstinputlisting" [TeX-arg-key-val LaTeX-listings-key-val-options-local]
       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))
+    '("lstset" (TeX-arg-key-val LaTeX-listings-key-val-options-local))
     '("lstloadlanguages" t)
     ;; 4.17 Short Inline Listing Commands
     '("lstMakeShortInline" [ "Options" ] "Character")
@@ -292,7 +340,7 @@ from `listings' package.")
    ;; New environments
    (LaTeX-add-environments
     '("lstlisting" LaTeX-env-args
-      [TeX-arg-key-val LaTeX-listings-key-val-options]))
+      [TeX-arg-key-val LaTeX-listings-key-val-options-local]))
    ;; Filling
    (make-local-variable 'LaTeX-indent-environment-list)
    (add-to-list 'LaTeX-indent-environment-list
-- 
2.6.0

>From 12ee20bf56cb40c8cb4371ae24e36a6d057c204b Mon Sep 17 00:00:00 2001
From: Arash Esbati <esb...@gmx.de>
Date: Thu, 8 Oct 2015 22:22:09 +0200
Subject: [PATCH 3/4] Remove unused `prompt' from arguments list.

* style/enumitem.el (LaTeX-arg-SetEnumitemKey): Remove unused
`prompt' from arguments list.
(LaTeX-arg-SetEnumitemValue): ditto.
---
 ChangeLog         | 4 ++++
 style/enumitem.el | 4 ++--
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index f699850..1754c48 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2015-10-08  Arash Esbati  <esb...@gmx.de>
 
+	* style/enumitem.el (LaTeX-arg-SetEnumitemKey): Remove unused
+	`prompt' from arguments list.
+	(LaTeX-arg-SetEnumitemValue): ditto.
+
 	* style/listings.el (LaTeX-listings-key-val-options-local): New
 	variable used for all key-val queries.
 	("listings-lstdefinestyle"): Add parsing support for
diff --git a/style/enumitem.el b/style/enumitem.el
index bca9203..dff94aa 100644
--- a/style/enumitem.el
+++ b/style/enumitem.el
@@ -221,7 +221,7 @@ key-val and the first item."
 		(current-fill-column)))
     (LaTeX-fill-paragraph nil)))
 
-(defun LaTeX-arg-SetEnumitemKey (optional &optional prompt)
+(defun LaTeX-arg-SetEnumitemKey (optional)
   "Ask for a new key to be defined and add it to
 `LaTeX-enumitem-key-val-options-local'."
   (LaTeX-enumitem-update-key-val-options)
@@ -239,7 +239,7 @@ key-val and the first item."
 ;; the elements and pass the result to
 ;; `LaTeX-add-enumitem-SetEnumitemValues'.  It will vanish upon next
 ;; invocation of `C-c C-n'.
-(defun LaTeX-arg-SetEnumitemValue (optional &optional prompt)
+(defun LaTeX-arg-SetEnumitemValue (optional)
   "Ask for a new value added to an existing key incl. the final
 replacement of the value."
   (LaTeX-enumitem-update-key-val-options)
-- 
2.6.0

>From 3178399ea07e26a45fe96e4085255e45977b4f69 Mon Sep 17 00:00:00 2001
From: Arash Esbati <esb...@gmx.de>
Date: Thu, 8 Oct 2015 22:34:30 +0200
Subject: [PATCH 4/4] Use `LaTeX-add-counters' on "LTchunksize".

* style/longtable.el ("longtable"): Use `LaTeX-add-counters' on
"LTchunksize" and not `TeX-add-symbols'.
---
 ChangeLog          | 3 +++
 style/longtable.el | 5 +++--
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 1754c48..ec8171c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2015-10-08  Arash Esbati  <esb...@gmx.de>
 
+	* style/longtable.el ("longtable"): Use `LaTeX-add-counters' on
+	"LTchunksize" and not `TeX-add-symbols'.
+
 	* style/enumitem.el (LaTeX-arg-SetEnumitemKey): Remove unused
 	`prompt' from arguments list.
 	(LaTeX-arg-SetEnumitemValue): ditto.
diff --git a/style/longtable.el b/style/longtable.el
index 3363119..6c9aeaf 100644
--- a/style/longtable.el
+++ b/style/longtable.el
@@ -58,8 +58,6 @@
 			  (LaTeX-newline)
 			  (indent-according-to-mode)))))))
    (TeX-add-symbols
-    ;; Parameter
-    '("LTchunksize" 0)
     ;; Commands to end table rows
     '("endhead" 0)
     '("endfirsthead" 0)
@@ -72,6 +70,9 @@
    (LaTeX-add-lengths
     "LTleft" "LTright" "LTpre" "LTpost" "LTcapwidth")
 
+   ;; This parameter is set with \setcounter
+   (LaTeX-add-counters "LTchunksize")
+
    ;; Use the enhanced table formatting
    (add-to-list 'LaTeX-indent-environment-list
 		'("longtable" LaTeX-indent-tabular))
-- 
2.6.0

_______________________________________________
auctex-devel mailing list
auctex-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/auctex-devel

Reply via email to