[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/auctex 0a1742f 01/28: Parse env's defined with `\lstnew
From: |
Tassilo Horn |
Subject: |
[elpa] externals/auctex 0a1742f 01/28: Parse env's defined with `\lstnewenvironment'. |
Date: |
Fri, 07 Aug 2015 15:59:15 +0000 |
branch: externals/auctex
commit 0a1742f7ffbe02052ef946bc4e22772ca8f72ae4
Author: Arash Esbati <address@hidden>
Commit: Tassilo Horn <address@hidden>
Parse env's defined with `\lstnewenvironment'.
* style/listings.el ("listings"): Add support for parsing new
env's defined with `\lstnewenvironment' command.
---
ChangeLog | 5 +++++
style/listings.el | 40 +++++++++++++++++++++++++++++++++++++++-
2 files changed, 44 insertions(+), 1 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 9be6aab..2c71ee2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2015-05-16 Arash Esbati <address@hidden>
+
+ * style/listings.el ("listings"): Add support for parsing new
+ env's defined with `\lstnewenvironment' command.
+
2015-05-08 Tassilo Horn <address@hidden>
* tex.el (TeX-mode-syntax-table): Use paired delimiter syntax for
diff --git a/style/listings.el b/style/listings.el
index ace5c97..aa91b77 100644
--- a/style/listings.el
+++ b/style/listings.el
@@ -1,6 +1,6 @@
;;; listings.el --- AUCTeX style for `listings.sty'
-;; Copyright (C) 2004, 2005, 2009, 2013 Free Software Foundation, Inc.
+;; Copyright (C) 2004, 2005, 2009, 2013, 2015 Free Software Foundation, Inc.
;; Author: Ralf Angeli <address@hidden>
;; Maintainer: address@hidden
@@ -28,6 +28,9 @@
;; This file adds support for `listings.sty'.
;;
+;; May 2015: The style detects new environments defined with
+;; `\lstnewenvironment'. Users need to invoke `C-c C-n' for this.
+;;
;; FIXME: Please make me more sophisticated!
;;; Code:
@@ -217,9 +220,44 @@
("multicolumn"))
"Key=value options for listings macros and environments.")
+(defvar LaTeX-auto-listings-lstnewenvironment nil
+ "Temporary for parsing the arguments of `\\lstnewenvironment'
+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)
+ "Matches the argument of `\\lstnewenvironment' from `listings.sty'.")
+
+(defun LaTeX-listings-auto-prepare ()
+ "Clear temporary variable from `listings.sty' before parsing."
+ (setq LaTeX-auto-listings-lstnewenvironment nil))
+
+(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))))
+ (add-to-list 'LaTeX-indent-environment-list `(,env current-indentation))
+ (add-to-list 'LaTeX-verbatim-environments-local env))))
+
+(add-hook 'TeX-auto-prepare-hook #'LaTeX-listings-auto-prepare t)
+(add-hook 'TeX-auto-cleanup-hook #'LaTeX-listings-auto-cleanup t)
+(add-hook 'TeX-update-style-hook #'TeX-auto-parse t)
+
(TeX-add-style-hook
"listings"
(lambda ()
+
+ ;; Add it to the parser
+ (TeX-auto-add-regexp LaTeX-listing-lstnewenvironment-regexp)
+
;; New symbols
(TeX-add-symbols
'("lstalias" ["Alias dialect"] "Alias" ["Dialect"] "Language")
- [elpa] externals/auctex updated (5f45de1 -> 1fc2c7a), Tassilo Horn, 2015/08/07
- [elpa] externals/auctex 11d759d 02/28: More font-lock fix for verbatim environment args., Tassilo Horn, 2015/08/07
- [elpa] externals/auctex 4e84c98 04/28: Add subtitle to slide-title class, Tassilo Horn, 2015/08/07
- [elpa] externals/auctex 0a1742f 01/28: Parse env's defined with `\lstnewenvironment'.,
Tassilo Horn <=
- [elpa] externals/auctex 752171a 05/28: Fix bug in LaTeX-backward-paragraph in narrowed buffers, Tassilo Horn, 2015/08/07
- [elpa] externals/auctex 0e3f3ac 03/28: New styles newpxtext.el and newpxmath.el., Tassilo Horn, 2015/08/07
- [elpa] externals/auctex b1e4d46 06/28: Consider args with \newenvironment with opt arg, Tassilo Horn, 2015/08/07
- [elpa] externals/auctex 0b85713 07/28: Query for optional env arg, Tassilo Horn, 2015/08/07
- [elpa] externals/auctex 1341b2c 09/28: Query for optional env arg defined with \lstnewenvironment., Tassilo Horn, 2015/08/07
- [elpa] externals/auctex 7a0d85f 10/28: New style pdfpages.el., Tassilo Horn, 2015/08/07
- [elpa] externals/auctex 3cd3e72 08/28: Restore Emacs 22 compatibility, Tassilo Horn, 2015/08/07
- [elpa] externals/auctex 8426ca5 12/28: Missing ConTeXt-(un)numbered-section-list-nl variables., Tassilo Horn, 2015/08/07
- [elpa] externals/auctex 0efe678 14/28: Improve completion of includepdf macro., Tassilo Horn, 2015/08/07
- [elpa] externals/auctex 8052cd5 13/28: Find warnings emitted by a package with digits in its name., Tassilo Horn, 2015/08/07