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. 86f4a1ecc37a8a9a5ce39


From: Tassilo Horn
Subject: [AUCTeX-diffs] GNU AUCTeX branch, master, updated. 86f4a1ecc37a8a9a5ce396f592557b9ddf224b77
Date: Tue, 17 Feb 2015 07:35:17 +0000

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  86f4a1ecc37a8a9a5ce396f592557b9ddf224b77 (commit)
      from  b2957c8b141f431b5a035ab174f80f91503c8233 (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 86f4a1ecc37a8a9a5ce396f592557b9ddf224b77
Author: Tassilo Horn <address@hidden>
Date:   Tue Feb 17 08:34:27 2015 +0100

    Add a hook that's run after an environment is modified
    
    * latex.el (LaTeX-after-insert-env-hook): Rename from
    `LaTeX-after-insert-env-hooks' which is now an obsolete variable
    alias.
    (LaTeX-after-modify-env-hook): New hook.
    (LaTeX-modify-environment): Run `LaTeX-after-modify-env-hook'.

diff --git a/ChangeLog b/ChangeLog
index 1a4d561..d3ba7df 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2015-02-17  Tassilo Horn  <address@hidden>
+
+       * latex.el (LaTeX-after-insert-env-hook): Rename from
+       `LaTeX-after-insert-env-hooks' which is now an obsolete variable
+       alias.
+       (LaTeX-after-modify-env-hook): New hook.
+       (LaTeX-modify-environment): Run `LaTeX-after-modify-env-hook'.
+
 2015-02-13  Tassilo Horn  <address@hidden>
 
        * tex.el (TeX-pdf-tools-sync-view, TeX-PDF-mode): Move addition of
diff --git a/latex.el b/latex.el
index 8409690..9c2646f 100644
--- a/latex.el
+++ b/latex.el
@@ -644,7 +644,11 @@ With prefix-argument, reopen environment afterwards."
                         marker))
        (move-marker marker nil)))))
 
-(defvar LaTeX-after-insert-env-hooks nil
+(if (featurep 'xemacs)
+    (define-obsolete-variable-alias 'LaTeX-after-insert-env-hooks 
'LaTeX-after-insert-env-hook)
+  (define-obsolete-variable-alias 'LaTeX-after-insert-env-hooks 
'LaTeX-after-insert-env-hook "11.89"))
+
+(defvar LaTeX-after-insert-env-hook nil
   "List of functions to be run at the end of `LaTeX-insert-environment'.
 Each function is called with three arguments: the name of the
 environment just inserted, the buffer position just before
@@ -738,26 +742,48 @@ allowing one level of TeX group braces."
          (regexp-quote TeX-grop) "]*" (regexp-quote TeX-grcl) "\\)*[^"
          (regexp-quote TeX-grcl) (regexp-quote TeX-grop) "]*\\)"))
 
+(defvar LaTeX-after-modify-env-hook nil
+  "List of functions to be run at the end of `LaTeX-modify-environment'.
+Each function is called with four arguments: the new name of the
+environment, the former name of the environment, the buffer
+position just before \\begin and the position just before
+\\end.")
+
 (defun LaTeX-modify-environment (environment)
   "Modify current ENVIRONMENT."
-  (save-excursion
-    (LaTeX-find-matching-end)
-    (re-search-backward (concat (regexp-quote TeX-esc)
-                               "end"
-                               (regexp-quote TeX-grop)
-                               (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)
-    (beginning-of-line 1)
-    (LaTeX-find-matching-begin)
-    (re-search-forward (concat (regexp-quote TeX-esc)
-                              "begin"
-                              (regexp-quote TeX-grop)
-                              (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)))
+  (let ((goto-end (lambda ()
+                   (LaTeX-find-matching-end)
+                   (re-search-backward (concat (regexp-quote TeX-esc)
+                                               "end"
+                                               (regexp-quote TeX-grop)
+                                               "\\("
+                                               (LaTeX-environment-name-regexp)
+                                               "\\)"
+                                               (regexp-quote TeX-grcl))
+                                       (save-excursion (beginning-of-line 1) 
(point)))))
+       (goto-begin (lambda ()
+                     (LaTeX-find-matching-begin)
+                     (prog1 (point)
+                       (re-search-forward (concat (regexp-quote TeX-esc)
+                                                  "begin"
+                                                  (regexp-quote TeX-grop)
+                                                  "\\("
+                                                  
(LaTeX-environment-name-regexp)
+                                                  "\\)"
+                                                  (regexp-quote TeX-grcl))
+                                          (save-excursion (end-of-line 1) 
(point)))))))
+    (save-excursion
+      (funcall goto-end)
+      (let ((old-env (match-string 1)))
+       (replace-match environment t t nil 1)
+       (beginning-of-line 1)
+       (funcall goto-begin)
+       (replace-match environment t t nil 1)
+       (end-of-line 1)
+       (run-hook-with-args 'LaTeX-after-modify-env-hook
+                           environment old-env
+                           (save-excursion (funcall goto-begin))
+                           (progn (funcall goto-end) (point)))))))
 
 (defun LaTeX-current-environment (&optional arg)
   "Return the name (a string) of the enclosing LaTeX environment.
@@ -5847,7 +5873,7 @@ i.e. you do _not_ have to cater for this yourself by 
adding \\\\' or $."
                  LaTeX-section-list)))
 
   (set (make-local-variable 'TeX-auto-full-regexp-list)
-       (append LaTeX-auto-regexp-list plain-TeX-auto-regexp-list))
+       (append LaTeX-auto-regexp-list plain-TeX-auto-regexp-list))
 
   (LaTeX-set-paragraph-start)
   (setq paragraph-separate
@@ -5863,10 +5889,10 @@ i.e. you do _not_ have to cater for this yourself by 
adding \\\\' or $."
        LaTeX-search-files-type-alist)
 
   (set (make-local-variable 'LaTeX-item-list) '(("description" . 
LaTeX-item-argument)
-                         ("thebibliography" . LaTeX-item-bib)
-                         ("array" . LaTeX-item-array)
-                         ("tabular" . LaTeX-item-array)
-                         ("tabular*" . LaTeX-item-tabular*)))
+                                               ("thebibliography" . 
LaTeX-item-bib)
+                                               ("array" . LaTeX-item-array)
+                                               ("tabular" . LaTeX-item-array)
+                                               ("tabular*" . 
LaTeX-item-tabular*)))
 
   (setq TeX-complete-list
        (append '(("\\\\cite\\[[^]\n\r\\%]*\\]{\\([^{}\n\r\\%,]*\\)"

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

Summary of changes:
 ChangeLog |    8 ++++++
 latex.el  |   74 +++++++++++++++++++++++++++++++++++++++++-------------------
 2 files changed, 58 insertions(+), 24 deletions(-)


hooks/post-receive
-- 
GNU AUCTeX



reply via email to

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