[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] 131/299: New hooks TeX-after-document-hook and LaTeX-after-usepac
From: |
Stefan Monnier |
Subject: |
[elpa] 131/299: New hooks TeX-after-document-hook and LaTeX-after-usepackage-hook. |
Date: |
Sun, 02 Nov 2014 03:10:53 +0000 |
monnier pushed a commit to branch externals/auctex
in repository elpa.
commit 1a6bb00615641a41db4036e760fe87f623164863
Author: Mosè Giordano <address@hidden>
Date: Tue Jun 11 00:17:43 2013 +0200
New hooks TeX-after-document-hook and LaTeX-after-usepackage-hook.
* latex.el (TeX-after-document-hook): New hook.
(TeX-arg-document): Use it.
(LaTeX-after-usepackage-hook): New hook.
(LaTeX-arg-usepackage): Use it, remove babel specific code.
* style/babel.el: Update copyright years.
(LaTeX-env-babel-lang): New function.
("babel"): Add `LaTeX-env-babel-lang' to
`LaTeX-after-usepackage-hook'.
---
ChangeLog | 12 ++++++++++++
latex.el | 25 +++++++++++++++++++------
style/babel.el | 15 ++++++++++-----
3 files changed, 41 insertions(+), 11 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index e1659a8..7cff52a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2013-06-11 Mos� Giordano <address@hidden>
+
+ * latex.el (TeX-after-document-hook): New hook.
+ (TeX-arg-document): Use it.
+ (LaTeX-after-usepackage-hook): New hook.
+ (LaTeX-arg-usepackage): Use it, remove babel specific code.
+
+ * style/babel.el: Update copyright years.
+ (LaTeX-env-babel-lang): New function.
+ ("babel"): Add `LaTeX-env-babel-lang' to
+ `LaTeX-after-usepackage-hook'.
+
2013-06-08 Mos� Giordano <address@hidden>
* tex.el (TeX-math-close-double-dollar): Remove.
diff --git a/latex.el b/latex.el
index 5795307..0051004 100644
--- a/latex.el
+++ b/latex.el
@@ -1776,6 +1776,11 @@ and this variable will be ignored."
Initialized once at the first time you prompt for a LaTeX class.
May be reset with `\\[universal-argument] \\[TeX-normal-mode]'.")
+(defvar TeX-after-document-hook nil
+ "List of functions to be run at the end of `TeX-arg-document'.
+
+To insert a hook here, you must insert it in the appropiate style file.")
+
(defun TeX-arg-document (optional &optional ignore)
"Insert arguments to documentclass.
OPTIONAL and IGNORE are ignored."
@@ -1796,6 +1801,8 @@ OPTIONAL and IGNORE are ignored."
LaTeX-global-class-files))
(if (zerop (length style))
(setq style LaTeX-default-style))
+ ;; Clean up hook before use.
+ (setq TeX-after-document-hook nil)
(TeX-run-style-hooks style)
(setq var (intern (format "LaTeX-%s-class-options" style)))
(if (or (and (boundp var)
@@ -1824,7 +1831,13 @@ OPTIONAL and IGNORE are ignored."
(TeX-remove-style)
;; defined in individual style hooks
- (TeX-update-style))
+ (TeX-update-style)
+ (run-hooks 'TeX-after-document-hook))
+
+(defvar LaTeX-after-usepackage-hook nil
+ "List of functions to be run at the end of `LaTeX-arg-usepackage'.
+
+To insert a hook here, you must insert it in the appropiate style file.")
(defun LaTeX-arg-usepackage (optional)
"Insert arguments to usepackage.
@@ -1843,6 +1856,8 @@ OPTIONAL is ignored."
'texinputs 'global t t))))))
(setq packages (TeX-completing-read-multiple
"Packages: " TeX-global-input-files))
+ ;; Clean up hook before use.
+ (setq LaTeX-after-usepackage-hook nil)
(mapc 'TeX-run-style-hooks packages)
(setq var (if (= 1 (length packages))
(intern (format "LaTeX-%s-package-options" (car packages)))
@@ -1869,11 +1884,9 @@ OPTIONAL is ignored."
(TeX-add-to-alist 'LaTeX-provided-package-options
(list (cons elt opts))))
packages))
- (insert LaTeX-optop options LaTeX-optcl)
- ;; When `babel' is loaded with options, load also language style files.
- (when (member "babel" packages)
- (mapc 'TeX-run-style-hooks (LaTeX-babel-active-languages))))
- (insert TeX-grop (mapconcat 'identity packages ",") TeX-grcl)))
+ (insert LaTeX-optop options LaTeX-optcl))
+ (insert TeX-grop (mapconcat 'identity packages ",") TeX-grcl)
+ (run-hooks 'LaTeX-after-usepackage-hook)))
(defcustom LaTeX-search-files-type-alist
'((texinputs "${TEXINPUTS.latex}" ("tex/generic/" "tex/latex/")
diff --git a/style/babel.el b/style/babel.el
index cd97038..784732d 100755
--- a/style/babel.el
+++ b/style/babel.el
@@ -1,6 +1,6 @@
;;; babel.el --- AUCTeX style for `babel.sty'
-;; Copyright (C) 2005 Free Software Foundation, Inc.
+;; Copyright (C) 2005, 2007, 2013 Free Software Foundation, Inc.
;; Author: Ralf Angeli <address@hidden>
;; Maintainer: address@hidden
@@ -63,7 +63,7 @@
;; Append element to `active-languages' to respect loading order.
;; `babel' package uses as default language the last loaded one.
(add-to-list 'active-languages elt t)))
- active-languages))
+ active-languages))
(defun TeX-arg-babel-lang (optional &optional prompt)
"Prompt for a language with completion and insert it as an argument."
@@ -76,12 +76,17 @@
env (format "{%s}" (completing-read "Language: "
(LaTeX-babel-active-languages)))))
+(defun LaTeX-babel-load-languages ()
+ "Load style files of babel active languages."
+ ;; Run style hooks for every active language in loading order, so
+ ;; `TeX-quote-language' will be correctly set.
+ (mapc 'TeX-run-style-hooks (LaTeX-babel-active-languages)))
+
(TeX-add-style-hook
"babel"
(lambda ()
- ;; Run style hooks for every active language in loading order, so
- ;; `TeX-quote-language' will be correctly set.
- (mapc 'TeX-run-style-hooks (LaTeX-babel-active-languages))
+ (LaTeX-babel-load-languages)
+ (add-hook 'LaTeX-after-usepackage-hook 'LaTeX-babel-load-languages nil t)
;; New symbols
(TeX-add-symbols
'("selectlanguage" TeX-arg-babel-lang)
- [elpa] 118/299: Add new style files fancyvrb.el and xparse.el., (continued)
- [elpa] 118/299: Add new style files fancyvrb.el and xparse.el., Stefan Monnier, 2014/11/01
- [elpa] 125/299: Simplify LaTeX-env-figure function., Stefan Monnier, 2014/11/01
- [elpa] 127/299: Execute TeX-run-compile in TeX-master-directory., Stefan Monnier, 2014/11/01
- [elpa] 120/299: Move remaining .cvsignore to .gitignore., Stefan Monnier, 2014/11/01
- [elpa] 122/299: Expand biblatex style file., Stefan Monnier, 2014/11/01
- [elpa] 129/299: Document LaTeX-find-matching-begin and LaTeX-find-matching-end., Stefan Monnier, 2014/11/01
- [elpa] 128/299: New variable TeX-electric-math., Stefan Monnier, 2014/11/01
- [elpa] 130/299: Add reference to Gmane thread in ChangeLog., Stefan Monnier, 2014/11/01
- [elpa] 133/299: Fix compile error with emacs bzr which assumes elisp files are UTF-8 encoded., Stefan Monnier, 2014/11/01
- [elpa] 132/299: Fix `TeX-next-error'., Stefan Monnier, 2014/11/01
- [elpa] 131/299: New hooks TeX-after-document-hook and LaTeX-after-usepackage-hook.,
Stefan Monnier <=
- [elpa] 136/299: Simplify TeX-doc-backend-alist., Stefan Monnier, 2014/11/01
- [elpa] 135/299: Put coding cookie in elisp header line., Stefan Monnier, 2014/11/01
- [elpa] 138/299: Fix compilation problem due to `dbus-ignore-errors' not being defined., Stefan Monnier, 2014/11/01
- [elpa] 134/299: Fix coding once again., Stefan Monnier, 2014/11/01
- [elpa] 139/299: Generate PROBLEMS file., Stefan Monnier, 2014/11/01
- [elpa] 142/299: Update texinfo files for Git., Stefan Monnier, 2014/11/01
- [elpa] 143/299: Fix spelling errors in tex-buf.el., Stefan Monnier, 2014/11/01
- [elpa] 137/299: Better check for DBUS support., Stefan Monnier, 2014/11/01
- [elpa] 140/299: Remove warnings and docs for ancient preview problems., Stefan Monnier, 2014/11/01
- [elpa] 141/299: Prefer TeX distro GS wrappers., Stefan Monnier, 2014/11/01