[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] elpa c7e1e47 05/26: [Fix #19281] Allow moodifying environments wi
From: |
Tassilo Horn |
Subject: |
[elpa] elpa c7e1e47 05/26: [Fix #19281] Allow moodifying environments with macros in their names. |
Date: |
Tue, 27 Jan 2015 12:11:10 +0000 |
branch: elpa
commit c7e1e47e8d7668cb63c531416d6c7f7dd5b3aa35
Author: Mosè Giordano <address@hidden>
Commit: Mosè Giordano <address@hidden>
[Fix #19281] Allow moodifying environments with macros in their names.
* latex.el (LaTeX-environment-name-regexp): New function.
(LaTeX-modify-environment): Use it.
(LaTeX-find-matching-end): Use `TeX-grop' instead of the
hard-coded "{". Search for the closing of the environment with
`re-search-forward' instead of `search-forward' and use
`LaTeX-environment-name-regexp': this allows to consider
environments with macros in their names. (Bug#19281)
(LaTeX-find-matching-begin): Use `TeX-grop' instead of the
hard-coded "{".
---
ChangeLog | 12 ++++++++++++
latex.el | 20 +++++++++++++++-----
2 files changed, 27 insertions(+), 5 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index d0c1160..10063c3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2014-12-12 Mos� Giordano <address@hidden>
+
+ * latex.el (LaTeX-environment-name-regexp): New function.
+ (LaTeX-modify-environment): Use it.
+ (LaTeX-find-matching-end): Use `TeX-grop' instead of the
+ hard-coded "{". Search for the closing of the environment with
+ `re-search-forward' instead of `search-forward' and use
+ `LaTeX-environment-name-regexp': this allows to consider
+ environments with macros in their names. (Bug#19281)
+ (LaTeX-find-matching-begin): Use `TeX-grop' instead of the
+ hard-coded "{".
+
2014-12-09 Mos� Giordano <address@hidden>
* style/babel.el (LaTeX-babel-active-languages): Move `nreverse'
diff --git a/latex.el b/latex.el
index 0022ae2..477ef66 100644
--- a/latex.el
+++ b/latex.el
@@ -729,6 +729,15 @@ environment just inserted, the buffer position just before
(run-hook-with-args 'LaTeX-after-insert-env-hooks
environment env-start env-end)))
+(defun LaTeX-environment-name-regexp ()
+ "Return the regexp matching the name of a LaTeX environment.
+This matches everything different from a TeX closing brace but
+allowing one level of TeX group braces."
+ (concat "\\([^" (regexp-quote TeX-grcl) (regexp-quote TeX-grop) "]*\\("
+ (regexp-quote TeX-grop) "[^" (regexp-quote TeX-grcl)
+ (regexp-quote TeX-grop) "]*" (regexp-quote TeX-grcl) "\\)*[^"
+ (regexp-quote TeX-grcl) (regexp-quote TeX-grop) "]*\\)"))
+
(defun LaTeX-modify-environment (environment)
"Modify current ENVIRONMENT."
(save-excursion
@@ -736,7 +745,7 @@ environment just inserted, the buffer position just before
(re-search-backward (concat (regexp-quote TeX-esc)
"end"
(regexp-quote TeX-grop)
- " *\\([a-zA-Z*]*\\)"
+ (LaTeX-environment-name-regexp)
(regexp-quote TeX-grcl))
(save-excursion (beginning-of-line 1) (point)))
(replace-match (concat TeX-esc "end" TeX-grop environment TeX-grcl) t t)
@@ -745,7 +754,7 @@ environment just inserted, the buffer position just before
(re-search-forward (concat (regexp-quote TeX-esc)
"begin"
(regexp-quote TeX-grop)
- " *\\([a-zA-Z*]*\\)"
+ (LaTeX-environment-name-regexp)
(regexp-quote TeX-grcl))
(save-excursion (end-of-line 1) (point)))
(replace-match (concat TeX-esc "begin" TeX-grop environment TeX-grcl) t
t)))
@@ -4124,7 +4133,7 @@ environment in commented regions with the same comment
prefix."
(comment-prefix (and in-comment (TeX-comment-prefix)))
(case-fold-search nil))
(save-excursion
- (skip-chars-backward "a-zA-Z \t{")
+ (skip-chars-backward (concat "a-zA-Z \t" (regexp-quote TeX-grop)))
(unless (bolp)
(backward-char 1)
(and (looking-at regexp)
@@ -4143,7 +4152,8 @@ environment in commented regions with the same comment
prefix."
(setq level (1+ level))
(setq level (1- level)))))
(if (= level 0)
- (search-forward "}")
+ (re-search-forward
+ (concat TeX-grop (LaTeX-environment-name-regexp) TeX-grcl))
(error "Can't locate end of current environment"))))
(defun LaTeX-find-matching-begin ()
@@ -4158,7 +4168,7 @@ environment in commented regions with the same comment
prefix."
(in-comment (TeX-in-commented-line))
(comment-prefix (and in-comment (TeX-comment-prefix)))
(case-fold-search nil))
- (skip-chars-backward "a-zA-Z \t{")
+ (skip-chars-backward (concat "a-zA-Z \t" (regexp-quote TeX-grop)))
(unless (bolp)
(backward-char 1)
(and (looking-at regexp)
- [elpa] elpa df97f94 13/26: Improve minted style., (continued)
- [elpa] elpa df97f94 13/26: Improve minted style., Tassilo Horn, 2015/01/27
- [elpa] elpa fff9412 14/26: Add hva file assoc to auto-mode-alist (bug#19426), Tassilo Horn, 2015/01/27
- [elpa] elpa 49ee91a 03/26: Fix byte-compile warnings., Tassilo Horn, 2015/01/27
- [elpa] elpa d3d05d4 12/26: Make some buffer-local vars document-local., Tassilo Horn, 2015/01/27
- [elpa] elpa ddd6b97 11/26: Improve minted style., Tassilo Horn, 2015/01/27
- [elpa] elpa 6e94ea0 09/26: Add (start of an) minted style., Tassilo Horn, 2015/01/27
- [elpa] elpa ff1f544 10/26: Fix encoding file:// uri., Tassilo Horn, 2015/01/27
- [elpa] elpa 63bcbcd 08/26: Obsolete LaTeX-verbatim-regexp defcustom, Tassilo Horn, 2015/01/27
- [elpa] elpa 0cc29f9 07/26: Fix void-variable error., Tassilo Horn, 2015/01/27
- [elpa] elpa fc9a240 06/26: Fix bug#19398 in TeX-evince-sync-view, Tassilo Horn, 2015/01/27
- [elpa] elpa c7e1e47 05/26: [Fix #19281] Allow moodifying environments with macros in their names.,
Tassilo Horn <=
- [elpa] elpa 8dd1455 04/26: Fix in style/babel.el., Tassilo Horn, 2015/01/27
- [elpa] elpa 8c6a5ae 02/26: [Fix #19301] Fix closing bracket in style/mathtools.el., Tassilo Horn, 2015/01/27
- [elpa] elpa 6bfd4c8 01/26: Add new styles., Tassilo Horn, 2015/01/27