[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/auctex 86f4a1e 12/35: Add a hook that's run after an en
From: |
Tassilo Horn |
Subject: |
[elpa] externals/auctex 86f4a1e 12/35: Add a hook that's run after an environment is modified |
Date: |
Sun, 22 Mar 2015 09:27:00 +0000 |
branch: externals/auctex
commit 86f4a1ecc37a8a9a5ce396f592557b9ddf224b77
Author: Tassilo Horn <address@hidden>
Commit: Tassilo Horn <address@hidden>
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'.
---
ChangeLog | 8 ++++++
latex.el | 74 +++++++++++++++++++++++++++++++++++++++++-------------------
2 files changed, 58 insertions(+), 24 deletions(-)
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\\%,]*\\)"
- [elpa] externals/auctex 4b2587d 01/35: Add new style currvita.el., (continued)
- [elpa] externals/auctex 4b2587d 01/35: Add new style currvita.el., Tassilo Horn, 2015/03/22
- [elpa] externals/auctex 061d8cd 02/35: New tcolorbox style, Tassilo Horn, 2015/03/22
- [elpa] externals/auctex 5276f35 03/35: Add PDF Tools support, Tassilo Horn, 2015/03/22
- [elpa] externals/auctex cc9c060 05/35: Fix compatibility with Emacs < 24., Tassilo Horn, 2015/03/22
- [elpa] externals/auctex cef38f9 04/35: Handle TeX-region in backward search with both PDF Tools and Evince, Tassilo Horn, 2015/03/22
- [elpa] externals/auctex 51e3aa8 06/35: Adapt to PDF Tool changes, Tassilo Horn, 2015/03/22
- [elpa] externals/auctex 1bc721b 07/35: Fix error introduced in previous commit, Tassilo Horn, 2015/03/22
- [elpa] externals/auctex adf90e9 09/35: Simplify TeX-pdf-tools-sync-view, Tassilo Horn, 2015/03/22
- [elpa] externals/auctex b858aae 10/35: Make TeX-pdf-tools-sync-view work with region files, Tassilo Horn, 2015/03/22
- [elpa] externals/auctex b2957c8 11/35: Fix bug in pdf-tools support, Tassilo Horn, 2015/03/22
- [elpa] externals/auctex 86f4a1e 12/35: Add a hook that's run after an environment is modified,
Tassilo Horn <=
- [elpa] externals/auctex 566426b 08/35: New style for color.sty, Tassilo Horn, 2015/03/22
- [elpa] externals/auctex 3cf92fc 14/35: Fix font-locking issue, Tassilo Horn, 2015/03/22
- [elpa] externals/auctex 39badf0 15/35: New defcustom LaTeX-fill-excluded-macros, Tassilo Horn, 2015/03/22
- [elpa] externals/auctex 83306b4 13/35: Add some expl3 support, Tassilo Horn, 2015/03/22
- [elpa] externals/auctex 074af82 16/35: Add docs for LaTeX-fill-excluded-macros, Tassilo Horn, 2015/03/22
- [elpa] externals/auctex 61ed48c 19/35: Replace add-to-list with pushnew, Tassilo Horn, 2015/03/22
- [elpa] externals/auctex 31c42ca 23/35: Indent \[...\] display math as a normal environment., Tassilo Horn, 2015/03/22
- [elpa] externals/auctex 41c5f9a 24/35: Improve error/warning reporting when file cannot be determined., Tassilo Horn, 2015/03/22
- [elpa] externals/auctex 59f9440 26/35: Fix void-function error occuring if cl is not loaded, Tassilo Horn, 2015/03/22
- [elpa] externals/auctex 4034de2 21/35: New style for caption.sty., Tassilo Horn, 2015/03/22