emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/auctex 2f22938 78/78: Merge branch 'master' into elpa


From: Tassilo Horn
Subject: [elpa] externals/auctex 2f22938 78/78: Merge branch 'master' into elpa
Date: Mon, 19 Oct 2015 09:11:21 +0000

branch: externals/auctex
commit 2f229381b3f7ae7188aabc46e99e035e7769af95
Merge: 62aca31 b072f9c
Author: Tassilo Horn <address@hidden>
Commit: Tassilo Horn <address@hidden>

    Merge branch 'master' into elpa
---
 .gitignore             |    1 -
 ChangeLog              |  421 ++++++++++++++++++++++++++++++
 Makefile.in            |   12 +-
 context.el             |  114 ++++++---
 doc/auctex.texi        |   62 ++++-
 doc/changes.texi       |   24 ++-
 doc/quickstart.texi    |   18 ++
 doc/tex-ref.tex        |   17 +-
 doc/todo.texi          |   16 +-
 font-latex.el          |  168 ++++++++-----
 latex.el               |   15 +-
 style/Alegreya.el      |  100 +++++++
 style/AlegreyaSans.el  |  112 ++++++++
 style/amsart.el        |    3 +-
 style/amsbook.el       |    3 +-
 style/array.el         |    8 +-
 style/article.el       |    3 +-
 style/caption.el       |   85 ++++++-
 style/enumitem.el      |    4 +-
 style/eso-pic.el       |    7 +-
 style/filecontents.el  |   10 +-
 style/fontenc.el       |   52 ++++
 style/gloss-italian.el |   68 +++++
 style/hyperref.el      |   12 +-
 style/listings.el      |   70 +++++-
 style/longtable.el     |   16 +-
 style/memoir.el        |    2 +
 style/newfloat.el      |  216 ++++++++++++++++
 style/polyglossia.el   |  355 +++++++++++++++++++++++++
 style/pstricks.el      |    3 +-
 style/report.el        |    5 +-
 style/scrartcl.el      |    3 +-
 style/scrreprt.el      |    1 +
 style/subcaption.el    |  158 ++++++++++++
 style/transparent.el   |   53 ++++
 style/wrapfig.el       |   15 +-
 tex-buf.el             |  668 +++++++++++++++++++++++++++++++++++++-----------
 tex.el                 |  238 +++++++++++++-----
 38 files changed, 2733 insertions(+), 405 deletions(-)

diff --git a/.gitignore b/.gitignore
index 7ddb905..24160a8 100644
--- a/.gitignore
+++ b/.gitignore
@@ -19,7 +19,6 @@ tex-site.el.out
 # Files generated while building the auto-generated files included in elpa.
 doc/preview-dtxdoc.texi
 doc/version.texi
-
 auto.el
 latex/prauctex.cfg
 latex/prauctex.def
diff --git a/ChangeLog b/ChangeLog
index c9875ac..0734420 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,7 +1,428 @@
+2015-10-19  Mos� Giordano  <address@hidden>
+
+       * tex-buf.el (TeX-command): Check that AUCTeX can find a working
+       TeX distribution before running some *TeX commands.
+
+2015-10-18  Mos� Giordano  <address@hidden>
+
+       * tex.el (fboundp): Define a `TeX-completing-read-multiple'
+       version for GNU Emacs >= 24.4.  Fixes bug#19504.
+
+2015-10-13  Mos� Giordano  <address@hidden>
+
+       * style/pstricks.el ("pstricks"): Do not disable PDF mode if XeTeX
+       engine is used.  Suggested by Mandar Mitra.
+
+2015-10-09  Tassilo Horn  <address@hidden>
+
+       * latex.el (LaTeX-fill-move-to-break-point): Fill $...$ like
+       \(...\) (bug#21645)
+
+2015-10-08  Mos� Giordano  <address@hidden>
+
+       * tex.el (TeX-expand-list-builtin): New variable.
+       (TeX-expand-list): Move all entries to `TeX-expand-list-builtin'
+       and update docstring.
+       (TeX-expand-list): New function.
+
+       * tex-buf.el (TeX-command-expand): Use `TeX-expand-list' function.
+
+       * doc/auctex.texi (Starting Viewers): Mention
+       `TeX-expand-list-builtin'.
+
+       * doc/changes.texi: Mention change to `TeX-expand-list'.
+
+2015-10-08  Arash Esbati  <address@hidden>
+
+       * style/longtable.el ("longtable"): Use `LaTeX-add-counters' on
+       "LTchunksize" and not `TeX-add-symbols'.
+
+       * style/enumitem.el (LaTeX-arg-SetEnumitemKey): Remove unused
+       `prompt' from arguments list.
+       (LaTeX-arg-SetEnumitemValue): ditto.
+
+       * style/listings.el (LaTeX-listings-key-val-options-local): New
+       variable used for all key-val queries.
+       ("listings-lstdefinestyle"): Add parsing support for
+       "\lstdefinestyle".
+       (LaTeX-listings-lstnewenvironment-regexp): Add missing "s" to
+       "listing".
+       (LaTeX-listings-update-style-key): New function adding newly
+       defined values to "style" key in
+       `LaTeX-listings-key-val-options-local'.
+       ("listings"): Extend "lstdefinestyle".
+
+       * style/wrapfig.el ("wrapfig"): Check for new floating
+       environments definded through "newfloat.el" and offer them as
+       completion to "wrapfloat" environment.
+
+2015-10-05  Mos� Giordano  <address@hidden>
+
+       * context.el (TeX-ConTeXt-sentinel): Parse ConTeXt Mark IV output.
+
+       * tex-buf.el (TeX-TeX-sentinel-check): Ditto.
+
+2015-10-05  Arash Esbati  <address@hidden>
+
+       * style/newfloat.el (LaTeX-newfloat-auto-cleanup): Check if
+       `LaTeX-caption-supported-float-types' from caption.el is bound and
+       update it accordingly.  Fix docstring.
+       ("newfloat"): Fix wrong check with (LaTeX-largest-level).
+       ("newfloat"): Use `LaTeX-newfloat-key-val-options-local' and
+       delete redundant code.
+
+2015-10-04  Mos� Giordano  <address@hidden>
+
+       * context.el (ConTeXt-Mark-version): New customizable and
+       safe-local variable.
+       (ConTeXt-expand-command): New function.
+       (ConTeXt-expand-options): Use `ConTeXt-Mark-version'.
+
+       * tex.el (TeX-command-list): Use %(cntxcom) expander in all
+       ConTeXt programs.  Remove MkIV entry.
+       (TeX-expand-list): Add %(cntxcom).
+
+2015-10-04  Tassilo Horn  <address@hidden>
+
+       * font-latex.el (font-latex-math-environments): Add math
+       environment.
+
+2015-10-04  Mos� Giordano  <address@hidden>
+
+       * tex.el (TeX-command-list): Add MkIV to `TeX-command-list'.
+
+2015-09-29  Mos� Giordano  <address@hidden>
+
+       * style/newfloat.el (LaTeX-newfloat-auto-cleanup): Replace another
+       `pushnew' with `add-to-list', previously overlooked.
+
+2015-09-28  Mos� Giordano  <address@hidden>
+
+       * style/newfloat.el: Do not require cl at loading time.
+       (LaTeX-newfloat-auto-cleanup): Append elements to
+       `LaTeX-label-alist' in order not to override possible custom
+       values.
+
+2015-09-27  Arash Esbati  <address@hidden>
+
+       * Makefile.in (STYLESRC): Add new style.
+
+       * style/newfloat.el: New file.
+
+       * style/longtable.el ("longtable"): Make package lengths available
+       through `LaTeX-add-lengths' and not `TeX-add-symbol'.
+
+2015-09-26  Mos� Giordano  <address@hidden>
+
+       * tex.el (TeX-search-files-kpathsea): Remove duplicates
+       directories.
+
+2015-09-26  Tassilo Horn  <address@hidden>
+
+       * tex.el (TeX--prettify-symbols-compose-p): New function.
+       (VirTeX-common-initialization): Use it.
+
+2015-09-25  Arash Esbati  <address@hidden>
+
+       * Makefile.in (STYLESRC): Add new style.
+
+       * style/subcaption.el: New file.
+
+       * style/caption.el (LaTeX-caption-key-val-options): Fix values of 
hypcap-key.
+       (LaTeX-caption-update-key-val-options): Add support for
+       subcaption.el if loaded.
+       (LaTeX-arg-caption-captionbox): Do not query for the third
+       optional arg. if the second one is empty.
+       ("caption"): Add support for all lowercase \continuedfloat*?.
+       ("caption"): Fix fontification for \captionof.
+
+       * style/hyperref.el ("hyperref"): Make
+       `LaTeX-indent-environment-list' local before adding new env's.
+
+       * style/filecontents.el ("filecontents"): Make
+       `LaTeX-indent-environment-list' local before adding new env's.
+
+       * style/fontenc.el: Fix mail address in Maintainer-header.
+
+2015-09-25  Mos� Giordano  <address@hidden>
+
+       * latex.el (LaTeX-common-initialization): Remove "abstract"
+       environment, it is not defined in latex.ltx.
+
+       * style/amsart.el ("amsart"): Add "abstract" environment.
+
+       * style/amsbook.el ("amsbook"): Ditto.
+
+       * style/article.el ("article"): Ditto.
+
+       * style/memoir.el ("memoir"): Ditto.
+
+       * style/report.el ("report"): Ditto.
+
+       * style/scrartcl.el ("scrartcl"): Ditto.
+
+       * style/scrreprt.el ("scrreprt"): Ditto.
+
+2015-09-24  Mos� Giordano  <address@hidden>
+
+       * tex.el (TeX-doc): Use default argument of `completing-read'.
+
+2015-09-22  Tassilo Horn  <address@hidden>
+
+       * latex.el (LaTeX-find-matching-end): Find correct end when point
+       is already on the name in \end{name}.
+
+2015-09-20  Mos� Giordano  <address@hidden>
+
+       * .gitignore: Do not ignore auto.el.
+
+       * Makefile.in (install-metadata): auto.el is not there anymore,
+       we do not need to test if preview is enabled here.
+
+2015-09-19  Tassilo Horn  <address@hidden>
+
+       * tex-buf.el (TeX-error-overview): Fix typo in error message.
+       (TeX-TeX-sentinel): Fix error parsing.
+
+2015-09-13  Arash Esbati  <address@hidden>
+
+       * style/eso-pic.el (LaTeX-eso-pic-package-options-list): Rename
+       from `LaTeX-eso-pic-package-options'.
+       (LaTeX-eso-pic-package-options): Use renamed variable.
+
+       * style/AlegreyaSans.el: New file.
+
+       * Makefile.in (STYLESRC): Add new style.
+
+       * style/Alegreya.el: New file.
+
+       * Makefile.in (STYLESRC): Add new style.
+
+       * style/fontenc.el: New file.
+
+2015-09-10  Mos� Giordano  <address@hidden>
+
+       * style/gloss-italian.el ("gloss-italian"): Fix "textitalian"
+       macro and "italian" environment arguments.
+
+       * style/polyglossia.el (LaTeX-polyglossia-prepare): Clear
+       `LaTeX-polyglossia-lang-list'.
+       (LaTeX-polyglossia-cleanup): Remove clearing of
+       `LaTeX-polyglossia-lang-list'.
+       (TeX-update-style-hook): Append
+       `LaTeX-polyglossia-load-languages'.
+       ("polyglossia"): Remove `LaTeX-polyglossia-load-languages' from
+       here.
+
+2015-09-09  Mos� Giordano  <address@hidden>
+
+       * style/polyglossia.el: Remove
+       `LaTeX-polyglossia-italian-options-list', moved to
+       gloss-italian.el.
+       (LaTeX-polyglossia-setkeys-regexp): Fix regexp.
+       (LaTeX-polyglossia-cleanup): Remove useless let-bound variables
+       and set `LaTeX-polyglossia-lang-list'.
+       (LaTeX-polyglossia-active-languages)
+       (LaTeX-polyglossia-lang-option-member): Use
+       `LaTeX-polyglossia-lang-list' variable instead of function.
+       (LaTeX-polyglossia-load-languages): New function.
+       ("polyglossia"): Use it.
+
+       * style/gloss-italian.el: New style file.
+
+       * Makefile.in (STYLESRC): Activate it.
+
+       * style/polyglossia.el: New style file.
+
+       * Makefile.in (STYLESRC): Activate it.
+
+2015-09-08  Arash Esbati  <address@hidden>
+
+       * style/hyperref.el ("hyperref"): Add completion for starred
+       version of `\autoref' incl. fontification.
+       ("hyperref"): Add fontification support for `\hypersetup'.
+
+2015-09-08  Tassilo Horn  <address@hidden>
+
+       * tex-buf.el (TeX-command-default): Fix bug where wrong command
+       was guessed for region files.
+
+2015-09-07  Mos� Giordano  <address@hidden>
+
+       * tex-buf.el (LaTeX-idx-md5-alist, LaTeX-idx-changed-alist): New
+       variables.
+       (TeX-command-sequence): Call file function without optional
+       arguments.
+       (TeX-command-default): Suggest "Index" when appropriate.
+       (TeX-run-TeX): Store value of `LaTeX-idx-md5-alist'.
+       (TeX-run-index): New function.
+       (TeX-LaTeX-sentinel): Set `LaTeX-idx-changed-alist'.
+       (TeX-index-sentinel): New function.
+
+       * tex.el (TeX-command-list): Mention "makeindex" in "Index" help.
+       Suggested by Arash Esbati.
+
+       * doc/changes.texi: Mention ability to suggest makeindex when
+       needed.
+
+       * doc/todo.texi (Wishlist): Remove reference to makeindex.
+
+       * doc/tex-ref.tex: Update copyright years.
+       Mention C-c C-a key binding.
+
+2015-09-05  Tassilo Horn  <address@hidden>
+
+       * font-latex.el (font-latex-unfontify-region): Also remove the
+       `invisible' text properties.
+
+2015-09-04  Mos� Giordano  <address@hidden>
+
+       * doc/auctex.texi (Starting a Command): Update references to
+       `TeX-command-run-all' and C-c C-a key binding.
+
+       * doc/changes.texi: Ditto.
+
+       * doc/quickstart.texi (Processing Facilities): Ditto.
+
+       * tex-buf.el (TeX-command-run-all): Use `universal-argument' to
+       reference C-u.
+
+2015-09-04  Tassilo Horn  <address@hidden>
+
+       * tex-buf.el (TeX-command-sequence-file-function): New variable.
+       (TeX-command-sequence): Use it.
+       (LaTeX-command-section-boundaries): Recognize end of document as
+       ultimate boundary.
+       (LaTeX-command-section): Signal an error if not in a LaTeX buffer.
+       (LaTeX-command-run-all-section): Ditto.
+
+       * tex.el: Add autoloads for the new commands.
+
+       * tex-buf.el (TeX-region-update): New function.
+       (TeX-command-region): Use it.
+       (LaTeX-command-section-boundaries): New function.
+       (LaTeX-command-section): Use it.
+       (TeX-command-run-all-region): New command.
+       (LaTeX-command-run-all-section): New command.
+       (TeX-command-run-all): Move it here from tex.el.
+
+       * tex.el (TeX-command-run-all): Rename from TeX-update.
+       (TeX-mode-map): Bind TeX-command-run-all to C-c C-a.
+
+2015-09-03  Tassilo Horn  <address@hidden>
+
+       * font-latex.el (font-latex-fontify-script): Add possible value
+       `multi-level' to allow raising/lowering scripts of scripts, and
+       another value `invisible' which in addition hides the ^ and _
+       characters in scripts.
+       (font-latex-match-script): Use it.
+       (font-latex-make-user-keywords): Add font-lock entry for script
+       signs.
+       (font-latex-match-script-chars): New function.
+
+       * tex.el (TeX-tex-mode): Don't ignore case when matching the
+       TeX-format-list regexes.
+       (TeX-expand-list): Add expansion of %(PDFout) to -output-format
+       option for AmS-TeX.
+       (TeX-command-list): Use it instead of calling the non-existing
+       pdfamstex command.
+
+2015-09-02  Tassilo Horn  <address@hidden>
+
+       * font-latex.el: Remove code which set up font-latex for use with
+       stock latex-mode on load.
+
+2015-09-01  Tassilo Horn  <address@hidden>
+
+       * tex-buf.el (TeX-command-sequence): Add argument for processing
+       the region file instead of the master file.
+
+       * tex.el (TeX--if-macro-fboundp): New portability macro.
+       (VirTeX-common-initialization): Use it.
+
+2015-08-31  Mos� Giordano  <address@hidden>
+
+       * tex-buf.el (TeX-previous-error): Delete point in error message.
+       (TeX-command-default)
+       (TeX-run-set-command): Take care of `TeX-PDF-via-dvips-ps2pdf'.
+       (TeX-run-dvips, TeX-run-ps2pdf): New functions.
+       (TeX-TeX-sentinel, TeX-TeX-sentinel-check, TeX-LaTeX-sentinel):
+       Take care of `TeX-PDF-via-dvips-ps2pdf'.
+       (TeX-dvips-sentinel, TeX-ps2pdf-sentinel): New functions.
+       (TeX-parse-command, TeX-output-revert-buffer): Delete point in
+       error message.
+
+       * tex.el (TeX-command-list): Add "Dvips" and "Ps2pdf" entries.
+       (TeX-expand-list): Take care of `TeX-PDF-via-dvips-ps2pdf'.
+       (TeX-PDF-via-dvips-ps2pdf): New customizable and safe-local
+       variable.
+       (TeX-toggle-PDF-via-dvips-ps2pdf): New function.
+       (TeX-mode-specific-command-menu-entries): Add "PDF via dvips +
+       ps2pdf" entry.
+
+       * doc/auctex.texi (Processor Options): Document
+       `TeX-PDF-via-dvips-ps2pdf' and fix a typo.
+
+       * doc/changes.texi: Mention `TeX-PDF-via-dvips-ps2pdf'.
+
+       * doc/quickstart.texi (Processing Facilities): Mention
+       `TeX-PDF-via-dvips-ps2pdf'.
+
+       * tex-buf.el: Update copyright year.
+       (TeX-command-sequence-max-runs-same-command)
+       (TeX-command-sequence-max-runs): New customizable variables.
+       (TeX-command-sequence-count-same-command)
+       (TeX-command-sequence-count, TeX-command-sequence-last-command)
+       (TeX-command-sequence-sentinel, TeX-command-sequence-command): New
+       variables.
+       (TeX-command-sequence): New function.
+       (TeX-command-default): New function, stripped off from
+       `TeX-command-query'.
+       (TeX-command-query): Use `TeX-command-default'.
+       (TeX-command-sequence-sentinel): New function.
+
+       * tex.el (TeX-update): New function.
+       (TeX-mode-map): Add key binding for `TeX-update'.
+       (TeX-mode-specific-command-menu-entries): Add entry for
+       `TeX-update'.
+
+       * doc/auctex.texi: Update copyright year.
+       (Starting a Command): Document `TeX-update'.
+
+       * doc/changes.texi: Update copyright year.
+       Mention `TeX-update'.
+
+       * doc/quickstart.texi (Processing Facilities): Mention
+       `TeX-update' and `TeX-error-overview'.
+
+       * doc/todo.texi: Update copyright year.
+       (Wishlist): Remove entry for `TeX-update'.
+
+2015-08-30  Arash Esbati  <address@hidden>
+
+       * style/caption.el ("caption"): Add support for undocumented
+       macros `\captionbox[*]'.
+       (LaTeX-arg-caption-captionbox): New function.
+
+       * Makefile.in (STYLESRC): Add new style.
+
+       * style/transparent.el: New file.
+
+       * style/filecontents.el ("filecontents"): Do not indent the
+       content of `filecontents[*]' environment.
+
+       * style/hyperref.el ("hyperref"): Do not indent the content of
+       `Form' environment.
+
+       * style/array.el ("array"): Add fontification for
+       `\newcolumntype'.
+
 2015-08-28  Tassilo Horn  <address@hidden>
 
        * Version 11.88.8 released.
 
+2015-08-28  Tassilo Horn  <address@hidden>
+
        * tex.el (TeX-mode-syntax-table): Use punctuation syntax for
        character | (bug#21366).
 
diff --git a/Makefile.in b/Makefile.in
index 853c2b3..ba31c43 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -149,8 +149,10 @@ STYLESRC = style/prosper.el \
           style/geometry.el  style/ltablex.el   style/ltxtable.el \
           style/mn2e.el      style/colortbl.el  style/attachfile.el \
           style/newpxtext.el style/newpxmath.el style/pdfpages.el \
-          style/mnras.el     style/environ.el   style/textpos.el \
-          style/vwcol.el
+          style/mnras.el     style/environ.el   style/polyglossia.el \
+          style/vwcol.el     style/textpos.el   style/transparent.el \
+          style/fontenc.el   style/Alegreya.el  style/gloss-italian.el \
+          style/newfloat.el  style/subcaption.el style/AlegreyaSans.el
 
 STYLEELC = $(STYLESRC:.el=.elc)
 
@@ -342,11 +344,7 @@ install-auto:
 install-metadata:
        test "x$(packagedir)" = xno || { \
          $(MKINSTALLDIRS) $(DESTDIR)$(packagedir)/pkginfo || : ; \
-         if test "x$(preview_enabled)" = xyes; then \
-           $(ELCC) -l prv-install -f preview-make-package 
$(DESTDIR)$(packagedir) "$(PACKAGE)" \"`echo $(AUCTEXDATE)|sed 
's/\(.*\)-\(.*\)-\(.*\)/\1.\2\3/'`\" \"$(AUCTEXVERSION)\" tex-site.el auto.el; \
-         else \
-           $(ELCC) -l prv-install -f preview-make-package 
$(DESTDIR)$(packagedir) "$(PACKAGE)" \"`echo $(AUCTEXDATE)|sed 
's/\(.*\)-\(.*\)-\(.*\)/\1.\2\3/'`\" \"$(AUCTEXVERSION)\" tex-site.el; \
-         fi && \
+         $(ELCC) -l prv-install -f preview-make-package 
$(DESTDIR)$(packagedir) "$(PACKAGE)" \"`echo $(AUCTEXDATE)|sed 
's/\(.*\)-\(.*\)-\(.*\)/\1.\2\3/'`\" \"$(AUCTEXVERSION)\" tex-site.el && \
          cd $(DESTDIR)$(packagedir) && \
          find "etc/$(PACKAGE)" "lisp/$(PACKAGE)" -print 
>"pkginfo/MANIFEST.$(PACKAGE)" && \
          for i in $(PACKAGE_INFO); do \
diff --git a/context.el b/context.el
index 30b670e..62d7b3a 100644
--- a/context.el
+++ b/context.el
@@ -1,6 +1,6 @@
 ;;; context.el --- Support for ConTeXt documents.
 
-;; Copyright (C) 2003-2006, 2008, 2010, 2012, 2014
+;; Copyright (C) 2003-2006, 2008, 2010, 2012, 2014, 2015
 ;;   Free Software Foundation, Inc.
 
 ;; Maintainer: Berend de Boer <address@hidden>
@@ -564,28 +564,43 @@ inserted after the sectioning command."
 ;; Various
 (defun TeX-ConTeXt-sentinel (process name)
   "Cleanup TeX output buffer after running ConTeXt."
-  (cond ((TeX-TeX-sentinel-check process name))
-       ((save-excursion
-          ;; in a full ConTeXt run there will multiple texutil
-          ;; outputs. Just looking for "another run needed" would
-          ;; find the first occurence
-          (goto-char (point-max))
-          (re-search-backward "TeXUtil " nil t)
-          (re-search-forward "another run needed" nil t))
-        (message (concat "You should run ConTeXt again "
-                         "to get references right, "
-                         (TeX-current-pages)))
-        (setq TeX-command-next TeX-command-default))
-       ((re-search-forward "removed files :" nil t)
-        (message "sucessfully cleaned up"))
-       ((re-search-forward "^ ?TeX\\(Exec\\|Util\\)" nil t) ;; strange regexp 
--pg
-        (message (concat name ": successfully formatted "
-                         (TeX-current-pages)))
-        (setq TeX-command-next TeX-command-Show))
-       (t
-        (message (concat name ": problems after "
-                         (TeX-current-pages)))
-        (setq TeX-command-next TeX-command-default))))
+  (cond
+   ;; Mark IV
+   ((with-current-buffer TeX-command-buffer
+      (string= ConTeXt-Mark-version "IV"))
+    (cond ((TeX-TeX-sentinel-check process name))
+         ((re-search-forward "fatal error: " nil t)
+          (message (concat name ": problems after "
+                           (TeX-current-pages)))
+          (setq TeX-command-next TeX-command-default))
+         (t
+          (message (concat name ": successfully formatted "
+                           (TeX-current-pages)))
+          (setq TeX-command-next TeX-command-Show))))
+   ;; Mark II
+   (t
+    (cond ((TeX-TeX-sentinel-check process name))
+         ((save-excursion
+            ;; in a full ConTeXt run there will multiple texutil
+            ;; outputs. Just looking for "another run needed" would
+            ;; find the first occurence
+            (goto-char (point-max))
+            (re-search-backward "TeXUtil " nil t)
+            (re-search-forward "another run needed" nil t))
+          (message (concat "You should run ConTeXt again "
+                           "to get references right, "
+                           (TeX-current-pages)))
+          (setq TeX-command-next TeX-command-default))
+         ((re-search-forward "removed files :" nil t)
+          (message "sucessfully cleaned up"))
+         ((re-search-forward "^ ?TeX\\(Exec\\|Util\\)" nil t) ;; strange 
regexp --pg
+          (message (concat name ": successfully formatted "
+                           (TeX-current-pages)))
+          (setq TeX-command-next TeX-command-Show))
+         (t
+          (message (concat name ": problems after "
+                           (TeX-current-pages)))
+          (setq TeX-command-next TeX-command-default))))))
 
 
 ;;; Environments
@@ -1576,24 +1591,51 @@ else.  There might be text before point."
 
 ;;; Option expander
 
+(defcustom ConTeXt-Mark-version "II"
+  "ConTeXt Mark version used for running ConTeXt."
+  :type "string"
+  :group 'TeX-command)
+(make-variable-buffer-local 'ConTeXt-Mark-version)
+(put 'ConTeXt-Mark-version 'safe-local-variable 'stringp)
+
 (defvar ConTeXt-texexec-option-nonstop "--nonstop "
   "Command line option for texexec to use nonstopmode.")
 
+(defun ConTeXt-expand-command ()
+  "Expand ConTeXt command.
+Use `ConTeXt-Mark-version' to choose the command."
+  (cond
+   ((string= ConTeXt-Mark-version "IV")
+    "context")
+   ;; In any other case fall back on Mark II.
+   (t
+    "texexec")))
+
 (defun ConTeXt-expand-options ()
   "Expand options for context command."
-  (concat
-   (let ((engine (eval (nth 4 (assq TeX-engine (TeX-engine-alist))))))
-     (when engine
-       (format "--engine=%s " engine)))
-   (unless (eq ConTeXt-current-interface "en")
-     (format "--interface=%s " ConTeXt-current-interface))
-   (when TeX-source-correlate-mode
-     (format "--passon=\"%s\" "
-            (if (eq (TeX-source-correlate-method-active) 'synctex)
-                TeX-synctex-tex-flags
-              TeX-source-specials-tex-flags)))
-   (unless TeX-interactive-mode
-     ConTeXt-texexec-option-nonstop)))
+  (cond
+   ;; Mark IV
+   ((string= ConTeXt-Mark-version "IV")
+    (concat
+     (if TeX-source-correlate-mode
+        "--synctex=1 ")
+     (unless TeX-interactive-mode
+       ConTeXt-texexec-option-nonstop)))
+   ;; In any other case fall back on Mark II.
+   (t
+    (concat
+     (let ((engine (eval (nth 4 (assq TeX-engine (TeX-engine-alist))))))
+       (when engine
+        (format "--engine=%s " engine)))
+     (unless (eq ConTeXt-current-interface "en")
+       (format "--interface=%s " ConTeXt-current-interface))
+     (when TeX-source-correlate-mode
+       (format "--passon=\"%s\" "
+              (if (eq (TeX-source-correlate-method-active) 'synctex)
+                  TeX-synctex-tex-flags
+                TeX-source-specials-tex-flags)))
+     (unless TeX-interactive-mode
+       ConTeXt-texexec-option-nonstop)))))
 
 ;;; Mode
 
diff --git a/doc/auctex.texi b/doc/auctex.texi
index 141afff..a7ac3ae 100644
--- a/doc/auctex.texi
+++ b/doc/auctex.texi
@@ -12,7 +12,7 @@ This manual is for @AUCTeX{}
 (version @value{VERSION} from @value{UPDATED}),
 a sophisticated TeX environment for Emacs.
 
-Copyright @copyright{} 1992-1995, 2001, 2002, 2004-2014
+Copyright @copyright{} 1992-1995, 2001, 2002, 2004-2015
 Free Software Foundation, Inc.
 
 @quotation
@@ -2700,6 +2700,18 @@ master file.  The command is then actually run on the 
region file.  See
 @code{TeX-command-region} for details.
 @end deffn
 
+It is also possible to compile automatically the whole document until it
+is ready with a single command: @code{TeX-command-run-all}.
+
address@hidden Command TeX-command-run-all
address@hidden C-c C-a
+(@kbd{C-c C-a}) Compile the current document until an error occurs or it
+is finished.  If compilation finishes successfully, run the viewer at
+the end.
address@hidden deffn
+
+Here are some relevant variables.
+
 @defopt TeX-region
 The name of the file for temporarily storing the text when formatting
 the current region.
@@ -2895,6 +2907,33 @@ In particular, fine-tuning the page breaks should be 
done with source
 specials switched off.
 @end deffn
 
+Sometimes you are requested, by journal rules or packages, to compile
+the document into @acronym{DVI} output.  Thus, if you want a
address@hidden document in the end you can either use address@hidden engine,
+see below for information about how to set engines, or compile the
+document with @command{tex} and then convert to @acronym{PDF} with
address@hidden@command{ps2pdf} before viewing it.  The latter can be
+done automatically in @AUCTeX{} by setting the
address@hidden variable to a non-nil value.
+
address@hidden TeX-PDF-via-dvips-ps2pdf
+With @code{TeX-PDF-mode} set to non-nil, if
address@hidden is non-nil too, the document is compiled
+with @command{tex} (or @command{latex}) instead of @command{pdftex} (or
address@hidden).  When the document is ready, @kbd{C-c C-c} will
+suggest to run @command{dvips} and then @command{ps2pdf} in order to
+convert the @acronym{DVI} file to @acronym{PDF}.  When the @acronym{PDF}
+file is finally ready, the next suggested command will be to open the
+viewer.
+
+This option can also be set as a file local variable, in order to use
+the sequence @address@hidden@command{ps2pdf} on a
+per-document basis.
+
+Recall the whole sequence of @kbd{C-c C-c} commands can be replace by
+the single @kbd{C-c C-a}.
address@hidden defopt
+
 @AUCTeX{} also allows you to easily select different @TeX{} engines for
 processing, either by using the entries in the @samp{TeXing Options}
 submenu below the @samp{Command} menu or by calling the function
@@ -2951,7 +2990,7 @@ means there is no command available.
 @end defopt
 
 Some @LaTeX{} packages requires the document to be compiled with a
-specific engine.  Notably examples are fontspec and polyglossia
+specific engine.  Notable examples are fontspec and polyglossia
 packages, which require address@hidden and address@hidden engines.  If you try 
to
 compile a document which loads one of such packages and the set engine
 is not one of those allowed you will be asked to select a different
@@ -3085,14 +3124,15 @@ conditionalized by prefixing them with predicates from
 @code{TeX-view-predicate-list} or
 @code{TeX-view-predicate-list-builtin}.  (See the doc string for the
 exact format to use.)  The command line can also contain placeholders as
-defined in @code{TeX-expand-list} which are expanded before the viewer
-is called.
+defined in @code{TeX-expand-list} and @code{TeX-expand-list-builtin}
+which are expanded before the viewer is called.
 
 The third element of each item is a string, or a list of strings, with
 the name of the executable, or executables, needed to open the output
-file in the viewer.  Placeholders defined in @code{TeX-expand-list} can
-be used here.  This element is optional and is used to check whether the
-viewer is actually available on the system.
+file in the viewer.  Placeholders defined in @code{TeX-expand-list} and
address@hidden can be used here.  This element is
+optional and is used to check whether the viewer is actually available
+on the system.
 
 A built-in viewer spec from @code{TeX-view-program-list-builtin} can be
 overwritten by defining a new viewer spec with the same name.
@@ -3100,10 +3140,10 @@ overwritten by defining a new viewer spec with the same 
name.
 
 Note that the viewer selection and invocation as described above will
 only work if certain default settings in @AUCTeX{} are intact.  For one,
-the whole viewer selection machinery will only be triggered if the
address@hidden expander in @code{TeX-expand-list} is unchanged.  So if you
-have trouble with the viewer invocation you might check if there is an
-older customization of the variable in place.  In addition, the use of a
+the whole viewer selection machinery will only be triggered if there is
+no @samp{%V} expander in @code{TeX-expand-list}.  So if you have trouble
+with the viewer invocation you might check if there is an older
+customization of the variable in place.  In addition, the use of a
 function in @code{TeX-view-program-list} only works if the View command
 in @code{TeX-command-list} makes use of the hook
 @code{TeX-run-discard-or-function}.
diff --git a/doc/changes.texi b/doc/changes.texi
index 2178387..0ed617e 100644
--- a/doc/changes.texi
+++ b/doc/changes.texi
@@ -1,5 +1,5 @@
 @c This is part of the AUCTeX manual.
address@hidden Copyright (C) 1994-2002, 2004-2010, 2012-2014 Free Software
address@hidden Copyright (C) 1994-2002, 2004-2010, 2012-2015 Free Software
 @c Foundation, Inc.
 @c See file auctex.texi for copying conditions.
 @include macros.texi
@@ -12,12 +12,17 @@
 
 @itemize @bullet
 @item
+You can now run all commands needed to compile a document and then open
+the viewer with a single command: @code{TeX-command-run-all}, bound to
address@hidden C-a}.
+
address@hidden
 Commands such as LaTeX and View can now be executed conveniently on the
 current section (or part, chapter, subsection, etc).  See
 @code{LaTeX-command-section} and
 @code{LaTeX-command-section-change-level}.
 @ifclear rawfile
-Also see the documentation at @xref{Starting a Command}.
address@hidden a Command}, for details.
 @end ifclear
 
 @item
@@ -25,6 +30,11 @@ Forward and backward search with Evince now also work when 
only a region
 of the document is compiled/viewed.
 
 @item
+With new option @code{TeX-PDF-via-dvips-ps2pdf} it is possible to
+compile a document to @acronym{DVI} and then convert it to @acronym{PDF}
+using @address@hidden before viewing it.
+
address@hidden
 New option @code{TeX-file-line-error} allows to select file:line:error
 style for error messages.
 
@@ -32,10 +42,20 @@ style for error messages.
 Indent @samp{\[...\]} math mode as a regular environment by default.
 
 @item
+Now @AUCTeX{} suggests to run @command{makeindex} when appropriate.
+
address@hidden
 @code{TeX-view-program-list} can contain, as third optional element of
 each item, the name of the executable(s) needed to open the viewer.
 
 @item
address@hidden variable has been split into
address@hidden and @code{TeX-expand-list-builtin}.  Only the
+former is intended to be customized by the user, the latter contains
+built-in expanders.  You might want to keep in @code{TeX-expand-list}
+only new expansion strings.
+
address@hidden
 When new option @code{TeX-check-engine} is non-nil, before running
 @LaTeX{} commands @AUCTeX{} will check whether the correct engine has
 been set, based upon known restrictions posed by @LaTeX{} packages.
diff --git a/doc/quickstart.texi b/doc/quickstart.texi
index 90076ce..b382018 100644
--- a/doc/quickstart.texi
+++ b/doc/quickstart.texi
@@ -228,6 +228,12 @@ When no processor invocation is necessary anymore, 
@AUCTeX{} will
 suggest to run a viewer, or you can chose to create a PostScript file
 using @command{dvips}, or to directly print it.
 
+Actually, there is another command which comes in handy to compile
+documents: type @kbd{C-c C-a} (@code{TeX-command-run-all}) and @AUCTeX{}
+will compile the document for you until it is ready and then run the
+viewer.  This is the same as issuing repeatedly @kbd{C-c C-c} and
+letting @AUCTeX{} guess the next command to run.
+
 At this place, a warning needs to be given: First, although @AUCTeX{} is
 really good in detecting the standard situations when an additional
 @command{latex} run is necessary, it cannot detect it always.  Second,
@@ -262,6 +268,14 @@ toggles usage of Omega/lambda.
 
 @end table
 
+There is also another possibility: compile the document with
address@hidden (or @command{latex}) and then convert the resulting
address@hidden file to @acronym{PDF} using
address@hidden@command{ps2pdf} sequence.  If you want to go by this
+route, when @code{TeX-PDF-via-dvips-ps2pdf} variable is non-nil,
address@hidden will suggest you to run the appropriate command when you type
address@hidden C-c}.  For details, see @ref{Processor Options}.
+
 @subsection Debugging @LaTeX{}
 
 When @AUCTeX{} runs a program, it creates an output buffer in which it
@@ -278,6 +292,10 @@ may be repeated until all errors have been dealt with.  By 
pressing
 @AUCTeX{} should notify you of overfull and underfull boxes in addition
 to regular errors.
 
+If you have a recent version of GNU Emacs (24 or later), issue @kbd{M-x
+TeX-error-overview RET} to see a nicely formatted list of all errors and
+warnings reported by the compiler.
+
 If a command got stuck in a seemingly infinite loop, or you want to stop
 execution for other reasons, you can use @kbd{C-c C-k} (for ``kill'').
 Similar to @kbd{C-l}, which centers the buffer you are in around your
diff --git a/doc/tex-ref.tex b/doc/tex-ref.tex
index 3ca96bc..de7edb8 100644
--- a/doc/tex-ref.tex
+++ b/doc/tex-ref.tex
@@ -29,7 +29,7 @@
 % compile-command: "tex tex-ref" or "pdftex tex-ref"
 %
 % Original author of Auc-TeX Reference Card:
-%                                  
+%
 %       Terrence Brannon, PO Box 5027, Bethlehem, PA 18015 , USA
 %  internet: address@hidden  (215) 758-1720 (215) 758-2104
 %
@@ -52,8 +52,8 @@
 
 \def\copyrightnotice{%
 \vskip 1ex plus 2 fill\begingroup\small
-\centerline{Copyright \copyright\ 1987, 1992, 1993, 2004, 2005, 2008,}
-\centerline{2010, 2012, 2014 Free Software Foundation, Inc.}
+\centerline{Copyright \copyright\ 1987, 1992-1994, 2004-2006, 2008, 2010,}
+\centerline{2012, 2014, 2015 Free Software Foundation, Inc.}
 \centerline{for AUC\TeX\ version \versionnumber}
 
 Permission is granted to make and distribute copies of
@@ -73,7 +73,7 @@ are preserved on all copies.
 
 \edef\ncolumns{\the\columnsperpage}
 
-\message{[\ncolumns\space 
+\message{[\ncolumns\space
   column\if 1\ncolumns\else s\fi\space per page]}
 
 \def\scaledmag#1{ scaled \magstep #1}
@@ -155,7 +155,7 @@ are preserved on all copies.
   \def\bye{\par\vfill\supereject
     \if a\abc \else\null\vfill\eject\fi
     \if a\abc \else\null\vfill\eject\fi
-    \end}  
+    \end}
 \fi
 
 % we won't be using math mode much, so redefine some of the characters
@@ -245,6 +245,7 @@ are preserved on all copies.
 \key{Toggle debug of bad boxes}{C-c C-t C-b}
 \key{Toggle debug of warnings}{C-c C-t C-w}
 \key{View output file}{C-c C-v}
+\key{Compile all and view output file}{C-c C-a}
 
 Commands you can run on the master file (with \kbd{C-c C-c}) or the
 region (with \kbd{C-c C-r}) include the following (starred versions
@@ -302,7 +303,7 @@ indicated in the mode line.
 \key{Complete \TeX\ macro}{M-TAB}
 \key{Smart ``quote''}{"}
 \key{Smart ``dollar''}{\$}
-  
+
 \section{Font Selection}
 
 \key{Insert {\bf bold\/} text}{C-c C-f C-b}
@@ -674,7 +675,7 @@ $\sp1$ An argument of \kbd{C-u} triggers a document scan 
first.
 
 \bye
 
-%%% Local Variables: 
+%%% Local Variables:
 %%% mode: plain-TeX
 %%% TeX-master: t
-%%% End: 
+%%% End:
diff --git a/doc/todo.texi b/doc/todo.texi
index cd5b2de..8025351 100644
--- a/doc/todo.texi
+++ b/doc/todo.texi
@@ -1,5 +1,5 @@
 @c This is part of the AUCTeX Manual.
address@hidden Copyright (C) 2004-2006, 2008, 2009, 2013, 2014 Free Software
address@hidden Copyright (C) 2004-2006, 2008, 2009, 2013-2015 Free Software
 @c Foundation, Inc.
 @c See the file auctex.texi for copying conditions.
 @ifset rawfile
@@ -138,9 +138,6 @@ This default value for TeX-master could then be controled 
with mapping
 based on the extension.
 
 @item
-Suggest @samp{makeindex} when appropriate.
-
address@hidden
 Use index files (when available) to speed up @kbd{C-c C-m include
 @key{RET}}.
 
@@ -190,17 +187,6 @@ stuff.  Suggested by John Interrante
 @samp{<interran@@uluru.Stanford.EDU>}.
 
 @item
-Make features.
-
-A new command @code{TeX-update} (@kbd{C-c C-u}) could be used to create
-an up-to-date dvi file by repeatedly running address@hidden, MakeIndex and
-(La)@TeX{}, until an error occurs or we are done.
-
-An alternative is to have an @samp{Update} command that ensures the
address@hidden file is up to date.  This could be called before printing and
-previewing.
-
address@hidden
 Documentation of variables that can be set in a style hook.
 
 We need a list of what can safely be done in an ordinary style hook.
diff --git a/font-latex.el b/font-latex.el
index 0bcc039..12ebd04 100644
--- a/font-latex.el
+++ b/font-latex.el
@@ -506,22 +506,22 @@ Generated by `font-latex-make-match-defun'.")
                         (eval ,face)
                       ,face)
                     limit)))))
-        ((eq type 'declaration)
-         (eval `(defun ,(intern (concat prefix name)) (limit)
-                  ,(concat "Fontify `" prefix name "' up to LIMIT.
+       ((eq type 'declaration)
+        (eval `(defun ,(intern (concat prefix name)) (limit)
+                 ,(concat "Fontify `" prefix name "' up to LIMIT.
 
 Generated by `font-latex-make-match-defun'.")
-                  (when ,(intern (concat prefix name))
-                    (font-latex-match-command-in-braces
-                     ,(intern (concat prefix name)) limit)))))
-        ((eq type 'noarg)
-         (eval `(defun ,(intern (concat prefix name)) (limit)
-                  ,(concat "Fontify `" prefix name "' up to LIMIT.
+                 (when ,(intern (concat prefix name))
+                   (font-latex-match-command-in-braces
+                    ,(intern (concat prefix name)) limit)))))
+       ((eq type 'noarg)
+        (eval `(defun ,(intern (concat prefix name)) (limit)
+                 ,(concat "Fontify `" prefix name "' up to LIMIT.
 
 Generated by `font-latex-make-match-defun'.")
-                  (when ,(intern (concat prefix name))
-                    (re-search-forward
-                     ,(intern (concat prefix name)) limit t)))))))
+                 (when ,(intern (concat prefix name))
+                   (re-search-forward
+                    ,(intern (concat prefix name)) limit t)))))))
 
 (defun font-latex-keyword-matcher (prefix name face type)
   "Return a matcher and highlighter as required by `font-lock-keywords'.
@@ -810,7 +810,7 @@ Generated by `font-latex-make-user-keywords'.")))
     (add-to-list 'font-latex-keywords-1 item)
     (add-to-list 'font-latex-keywords-2 item))
   (dolist (item
-          '((font-latex-match-math-env
+          `((font-latex-match-math-env
              (0 'font-latex-warning-face t t)
              (1 'font-latex-math-face append t))
             (font-latex-match-math-envII
@@ -818,7 +818,9 @@ Generated by `font-latex-make-user-keywords'.")))
             (font-latex-match-simple-command
              (0 'font-latex-sedate-face append))
             (font-latex-match-script
-             (1 (font-latex-script (match-beginning 0)) append))))
+             (1 (font-latex-script (match-beginning 0)) append))
+            (font-latex-match-script-chars
+             (0 '(face font-latex-math-face invisible t)))))
     (add-to-list 'font-latex-keywords-2 item t)))
 (font-latex-make-user-keywords)
 
@@ -851,10 +853,28 @@ locking machinery will be triggered."
 
 (defcustom font-latex-fontify-script (not (featurep 'xemacs))
   "If non-nil, fontify subscript and superscript strings.
-This feature does not work in XEmacs."
-  :type 'boolean
+This feature does not work in XEmacs.
+
+By default, super/subscripts are raised/lowered if this variable
+is non-nil.  This fontification only affects one level of
+scripts, e.g., in x^{y^z}, the y and the z have the same size and
+are equally raised over x.
+
+If this variable is set to the symbol `multi-level', then y is
+raised above x, and z is raised above y.  With many script
+levels, the text might become too small to be readable.
+
+If this variable is set to the symbol `invisible', then the
+effect is essentially like `multi-level' but additionally the
+script operators ^ and _ are not displayed."
+  :type '(choice (boolean :tag "Enabled")
+                (const :tag "Multiple levels" multi-level)
+                (const :tag "Hide ^ and _" invisible))
   :group 'font-latex)
-(put 'font-latex-fontify-script 'safe-local-variable 'TeX-booleanp)
+(put 'font-latex-fontify-script 'safe-local-variable
+     (lambda (val)
+       (or (TeX-booleanp val)
+          (memq val '(multi-level invisible)))))
 
 (defcustom font-latex-script-display '((raise -0.3) . (raise 0.3))
   "Display specification for subscript and superscript content.
@@ -1084,14 +1104,14 @@ have changed."
                  '(:inherit fixed-pitch)
                '(:family "courier"))))
     `((((class grayscale) (background light))
-        (:foreground "DimGray" ,@font))
-       (((class grayscale) (background dark))
-        (:foreground "LightGray" ,@font))
-       (((class color) (background light))
-        (:foreground "SaddleBrown" ,@font))
-       (((class color) (background dark))
-        (:foreground "burlywood" ,@font))
-       (t (,@font))))
+       (:foreground "DimGray" ,@font))
+      (((class grayscale) (background dark))
+       (:foreground "LightGray" ,@font))
+      (((class color) (background light))
+       (:foreground "SaddleBrown" ,@font))
+      (((class color) (background dark))
+       (:foreground "burlywood" ,@font))
+      (t (,@font))))
   "Face used to highlight TeX verbatim environments."
   :group 'font-latex-highlighting-faces)
 
@@ -1197,8 +1217,8 @@ triggers Font Lock to recognize the change."
   ;; `VirTeX-common-initialization' and place it in the different
   ;; `xxx-mode' calls instead, but _after_ `major-mode' is set.
   (let ((defaults
-        `((font-latex-keywords font-latex-keywords-1 font-latex-keywords-2)
-          nil nil ,font-latex-syntax-alist nil))
+         `((font-latex-keywords font-latex-keywords-1 font-latex-keywords-2)
+           nil nil ,font-latex-syntax-alist nil))
        (variables
         '((font-lock-comment-start-regexp . "%")
           (font-lock-mark-block-function . mark-paragraph)
@@ -1239,21 +1259,21 @@ triggers Font Lock to recognize the change."
 
 (defun font-latex-jit-lock-force-redisplay (buf start end)
   "Compatibility for Emacsen not offering `jit-lock-force-redisplay'."
-    ;; The following block is an expansion of `jit-lock-force-redisplay'
-    ;; and involved macros taken from CVS Emacs on 2007-04-28.
-    (with-current-buffer buf
-      (let ((modified (buffer-modified-p)))
-       (unwind-protect
-           (let ((buffer-undo-list t)
-                 (inhibit-read-only t)
-                 (inhibit-point-motion-hooks t)
-                 (inhibit-modification-hooks t)
-                 deactivate-mark
-                 buffer-file-name
-                 buffer-file-truename)
-             (put-text-property start end 'fontified t))
-         (unless modified
-           (restore-buffer-modified-p nil))))))
+  ;; The following block is an expansion of `jit-lock-force-redisplay'
+  ;; and involved macros taken from CVS Emacs on 2007-04-28.
+  (with-current-buffer buf
+    (let ((modified (buffer-modified-p)))
+      (unwind-protect
+         (let ((buffer-undo-list t)
+               (inhibit-read-only t)
+               (inhibit-point-motion-hooks t)
+               (inhibit-modification-hooks t)
+               deactivate-mark
+               buffer-file-name
+               buffer-file-truename)
+           (put-text-property start end 'fontified t))
+       (unless modified
+         (restore-buffer-modified-p nil))))))
 
 (defun font-latex-fontify-region (beg end &optional loudly)
   "Fontify region from BEG to END.
@@ -1283,16 +1303,18 @@ If optional argument is non-nil, print status messages."
   ;; property is only added if `font-lock-multiline' is bound.)
   (unless (boundp 'font-lock-multiline)
     (remove-text-properties beg end '(font-latex-multiline)))
-  (while (< beg end)
-    (let ((next (next-single-property-change beg 'display nil end))
-         (prop (get-text-property beg 'display)))
-      (if (and (eq (car-safe prop) 'raise)
-              (member (car-safe (cdr prop))
-                      (list (nth 1 (car font-latex-script-display))
-                            (nth 1 (cdr font-latex-script-display))))
-              (null (cddr prop)))
-         (put-text-property beg next 'display nil))
-      (setq beg next))))
+  (let ((start beg))
+    (while (< beg end)
+      (let ((next (next-single-property-change beg 'display nil end))
+           (prop (get-text-property beg 'display)))
+       (if (and (eq (car-safe prop) 'raise)
+                (member (car-safe (cdr prop))
+                        (list (nth 1 (car font-latex-script-display))
+                              (nth 1 (cdr font-latex-script-display))))
+                (null (cddr prop)))
+           (put-text-property beg next 'display nil))
+       (setq beg next)))
+    (remove-text-properties start end '(invisible))))
 
 (defadvice font-lock-after-change-function (before font-latex-after-change
                                                   activate)
@@ -1688,7 +1710,7 @@ END marks boundaries for searching for environment ends."
       nil)))
 
 (defcustom font-latex-math-environments
-  '("display" "displaymath" "equation" "eqnarray" "gather" "multline"
+  '("display" "displaymath" "equation" "eqnarray" "gather" "math" "multline"
     "align" "alignat" "xalignat" "xxalignat" "flalign")
   "List of math environment names for font locking."
   :type '(repeat string)
@@ -1852,11 +1874,12 @@ END marks boundaries for searching for quotation ends."
   (when (and font-latex-fontify-script
             (re-search-forward "[_^] *\\([^\n\\{}]\\|\
 \\\\\\(address@hidden|[^ \t\n]\\)\\|\\({\\)\\)" limit t))
-    (if (font-latex-faces-present-p '(font-latex-subscript-face
-                                     font-latex-superscript-face))
-       ;; Apply subscript and superscript highlighting only once in
-       ;; order to prevent the font size becoming too small.  We set
-       ;; an empty match to do that.
+    (if (and (not (memq font-latex-fontify-script '(multi-level invisible)))
+            (font-latex-faces-present-p '(font-latex-subscript-face
+                                          font-latex-superscript-face)))
+       ;; Apply subscript and superscript highlighting only once (in case
+       ;; font-latex-fontify-script is not 'multi-level) in order to prevent
+       ;; the font size becoming too small.  We set an empty match to do that.
        (let ((point (point)))
          (store-match-data (list point point point point)))
       (when (match-end 3)
@@ -1871,6 +1894,22 @@ END marks boundaries for searching for quotation ends."
                              (list beg beg beg beg))))))
     t))
 
+(defun font-latex-match-script-chars (limit)
+  (and (eq font-latex-fontify-script 'invisible)
+       (re-search-forward "[_^]" limit t)
+       (let ((pos (match-beginning 0)))
+        (and (font-latex-faces-present-p 'font-latex-math-face pos)
+             (not (font-latex-faces-present-p '(font-lock-constant-face
+                                                font-lock-builtin-face
+                                                font-lock-comment-face
+                                                font-latex-verbatim-face) pos))
+             ;; Check for backslash quoting
+             (not (let ((odd nil)
+                        (pos pos))
+                    (while (eq (char-before pos) ?\\)
+                      (setq pos (1- pos) odd (not odd)))
+                    odd))))))
+
 ;; Copy and adaption of `tex-font-lock-suscript' from tex-mode.el in
 ;; GNU Emacs on 2004-07-07.
 (defun font-latex-script (pos)
@@ -1903,7 +1942,6 @@ END marks boundaries for searching for quotation ends."
                   ,(cdr font-latex-script-display))
          'font-latex-superscript-face)))))
 
-
 ;;; docTeX
 
 (defvar font-latex-doctex-preprocessor-face
@@ -1913,7 +1951,7 @@ END marks boundaries for searching for quotation ends."
 (defface font-latex-doctex-preprocessor-face
   '((t (:inherit (font-latex-doctex-documentation-face
                  font-lock-builtin-face ; Emacs 21 does not provide
-                                        ; the preprocessor face.
+                                       ; the preprocessor face.
                  font-lock-preprocessor-face))))
   "Face used to highlight preprocessor directives in docTeX mode."
   :group 'font-latex-highlighting-faces)
@@ -1982,12 +2020,10 @@ END marks boundaries for searching for quotation ends."
 
 ;;; Installation in non-AUCTeX LaTeX mode
 
-(add-hook 'latex-mode-hook 'font-latex-setup)
-;; If font-latex is loaded using a latex-mode-hook, then the add-hook above
-;; won't be called this time around.  Check for this now:
-(if (eq major-mode 'latex-mode)
-    (font-latex-setup))
-
+;; Here used to be some code which tried to magically make things work and
+;; thereby broke other stuff.  If you want to use font-latex with stock
+;; latex-mode, then please just add `font-latex-setup' to `latex-mode-hook'
+;; yourself.
 
 ;;; Byte-compilation of generated functions
 
diff --git a/latex.el b/latex.el
index 8f613c2..ade8c6c 100644
--- a/latex.el
+++ b/latex.el
@@ -3935,8 +3935,8 @@ space does not end a sentence, so don't break a line 
there."
                     (if (member match-string '("$" "$$"))
                         (save-excursion
                           (skip-chars-backward "$")
-                          (not (TeX-search-backward-unescaped
-                                match-string (line-beginning-position) t)))
+                          (TeX-search-backward-unescaped
+                           match-string (line-beginning-position) t))
                       (texmathp-match-switch (line-beginning-position)))))
              (save-excursion
                (skip-chars-forward "^ \n")
@@ -4198,13 +4198,14 @@ 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))
-    (save-excursion
+    (let ((pt (point)))
       (skip-chars-backward (concat "a-zA-Z \t" (regexp-quote TeX-grop)))
       (unless (bolp)
        (backward-char 1)
-       (and (looking-at regexp)
-            (char-equal (char-after (1+ (match-beginning 0))) ?e)
-            (setq level 0))))
+       (if (and (looking-at regexp)
+                (char-equal (char-after (1+ (match-beginning 0))) ?e))
+           (setq level 0)
+         (goto-char pt))))
     (while (and (> level 0) (re-search-forward regexp nil t))
       (when (or (and LaTeX-syntactic-comments
                     (eq in-comment (TeX-in-commented-line))
@@ -5970,7 +5971,7 @@ i.e. you do _not_ have to cater for this yourself by 
adding \\\\' or $."
 
    "sloppypar" "picture" "tabbing" "verbatim" "verbatim*"
    "flushright" "flushleft" "displaymath" "math" "quote" "quotation"
-   "abstract" "center" "titlepage" "verse" "eqnarray*"
+   "center" "titlepage" "verse" "eqnarray*"
 
    ;; The following are not defined in latex.el, but in a number of
    ;; other style files.  I'm to lazy to copy them to all the
diff --git a/style/Alegreya.el b/style/Alegreya.el
new file mode 100644
index 0000000..e2a444f
--- /dev/null
+++ b/style/Alegreya.el
@@ -0,0 +1,100 @@
+;;; Alegreya.el --- AUCTeX style for `Alegreya.sty' (v2015/09/02)
+
+;; Copyright (C) 2015 Free Software Foundation, Inc.
+
+;; Author: Arash Esbati <esbati'at'gmx.de>
+;; Maintainer: address@hidden
+;; Created: 2015-09-12
+;; Keywords: tex
+
+;; This file is part of AUCTeX.
+
+;; AUCTeX is free software; you can redistribute it and/or modify it
+;; under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 3, or (at your option)
+;; any later version.
+
+;; AUCTeX is distributed in the hope that it will be useful, but
+;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+;; General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with AUCTeX; see the file COPYING.  If not, write to the Free
+;; Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+;; 02110-1301, USA.
+
+;;; Commentary:
+
+;; This file adds support for `Alegreya.sty' (v2015/09/02).
+;; `Alegreya.sty' is part of TeXLive.
+
+;;; Code:
+
+(TeX-add-style-hook
+ "Alegreya"
+ (lambda ()
+
+   ;; Run style hook for packages loaded by Alegreya
+   (TeX-run-style-hooks "textcomp")
+
+   ;; Load `fontaxes' or `fontspec' dep. on `type1' option:
+   (if (or (LaTeX-provided-package-options-member "Alegreya" "type1")
+          (LaTeX-provided-package-options-member "Alegreya" "type1=true"))
+       (TeX-run-style-hooks "fontaxes")
+     (TeX-run-style-hooks "fontspec"))
+
+   (TeX-add-symbols
+    ;; Should be used in preamble only
+    '("useosf")
+    ;; Text commands
+    '("Alegreya"      -1)
+    '("AlegreyaSC"    -1)
+    '("AlegreyaBlack" -1)
+    '("AlegreyaLF"    -1)
+    '("AlegreyaOsF"   -1)
+    '("AlegreyaTLF"   -1)
+    '("AlegreyaTOsF"  -1)
+    '("textsu"         t)  ; superior figures
+    '("sufigures"     -1)  ;
+    '("textin"         t)  ; inferior figures
+    '("infigures"     -1))
+
+   ;; Fontification
+   (when (and (featurep 'font-latex)
+             (eq TeX-install-font-lock 'font-latex-setup))
+     (font-latex-add-keywords '(("textsu"    "{")
+                               ("textin"    "{"))
+                             'type-command)
+     (font-latex-add-keywords '(("Alegreya"      "")
+                               ("AlegreyaSC"    "")
+                               ("AlegreyaBlack" "")
+                               ("AlegreyaLF"    "")
+                               ("AlegreyaOsF"   "")
+                               ("AlegreyaTLF"   "")
+                               ("AlegreyaTOsF"  "")
+                               ("sufigures"     "")
+                               ("infigures"     ""))
+                             'type-declaration)))
+ LaTeX-dialect)
+
+(defvar LaTeX-Alegreya-package-options-list
+  '(("lining"       ("true" "false"))
+    ("lf"           ("true" "false"))
+    ("oldstyle"     ("true" "false"))
+    ("osf"          ("true" "false"))
+    ("tabular"      ("true" "false"))
+    ("tf"           ("true" "false"))
+    ("proportional" ("true" "false"))
+    ("pf"           ("true" "false"))
+    ("black"        ("true" "false"))
+    ("type1"        ("true" "false"))
+    ("scaled")
+    ("scale"))
+  "Package options for the Alegreya package.")
+
+(defun LaTeX-Alegreya-package-options ()
+  "Prompt for package options for the Alegreya package."
+  (TeX-read-key-val t LaTeX-Alegreya-package-options-list))
+
+;;; Alegreya.el ends here
diff --git a/style/AlegreyaSans.el b/style/AlegreyaSans.el
new file mode 100644
index 0000000..4d9b497
--- /dev/null
+++ b/style/AlegreyaSans.el
@@ -0,0 +1,112 @@
+;;; AlegreyaSans.el --- AUCTeX style for `AlegreyaSans.sty' (v2015/09/02)
+
+;; Copyright (C) 2015 Free Software Foundation, Inc.
+
+;; Author: Arash Esbati <esbati'at'gmx.de>
+;; Maintainer: address@hidden
+;; Created: 2015-09-12
+;; Keywords: tex
+
+;; This file is part of AUCTeX.
+
+;; AUCTeX is free software; you can redistribute it and/or modify it
+;; under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 3, or (at your option)
+;; any later version.
+
+;; AUCTeX is distributed in the hope that it will be useful, but
+;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+;; General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with AUCTeX; see the file COPYING.  If not, write to the Free
+;; Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+;; 02110-1301, USA.
+
+;;; Commentary:
+
+;; This file adds support for `AlegreyaSans.sty' (v2015/09/02).
+;; `AlegreyaSans.sty' is part of TeXLive.
+
+;;; Code:
+
+(TeX-add-style-hook
+ "AlegreyaSans"
+ (lambda ()
+
+   ;; Run style hook for packages loaded by AlegreyaSans
+   (TeX-run-style-hooks "textcomp")
+
+   ;; Load `fontaxes' or `fontspec' dep. on `type1' option:
+   (if (or (LaTeX-provided-package-options-member "AlegreyaSans" "type1")
+          (LaTeX-provided-package-options-member "AlegreyaSans" "type1=true"))
+       (TeX-run-style-hooks "fontaxes")
+     (TeX-run-style-hooks "fontspec"))
+
+   (TeX-add-symbols
+    ;; Should be used in preamble only
+    '("useosf")
+    ;; Text commands
+    '("AlegreyaSans"           -1)
+    '("AlegreyaSansLF"         -1)
+    '("AlegreyaSansOsF"        -1)
+    '("AlegreyaSansTLF"        -1)
+    '("AlegreyaSansTOsF"       -1)
+    '("AlegreyaSansThin"       -1)
+    '("AlegreyaSansLight"      -1)
+    '("AlegreyaSansMedium"     -1)
+    '("AlegreyaSansExtraBold"  -1)
+    '("AlegreyaSansBlack"      -1)
+    '("AlegreyaSansSC"         -1)
+    '("textsu"                  t)  ; superior figures
+    '("sufigures"              -1)  ;
+    '("textin"                  t)  ; inferior figures
+    '("infigures"              -1))
+
+   ;; Fontification
+   (when (and (featurep 'font-latex)
+             (eq TeX-install-font-lock 'font-latex-setup))
+     (font-latex-add-keywords '(("textsu"    "{")
+                               ("textin"    "{"))
+                             'type-command)
+     (font-latex-add-keywords '(("AlegreyaSans"           "")
+                               ("AlegreyaSansLF"         "")
+                               ("AlegreyaSansOsF"        "")
+                               ("AlegreyaSansTLF"        "")
+                               ("AlegreyaSansTOsF"       "")
+                               ("AlegreyaSansLight"      "")
+                               ("AlegreyaSansMedium"     "")
+                               ("AlegreyaSansExtraBold"  "")
+                               ("AlegreyaSansBlack"      "")
+                               ("AlegreyaSansSC"         "")
+                               ("sufigures"              "")
+                               ("infigures"              ""))
+                             'type-declaration)))
+ LaTeX-dialect)
+
+(defvar LaTeX-AlegreyaSans-package-options-list
+  '(("lining"       ("true" "false"))
+    ("lf"           ("true" "false"))
+    ("oldstyle"     ("true" "false"))
+    ("osf"          ("true" "false"))
+    ("tabular"      ("true" "false"))
+    ("tf"           ("true" "false"))
+    ("proportional" ("true" "false"))
+    ("pf"           ("true" "false"))
+    ("black"        ("true" "false"))
+    ("extrabold"    ("true" "false"))
+    ("thin"         ("true" "false"))
+    ("light"        ("true" "false"))
+    ("medium"       ("true" "false"))
+    ("type1"        ("true" "false"))
+    ("sfdefault"    ("true" "false"))
+    ("scaled")
+    ("scale"))
+  "Package options for the AlegreyaSans package.")
+
+(defun LaTeX-AlegreyaSans-package-options ()
+  "Prompt for package options for the AlegreyaSans package."
+  (TeX-read-key-val t LaTeX-AlegreyaSans-package-options-list))
+
+;;; AlegreyaSans.el ends here
diff --git a/style/amsart.el b/style/amsart.el
index 8e3ae5c..26a054c 100644
--- a/style/amsart.el
+++ b/style/amsart.el
@@ -5,7 +5,8 @@
 (TeX-add-style-hook "amsart"
  (function
   (lambda ()
-    (TeX-run-style-hooks "amsmath" "amsthm")))
+    (TeX-run-style-hooks "amsmath" "amsthm")
+    (LaTeX-add-environments "abstract")))
  LaTeX-dialect)
 
 ;;; amsart.el ends here.
diff --git a/style/amsbook.el b/style/amsbook.el
index 192b807..0bdbe3a 100644
--- a/style/amsbook.el
+++ b/style/amsbook.el
@@ -5,7 +5,8 @@
 (TeX-add-style-hook "amsbook"
  (function
   (lambda ()
-    (TeX-run-style-hooks "amsmath" "amsthm")))
+    (TeX-run-style-hooks "amsmath" "amsthm")
+    (LaTeX-add-environments "abstract")))
  LaTeX-dialect)
 
 ;;; amsbook.el ends here.
diff --git a/style/array.el b/style/array.el
index 058eb92..645371d 100644
--- a/style/array.el
+++ b/style/array.el
@@ -90,7 +90,13 @@ and make it buffer local. "
 
    ;; `array.sty' adds some new column specification letters.
    (set (make-local-variable 'LaTeX-array-column-letters)
-       (concat LaTeX-array-column-letters "m" "b")))
+       (concat LaTeX-array-column-letters "m" "b"))
+
+   ;; Fontification
+   (when (and (featurep 'font-latex)
+             (eq TeX-install-font-lock 'font-latex-setup))
+     (font-latex-add-keywords '(("newcolumntype" "{[{"))
+                             'function)))
  LaTeX-dialect)
 
 (defvar LaTeX-array-package-options nil
diff --git a/style/article.el b/style/article.el
index d4842f1..4bfd881 100644
--- a/style/article.el
+++ b/style/article.el
@@ -14,7 +14,8 @@
    (LaTeX-largest-level-set "section")
    (LaTeX-add-counters "part" "section" "subsection" "subsubsection" 
"paragraph"
                       "subparagraph" "figure" "table")
-   (LaTeX-add-pagestyles "headings" "myheadings"))
+   (LaTeX-add-pagestyles "headings" "myheadings")
+   (LaTeX-add-environments "abstract"))
  LaTeX-dialect)
 
 ;;; article.el ends here
diff --git a/style/caption.el b/style/caption.el
index 0ec6c29..4412443 100644
--- a/style/caption.el
+++ b/style/caption.el
@@ -1,4 +1,4 @@
-;;; caption.el --- AUCTeX style for `caption.sty' (v3.3-89)
+;;; caption.el --- AUCTeX style for `caption.sty' (v3.3-111)
 
 ;; Copyright (C) 2015 Free Software Foundation, Inc.
 
@@ -26,7 +26,7 @@
 
 ;;; Commentary:
 
-;; This file adds support for `caption.sty' (v3.3-89) from 2013/05/02.
+;; This file adds support for `caption.sty' (v3.3-111) from 2015/09/17.
 ;; `caption.sty' is part of TeXLive.
 
 ;; If things do not work or when in doubt, press `C-c C-n'.  Comments
@@ -53,7 +53,7 @@
               "stretch" "normalcolor" "color" "normal"))
     ("format" ("plain" "hang"))
     ("hangindent")
-    ("hypcap")
+    ("hypcap" ("false" "no" "off" "0" "true" "yes" "on" "1"))
     ("hypcapspace")
     ("indention")
     ("justification" ("justified" "centering" "centerlast" "centerfirst"
@@ -151,18 +151,33 @@ in `caption'-completions."
                       (downcase (substring (nth 1 keyvals) 0 8)))
                      (t (downcase (nth 1 keyvals)))))
           (val (nth 2 keyvals))
-          ;; (key-match (car (assoc key LaTeX-caption-key-val-options-local)))
           (val-match (cdr (assoc key LaTeX-caption-key-val-options-local)))
-          (temp  (copy-alist LaTeX-caption-key-val-options-local))
-          (opts (assq-delete-all (car (assoc key temp)) temp)))
+          (temp (copy-alist LaTeX-caption-key-val-options-local))
+          ;; If `subcaption.el' is loaded, delete and update also the
+          ;; entry for `subrefformat' when processing the `labelformat'.
+          (opts (progn
+                  (when (and (string-equal key "labelformat")
+                             (boundp 'LaTeX-subcaption-key-val-options))
+                    (setq temp
+                          (assq-delete-all
+                           (car (assoc (caar LaTeX-subcaption-key-val-options) 
temp))
+                           temp)))
+                  (assq-delete-all (car (assoc key temp)) temp))))
       ;; For `\DeclareCaptionOption', only add the value
       ;; (remember:      key=^^^^^^, val="defined key")
       (if (string-equal key "option")
          (pushnew (list val) opts :test #'equal)
-       ;; For anything but `\DeclareCaptionOption', do the standard procedure
+       ;; For anything but `\DeclareCaptionOption', do the standard
+       ;; procedure.  Again, take care of `subrefformat' for `subcaption.el'.
        (if val-match
-           (pushnew (list key (delete-dups (apply 'append (list val) 
val-match)))
-                    opts :test #'equal)
+           (progn
+             (when (and (string-equal key "labelformat")
+                        (boundp 'LaTeX-subcaption-key-val-options))
+               (pushnew (list "subrefformat"
+                              (delete-dups (apply 'append (list val) 
val-match)))
+                        opts :test #'equal))
+             (pushnew (list key (delete-dups (apply 'append (list val) 
val-match)))
+                      opts :test #'equal))
          (pushnew (list key (list val)) opts :test #'equal)))
       (setq LaTeX-caption-key-val-options-local (copy-alist opts)))))
 
@@ -190,6 +205,47 @@ suffix of the command."
           format name))
     (TeX-argument-insert name optional)))
 
+;; Support for an undocumented feature of caption.sty:
+;; `\captionbox' sets the width of the caption equal to the width of
+;; the contents (a feature provided e.g. by `threeparttable.sty').
+;; The starred version typesets the caption without label and without
+;; entry to the list of figures or tables.
+
+;; The first mandatory argument {<heading>} contains the caption text
+;; and the label.  We use `TeX-insert-macro' to do the job. (Thanks to
+;; M. Giordano for his valuable comments on this!)
+
+;; Syntax:
+;; \captionbox[<list entry>]{<heading>}[<width>][<inner-pos>]{<contents>}
+;; \captionbox*{<heading>}[<width>][<inner-pos>]{<contents>}
+
+(defun LaTeX-arg-caption-captionbox (optional &optional star prompt)
+  "Query for the arguments of `\\captionbox' incl. a label and
+insert them.  If STAR is t, then do not query for a `\\label' and
+insert only a caption."
+  (let ((caption (TeX-read-string
+                 (TeX-argument-prompt optional prompt "Caption"))))
+    (LaTeX-indent-line)
+    (insert TeX-grop caption)
+    (unless star (TeX-insert-macro "label"))
+    (insert TeX-grcl))
+  (let* ((width (completing-read (TeX-argument-prompt t prompt "Width")
+                                (mapcar (lambda(elt) (concat TeX-esc (car 
elt)))
+                                        (LaTeX-length-list))))
+        (inpos (when (and width (not (string-equal width "")))
+                 (completing-read (TeX-argument-prompt t prompt "Inner 
position")
+                                  '("c" "l" "r" "s")))))
+    (cond (;; 2 optional args
+          (and width (not (string-equal width ""))
+               inpos (not (string-equal inpos "")))
+          (insert (format "[%s][%s]" width inpos)))
+         (;; 1st opt. arg, 2nd empty opt. arg
+          (and width (not (string-equal width ""))
+               (string-equal inpos ""))
+          (insert (format "[%s]" width)))
+         (t ; Do nothing if both empty
+          (ignore)))))
+
 (TeX-add-style-hook
  "caption"
  (lambda ()
@@ -240,7 +296,15 @@ suffix of the command."
       (TeX-arg-eval completing-read (TeX-argument-prompt nil nil "Float type")
                    LaTeX-caption-supported-float-types))
 
+    '("captionbox"  ["List entry"] (LaTeX-arg-caption-captionbox) t)
+
+    '("captionbox*" (LaTeX-arg-caption-captionbox t) t)
+
     '("ContinuedFloat" 0)
+    '("ContinuedFloat*" 0)
+
+    '("continuedfloat" 0)
+    '("continuedfloat*" 0)
 
     '("DeclareCaptionFont"
       (LaTeX-arg-caption-DeclareCaption "Font") t)
@@ -286,7 +350,8 @@ suffix of the command."
              (eq TeX-install-font-lock 'font-latex-setup))
      (font-latex-add-keywords '(("caption"           "*[{")
                                ("captionlistentry"  "[{")
-                               ("captionof"         "*[{"))
+                               ("captionof"         "*{[{")
+                               ("captionbox"        "*[{[[{"))
                              'textual)
      (font-latex-add-keywords '(("captionsetup"                  "*[{")
                                ("clearcaptionsetup"             "*[{")
diff --git a/style/enumitem.el b/style/enumitem.el
index bca9203..dff94aa 100644
--- a/style/enumitem.el
+++ b/style/enumitem.el
@@ -221,7 +221,7 @@ key-val and the first item."
                (current-fill-column)))
     (LaTeX-fill-paragraph nil)))
 
-(defun LaTeX-arg-SetEnumitemKey (optional &optional prompt)
+(defun LaTeX-arg-SetEnumitemKey (optional)
   "Ask for a new key to be defined and add it to
 `LaTeX-enumitem-key-val-options-local'."
   (LaTeX-enumitem-update-key-val-options)
@@ -239,7 +239,7 @@ key-val and the first item."
 ;; the elements and pass the result to
 ;; `LaTeX-add-enumitem-SetEnumitemValues'.  It will vanish upon next
 ;; invocation of `C-c C-n'.
-(defun LaTeX-arg-SetEnumitemValue (optional &optional prompt)
+(defun LaTeX-arg-SetEnumitemValue (optional)
   "Ask for a new value added to an existing key incl. the final
 replacement of the value."
   (LaTeX-enumitem-update-key-val-options)
diff --git a/style/eso-pic.el b/style/eso-pic.el
index 8b43535..b1bedb2 100644
--- a/style/eso-pic.el
+++ b/style/eso-pic.el
@@ -72,9 +72,8 @@
     "gridSetup" "LenToUnit"))
  LaTeX-dialect)
 
-(defvar LaTeX-eso-pic-package-options
-  '(;;
-    ("pscoord"      ("true" "false"))
+(defvar LaTeX-eso-pic-package-options-list
+  '(("pscoord"      ("true" "false"))
     ("texcoord"     ("true" "false"))
     ("grid"         ("true" "false"))
     ("gridunit"     ("mm" "in" "bp" "pt"))
@@ -86,6 +85,6 @@
 
 (defun LaTeX-eso-pic-package-options nil
   "Prompt for package options for the eso-pic package."
-  (TeX-read-key-val t LaTeX-eso-pic-package-options))
+  (TeX-read-key-val t LaTeX-eso-pic-package-options-list))
 
 ;;; eso-pic.el ends here
diff --git a/style/filecontents.el b/style/filecontents.el
index 493b6c7..256c214 100644
--- a/style/filecontents.el
+++ b/style/filecontents.el
@@ -1,6 +1,6 @@
 ;;; filecontents.el --- AUCTeX style for `filecontents.sty'
 
-;; Copyright (C) 2013, 2014 Free Software Foundation, Inc.
+;; Copyright (C) 2013--2015 Free Software Foundation, Inc.
 
 ;; Author: Mads Jensen <address@hidden>
 ;; Maintainer: address@hidden
@@ -38,7 +38,13 @@
  (lambda ()
    (LaTeX-add-environments
     '("filecontents" LaTeX-env-filecontents)
-    '("filecontents*" LaTeX-env-filecontents)))
+    '("filecontents*" LaTeX-env-filecontents))
+
+   (make-local-variable 'LaTeX-indent-environment-list)
+   (add-to-list 'LaTeX-indent-environment-list
+               '("filecontents" current-indentation))
+   (add-to-list 'LaTeX-indent-environment-list
+               '("filecontents*" current-indentation)))
  LaTeX-dialect)
 
 (defun LaTeX-env-filecontents (environment)
diff --git a/style/fontenc.el b/style/fontenc.el
new file mode 100644
index 0000000..c57f6d7
--- /dev/null
+++ b/style/fontenc.el
@@ -0,0 +1,52 @@
+;;; fontenc.el --- AUCTeX style for `fontenc.sty' (v1.99g)
+
+;; Copyright (C) 2015 Free Software Foundation, Inc.
+
+;; Author: Arash Esbati <esbati'at'gmx.de>
+;; Maintainer: address@hidden
+;; Created: 2015-09-12
+;; Keywords: tex
+
+;; This file is part of AUCTeX.
+
+;; AUCTeX is free software; you can redistribute it and/or modify it
+;; under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 3, or (at your option)
+;; any later version.
+
+;; AUCTeX is distributed in the hope that it will be useful, but
+;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+;; General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with AUCTeX; see the file COPYING.  If not, write to the Free
+;; Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+;; 02110-1301, USA.
+
+;;; Commentary:
+
+;; This file adds support for `fontenc.sty' (v1.99g) from 2005/09/27.
+;; `fontenc.sty' is a standard LaTeX package and part of TeXLive.
+
+;;; Code:
+
+(defvar LaTeX-fontenc-package-options-list
+  '(;; 128+ glyph encodings (text)
+    "OT1" "OT2" "OT3" "OT4" "OT6"
+    ;; 256 glyph encodings (text)
+    "T1" "T2A" "T2B" "T2C" "T3" "T4" "T5"
+    ;; 256 glyph encodings (text extended)
+    "X2"
+    ;; Other encodings
+    "LY1" "LV1" "LGR")
+  "Package options for the fontenc package.")
+
+(defun LaTeX-fontenc-package-options ()
+  "Prompt for package options for the fontenc package."
+  (mapconcat 'identity
+            (TeX-completing-read-multiple
+             "Encoding(s): "
+             LaTeX-fontenc-package-options-list) ","))
+
+;;; fontenc.el ends here
diff --git a/style/gloss-italian.el b/style/gloss-italian.el
new file mode 100644
index 0000000..c786bb4
--- /dev/null
+++ b/style/gloss-italian.el
@@ -0,0 +1,68 @@
+;;; gloss-italian.el --- Italian support for polyglossia package.
+
+;; Copyright (C) 2015 Free Software Foundation, Inc.
+
+;; Maintainer: address@hidden
+;; Author: Mosè Giordano <address@hidden>
+;; Keywords: tex
+
+;; This file is part of AUCTeX.
+
+;; AUCTeX is free software; you can redistribute it and/or modify it
+;; under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 3, or (at your option)
+;; any later version.
+
+;; AUCTeX is distributed in the hope that it will be useful, but
+;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+;; General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with AUCTeX; see the file COPYING.  If not, write to the Free
+;; Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+;; 02110-1301, USA.
+
+;;; Commentary:
+
+;; This is based on italian.el style file, adapted to polyglossia package.
+
+;;; Code:
+
+(defvar TeX-language-it-hook nil
+  "Hook run for Italian texts.")
+
+(TeX-add-style-hook
+ "gloss-italian"
+ (lambda ()
+   (TeX-add-symbols
+    '("textitalian" [TeX-arg-key-val LaTeX-polyglossia-italian-options-list] 
t))
+   (LaTeX-add-environments
+    '("italian"
+      LaTeX-env-args [TeX-arg-key-val LaTeX-polyglossia-italian-options-list]))
+
+   (when (or (LaTeX-polyglossia-lang-option-member "italian" 
"babelshorthands=true")
+            (LaTeX-polyglossia-lang-option-member "italian" "babelshorthands"))
+     (unless (eq (car TeX-quote-language) 'override)
+       (let ((open-quote (if (and (boundp 'LaTeX-italian-open-quote)
+                                 LaTeX-italian-open-quote)
+                            LaTeX-italian-open-quote
+                          "\"<"))
+            (close-quote (if (and (boundp 'LaTeX-italian-close-quote)
+                                  LaTeX-italian-close-quote)
+                             LaTeX-italian-close-quote
+                           "\">")))
+        (setq TeX-quote-language
+              `("italian" ,open-quote ,close-quote ,TeX-quote-after-quote))))
+
+     ;; Fontification of quotation marks.
+     (when (fboundp 'font-latex-add-quotes)
+       (font-latex-add-quotes '("\"<" "\">" french))))
+   (run-hooks 'TeX-language-it-hook))
+ LaTeX-dialect)
+
+(defvar LaTeX-polyglossia-italian-options-list
+  '(("babelshorthands" ("true" "false")))
+  "Italian language options for the polyglossia package.")
+
+;;; gloss-italian.el ends here
diff --git a/style/hyperref.el b/style/hyperref.el
index a1eee7c..630f24c 100644
--- a/style/hyperref.el
+++ b/style/hyperref.el
@@ -1,6 +1,6 @@
 ;;; hyperref.el --- AUCTeX style for `hyperref.sty' v6.83m
 
-;; Copyright (C) 2008, 2013, 2014 Free Software Foundation, Inc.
+;; Copyright (C) 2008, 2013--2015 Free Software Foundation, Inc.
 
 ;; Author: Ralf Angeli <address@hidden>
 ;; Maintainer: address@hidden
@@ -230,6 +230,7 @@
     '("hypertarget" "Name" "Text")
     '("phantomsection" 0)
     '("autoref" TeX-arg-ref)
+    '("autoref*" TeX-arg-ref)
     '("ref*" TeX-arg-ref)
     '("pageref*" TeX-arg-ref)
     '("autopageref" TeX-arg-ref)
@@ -266,6 +267,11 @@
    (LaTeX-add-environments
     '("Form"))
 
+   ;; Do not indent the content of the "Form"-env; it is odd if the
+   ;; whole document is indented.
+   (make-local-variable 'LaTeX-indent-environment-list)
+   (add-to-list 'LaTeX-indent-environment-list '("Form" current-indentation))
+
    (add-to-list 'LaTeX-verbatim-macros-with-braces-local "nolinkurl")
    (add-to-list 'LaTeX-verbatim-macros-with-braces-local "hyperbaseurl")
    (add-to-list 'LaTeX-verbatim-macros-with-braces-local "hyperimage")
@@ -283,11 +289,13 @@
                                ("hyperref" "{{{{")
                                ("hyperlink" "{{")
                                ("hypertarget" "{{")
-                               ("autoref" "{")
+                               ("autoref" "*{")
                                ("ref" "*{")
                                ("pageref" "*{")
                                ("autopageref" "*{"))
                              'reference)
+     (font-latex-add-keywords '(("hypersetup" "{"))
+                             'function)
      ;; For syntactic fontification, e.g. verbatim constructs.
      (font-latex-set-syntactic-keywords))
 
diff --git a/style/listings.el b/style/listings.el
index f9aee45..0dff6ec 100644
--- a/style/listings.el
+++ b/style/listings.el
@@ -31,10 +31,16 @@
 ;; May 2015: The style detects new environments defined with
 ;; `\lstnewenvironment'.  Users need to invoke `C-c C-n' for this.
 ;;
+;; October 2015: The style detects new "styles" defined with
+;; `\lstdefinestyle' and offers them during key-value query.
+;;
 ;; FIXME: Please make me more sophisticated!
 
 ;;; Code:
 
+;; Needed for compiling `pushnew':
+(eval-when-compile (require 'cl))
+
 ;; The following are options taken from chapter 4 of the listings
 ;; manual (2007/02/22 Version 1.4).
 (defvar LaTeX-listings-key-val-options
@@ -220,11 +226,16 @@
     ("multicolumn"))
   "Key=value options for listings macros and environments.")
 
+(defvar LaTeX-listings-key-val-options-local nil
+  "Buffer-local Key=value options for listings macros and environments.")
+(make-variable-buffer-local 'LaTeX-listings-key-val-options-local)
+
+;; Setup for \lstnewenvironment:
 (defvar LaTeX-auto-listings-lstnewenvironment nil
   "Temporary for parsing the arguments of `\\lstnewenvironment'
 from `listings' package.")
 
-(defvar LaTeX-listing-lstnewenvironment-regexp
+(defvar LaTeX-listings-lstnewenvironment-regexp
   `(,(concat "\\\\lstnewenvironment"
             "[ \t\n\r]*{\\([A-Za-z0-9]+\\)}%?"
             "[ \t\n\r]*\\[?\\([0-9]?\\)\\]?%?"
@@ -232,12 +243,36 @@ from `listings' package.")
     (1 2 3) LaTeX-auto-listings-lstnewenvironment)
   "Matches the argument of `\\lstnewenvironment' from `listings.sty'.")
 
+;; Setup for \lstdefinestyle:
+(TeX-auto-add-type "listings-lstdefinestyle" "LaTeX")
+
+(defvar LaTeX-listings-lstdefinestyle-regexp
+  '("\\\\lstdefinestyle{\\([^}]+\\)}"
+    1 LaTeX-auto-listings-lstdefinestyle)
+  "Matches the argument of \"\\lstdefinestyle\" from
+\"listings\" package.")
+
+(defun LaTeX-listings-update-style-key ()
+  "Update the \"style\" key from `LaTeX-listings-key-val-options-local'
+with user-defined values via the \"lstdefinestyle\" macro."
+  (let* ((elt (assoc "style" LaTeX-listings-key-val-options-local))
+        (key (car elt))
+        (temp (copy-alist LaTeX-listings-key-val-options-local))
+        (opts (assq-delete-all (car (assoc key temp)) temp)))
+    (pushnew (list key (delete-dups
+                       (mapcar 'car (LaTeX-listings-lstdefinestyle-list))))
+            opts :test #'equal)
+    (setq LaTeX-listings-key-val-options-local
+         (copy-alist opts))))
+
 (defun LaTeX-listings-auto-prepare ()
   "Clear temporary variable from `listings.sty' before parsing."
-  (setq LaTeX-auto-listings-lstnewenvironment nil))
+  (setq LaTeX-auto-listings-lstnewenvironment nil)
+  (setq LaTeX-auto-listings-lstdefinestyle    nil))
 
 (defun LaTeX-listings-auto-cleanup ()
-  "Process the parsed results of `\\lstnewenvironment'."
+  "Process the parsed results of \"\\lstnewenvironment\" and
+\"\\lstdefinestyle\"."
   (dolist (env-args LaTeX-auto-listings-lstnewenvironment)
     (let ((env  (car   env-args))
          (args (cadr  env-args))
@@ -256,7 +291,9 @@ from `listings' package.")
            (t ; No args
             (add-to-list 'LaTeX-auto-environment (list env))))
       (add-to-list 'LaTeX-indent-environment-list `(,env current-indentation))
-      (add-to-list 'LaTeX-verbatim-environments-local env))))
+      (add-to-list 'LaTeX-verbatim-environments-local env)))
+  (when (LaTeX-listings-lstdefinestyle-list)
+    (LaTeX-listings-update-style-key)))
 
 (add-hook 'TeX-auto-prepare-hook #'LaTeX-listings-auto-prepare t)
 (add-hook 'TeX-auto-cleanup-hook #'LaTeX-listings-auto-cleanup t)
@@ -266,21 +303,32 @@ from `listings' package.")
  "listings"
  (lambda ()
 
-   ;; Add it to the parser
-   (TeX-auto-add-regexp LaTeX-listing-lstnewenvironment-regexp)
+   ;; Add to parser:
+   (TeX-auto-add-regexp LaTeX-listings-lstnewenvironment-regexp)
+   (TeX-auto-add-regexp LaTeX-listings-lstdefinestyle-regexp)
+
+   ;; Local version of key-val options:
+   (setq LaTeX-listings-key-val-options-local
+        (copy-alist LaTeX-listings-key-val-options))
 
    ;; New symbols
    (TeX-add-symbols
     '("lstalias" ["Alias dialect"] "Alias" ["Dialect"] "Language")
-    '("lstdefinestyle" "Style name"
-      (TeX-arg-key-val LaTeX-listings-key-val-options))
+    '("lstdefinestyle"
+      (TeX-arg-eval
+       (lambda ()
+        (let ((name (TeX-read-string "Style name: ")))
+          (LaTeX-add-listings-lstdefinestyles name)
+          (LaTeX-listings-update-style-key)
+          (format "%s" name))))
+      (TeX-arg-key-val LaTeX-listings-key-val-options-local))
     '("lstinline" TeX-arg-verb)
-    '("lstinputlisting" [TeX-arg-key-val LaTeX-listings-key-val-options]
+    '("lstinputlisting" [TeX-arg-key-val LaTeX-listings-key-val-options-local]
       TeX-arg-file)
     "lstlistoflistings"
     '("lstnewenvironment" "Name" ["Number or arguments"] ["Default argument"]
       "Starting code" "Ending code")
-    '("lstset" (TeX-arg-key-val LaTeX-listings-key-val-options))
+    '("lstset" (TeX-arg-key-val LaTeX-listings-key-val-options-local))
     '("lstloadlanguages" t)
     ;; 4.17 Short Inline Listing Commands
     '("lstMakeShortInline" [ "Options" ] "Character")
@@ -292,7 +340,7 @@ from `listings' package.")
    ;; New environments
    (LaTeX-add-environments
     '("lstlisting" LaTeX-env-args
-      [TeX-arg-key-val LaTeX-listings-key-val-options]))
+      [TeX-arg-key-val LaTeX-listings-key-val-options-local]))
    ;; Filling
    (make-local-variable 'LaTeX-indent-environment-list)
    (add-to-list 'LaTeX-indent-environment-list
diff --git a/style/longtable.el b/style/longtable.el
index 353336d..6c9aeaf 100644
--- a/style/longtable.el
+++ b/style/longtable.el
@@ -1,6 +1,6 @@
 ;;; longtable.el --- AUCTeX style for `longtable.sty'.
 
-;; Copyright (C) 2013, 2014  Free Software Foundation, Inc.
+;; Copyright (C) 2013--2015  Free Software Foundation, Inc.
 
 ;; Maintainer: address@hidden
 ;; Author: Mosè Giordano <address@hidden>
@@ -58,13 +58,6 @@
                          (LaTeX-newline)
                          (indent-according-to-mode)))))))
    (TeX-add-symbols
-    ;; Parameters
-    '("LTleft" 0)
-    '("LTright" 0)
-    '("LTpre" 0)
-    '("LTpost" 0)
-    '("LTcapwidth" 0)
-    '("LTchunksize" 0)
     ;; Commands to end table rows
     '("endhead" 0)
     '("endfirsthead" 0)
@@ -73,6 +66,13 @@
     ;; Caption commands
     '("caption*" 1))
 
+   ;; These parameters are set with \setlength
+   (LaTeX-add-lengths
+    "LTleft" "LTright" "LTpre" "LTpost" "LTcapwidth")
+
+   ;; This parameter is set with \setcounter
+   (LaTeX-add-counters "LTchunksize")
+
    ;; Use the enhanced table formatting
    (add-to-list 'LaTeX-indent-environment-list
                '("longtable" LaTeX-indent-tabular))
diff --git a/style/memoir.el b/style/memoir.el
index 68b74dc..563adbe 100644
--- a/style/memoir.el
+++ b/style/memoir.el
@@ -65,6 +65,8 @@
 
     "leadpagetoclevel")
 
+   (LaTeX-add-environments "abstract")
+
    ;; Emulated packages.  The `memoir' class contains a list of files
    ;; emulated at the end of the class-file
    (TeX-run-style-hooks
diff --git a/style/newfloat.el b/style/newfloat.el
new file mode 100644
index 0000000..4cde32e
--- /dev/null
+++ b/style/newfloat.el
@@ -0,0 +1,216 @@
+;;; newfloat.el --- AUCTeX style for `newfloat.sty' (v1.1-109)
+
+;; Copyright (C) 2015 Free Software Foundation, Inc.
+
+;; Author: Arash Esbati <esbati'at'gmx.de>
+;; Maintainer: address@hidden
+;; Created: 2015-09-19
+;; Keywords: tex
+
+;; This file is part of AUCTeX.
+
+;; AUCTeX is free software; you can redistribute it and/or modify it
+;; under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 3, or (at your option)
+;; any later version.
+
+;; AUCTeX is distributed in the hope that it will be useful, but
+;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+;; General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with AUCTeX; see the file COPYING.  If not, write to the Free
+;; Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+;; 02110-1301, USA.
+
+;;; Commentary:
+
+;; This file adds support for `newfloat.sty' (v1.1-109) from 2015/09/17.
+;; `newfloat.sty' is part of TeXLive.
+
+;; This style has some facilities to process the newly defined
+;; floating environments within AUCTeX, e.g. indentation, label
+;; addition etc.  Currently it makes provision for `figure', `table'
+;; and `verbatim' floating types.  To make things work, the style
+;; needs some help from the user.  When a new floating environment is
+;; defined, the user should pass the floating type as a comment to
+;; AUCTeX, e.g.
+;;
+;;     \DeclareFloatingEnvironment[
+;;       name=Code,
+;;       listname={List of Codes},
+;;       fileext=lol]{code}  %  {verbatim}
+;;
+;; Note the `{verbatim}' as a comment after the name of the float env.
+;; Due to parsing reasons, this key-word must be in the same line as
+;; the name of the float and enclosed in braces `{}'.
+;;
+;; Before the opening brace, only spaces and comment chars `%' are
+;; allowed.  Anything following the closing brace `}' is ignored.
+
+;; If things do not work or when in doubt, press `C-c C-n'.  Comments
+;; for improvement are welcome.
+
+;;; Code:
+
+;; Needed for auto-parsing.
+(require 'tex)
+
+(defvar LaTeX-newfloat-key-val-options
+  '(("fileext")
+    ("listname")
+    ("name")
+    ("placement" ("t" "b" "p" "tbp" "htbp"))
+    ("chapterlistsgaps" ("on" "off")))
+  "Key=value options for newfloat macros.")
+
+(defvar LaTeX-newfloat-key-val-options-local nil
+  "Buffer-local Key=value options for newfloat macros.")
+(make-variable-buffer-local 'LaTeX-newfloat-key-val-options-local)
+
+;; Setup parsing for \DeclareFloatingEnvironment:
+(TeX-auto-add-type "newfloat-DeclareFloatingEnvironment" "LaTeX")
+
+(defvar LaTeX-newfloat-DeclareFloatingEnvironment-regex
+  `(,(concat "\\\\DeclareFloatingEnvironment"
+            "[ \t\n\r%]*"
+            "\\["
+            "[ \t\n\r%{}a-zA-Z0-9=,-]*"
+            "\\]"
+            "[ \t\n\r%]*"
+            "{\\([^}]+\\)}"
+            "\\(?:[ %]*{\\([^}]*\\)}\\)?")
+    (1 2) LaTeX-auto-newfloat-DeclareFloatingEnvironment)
+  "Matches the argument of `\\DeclareFloatingEnvironment' from
+`newfloat.sty'.")
+
+(defun LaTeX-newfloat-auto-prepare ()
+  "Clear `LaTeX-auto-newfloat-DeclareFloatingEnvironment' before parsing."
+  (setq LaTeX-auto-newfloat-DeclareFloatingEnvironment nil))
+
+(defun LaTeX-newfloat-auto-cleanup ()
+  "Process definded floats with \\DeclareFloatingEnvironment.
+Depending on floating type passed as a comment to
+AUCTeX (\"figure\", \"table\" or \"verbatim\"), update
+`LaTeX-figure-label' and `LaTeX-table-label'.  If RefTeX is
+loaded, add the new floating environment via
+`reftex-add-label-environments'.  For \"verbatim\" environments,
+update `LaTeX-indent-environment-list' to suppress indentation.
+If `caption.el' is loaded, add the new floating environment to
+`LaTeX-caption-supported-float-types'.  Also define the macros
+\"listofENVs\" and \"listofENVes\"."
+  (dolist (flt-type (LaTeX-newfloat-DeclareFloatingEnvironment-list))
+    (let ((flt  (car  flt-type))
+         (type (cadr flt-type)))
+      (cond ((string-equal type "figure")
+            (LaTeX-add-environments `(,flt LaTeX-env-figure))
+            (add-to-list 'LaTeX-label-alist `(,flt . LaTeX-figure-label) t)
+            (when (fboundp 'reftex-add-label-environments)
+              (reftex-add-label-environments
+               `((,flt ?f ,LaTeX-figure-label "~\\ref{%s}" caption nil nil)))))
+           ((string-equal type "table")
+            (LaTeX-add-environments `(,flt LaTeX-env-figure))
+            (add-to-list 'LaTeX-label-alist `(,flt . LaTeX-table-label) t)
+            (when (fboundp 'reftex-add-label-environments)
+              (reftex-add-label-environments
+               `((,flt ?t ,LaTeX-table-label "~\\ref{%s}" caption nil nil)))))
+           ((string-equal type "verbatim")
+            (LaTeX-add-environments flt)
+            (add-to-list (make-local-variable 'LaTeX-indent-environment-list)
+                         `(,flt current-indentation) t)
+            (when (fboundp 'reftex-add-label-environments)
+              (reftex-add-label-environments
+               `((,flt ?l "lst:" "~\\ref{%s}" caption nil nil)))))
+           (t
+            (LaTeX-add-environments flt)))
+      (when (boundp 'LaTeX-caption-supported-float-types)
+       (add-to-list (make-local-variable 'LaTeX-caption-supported-float-types)
+                    flt))
+      (if (string-equal "e" (substring flt -1))
+         (TeX-add-symbols (concat "listof" flt "s"))
+       (TeX-add-symbols
+        (concat "listof" flt "s")
+        (concat "listof" flt "es"))))))
+
+(add-hook 'TeX-auto-prepare-hook #'LaTeX-newfloat-auto-prepare t)
+(add-hook 'TeX-auto-prepare-hook #'LaTeX-newfloat-auto-cleanup t)
+(add-hook 'TeX-update-style-hook #'TeX-auto-parse t)
+
+(TeX-add-style-hook
+ "newfloat"
+ (lambda ()
+
+   ;; Add newfloat to the parser.
+   (TeX-auto-add-regexp LaTeX-newfloat-DeclareFloatingEnvironment-regex)
+
+   ;; Depending on class, add "within" key to the local options list
+   ;; and use it.
+   (setq LaTeX-newfloat-key-val-options-local
+        (copy-alist LaTeX-newfloat-key-val-options))
+
+   (if (< (LaTeX-largest-level) 2)
+       (add-to-list 'LaTeX-newfloat-key-val-options-local
+                   '("within" ("chapter" "section" "none")))
+     (add-to-list 'LaTeX-newfloat-key-val-options-local
+                 '("within" ("section" "none"))))
+
+   ;; Commands:
+   (TeX-add-symbols
+    '("DeclareFloatingEnvironment"
+      [TeX-arg-key-val LaTeX-newfloat-key-val-options-local]
+      (TeX-arg-eval
+       (lambda ()
+        (let ((newfloat (TeX-read-string
+                        (TeX-argument-prompt nil nil "Floating environment"))))
+          (LaTeX-add-newfloat-DeclareFloatingEnvironments newfloat)
+          (format "%s" newfloat)))))
+
+    '("SetupFloatingEnvironment"
+      (TeX-arg-eval completing-read
+                   (TeX-argument-prompt nil nil "Floating environment")
+                   (mapcar 'car 
(LaTeX-newfloat-DeclareFloatingEnvironment-list)))
+      (TeX-arg-key-val LaTeX-newfloat-key-val-options-local))
+
+    '("ForEachFloatingEnvironment" t)
+    '("ForEachFloatingEnvironment*" t)
+
+    '("PrepareListOf"
+      (TeX-arg-eval completing-read
+                   (TeX-argument-prompt nil nil "Floating environment")
+                   (mapcar 'car 
(LaTeX-newfloat-DeclareFloatingEnvironment-list)))
+      t)
+
+    '("newfloatsetup"
+      (TeX-arg-eval
+       (lambda ()
+        (let ((keyvals (TeX-read-key-val
+                        nil
+                        (append '(("chapterlistsgap"))
+                                (if (< (LaTeX-largest-level) 2)
+                                    '(("within" ("chapter" "section" "none")))
+                                  '(("within" ("section" "none"))))))))
+          (format "%s" keyvals))))))
+
+   ;; Fontification
+   (when (and (featurep 'font-latex)
+             (eq TeX-install-font-lock 'font-latex-setup))
+     (font-latex-add-keywords '(("DeclareFloatingEnvironment"  "[{")
+                               ("SetupFloatingEnvironment"    "{{")
+                               ("ForEachFloatingEnvironment"  "*{")
+                               ("PrepareListOf"               "{{")
+                               ("newfloatsetup"               "{"))
+                             'function)))
+ LaTeX-dialect)
+
+(defun LaTeX-newfloat-package-options ()
+  "Prompt for package options for the newfloat package."
+  (TeX-read-key-val
+   t
+   (append
+    '(("chapterlistsgap"))
+    (if (< (LaTeX-largest-level) 2)
+       '(("within" ("chapter" "section" "none")))
+      '(("within" ("section" "none")))))))
+
+;;; newfloat.el ends here
diff --git a/style/polyglossia.el b/style/polyglossia.el
new file mode 100644
index 0000000..6e902a4
--- /dev/null
+++ b/style/polyglossia.el
@@ -0,0 +1,355 @@
+;;; polyglossia.el --- AUCTeX style for `polyglossia.sty' version 1.42.0.
+
+;; Copyright (C) 2015 Free Software Foundation, Inc.
+
+;; Maintainer: address@hidden
+;; Author: Mosè Giordano <address@hidden>
+;; Keywords: tex
+
+;; This file is part of AUCTeX.
+
+;; AUCTeX is free software; you can redistribute it and/or modify it
+;; under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 3, or (at your option)
+;; any later version.
+
+;; AUCTeX is distributed in the hope that it will be useful, but
+;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+;; General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with AUCTeX; see the file COPYING.  If not, write to the Free
+;; Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+;; 02110-1301, USA.
+
+;;; Commentary:
+
+;; This file adds support for `polyglossia.sty' version 1.42.0.
+
+;;; TODO:
+
+;;  -- Create language specific styles with names `gloss-<lang>.el'.  They
+;;     should add `text<lang>' macros, `<lang>' environments (`Arabic' for
+;;     `arabic' language), and the others language-specific commands.
+
+;;; Code:
+
+(require 'tex) ;Indispensable when compiling the call to `TeX-auto-add-type'.
+
+(TeX-auto-add-type "polyglossia-lang" "LaTeX")
+
+;; Self Parsing -- see (info "(auctex)Hacking the Parser").
+(defvar LaTeX-polyglossia-lang-regexp
+  (concat "\\\\set\\(defaultlanguage\\|mainlanguage\\|otherlanguages?\\)"
+         "[ \t\n\r]*\\(?:\\[\\(.*\\)\\]\\)?[ \t\n\r]*{\\([A-Za-z, ]+\\)}")
+  "Matches languages set with polyglossia macros.")
+
+(defvar LaTeX-polyglossia-setkeys-regexp
+  (concat "\\\\setkeys"
+         "[ \t\n\r]*{\\([A-Za-z]+\\)}[ \t\n\r]*{\\([^}]*\\)}")
+  "Matches polyglossia languages options set using \"\setkeys\".")
+
+(defvar LaTeX-auto-polyglossia-lang nil
+  "Temporary for parsing polyglossia languages.")
+
+(defvar LaTeX-auto-polyglossia-setkeys nil
+  "Temporary for parsing polyglossia language options.")
+
+(defun LaTeX-polyglossia-prepare ()
+  "Clear some polyglossia variables before use."
+  (setq LaTeX-auto-polyglossia-lang nil
+       LaTeX-auto-polyglossia-setkeys nil
+       LaTeX-polyglossia-lang-list nil))
+
+(defun LaTeX-polyglossia-cleanup ()
+  "Move languages and their options from
+`LaTeX-auto-polyglossia-lang' to `LaTeX-polyglossia-lang-list'."
+  ;; Example: now the value of `LaTeX-auto-polyglossia-lang' is something like
+  ;;   '(("danish" "defaultlanguage" "")
+  ;;     ("arabic" "otherlanguage" "locale=tunisia,numerals=maghrib")
+  ;;     ("german" "otherlanguage" "spelling=new,script=latin")
+  ;;     ("icelandic,brazil,sanskrit" "otherlanguages" ""))
+  ;; We want to end up with a list like
+  ;;   '(("danish" "defaultlanguage")
+  ;;     ("arabic" "otherlanguage" "locale=tunisia" "numerals=maghrib")
+  ;;     ("german" "otherlanguage" "spelling=new" "script=latin")
+  ;;     ("icelandic" "otherlanguages")
+  ;;     ("brazil" "otherlanguages")
+  ;;     ("sanskrit" "otherlanguages" "script=Devanagari"))
+  ;; with "script=Devanagari" option to "sanskrit" language set using
+  ;; "\setkeys".
+  ;; In each element of the alist, the key is the language, the second value is
+  ;; the polyglossia command which set the language, the rest of values is the
+  ;; list of options given to the language.
+  (let (opts otheropts)
+    (mapc
+     (lambda (elt)
+       (mapc
+       (lambda (language)
+         ;; `opts' is the string of options for `language', set using
+         ;; "\setdefaultlanguage" or "\setotherlanguage".
+         (setq opts (cdr (cdr elt)))
+         ;; `otheropts' is the string of options for `language' set using
+         ;; "\setkeys".
+         (setq otheropts
+               (car (cdr (assoc language LaTeX-auto-polyglossia-setkeys))))
+         (add-to-list
+          'LaTeX-polyglossia-lang-list
+          (append
+           (list language) (list (nth 1 elt))
+           (unless (equal opts '(""))
+             (LaTeX-listify-package-options (car opts)))
+           (if otheropts (LaTeX-listify-package-options otheropts))) t))
+       (LaTeX-listify-package-options (car elt))))
+     LaTeX-auto-polyglossia-lang)))
+
+(add-hook 'TeX-auto-prepare-hook #'LaTeX-polyglossia-prepare)
+(add-hook 'TeX-auto-cleanup-hook #'LaTeX-polyglossia-cleanup)
+(add-hook 'TeX-update-style-hook #'TeX-auto-parse t)
+;; Run style hooks for every active language.  This *has* to be done after
+;; `TeX-auto-parse'.
+(add-hook 'TeX-update-style-hook #'LaTeX-polyglossia-load-languages t)
+
+(defvar LaTeX-polyglossia-language-list
+  '("albanian" "amharic" "arabic" "armenian" "asturian" "bahasai" "bahasam"
+    "basque" "bengali" "brazil" "breton" "bulgarian" "catalan" "coptic"
+    "croatian" "czech" "danish" "divehi" "dutch" "english" "esperanto"
+    "estonian" "farsi" "finnish" "french" "friulan" "galician" "german" "greek"
+    "hebrew" "hindi" "icelandic" "interlingua" "irish" "italian" "kannada"
+    "khmer" "korean" "lao" "latin" "latvian" "lithuanian" "lsorbian" "magyar"
+    "malayalam" "marathi" "nko" "norsk" "nynorsk" "occitan" "piedmontese"
+    "polish" "portuges" "romanian" "romansh" "russian" "samin" "sanskrit"
+    "scottish" "serbian" "slovak" "slovenian" "spanish" "swedish" "syriac"
+    "tamil" "telugu" "thai" "tibetan" "turkish" "turkmen" "ukrainian" "urdu"
+    "usorbian" "vietnamese" "welsh")
+  "List of languages supported by the polyglossia LaTeX package.")
+
+(defun LaTeX-polyglossia-active-languages ()
+  "Return a list of polyglossia languages used in the document.
+The last language is the default one."
+  (let (active-languages default)
+    (mapc
+     (lambda (elt)
+       (setq default (or (string-equal "defaultlanguage" (nth 1 elt))
+                        (string-equal "mainlanguage" (nth 1 elt))))
+       ;; Append the language to the list if it's the default one.
+       (add-to-list 'active-languages (car elt) default))
+     LaTeX-polyglossia-lang-list)
+    active-languages))
+
+(defun LaTeX-polyglossia-lang-option-member (language option)
+  "Return non-nil if OPTION has been given to polyglossia LANGUAGE.
+The value is actually the tail of the list of options given to LANGUAGE."
+  (member option (cdr (cdr (assoc language LaTeX-polyglossia-lang-list)))))
+
+(defun LaTeX-arg-polyglossia-lang (_optional default multiple setkeys)
+  "Prompt for language and its options with completion and insert them
+as arguments.
+
+This function is triggered by \"\setdefaultlanguage\",
+\"\setotherlanguage\", \"\setotherlanguages\", and \"\setkeys\"
+macros by polyglossia package.
+
+OPTIONAL is ignored, if DEFAULT is non-nil treat inserted
+language as default, if MULTIPLE is non-nil prompt for multiple
+languages, if SETKEYS is non-nil insert options as second
+mandatory argument."
+  ;; DEFAULT =  t , MULTIPLE = nil, SETKEYS = nil: "\setdefaultlanguage".
+  ;; DEFAULT = nil, MULTIPLE = nil, SETKEYS = nil: "\setotherlanguage".
+  ;; DEFAULT = nil, MULTIPLE =  t , SETKEYS = nil: "\setotherlanguages".
+  ;; DEFAULT = nil, MULTIPLE = nil, SETKEYS =  t : "\setkeys".
+  (let ((language (funcall
+                  (if multiple
+                      'TeX-completing-read-multiple
+                    'completing-read)
+                  (if multiple "Languages: " "Language: ")
+                  (if setkeys
+                      (LaTeX-polyglossia-active-languages)
+                    LaTeX-polyglossia-language-list)))
+       var  options)
+    (if multiple
+       (mapc (lambda (elt) (TeX-run-style-hooks (concat "gloss-" elt)))
+             language)
+      (TeX-run-style-hooks (concat "gloss-" language)))
+    ;; "\setotherlanguages" doesn't take options, don't prompt for them.
+    (setq options
+         (if multiple ""
+           (setq var (intern (format "LaTeX-polyglossia-%s-options-list" 
language)))
+           (if (and (boundp var) (symbol-value var))
+               ;; "\setdefaultlanguage" and "\setotherlanguage" use `options'
+               ;; as first optional argument; "\setkeys" uses `options' as
+               ;; second mandatory argument.
+               (TeX-read-key-val (not setkeys) (symbol-value var))
+             ;; When `LaTeX-polyglossia-<lang>-options-list' is nil or not
+             ;; defined, don't prompt for options.
+             "")))
+    (unless setkeys
+      (let ((TeX-arg-opening-brace LaTeX-optop)
+           (TeX-arg-closing-brace LaTeX-optcl))
+       (TeX-argument-insert options t)))
+    (if multiple
+       (setq language (mapconcat 'identity language ",")))
+    (TeX-argument-insert language nil)
+    (if setkeys
+       (TeX-argument-insert options nil))))
+
+(defun LaTeX-arg-polyglossiasetup-options (optional)
+  "Prompt for setup options of polyglossia package.
+If OPTIONAL is non-nil, insert the resulting value as an optional
+argument, otherwise as a mandatory one."
+  (TeX-arg-key-val optional
+                  '(("language") ;; TODO: add completion in `fontspec.el', see
+                                 ;; "\newfontlanguage"s in 
`fontspec-xetex.sty'.
+                    ("hyphennames")
+                    ("script") ;; TODO: add completion in `fontspec.el', see
+                               ;; "\newfontscript"s in `fontspec-xetex.sty'.
+                    ("direction" ("RL" "LR"))
+                    ("scripttag")
+                    ("langtag")
+                    ("hyphenmins")
+                    ("frenchspacing" ("true" "false"))
+                    ("indentfirst" ("true" "false"))
+                    ("fontsetup" ("true" "false"))
+                    ;; The following options aren't already implemented but are
+                    ;; present in `polyglossia.sty' comments.
+                    ;; ("nouppercase" ("true" "false"))
+                    ;; ("localalph")
+                    ;; ("localnumber")
+                    )))
+
+(defun LaTeX-polyglossia-load-languages ()
+  "Load style files of babel active languages."
+  (mapc (lambda (elt) (TeX-run-style-hooks (concat "gloss-" elt)))
+       (LaTeX-polyglossia-active-languages)))
+
+(TeX-add-style-hook
+ "polyglossia"
+ (lambda ()
+   (TeX-check-engine-add-engines 'luatex 'xetex)
+   (TeX-auto-add-regexp
+    `(,LaTeX-polyglossia-lang-regexp (3 1 2) LaTeX-auto-polyglossia-lang))
+   (TeX-auto-add-regexp
+    `(,LaTeX-polyglossia-setkeys-regexp (1 2) LaTeX-auto-polyglossia-setkeys))
+   (TeX-run-style-hooks "etoolbox" "makecmds" "xkeyval" "fontspec")
+   (TeX-add-symbols
+    '("setdefaultlanguage" (LaTeX-arg-polyglossia-lang  t  nil nil))
+    '("setmainlanguage"    (LaTeX-arg-polyglossia-lang  t  nil nil))
+    '("setotherlanguage"   (LaTeX-arg-polyglossia-lang nil nil nil))
+    '("setotherlanguages"  (LaTeX-arg-polyglossia-lang nil  t  nil))
+    '("setkeys"            (LaTeX-arg-polyglossia-lang nil nil  t ))
+    '("PolyglossiaSetup"   (TeX-arg-eval completing-read "Language: "
+                                        (LaTeX-polyglossia-active-languages))
+      LaTeX-arg-polyglossiasetup-options)
+    "selectbackgroundlanguage"
+    '("resetdefaultlanguage" ["argument"] 1)
+    "normalfontlatin"
+    "rmfamilylatin"
+    "sffamilylatin"
+    "ttfamilylatin"
+    "selectlanguage"
+    "foreignlanguage")
+
+   (TeX-declare-expert-macros
+    "polyglossia"
+    "PolyglossiaSetup" "selectbackgroundlanguage" "resetdefaultlanguage"
+    "normalfontlatin" "rmfamilylatin" "sffamilylatin" "ttfamilylatin"
+    "selectlanguage" "foreignlanguage")
+
+   ;; Fontification
+   (when (and (featurep 'font-latex)
+             (eq TeX-install-font-lock 'font-latex-setup))
+     (font-latex-add-keywords '(("setdefaultlanguage" "[{")
+                               ("setmainlanguage" "[{")
+                               ("setotherlanguage" "[{")
+                               ("setotherlanguages" "{")
+                               ("setkeys" "{{"))
+                             'function)))
+ LaTeX-dialect)
+
+;; TODO: move each option variable in its specific `gloss-<lang>.el' file.
+(defvar LaTeX-polyglossia-arabic-options-list
+  '(("calendar" ("gregorian" "islamic"))
+    ("locale" ("default" "mashriq" "libya" "algeria" "tunisia" "morocco" 
"mauritania"))
+    ("numerals" ("mashriq" "maghrib"))
+    ("abjadjimnotail" ("false" "true")))
+  "Arabic language options for the polyglossia package.")
+
+(defvar LaTeX-polyglossia-bengali-options-list
+  '(("numerals" ("Western" "Devanagari"))
+    ("changecounternumbering" ("true" "false")))
+  "Bengali language options for the polyglossia package.")
+
+(defvar LaTeX-polyglossia-catalan-options-list
+  '(("babelshorthands" ("true" "false")))
+  "Catalan language options for the polyglossia package.")
+
+(defvar LaTeX-polyglossia-dutch-options-list
+  '(("babelshorthands" ("true" "false")))
+  "Dutch language options for the polyglossia package.")
+
+(defvar LaTeX-polyglossia-english-options-list
+  '(("variant" ("american" "usmax" "british" "australian" "newzealand"))
+    ("ordinalmonthday" ("true" "false")))
+  "English language options for the polyglossia package.")
+
+(defvar LaTeX-polyglossia-farsi-options-list
+  '(("numerals" ("western" "eastern"))
+    ;; ("locale") ;; not yet implemented
+    ;; ("calendar") ;; not yet implemented
+    )
+  "Farsi language options for the polyglossia package.")
+
+(defvar LaTeX-polyglossia-german-options-list
+  '(("variant" ("german" "austrian" "swiss"))
+    ("spelling" ("new" "old"))
+    ("latesthyphen" ("true" "false"))
+    ("babelshorthands" ("true" "false"))
+    ("script" ("latin" "fraktur")))
+  "German language options for the polyglossia package.")
+
+(defvar LaTeX-polyglossia-greek-options-list
+  '(("variant" ("monotonic" "polytonic" "ancient"))
+    ("numerals" ("greek" "arabic"))
+    ("attic" ("true" "false")))
+  "Greek language options for the polyglossia package.")
+
+(defvar LaTeX-polyglossia-hebrew-options-list
+  '(("numerals" ("hebrew" "arabic"))
+    ("calendar" ("hebrew" "gregorian")))
+  "Hebrew language options for the polyglossia package.")
+
+(defvar LaTeX-polyglossia-hindi-options-list
+  '(("numerals" ("Western" "Devanagari")))
+  "Hindi language options for the polyglossia package.")
+
+(defvar LaTeX-polyglossia-lao-options-list
+  '(("numerals" ("lao" "arabic")))
+  "Lao language options for the polyglossia package.")
+
+(defvar LaTeX-polyglossia-russian-options-list
+  '(("spelling" ("modern" "old"))
+    ("babelshorthands" ("true" "false")))
+  "Russian language options for the polyglossia package.")
+
+(defvar LaTeX-polyglossia-sanskrit-options-list
+  '(("Script" ("Devanagari")))
+  "Sanskrit language options for the polyglossia package.")
+
+(defvar LaTeX-polyglossia-serbian-options-list
+  '(("script" ("cyrillic" "latin")))
+  "Serbian language options for the polyglossia package.")
+
+(defvar LaTeX-polyglossia-syriac-options-list
+  '(("numerals" ("western" "eastern" "abjad")))
+  "Syriac language options for the polyglossia package.")
+
+(defvar LaTeX-polyglossia-thai-options-list
+  '(("numerals" ("thai" "arabic")))
+  "Thai language options for the polyglossia package.")
+
+(defvar LaTeX-polyglossia-package-options
+  '("babelshorthands" "localmarks" "nolocalmarks" "quiet")
+  "Package options for the polyglossia package.")
+
+;;; polyglossia.el ends here
diff --git a/style/pstricks.el b/style/pstricks.el
index 02b2c30..5b6e828 100644
--- a/style/pstricks.el
+++ b/style/pstricks.el
@@ -776,7 +776,8 @@ comma separated list. Point has to be within the sexp to 
modify."
 (TeX-add-style-hook
  "pstricks"
  (lambda ()
-   (unless (member "pst-pdf" TeX-active-styles)
+   (unless (or (member "pst-pdf" TeX-active-styles)
+              (eq TeX-engine 'xetex))
      (TeX-PDF-mode-off))
    (mapc 'TeX-auto-add-regexp LaTeX-auto-pstricks-regexp-list)
    (LaTeX-add-environments
diff --git a/style/report.el b/style/report.el
index 6a4e638..7fa96b2 100644
--- a/style/report.el
+++ b/style/report.el
@@ -11,11 +11,12 @@
 
 (TeX-add-style-hook
  "report"
- (lambda () 
+ (lambda ()
    (LaTeX-largest-level-set "chapter")
    (LaTeX-add-counters "part" "chapter" "section" "subsection" "subsubsection"
                       "paragraph" "subparagraph" "figure" "table")
-   (LaTeX-add-pagestyles "headings" "myheadings"))
+   (LaTeX-add-pagestyles "headings" "myheadings")
+   (LaTeX-add-environments "abstract"))
  LaTeX-dialect)
 
 ;;; report.el ends here
diff --git a/style/scrartcl.el b/style/scrartcl.el
index 74b83d5..101ce1c 100644
--- a/style/scrartcl.el
+++ b/style/scrartcl.el
@@ -20,7 +20,8 @@
    (lambda ()
      (LaTeX-largest-level-set "section")
      ;; load basic definitons
-     (TeX-run-style-hooks "scrbase"))
+     (TeX-run-style-hooks "scrbase")
+     (LaTeX-add-environments "abstract"))
    LaTeX-dialect)
 
 ;;; scrartcl.el ends here
diff --git a/style/scrreprt.el b/style/scrreprt.el
index 57ec0af..636b14e 100644
--- a/style/scrreprt.el
+++ b/style/scrreprt.el
@@ -43,6 +43,7 @@
     '("setpartpreamble" [ TeX-arg-KOMA-setpreamble ] [ "Width" ] t)
     '("setchapterpreamble" [ TeX-arg-KOMA-setpreamble ] [ "Width" ] t)
     '("dictum" [ "Author" ] t))
+   (LaTeX-add-environments "abstract")
    (LaTeX-section-list-add-locally '("addchap" 1))
    (make-local-variable 'LaTeX-section-label)
    (setq LaTeX-section-label (append
diff --git a/style/subcaption.el b/style/subcaption.el
new file mode 100644
index 0000000..83b20a0
--- /dev/null
+++ b/style/subcaption.el
@@ -0,0 +1,158 @@
+;;; subcaption.el --- AUCTeX style for `subcaption.sty' (v1.1-100)
+
+;; Copyright (C) 2015 Free Software Foundation, Inc.
+
+;; Author: Arash Esbati <esbati'at'gmx.de>
+;; Maintainer: address@hidden
+;; Created: 2015-09-19
+;; Keywords: tex
+
+;; This file is part of AUCTeX.
+
+;; AUCTeX is free software; you can redistribute it and/or modify it
+;; under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 3, or (at your option)
+;; any later version.
+
+;; AUCTeX is distributed in the hope that it will be useful, but
+;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+;; General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with AUCTeX; see the file COPYING.  If not, write to the Free
+;; Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+;; 02110-1301, USA.
+
+;;; Commentary:
+
+;; This file adds support for `subcaption.sty' (v1.1-100) from
+;; 2015-09-15.  `subcaption.sty' is part of TeXLive.
+
+;;; Code:
+
+(defvar LaTeX-subcaption-key-val-options
+  '(("subrefformat" ("default" "empty" "simple" "brace" "parens")))
+  "Key=value options for subcaption package.  This key takes the
+same values as \"labelformat\" from caption package.")
+
+(defun LaTeX-arg-subcaption-subcaption (optional &optional star prompt)
+  "Query for the arguments of \\subcaption incl. a label and
+insert them.  If STAR is t, then do not query for the lof entry
+and \\label and insert only a caption."
+  (let ((lof (unless star
+              (TeX-read-string
+               (TeX-argument-prompt t prompt "List entry"))))
+       (caption (TeX-read-string
+                 (TeX-argument-prompt optional prompt "Sub-caption"))))
+    (LaTeX-indent-line)
+    (when (and lof (not (string-equal lof "")))
+      (insert LaTeX-optop lof LaTeX-optcl))
+    (insert TeX-grop caption TeX-grcl)
+    (unless star
+      (LaTeX-newline)
+      (LaTeX-indent-line)
+      (TeX-insert-macro "label"))))
+
+(defun LaTeX-arg-subcaption-subcaptionbox (optional &optional star prompt)
+  "Query for the arguments of \\subcaptionbox incl. a label and
+insert them.  If STAR is t, then do not query for a \\label and
+insert only a caption."
+  (let ((caption (TeX-read-string
+                 (TeX-argument-prompt optional prompt "Sub-caption"))))
+    (LaTeX-indent-line)
+    (insert TeX-grop caption)
+    (unless star (TeX-insert-macro "label"))
+    (insert TeX-grcl))
+  (let* ((width (completing-read (TeX-argument-prompt t prompt "Width")
+                                (mapcar (lambda (elt) (concat TeX-esc (car 
elt)))
+                                        (LaTeX-length-list))))
+        (inpos (when (and width (not (string-equal width "")))
+                 (completing-read (TeX-argument-prompt t prompt "Inner 
position")
+                                  '("c" "l" "r" "s")))))
+    (cond (;; 2 optional args
+          (and width (not (string-equal width ""))
+               inpos (not (string-equal inpos "")))
+          (insert (format "[%s][%s]" width inpos)))
+         (;; 1st opt. arg, 2nd empty opt. arg
+          (and width (not (string-equal width ""))
+               (string-equal inpos ""))
+          (insert (format "[%s]" width)))
+         (t ; Do nothing if both empty
+          (ignore)))))
+
+(TeX-add-style-hook
+ "subcaption"
+ (lambda ()
+   ;; Run style hook for caption.el
+   (TeX-run-style-hooks "caption")
+
+   ;; Make "subrefformat" available in key-vals of caption.el:
+   (setq LaTeX-caption-key-val-options-local
+        (append LaTeX-subcaption-key-val-options
+                LaTeX-caption-key-val-options-local))
+
+   (TeX-add-symbols
+    ;; Basic commands
+    '("subcaption"     (LaTeX-arg-subcaption-subcaption))
+    '("subcaption*"    (LaTeX-arg-subcaption-subcaption t))
+    '("subcaptionbox"  ["List entry"] (LaTeX-arg-subcaption-subcaptionbox) t)
+    '("subcaptionbox*" (LaTeX-arg-subcaption-subcaptionbox t) t)
+    '("subref"         TeX-arg-ref)
+    ;; \subref* is only available with hyperref.sty loaded, we don't
+    ;; check if hyperref.el is loaded and make it available directly.
+    '("subref*"        TeX-arg-ref)
+    '("phantomcaption"    0)
+    '("phantomsubcaption" 0))
+
+   ;; The next 2 macros are part of the kernel of caption.sty, but we
+   ;; load them within subcaption.el.
+   (TeX-add-symbols
+    '("DeclareCaptionSubType"
+      [TeX-arg-eval
+       completing-read (TeX-argument-prompt t nil "Numbering scheme")
+       '("arabic" "roman" "Roman" "alph" "Alph" "fnsymbol")]
+      (TeX-arg-eval
+       completing-read (TeX-argument-prompt nil nil "Type")
+       '("figure" "table")))
+
+    '("DeclareCaptionSubType*"
+      [TeX-arg-eval completing-read
+                   (TeX-argument-prompt t nil "Numbering scheme")
+                   '("arabic" "roman" "Roman" "alph" "Alph" "fnsymbol")]
+      (TeX-arg-eval completing-read
+                   (TeX-argument-prompt nil nil "Type")
+                   '("figure" "table"))))
+
+   ;; The subfigure & subtable environments
+   (LaTeX-add-environments
+    '("subfigure" LaTeX-env-minipage)
+    '("subtable"  LaTeX-env-minipage))
+
+   ;; Introduce env's to RefTeX if loaded
+   (when (fboundp 'reftex-add-label-environments)
+     (reftex-add-label-environments
+      `(("subfigure" ?f ,LaTeX-figure-label "~\\ref{%s}" caption)
+       ("subtable"  ?t ,LaTeX-table-label  "~\\ref{%s}" caption))))
+
+   ;; Fontification
+   (when (and (featurep 'font-latex)
+             (eq TeX-install-font-lock 'font-latex-setup))
+     (font-latex-add-keywords '(("subcaption"            "*[{")
+                               ("subcaptionbox"         "*[{[[{")
+                               ("phantomcaption"        "")
+                               ("phantomsubcaption"     ""))
+                             'textual)
+     (font-latex-add-keywords '(("subref"                "*{"))
+                             'reference)
+     (font-latex-add-keywords '(("DeclareCaptionSubType" "*[{"))
+                             'function)) )
+ LaTeX-dialect)
+
+(defun LaTeX-subcaption-package-options ()
+  "Prompt for package options for the subcaption package."
+  (TeX-read-key-val t
+   (append LaTeX-subcaption-key-val-options
+          LaTeX-caption-key-val-options)))
+
+;;; subcaption.el ends here
diff --git a/style/transparent.el b/style/transparent.el
new file mode 100644
index 0000000..3a7fad5
--- /dev/null
+++ b/style/transparent.el
@@ -0,0 +1,53 @@
+;;; transparent.el --- AUCTeX style for `transparent.sty' (v1.0)
+
+;; Copyright (C) 2015 Free Software Foundation, Inc.
+
+;; Author: Arash Esbati <esbati'at'gmx.de>
+;; Maintainer: address@hidden
+;; Created: 2015-08-15
+;; Keywords: tex
+
+;; This file is part of AUCTeX.
+
+;; AUCTeX is free software; you can redistribute it and/or modify it
+;; under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 3, or (at your option)
+;; any later version.
+
+;; AUCTeX is distributed in the hope that it will be useful, but
+;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+;; General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with AUCTeX; see the file COPYING.  If not, write to the Free
+;; Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+;; 02110-1301, USA.
+
+;;; Commentary:
+
+;; This file adds support for `transparent.sty' (v1.0) from 2007/01/08.
+;; `transparent.sty' is part of TeXLive.
+
+;;; Code:
+
+(TeX-add-style-hook
+ "transparent"
+ (lambda ()
+   (TeX-add-symbols
+    '("transparent"     "Transparency value (between 0,1)")
+    '("texttransparent" "Transparency value (between 0,1)" t))
+
+   ;; Fontification
+   (when (and (featurep 'font-latex)
+             (eq TeX-install-font-lock 'font-latex-setup))
+     (font-latex-add-keywords '(("transparent"     "{"))
+                             'type-declaration)
+     (font-latex-add-keywords '(("texttransparent" "{{"))
+                             'type-command)))
+ LaTeX-dialect)
+
+(defvar LaTeX-transparent-package-options nil
+  "Package options for the transparent package.")
+
+;;; transparent.el ends here
diff --git a/style/wrapfig.el b/style/wrapfig.el
index 097e5ad..64bb265 100644
--- a/style/wrapfig.el
+++ b/style/wrapfig.el
@@ -1,6 +1,6 @@
 ;;; wrapfig.el --- AUCTeX style for `wrapfig.sty' version v3.6
 
-;; Copyright (C) 2014 Free Software Foundation, Inc.
+;; Copyright (C) 2014, 2015 Free Software Foundation, Inc.
 
 ;; Author: Arash Esbati <esbati'at'gmx.de>
 ;; Maintainer: address@hidden
@@ -78,11 +78,22 @@
            (format "{%s}" width))))))
     ;;
     ;; \begin{wrapfloat}{<Type>}[No.lines]{Placement}[Overhang]{Width} ... 
\end{wrapfloat}
+    ;;
+    ;; <Type> can be a new floating environment defined with
+    ;; "\DeclareFloatingEnvironment" from newfloat.el.  We check if
+    ;; the function `LaTeX-newfloat-DeclareFloatingEnvironment-list'
+    ;; is bound and returns non-nil before offering environment for
+    ;; completion.  Otherwise, just ask user without completion.
     '("wrapfloat"
       (lambda (env &rest ignore)
        (LaTeX-insert-environment
         env
-        (let ((floattype (TeX-read-string "Float type: "))
+        (let ((floattype (if (and (fboundp 
'LaTeX-newfloat-DeclareFloatingEnvironment-list)
+                                  
(LaTeX-newfloat-DeclareFloatingEnvironment-list))
+                             (completing-read
+                              "Float type: "
+                              (mapcar 'car 
(LaTeX-newfloat-DeclareFloatingEnvironment-list)))
+                           (TeX-read-string "Float type: ")))
               (narrow    (TeX-read-string "(Optional) Number of narrow lines: 
"))
               (placement (completing-read
                           "Placement: " '(("r") ("R")
diff --git a/tex-buf.el b/tex-buf.el
index 3be47d7..ec3653c 100644
--- a/tex-buf.el
+++ b/tex-buf.el
@@ -1,6 +1,6 @@
 ;;; tex-buf.el --- External commands for AUCTeX.
 
-;; Copyright (C) 1991-1999, 2001-2014 Free Software Foundation, Inc.
+;; Copyright (C) 1991-1999, 2001-2015 Free Software Foundation, Inc.
 
 ;; Maintainer: address@hidden
 ;; Keywords: tex, wp
@@ -142,6 +142,21 @@ pinned region will get unpinned and vice versa."
     (setq TeX-command-region-end nil)
     (message "TeX region unpinned.")))
 
+(defun TeX-region-update ()
+  "Update the TeX-region file."
+  ;; Note that TeX-command-region-begin is not a marker when called
+  ;; from TeX-command-buffer.
+  (and (or (null TeX-command-region-begin)
+          (markerp TeX-command-region-begin))
+       (TeX-active-mark)
+       (TeX-pin-region (region-beginning) (region-end)))
+  (let ((begin (or TeX-command-region-begin (region-beginning)))
+       (end (or TeX-command-region-end (region-end))))
+    (TeX-region-create (TeX-region-file TeX-default-extension)
+                      (buffer-substring begin end)
+                      (file-name-nondirectory (buffer-file-name))
+                      (TeX-current-offset begin))))
+
 (defun TeX-command-region (&optional override-confirm)
   "Run TeX on the current region.
 
@@ -163,18 +178,7 @@ If the master file for the document has a trailer, it is 
written to
 the temporary file before the region itself.  The document's trailer is
 all text after `TeX-trailer-start'."
   (interactive "P")
-  ;; Note that TeX-command-region-begin is not a marker when called
-  ;; from TeX-command-buffer.
-  (and (or (null TeX-command-region-begin)
-          (markerp TeX-command-region-begin))
-       (TeX-active-mark)
-       (TeX-pin-region (region-beginning) (region-end)))
-  (let ((begin (or TeX-command-region-begin (region-beginning)))
-       (end (or TeX-command-region-end (region-end))))
-    (TeX-region-create (TeX-region-file TeX-default-extension)
-                      (buffer-substring begin end)
-                      (file-name-nondirectory (buffer-file-name))
-                      (TeX-current-offset begin)))
+  (TeX-region-update)
   (TeX-command (TeX-command-query (TeX-region-file nil t)) 'TeX-region-file
               override-confirm))
 
@@ -322,7 +326,7 @@ This works only with TeX commands and if the
          (TeX-parse-TeX (- arg) nil)
        ;; XXX: moving backward in the errors hasn't yet been implemented for
        ;; other parsing functions.
-       (error "Jumping to previous error not supported.")))))
+       (error "Jumping to previous error not supported")))))
 
 ;;; Command Query
 
@@ -332,6 +336,17 @@ This works only with TeX commands and if the
 (defconst TeX-error-overview-buffer-name "*TeX errors*"
   "Name of the buffer in which to show error list.")
 
+(defvar LaTeX-idx-md5-alist nil
+  "Alist of MD5 hashes of idx file.
+
+Car is the idx file, cdr is its md5 hash.")
+
+(defvar LaTeX-idx-changed-alist nil
+  "Whether the idx files changed.
+
+Car is the idx file, cdr is whether idx changed after LaTeX
+run.")
+
 (defcustom TeX-check-engine t
   "Whether AUCTeX should check the correct engine has been set before running 
LaTeX commands."
   :group 'TeX-command
@@ -464,6 +479,18 @@ been set."
       (if (get-buffer TeX-error-overview-buffer-name)
          (kill-buffer TeX-error-overview-buffer-name)))
 
+    ;; Before running some commands, check that AUCTeX is able to find "tex"
+    ;; program.
+    (and (member name '("TeX" "LaTeX" "AmSTeX" "ConTeXt" "ConTeXt Full"))
+        (not (executable-find TeX-command))
+        (error (format "ERROR: AUCTeX cannot find a working TeX distribution.
+Make sure you have one and that TeX binaries are in PATH environment 
variable%s"
+                       (if (eq system-type 'darwin)
+                           ".
+If you are using OS X El Capitan or later
+remember to add /Library/TeX/texbin/ to your PATH"
+                         ""))))
+
     ;; Now start the process
     (setq file (funcall file))
     (TeX-process-set-variable file 'TeX-command-next TeX-command-Show)
@@ -487,7 +514,7 @@ without further expansion."
                (list "%%" (lambda nil
                             (setq pos (1+ pos))
                             "%"))
-               (or list TeX-expand-list))
+               (or list (TeX-expand-list)))
          pat (regexp-opt (mapcar #'car list)))
     (while (setq pos (string-match pat command pos))
       (setq string (match-string 0 command)
@@ -511,7 +538,7 @@ without further expansion."
                               ;; Advance past the file name in order to
                               ;; prevent expanding any substring of it.
                               (setq pos (+ pos (length expansion-res))))
-                              expansion-res)
+                           expansion-res)
                           (t
                            (error "Nonexpansion %s" expansion)))))
       (if (stringp string)
@@ -522,8 +549,8 @@ without further expansion."
 (defun TeX-check-files (derived originals extensions)
   "Check if DERIVED is newer than any of the ORIGINALS.
 Try each original with each member of EXTENSIONS, in all directories
-in `TeX-check-path'. Returns true if any of the ORIGINALS with any of the
-EXTENSIONS are newer than DERIVED. Will prompt to save the buffer of any
+in `TeX-check-path'.  Returns true if any of the ORIGINALS with any of the
+EXTENSIONS are newer than DERIVED.  Will prompt to save the buffer of any
 ORIGINALS which are modified but not saved yet."
   (let (existingoriginals
         found
@@ -555,6 +582,126 @@ ORIGINALS which are modified but not saved yet."
           (setq found t)))
     found))
 
+(defcustom TeX-command-sequence-max-runs-same-command 4
+  "Maximum number of runs of the same command."
+  :type 'integer
+  :group 'TeX-command)
+
+(defcustom TeX-command-sequence-max-runs 12
+  "Maximum number of total runs."
+  :type 'integer
+  :group 'TeX-command)
+
+(defvar TeX-command-sequence-count-same-command 1
+  "Counter for the runs of the same command in `TeX-command-sequence'.")
+
+(defvar TeX-command-sequence-count 1
+  "Counter for the total runs of `TeX-command-sequence'.")
+
+(defvar TeX-command-sequence-last-command nil
+  "Last command run in `TeX-command-sequence'.")
+
+(defvar TeX-command-sequence-sentinel nil
+  "Sentinel for `TeX-command-sequence'.")
+
+(defvar TeX-command-sequence-file-function nil
+  "File function for `TeX-command-sequence'.")
+
+(defvar TeX-command-sequence-command nil
+  "Command argument for `TeX-command-sequence'.
+
+It is set in `TeX-command-sequence' and used in
+`TeX-command-sequence-sentinel' to call again
+`TeX-command-sequence' with the appropriate command argument.")
+
+(defun TeX-command-sequence (command &optional reset file-fn)
+  "Run a sequence of TeX commands defined by COMMAND.
+
+The COMMAND argument may be
+
+  * nil: no command will be run in this case
+
+  * a string with a command from `TeX-command-list'
+
+  * a non-nil list of strings, which are commands from
+    `TeX-command-list'; the car of the list is used as command to
+    be executed in the first run of `TeX-command-sequence', the
+    cdr of the list will be passed to the function in the next
+    run, etc.
+
+  * a function name, returning a string which is command from
+    `TeX-command-list'; it will be funcall'd (without arguments!)
+    and used again in the next run of `TeX-command-sequence'.
+
+  * with any other value the function `TeX-command-default' is
+    used to determine the command to run, until a stopping
+    condition is met.
+
+This function runs at most
+`TeX-command-sequence-max-runs-same-command' times the same
+command in a row, and `TeX-command-sequence-max-runs' times in
+total in any case.  It ends when `TeX-command-Show' is the
+command to be run.
+
+A non-nil value for the optional argument RESET means this is the
+first run of the function and some variables need to be reset.
+
+FILE-FN is a function of zero arguments returning the current
+filename.  Valid choices are `TeX-master-file' (default if
+omitted) and `TeX-region-file'."
+  (setq TeX-command-sequence-file-function (or file-fn #'TeX-master-file))
+  (if (null command)
+      (message "No command to run.")
+    (let (cmd process)
+      (cond
+       ((stringp command)
+       (setq cmd command
+             TeX-command-sequence-command nil))
+       ((listp command)
+       (setq cmd (pop command)
+             TeX-command-sequence-command command))
+       ((functionp command)
+       (setq cmd (funcall command)
+             TeX-command-sequence-command command))
+       (t
+       (setq cmd (TeX-command-default
+                  ;; File function should be called with nil `nondirectory'
+                  ;; argument, otherwise `TeX-command-sequence' won't work in
+                  ;; included files not placed in `TeX-master-directory'.
+                  (funcall TeX-command-sequence-file-function))
+             TeX-command-sequence-command t)))
+      (TeX-command cmd TeX-command-sequence-file-function 0)
+      (when reset
+       (setq TeX-command-sequence-count-same-command 1
+             TeX-command-sequence-count 1
+             TeX-command-sequence-last-command nil))
+      (cond
+       ;; Stop when the same command has been run
+       ;; `TeX-command-sequence-max-runs-same-command' times in a row.
+       ((>= TeX-command-sequence-count-same-command
+           TeX-command-sequence-max-runs-same-command)
+       (message "Stopping after running %S %d times in a row."
+                TeX-command-sequence-last-command
+                TeX-command-sequence-count-same-command))
+       ;; Stop when there have been `TeX-command-sequence-max-runs' total
+       ;; compilations.
+       ((>= TeX-command-sequence-count TeX-command-sequence-max-runs)
+       (message "Stopping after %d compilations." TeX-command-sequence-count))
+       ;; The command just run is `TeX-command-Show'.
+       ((equal command TeX-command-Show))
+       ;; In any other case continue: increase counters (when needed), update
+       ;; `TeX-command-sequence-last-command' and run the sentinel.
+       (t
+       (if (equal cmd TeX-command-sequence-last-command)
+           (setq TeX-command-sequence-count-same-command
+                 (1+ TeX-command-sequence-count-same-command))
+         (setq TeX-command-sequence-count-same-command 1))
+       (setq TeX-command-sequence-count (1+ TeX-command-sequence-count)
+             TeX-command-sequence-last-command cmd)
+       (and (setq process (get-buffer-process (current-buffer)))
+            (setq TeX-command-sequence-sentinel (process-sentinel process))
+            (set-process-sentinel process 'TeX-command-sequence-sentinel)))))))
+
 (defcustom TeX-save-query t
   "*If non-nil, ask user for permission to save files before starting TeX."
   :group 'TeX-command
@@ -562,29 +709,56 @@ ORIGINALS which are modified but not saved yet."
 
 (defvar TeX-command-history nil)
 
+(defun TeX-command-default (name)
+  "Guess the next command to be run on NAME."
+  (let ((command-next nil))
+    (cond (;; name might be absolute or relative, so expand it for
+          ;; comparison.
+          (if (string-equal (expand-file-name name)
+                            (expand-file-name TeX-region))
+              (TeX-check-files (concat name "." (TeX-output-extension))
+                               ;; Each original will be checked for all dirs
+                               ;; in `TeX-check-path' so this needs to be just
+                               ;; a filename without directory.
+                               (list (file-name-nondirectory name))
+                               TeX-file-extensions)
+            (TeX-save-document (TeX-master-file)))
+          TeX-command-default)
+         ((and (memq major-mode '(doctex-mode latex-mode))
+               ;; Want to know if bib file is newer than .bbl
+               ;; We don't care whether the bib files are open in emacs
+               (TeX-check-files (concat name ".bbl")
+                                (mapcar 'car
+                                        (LaTeX-bibliography-list))
+                                (append BibTeX-file-extensions
+                                        TeX-Biber-file-extensions)))
+          ;; We should check for bst files here as well.
+          (if LaTeX-using-Biber TeX-command-Biber TeX-command-BibTeX))
+         ((and
+           ;; Rational: makeindex should be run when final document is almost
+           ;; complete (see
+           ;; 
http://tex.blogoverflow.com/2012/09/dont-forget-to-run-makeindex/),
+           ;; otherwise, after following latex runs, index pages may change due
+           ;; to changes in final document, resulting in extra makeindex and
+           ;; latex runs.
+           (member
+            (setq command-next
+                  (TeX-process-get-variable
+                   name
+                   'TeX-command-next
+                   (if (and TeX-PDF-via-dvips-ps2pdf TeX-PDF-mode)
+                       "Dvips"
+                     TeX-command-Show)))
+            (list "Dvips" TeX-command-Show))
+           (cdr (assoc (expand-file-name (concat name ".idx"))
+                       LaTeX-idx-changed-alist)))
+          "Index")
+         (command-next)
+         (TeX-command-Show))))
+
 (defun TeX-command-query (name)
   "Query the user for what TeX command to use."
-  (let* ((default
-          (cond ((if (string-equal name TeX-region)
-                     (TeX-check-files (concat name "." (TeX-output-extension))
-                                      (list name)
-                                      TeX-file-extensions)
-                   (TeX-save-document (TeX-master-file)))
-                 TeX-command-default)
-                ((and (memq major-mode '(doctex-mode latex-mode))
-                      ;; Want to know if bib file is newer than .bbl
-                      ;; We don't care whether the bib files are open in emacs
-                      (TeX-check-files (concat name ".bbl")
-                                       (mapcar 'car
-                                               (LaTeX-bibliography-list))
-                                       (append BibTeX-file-extensions
-                                               TeX-Biber-file-extensions)))
-                 ;; We should check for bst files here as well.
-                 (if LaTeX-using-Biber TeX-command-Biber TeX-command-BibTeX))
-                ((TeX-process-get-variable name
-                                           'TeX-command-next
-                                           TeX-command-Show))
-                (TeX-command-Show)))
+  (let* ((default (TeX-command-default name))
          (completion-ignore-case t)
          (answer (or TeX-command-force
                      (completing-read
@@ -762,7 +936,8 @@ Return the new process."
 (defun TeX-run-set-command (name command)
   "Remember TeX command to use to NAME and set corresponding output extension."
   (setq TeX-command-default name
-       TeX-output-extension (if TeX-PDF-mode "pdf" "dvi"))
+       TeX-output-extension
+       (if (and (null TeX-PDF-via-dvips-ps2pdf) TeX-PDF-mode) "pdf" "dvi"))
   (let ((case-fold-search t)
        (lst TeX-command-output-list))
     (while lst
@@ -801,7 +976,8 @@ run of `TeX-run-TeX', use
   ;; Save information in TeX-error-report-switches
   ;; Initialize error to nil (no error) for current master.
   ;; Presence of error is reported inside `TeX-TeX-sentinel-check'
-  (let ((current-master (TeX-master-file)))
+  (let ((current-master (TeX-master-file))
+       (idx-file nil) (element nil))
     ;; the current master file is saved because error routines are
     ;; parsed in other buffers;
     (setq TeX-error-report-switches
@@ -810,7 +986,22 @@ run of `TeX-run-TeX', use
     ;; reset error to nil (no error)
     (setq TeX-error-report-switches
          (plist-put TeX-error-report-switches
-                    (intern current-master) nil)))
+                    (intern current-master) nil))
+
+    ;; Store md5 hash of the index file before running LaTeX.
+    (and (memq major-mode '(doctex-mode latex-mode))
+        (prog1 (file-exists-p
+                (setq idx-file (expand-file-name (concat file ".idx"))))
+          ;; In order to avoid confusion and pollution of
+          ;; `LaTeX-idx-md5-alist', remove from this alist all md5 hashes of
+          ;; the current index file.  Note `assq-delete-all' doesn't work with
+          ;; string keys and has problems with non-list elements in Emacs 21
+          ;; (see file tex-site.el).
+          (while (setq element (assoc idx-file LaTeX-idx-md5-alist))
+            (setq LaTeX-idx-md5-alist (delq element LaTeX-idx-md5-alist))))
+        (with-temp-buffer
+          (insert-file-contents idx-file)
+          (push (cons idx-file (md5 (current-buffer))) LaTeX-idx-md5-alist))))
 
   ;; can we assume that TeX-sentinel-function will not be changed
   ;; during (TeX-run-format ..)? --pg
@@ -846,6 +1037,41 @@ run of `TeX-run-TeX', use
         process
       (TeX-synchronous-sentinel name file process))))
 
+(defun TeX-run-dvips (name command file)
+  "Create a process for NAME using COMMAND to convert FILE with dvips."
+  (let ((process (TeX-run-command name command file)))
+    (setq TeX-sentinel-function 'TeX-dvips-sentinel)
+    (if TeX-process-asynchronous
+        process
+      (TeX-synchronous-sentinel name file process))))
+
+(defun TeX-run-ps2pdf (name command file)
+  "Create a process for NAME using COMMAND to convert FILE with ps2pdf."
+  (let ((process (TeX-run-command name command file)))
+    (setq TeX-sentinel-function 'TeX-ps2pdf-sentinel)
+    (if TeX-process-asynchronous
+        process
+      (TeX-synchronous-sentinel name file process))))
+
+(defun TeX-run-index (name command file)
+  "Create a process for NAME using COMMAND to compile the index file."
+  (let ((process (TeX-run-command name command file))
+       (element nil))
+    (setq TeX-sentinel-function 'TeX-index-sentinel)
+    ;; Same cleaning as that for `LaTeX-idx-md5-alist' in `TeX-run-TeX'.
+    (while (setq element
+                ;; `file' has been determined in `TeX-command-buffer', while
+                ;; this function has `TeX-master-directory' as
+                ;; `default-directory', then we have to expand `file' file-name
+                ;; in the same directory of `TeX-command-buffer'.
+                (assoc (with-current-buffer TeX-command-buffer
+                           (expand-file-name (concat file ".idx")))
+                       LaTeX-idx-changed-alist))
+      (setq LaTeX-idx-changed-alist (delq element LaTeX-idx-changed-alist)))
+    (if TeX-process-asynchronous
+        process
+      (TeX-synchronous-sentinel name file process))))
+
 (defun TeX-run-compile (name command file)
   "Ignore first and third argument, start compile with second argument."
   (let ((default-directory (TeX-master-directory)))
@@ -1053,13 +1279,16 @@ Open the error overview if
 `TeX-error-overview-open-after-TeX-run' is non-nil and there are
 errors or warnings to show."
   (if (TeX-TeX-sentinel-check process name)
-      ()
+      (progn
+       (if TeX-parse-all-errors
+           (TeX-parse-all-errors))
+       (if (and TeX-error-overview-open-after-TeX-run TeX-error-list)
+           (TeX-error-overview)))
     (message (concat name ": formatted " (TeX-current-pages)))
-    (if TeX-parse-all-errors
-       (TeX-parse-all-errors))
-    (if (and TeX-error-overview-open-after-TeX-run TeX-error-list)
-       (TeX-error-overview))
-    (setq TeX-command-next TeX-command-Show)))
+    (if (with-current-buffer TeX-command-buffer
+         (and TeX-PDF-via-dvips-ps2pdf TeX-PDF-mode))
+       (setq TeX-command-next "Dvips")
+      (setq TeX-command-next TeX-command-Show))))
 
 (defun TeX-current-pages ()
   "Return string indicating the number of pages formatted."
@@ -1075,17 +1304,33 @@ errors or warnings to show."
 Return nil ifs no errors were found."
   (save-excursion
     (goto-char (point-max))
-    (if (re-search-backward "^Output written on \\(.*?\\) (\\([0-9]+\\) page"
-                           nil t)
+    (cond
+     ((and (string-match "ConTeXt" name)
+          (with-current-buffer TeX-command-buffer
+            (string= ConTeXt-Mark-version "IV")))
+      (when (re-search-backward " > result saved in file: \\(.*?\\), " nil t)
        (let ((output-file (TeX-match-buffer 1)))
-         (setq TeX-current-page (concat "{" (TeX-match-buffer 2) "}"))
          ;; Shave off quotation marks if present.
          (when (string-match "\\`\"\\(.*\\)\"\\'" output-file)
            (setq output-file (match-string 1 output-file)))
          (setq TeX-output-extension
                (if (string-match "\\.\\([^.]*\\)$" output-file)
                    (match-string 1 output-file)
-                 "dvi")))))
+                 "dvi")))
+       (if (re-search-forward ", \\([0-9]+\\) shipped pages, " nil t)
+           (setq TeX-current-page (concat "{" (TeX-match-buffer 1) "}")))))
+     (t
+      (if (re-search-backward "^Output written on \\(.*?\\) (\\([0-9]+\\) page"
+                             nil t)
+         (let ((output-file (TeX-match-buffer 1)))
+           (setq TeX-current-page (concat "{" (TeX-match-buffer 2) "}"))
+           ;; Shave off quotation marks if present.
+           (when (string-match "\\`\"\\(.*\\)\"\\'" output-file)
+             (setq output-file (match-string 1 output-file)))
+           (setq TeX-output-extension
+                 (if (string-match "\\.\\([^.]*\\)$" output-file)
+                     (match-string 1 output-file)
+                   "dvi")))))))
   (if process (TeX-format-mode-line process))
   (if (re-search-forward "^\\(!\\|.*:[0-9]+:\\) " nil t)
       (progn
@@ -1100,7 +1345,10 @@ Return nil ifs no errors were found."
                                            'TeX-current-master))
                         t))
        t)
-    (setq TeX-command-next TeX-command-Show)
+    (if (with-current-buffer TeX-command-buffer
+         (and TeX-PDF-via-dvips-ps2pdf TeX-PDF-mode))
+       (setq TeX-command-next "Dvips")
+      (setq TeX-command-next TeX-command-Show))
     nil))
 
 (defun TeX-LaTeX-sentinel-has-warnings ()
@@ -1182,12 +1430,18 @@ Rerun to get outlines right" nil t)
        ((re-search-forward "^LaTeX Warning: Reference" nil t)
         (message "%s%s%s" name ": there were unresolved references, "
                  (TeX-current-pages))
-        (setq TeX-command-next TeX-command-Show))
+        (if (with-current-buffer TeX-command-buffer
+              (and TeX-PDF-via-dvips-ps2pdf TeX-PDF-mode))
+            (setq TeX-command-next "Dvips")
+          (setq TeX-command-next TeX-command-Show)))
        ((re-search-forward "^\\(?:LaTeX Warning: Citation\\|\
 Package natbib Warning:.*undefined citations\\)" nil t)
         (message "%s%s%s" name ": there were unresolved citations, "
                  (TeX-current-pages))
-        (setq TeX-command-next TeX-command-Show))
+        (if (with-current-buffer TeX-command-buffer
+              (and TeX-PDF-via-dvips-ps2pdf TeX-PDF-mode))
+            (setq TeX-command-next "Dvips")
+          (setq TeX-command-next TeX-command-Show)))
        ((re-search-forward "Package longtable Warning: Table widths have \
 changed\\. Rerun LaTeX\\." nil t)
         (message
@@ -1213,10 +1467,34 @@ Rerun to get mark in right position\\." nil t)
                                    ")"))))
           (message "%s" (concat name ": successfully formatted "
                                 (TeX-current-pages) add-info)))
-        (setq TeX-command-next TeX-command-Show))
+        (if (with-current-buffer TeX-command-buffer
+              (and TeX-PDF-via-dvips-ps2pdf TeX-PDF-mode))
+            (setq TeX-command-next "Dvips")
+          (setq TeX-command-next TeX-command-Show)))
        (t
         (message "%s%s%s" name ": problems after " (TeX-current-pages))
         (setq TeX-command-next TeX-command-default)))
+
+  ;; Check whether the idx file changed.
+  (let ((idx-file nil) (master nil))
+    (and (file-exists-p
+         (setq idx-file
+               (concat
+                (setq master
+                      (with-current-buffer TeX-command-buffer
+                        (expand-file-name (TeX-active-master)))) ".idx")))
+        ;; imakeidx package automatically runs makeindex, thus, we need to be
+        ;; sure .ind file isn't newer than .idx.
+        (TeX-check-files (concat master ".ind")
+                         (list (file-name-nondirectory master)) '("idx"))
+        (with-temp-buffer
+          (insert-file-contents idx-file)
+          (not (equal
+                ;; Compare old md5 hash of the idx file with the new one.
+                (cdr (assoc idx-file LaTeX-idx-md5-alist))
+                (md5 (current-buffer)))))
+        (push (cons idx-file t) LaTeX-idx-changed-alist)))
+
   (unless TeX-error-list
     (run-hook-with-args 'TeX-after-TeX-LaTeX-command-finished-hook
                        (with-current-buffer TeX-command-buffer
@@ -1268,6 +1546,66 @@ Rerun to get mark in right position\\." nil t)
                      "Run LaTeX again to get citations right."))
     (setq TeX-command-next TeX-command-default))))
 
+(defun TeX-dvips-sentinel (_process _name)
+  "Cleanup TeX output buffer after running dvips."
+  (goto-char (point-max))
+  (cond
+   ((search-backward "TeX Output exited abnormally" nil t)
+    (message "Dvips failed.  Type `%s' to display output."
+            (substitute-command-keys
+              "\\<TeX-mode-map>\\[TeX-recenter-output-buffer]")))
+   (t
+    (if (with-current-buffer TeX-command-buffer
+         (and TeX-PDF-via-dvips-ps2pdf TeX-PDF-mode))
+       (setq TeX-output-extension "ps"
+             TeX-command-next "Ps2pdf"))
+    (message "Dvips finished successfully. "))))
+
+(defun TeX-ps2pdf-sentinel (_process _name)
+  "Cleanup TeX output buffer after running ps2pdf."
+  (goto-char (point-max))
+  (cond
+   ((search-backward "TeX Output exited abnormally" nil t)
+    (message "ps2pdf failed.  Type `%s' to display output."
+            (substitute-command-keys
+              "\\<TeX-mode-map>\\[TeX-recenter-output-buffer]")))
+   (t
+    (if (with-current-buffer TeX-command-buffer
+         (and TeX-PDF-via-dvips-ps2pdf TeX-PDF-mode))
+       (setq TeX-command-next TeX-command-Show
+             TeX-output-extension "pdf"))
+    (message "ps2pdf finished successfully. "))))
+
+(defun TeX-index-sentinel (_process _name)
+  "Cleanup TeX output buffer after compiling index."
+  (goto-char (point-max))
+  (cond
+   ((search-backward "TeX Output exited abnormally" nil t)
+    (message "Index failed.  Type `%s' to display output."
+            (substitute-command-keys
+              "\\<TeX-mode-map>\\[TeX-recenter-output-buffer]")))
+   (t
+    (setq TeX-command-next TeX-command-default)
+    (message (concat "Index finished successfully. "
+                    "Run LaTeX again to get index right.")))))
+
+(defun TeX-command-sequence-sentinel (process string)
+  "Call the appropriate sentinel for the current process.
+
+If there are no errors, call back `TeX-command-sequence' using
+`TeX-command-sequence-command' as command argument, unless this
+variable is nil."
+  (with-current-buffer (process-buffer process)
+    (funcall TeX-command-sequence-sentinel process string)
+    (if (string-match "\\(finished\\|exited\\)" string)
+       (with-current-buffer TeX-command-buffer
+         (unless
+             (or
+              (plist-get TeX-error-report-switches (intern (TeX-master-file)))
+              (null TeX-command-sequence-command))
+           (TeX-command-sequence TeX-command-sequence-command nil
+                                 TeX-command-sequence-file-function))))))
+
 ;;; Process Control
 
 
@@ -1400,7 +1738,7 @@ command."
 
 (defvar TeX-parse-function nil
   "Function to call to parse content of TeX output buffer.")
- (make-variable-buffer-local 'TeX-parse-function)
+(make-variable-buffer-local 'TeX-parse-function)
 
 (defun TeX-background-filter (process string)
   "Filter to process background output."
@@ -1668,6 +2006,27 @@ levels are defined by `LaTeX-section-list'."
                 old-level (car (rassoc (list LaTeX-command-section-level)
                                        LaTeX-section-list)))))))
 
+(defun LaTeX-command-section-boundaries ()
+  "Return the boundaries of the current section as (start . end).
+The section is determined by `LaTeX-command-section-level'."
+  (let* ((case-fold-search nil)
+        (rx (concat "\\\\" (regexp-opt
+                            (mapcar
+                             (lambda (level)
+                               (car (rassoc (list level) LaTeX-section-list)))
+                             (let (r)
+                               (dotimes (i (1+ (LaTeX-command-section-level)))
+                                 (push i r))
+                               r)))
+                    "{")))
+    (cons (save-excursion
+           (re-search-backward rx nil t)
+           (point))
+         (save-excursion
+           (re-search-forward (concat rx "\\|\\\\end{document}") nil t)
+           (forward-line 0)
+           (point)))))
+
 (defun LaTeX-command-section (&optional override-confirm)
   "Run a command on the current section.
 
@@ -1683,24 +2042,43 @@ If a prefix argument OVERRIDE-CONFIRM is given, 
confirmation will
 depend on it being positive instead of the entry in
 `TeX-command-list'."
   (interactive "P")
-  (let* ((case-fold-search t)
-        (rx (concat "\\\\" (regexp-opt
-                            (mapcar
-                             (lambda (level)
-                               (car (rassoc (list level) LaTeX-section-list)))
-                             (let (r)
-                               (dotimes (i (1+ (LaTeX-command-section-level)))
-                                 (push i r))
-                               r)))
-                    "{"))
-        (TeX-command-region-begin (save-excursion
-                                    (re-search-backward rx nil t)
-                                    (point)))
-        (TeX-command-region-end (save-excursion
-                                  (re-search-forward rx nil t)
-                                  (forward-line 0)
-                                  (point))))
-    (TeX-command-region override-confirm)))
+  (if (eq major-mode 'latex-mode)
+      (let* ((bounds (LaTeX-command-section-boundaries))
+            (TeX-command-region-begin (car bounds))
+            (TeX-command-region-end (cdr bounds)))
+       (TeX-command-region override-confirm))
+    (error "LaTeX-command-section can only be run on LaTeX documents")))
+
+(defun TeX-command-run-all-region ()
+  "Compile the current region until an error occurs or it is finished."
+  (interactive)
+  (TeX-region-update)
+  (TeX-command-sequence t t #'TeX-region-file))
+
+(defun LaTeX-command-run-all-section ()
+  "Compile the current section until an error occurs or it is finished."
+  (interactive)
+  (if (eq major-mode 'latex-mode)
+      (let* ((bounds (LaTeX-command-section-boundaries))
+            (TeX-command-region-begin (car bounds))
+            (TeX-command-region-end (cdr bounds)))
+       (TeX-region-update)
+       (TeX-command-sequence t t #'TeX-region-file))
+    (error "LaTeX-command-run-all-section can only be run on LaTeX 
documents")))
+
+(defun TeX-command-run-all (arg)
+  "Compile the current document until an error occurs or it is finished.
+With a prefix ARG (`\\[universal-argument] \\[TeX-command-run-all]'),
+compile the current region instead, e.g, call
+`TeX-command-run-all-region'.  With multiple prefix
+arguments (`\\[universal-argument] \\[universal-argument] 
\\[TeX-command-run-all]'),
+compile the current section instead, e.g. call
+`LaTeX-command-run-all-section'."
+  (interactive "P")
+  (cond
+   ((null arg)       (TeX-command-sequence t t))
+   ((= 4 (car arg))  (TeX-command-run-all-region))
+   (t                (LaTeX-command-run-all-section))))
 
 ;;; Parsing
 
@@ -1709,17 +2087,17 @@ depend on it being positive instead of the entry in
 (defvar TeX-error-point nil
   "How far we have parsed until now.")
 
- (make-variable-buffer-local 'TeX-error-point)
+(make-variable-buffer-local 'TeX-error-point)
 
 (defvar TeX-error-file nil
   "Stack of files in which errors have occurred.")
 
- (make-variable-buffer-local 'TeX-error-file)
+(make-variable-buffer-local 'TeX-error-file)
 
 (defvar TeX-error-offset nil
   "Add this to any line numbers from TeX.  Stack like `TeX-error-file'.")
 
- (make-variable-buffer-local 'TeX-error-offset)
+(make-variable-buffer-local 'TeX-error-offset)
 
 (defun TeX-parse-reset (&optional reparse)
   "Reset all variables used for parsing TeX output.
@@ -1738,7 +2116,7 @@ If optional argument REPARSE is non-nil, reparse the 
output log."
 ;; be ignored, because `TeX-next-error' can call any of these functions.
 (defun TeX-parse-command (arg reparse)
   "We can't parse anything but TeX."
-  (error "I cannot parse %s output, sorry."
+  (error "I cannot parse %s output, sorry"
         (if (TeX-active-process)
             (process-name (TeX-active-process))
           "this")))
@@ -2228,40 +2606,40 @@ a bad box."
 
 (defcustom TeX-error-description-list
   '(("\\(?:Package Preview Error\\|Preview\\):.*" .
-"The `auctex' option to `preview' should not be applied manually.
+     "The `auctex' option to `preview' should not be applied manually.
 If you see this error message outside of a preview run, either
 you did something too clever, or AUCTeX something too stupid.")
 
     ("Bad \\\\line or \\\\vector argument.*" .
-"The first argument of a \\line or \\vector command, which specifies the
+     "The first argument of a \\line or \\vector command, which specifies the
 slope, is illegal\.")
 
     ("Bad math environment delimiter.*" .
-"TeX has found either a math-mode-starting command such as \\[ or \\(
+     "TeX has found either a math-mode-starting command such as \\[ or \\(
 when it is already in math mode, or else a math-mode-ending command
 such as \\) or \\] while in LR or paragraph mode.  The problem is caused
 by either unmatched math mode delimiters or unbalanced braces\.")
 
     ("Bad use of \\\\\\\\.*" .
-"A \\\\ command appears between paragraphs, where it makes no sense. This
+     "A \\\\ command appears between paragraphs, where it makes no sense. This
 error message occurs when the \\\\ is used in a centering or flushing
 environment or else in the scope of a centering or flushing
 declaration.")
 
     ("\\\\begin{[^ ]*} ended by \\\\end{[^ ]*}." .
-"LaTeX has found an \\end command that doesn't match the corresponding
+     "LaTeX has found an \\end command that doesn't match the corresponding
 \\begin command. You probably misspelled the environment name in the
 \\end command, have an extra \\begin, or else forgot an \\end.")
 
     ("Can be used only in preamble." .
-"LaTeX has encountered, after the \\begin{document}, one of the
+     "LaTeX has encountered, after the \\begin{document}, one of the
 following commands that should appear only in the preamble:
 \\documentclass, \\nofiles, \\includeonly, \\makeindex, or
 \\makeglossary.  The error is also caused by an extra \\begin{document}
 command.")
 
     ("Command name [^ ]* already used.*" .
-"You are using \\newcommand, \\newenvironment, \\newlength, \\newsavebox,
+     "You are using \\newcommand, \\newenvironment, \\newlength, \\newsavebox,
 or \\newtheorem to define a command or environment name that is
 already defined, or \\newcounter to define a counter that already
 exists. (Defining an environment named gnu automatically defines the
@@ -2269,7 +2647,7 @@ command \\gnu.) You'll have to choose a new name or, in 
the case of
 \\newcommand or \\newenvironment, switch to the \\renew ...  command.")
 
     ("Counter too large." .
-"1. Some object that is numbered with letters, probably an item in a
+     "1. Some object that is numbered with letters, probably an item in a
 enumerated list, has received a number greater than 26. Either you're
 making a very long list or you've been resetting counter values.
 
@@ -2278,11 +2656,11 @@ and LaTeX has run out of letters or symbols. This is 
probably caused
 by too many \\thanks commands.")
 
     ("Environment [^ ]* undefined." .
-"LaTeX has encountered a \\begin command for a nonexistent environment.
+     "LaTeX has encountered a \\begin command for a nonexistent environment.
 You probably misspelled the environment name. ")
 
     ("Float(s) lost." .
-"You put a figure or table environment or a \\marginpar command inside a
+     "You put a figure or table environment or a \\marginpar command inside a
 parbox---either one made with a minipage environment or \\parbox
 command, or one constructed by LaTeX in making a footnote, figure,
 etc. This is an outputting error, and the offending environment or
@@ -2291,70 +2669,70 @@ the problem. One or more figures, tables, and/or 
marginal notes have
 been lost, but not necessarily the one that caused the error.")
 
     ("Illegal character in array arg." .
-"There is an illegal character in the argument of an array or tabular
+     "There is an illegal character in the argument of an array or tabular
 environment, or in the second argument of a \\multicolumn command.")
 
     ("Missing \\\\begin{document}." .
-"LaTeX produced printed output before encountering a \\begin{document}
+     "LaTeX produced printed output before encountering a \\begin{document}
 command. Either you forgot the \\begin{document} command or there is
 something wrong in the preamble. The problem may be a stray character
 or an error in a declaration---for example, omitting the braces around
 an argument or forgetting the \\ in a command name.")
 
     ("Missing p-arg in array arg.*" .
-"There is a p that is not followed by an expression in braces in the
+     "There is a p that is not followed by an expression in braces in the
 argument of an array or tabular environment, or in the second argument
 of a \\multicolumn command.")
 
     ("Missing @-exp in array arg." .
-"There is an @ character not followed by an @-expression in the
+     "There is an @ character not followed by an @-expression in the
 argument of an array or tabular environment, or in the second argument
 of a \\multicolumn command.")
 
     ("No such counter." .
-"You have specified a nonexistent counter in a \\setcounter or
+     "You have specified a nonexistent counter in a \\setcounter or
 \\addtocounter command. This is probably caused by a simple typing
 error.  However, if the error occurred while a file with the extension
 aux is being read, then you probably used a \\newcounter command
 outside the preamble.")
 
     ("Not in outer par mode." .
-"You had a figure or table environment or a \\marginpar command in math
+     "You had a figure or table environment or a \\marginpar command in math
 mode or inside a parbox.")
 
     ("\\\\pushtabs and \\\\poptabs don't match." .
-"LaTeX found a \\poptabs with no matching \\pushtabs, or has come to the
+     "LaTeX found a \\poptabs with no matching \\pushtabs, or has come to the
 \\end{tabbing} command with one or more unmatched \\pushtabs commands.")
 
     ("Something's wrong--perhaps a missing \\\\item." .
-"The most probable cause is an omitted \\item command in a list-making
+     "The most probable cause is an omitted \\item command in a list-making
 environment. It is also caused by forgetting the argument of a
 thebibliography environment.")
 
     ("Tab overflow." .
-"A \\= command has exceeded the maximum number of tab stops that LaTeX
+     "A \\= command has exceeded the maximum number of tab stops that LaTeX
 permits.")
 
     ("There's no line here to end." .
-"A \\newline or \\\\ command appears between paragraphs, where it makes no
+     "A \\newline or \\\\ command appears between paragraphs, where it makes no
 sense. If you're trying to ``leave a blank line'', use a \\vspace
 command.")
 
     ("This may be a LaTeX bug." .
-"LaTeX has become thoroughly confused. This is probably due to a
+     "LaTeX has become thoroughly confused. This is probably due to a
 previously detected error, but it is possible that you have found an
 error in LaTeX itself. If this is the first error message produced by
 the input file and you can't find anything wrong, save the file and
 contact the person listed in your Local Guide.")
 
     ("Too deeply nested." .
-"There are too many list-making environments nested within one another.
+     "There are too many list-making environments nested within one another.
 How many levels of nesting are permitted may depend upon what computer
 you are using, but at least four levels are provided, which should be
 enough.")
 
     ("Too many unprocessed floats." .
-"While this error can result from having too many \\marginpar commands
+     "While this error can result from having too many \\marginpar commands
 on a page, a more likely cause is forcing LaTeX to save more figures
 and tables than it has room for.  When typesetting its continuous
 scroll, LaTeX saves figures and tables separately and inserts them as
@@ -2370,38 +2748,38 @@ argument says it must go. This is likely to happen if 
the argument
 does not contain a p option.")
 
     ("Undefined tab position." .
-"A \\>, \\+, \\-, or \\< command is trying to go to a nonexistent tab
+     "A \\>, \\+, \\-, or \\< command is trying to go to a nonexistent tab
 position---one not defined by a \\= command.")
 
     ("\\\\< in mid line." .
-"A \\< command appears in the middle of a line in a tabbing environment.
+     "A \\< command appears in the middle of a line in a tabbing environment.
 This command should come only at the beginning of a line.")
 
     ("Double subscript." .
-"There are two subscripts in a row in a mathematical
+     "There are two subscripts in a row in a mathematical
 formula---something like x_{2}_{3}, which makes no sense.")
 
     ("Double superscript." .
-"There are two superscripts in a row in a mathematical
+     "There are two superscripts in a row in a mathematical
 formula---something like x^{2}^{3}, which makes no sense.")
 
     ("Extra alignment tab has been changed to \\\\cr." .
-"There are too many separate items (column entries) in a single row of
+     "There are too many separate items (column entries) in a single row of
 an array or tabular environment. In other words, there were too many &
 's before the end of the row. You probably forgot the \\\\ at the end of
 the preceding row.")
 
     ("Extra \\}, or forgotten \\$." .
-"The braces or math mode delimiters don't match properly. You probably
+     "The braces or math mode delimiters don't match properly. You probably
 forgot a {, \\[, \\(, or $.")
 
     ("Font [^ ]* not loaded: Not enough room left." .
-"The document uses more fonts than TeX has room for. If different parts
+     "The document uses more fonts than TeX has room for. If different parts
 of the document use different fonts, then you can get around the
 problem by processing it in parts.")
 
     ("I can't find file `.*'." .
-"TeX can't find a file that it needs. If the name of the missing file
+     "TeX can't find a file that it needs. If the name of the missing file
 has the extension tex, then it is looking for an input file that you
 specified---either your main file or another file inserted with an
 \\input or \\include command. If the missing file has the extension sty
@@ -2409,7 +2787,7 @@ specified---either your main file or another file 
inserted with an
 option.")
 
     ("Illegal parameter number in definition of .*" .
-"This is probably caused by a \\newcommand, \\renewcommand,
+     "This is probably caused by a \\newcommand, \\renewcommand,
 \\newenvironment, or \\renewenvironment command in which a # is used
 incorrectly.  A # character, except as part of the command name \\#,
 can be used only to indicate an argument parameter, as in #2, which
@@ -2419,7 +2797,7 @@ like #2 in the last argument of a \\newenvironment or 
\\renewenvironment
 command.")
 
     ("Illegal unit of measure ([^ ]* inserted)." .
-"If you just got a
+     "If you just got a
 
       ! Missing number, treated as zero.
 
@@ -2431,16 +2809,16 @@ should result in correct output. However, the error can 
also be caused
 by omitting a command argument.")
 
     ("Misplaced alignment tab character \\&." .
-"The special character &, which should be used only to separate items
+     "The special character &, which should be used only to separate items
 in an array or tabular environment, appeared in ordinary text. You
 probably meant to type \\&.")
 
     ("Missing control sequence inserted." .
-"This is probably caused by a \\newcommand, \\renewcommand, \\newlength,
+     "This is probably caused by a \\newcommand, \\renewcommand, \\newlength,
 or \\newsavebox command whose first argument is not a command name.")
 
     ("Missing number, treated as zero." .
-"This is usually caused by a LaTeX command expecting but not finding
+     "This is usually caused by a LaTeX command expecting but not finding
 either a number or a length as an argument. You may have omitted an
 argument, or a square bracket in the text may have been mistaken for
 the beginning of an optional argument. This error is also caused by
@@ -2448,11 +2826,11 @@ putting \\protect in front of either a length command 
or a command such
 as \\value that produces a number.")
 
     ("Missing [{}] inserted." .
-"TeX has become confused. The position indicated by the error locator
+     "TeX has become confused. The position indicated by the error locator
 is probably beyond the point where the incorrect input is.")
 
     ("Missing \\$ inserted." .
-"TeX probably found a command that can be used only in math mode when
+     "TeX probably found a command that can be used only in math mode when
 it wasn't in math mode.  Remember that unless stated otherwise, all
 all the commands of Section 3.3 in LaTeX Book (Lamport) can be used
 only in math mode. TeX is not in math mode when it begins processing
@@ -2461,28 +2839,28 @@ math environment. This error also occurs if TeX 
encounters a blank
 line when it is in math mode.")
 
     ("Not a letter." .
-"Something appears in the argument of a \\hyphenation command that
+     "Something appears in the argument of a \\hyphenation command that
 doesn't belong there.")
 
     ("Paragraph ended before [^ ]* was complete." .
-"A blank line occurred in a command argument that shouldn't contain
+     "A blank line occurred in a command argument that shouldn't contain
 one. You probably forgot the right brace at the end of an argument.")
 
     ("\\\\[^ ]*font [^ ]* is undefined .*" .
-"These errors occur when an uncommon font is used in math mode---for
+     "These errors occur when an uncommon font is used in math mode---for
 example, if you use a \\sc command in a formula inside a footnote,
 calling for a footnote-sized small caps font.  This problem is solved
 by using a \\load command.")
 
     ("Font .* not found." .
-"You requested a family/series/shape/size combination that is totally
+     "You requested a family/series/shape/size combination that is totally
 unknown.  There are two cases in which this error can occur:
   1) You used the \\size macro to select a size that is not available.
   2) If you did not do that, go to your local `wizard' and
      complain fiercely that the font selection tables are corrupted!")
 
     ("TeX capacity exceeded, sorry .*" .
-"TeX has just run out of space and aborted its execution. Before you
+     "TeX has just run out of space and aborted its execution. Before you
 panic, remember that the least likely cause of this error is TeX not
 having the capacity to process your document.  It was probably an
 error in your input file that caused TeX to run out of room. The
@@ -2583,14 +2961,14 @@ turn has a \\footnotesize declaration whose scope 
contains a \\multiput
 command containing a ....")
 
     ("Text line contains an invalid character." .
-"The input contains some strange character that it shouldn't. A mistake
+     "The input contains some strange character that it shouldn't. A mistake
 when creating the file probably caused your text editor to insert this
 character. Exactly what could have happened depends upon what text
 editor you used. If examining the input file doesn't reveal the
 offending character, consult the Local Guide for suggestions.")
 
     ("Undefined control sequence."   .
-"TeX encountered an unknown command name. You probably misspelled the
+     "TeX encountered an unknown command name. You probably misspelled the
 name. If this message occurs when a LaTeX command is being processed,
 the command is probably in the wrong place---for example, the error
 can be produced by an \\item command that's not inside a list-making
@@ -2598,43 +2976,43 @@ environment. The error can also be caused by a missing 
\\documentclass
 command.")
 
     ("Use of [^ ]* doesn't match its definition." .
-"It's probably one of the picture-drawing commands, and you have used
+     "It's probably one of the picture-drawing commands, and you have used
 the wrong syntax for specifying an argument. If it's address@hidden that
 doesn't match its definition, then there is something wrong in an
 @-expression in the argument of an array or tabular
 environment---perhaps a fragile command that is not \\protect'ed.")
 
     ("You can't use `macro parameter character \\#' in [^ ]* mode." .
-"The special character # has appeared in ordinary text. You probably
+     "The special character # has appeared in ordinary text. You probably
 meant to type \\#.")
 
     ("Overfull \\\\hbox .*" .
-"Because it couldn't find a good place for a line break, TeX put more
+     "Because it couldn't find a good place for a line break, TeX put more
 on this line than it should.")
 
     ("Overfull \\\\vbox .*" .
-"Because it couldn't find a good place for a page break, TeX put more
+     "Because it couldn't find a good place for a page break, TeX put more
 on the page than it should. ")
 
     ("Underfull \\\\hbox .*" .
-"Check your output for extra vertical space.  If you find some, it was
+     "Check your output for extra vertical space.  If you find some, it was
 probably caused by a problem with a \\\\ or \\newline command---for
 example, two \\\\ commands in succession. This warning can also be
 caused by using the sloppypar environment or \\sloppy declaration, or
 by inserting a \\linebreak command.")
 
     ("Underfull \\\\vbox .*" .
-"TeX could not find a good place to break the page, so it produced a
+     "TeX could not find a good place to break the page, so it produced a
 page without enough text on it. ")
 
-;; New list items should be placed here
-;;
-;; ("err-regexp" . "context")
-;;
-;; the err-regexp item should match anything
+    ;; New list items should be placed here
+    ;;
+    ;; ("err-regexp" . "context")
+    ;;
+    ;; the err-regexp item should match anything
 
     (".*" . "No help available"))      ; end definition
-"A list of the form (\"err-regexp\" . \"context\") used by function
+  "A list of the form (\"err-regexp\" . \"context\") used by function
 `TeX-help-error' to display help-text on an error message or warning.
 err-regexp should be a regular expression matching the error message
 given from TeX/LaTeX, and context should be some lines describing that
@@ -2853,7 +3231,7 @@ forward, if negative)."
   "List of errors to be used in the error overview.")
 
 (define-derived-mode TeX-error-overview-mode tabulated-list-mode
-  "TeX errors"
+                    "TeX errors"
   "Major mode for listing TeX errors."
   (setq tabulated-list-format [("File" 25 nil)
                                ("Line" 4 nil :right-align t)
@@ -2935,7 +3313,7 @@ forward, if negative)."
                                           TeX-error-overview-buffer-name)
                        (set-window-dedicated-p (selected-window) t))
                    (TeX-pop-to-buffer TeX-error-overview-buffer-name))))
-           (error "No errror or warning to show"))
+           (error "No error or warning to show"))
        (error "No process for this document"))
     (error "Error overview is available only in Emacs 24 or later")))
 
@@ -2989,13 +3367,13 @@ forward, if negative)."
   "Keymap for `TeX-output-mode'.")
 
 (define-derived-mode TeX-output-mode TeX-special-mode "TeX Output"
-    "Major mode for viewing TeX output.
+  "Major mode for viewing TeX output.
 \\{TeX-output-mode-map} "
-    :syntax-table nil
-    (set (make-local-variable 'revert-buffer-function)
-        #'TeX-output-revert-buffer)
-    ;; special-mode makes it read-only which prevents input from TeX.
-    (setq buffer-read-only nil))
+  :syntax-table nil
+  (set (make-local-variable 'revert-buffer-function)
+       #'TeX-output-revert-buffer)
+  ;; special-mode makes it read-only which prevents input from TeX.
+  (setq buffer-read-only nil))
 
 (defun TeX-output-revert-buffer (ignore-auto noconfirm)
   "Rerun the TeX command which of which this buffer was the output."
@@ -3008,7 +3386,7 @@ forward, if negative)."
           (TeX-command name (if (string-match "_region_" file)
                                 'TeX-region-file
                               'TeX-master-file))))
-    (error "Unable to find what command to run.")))
+    (error "Unable to find what command to run")))
 
 (provide 'tex-buf)
 
diff --git a/tex.el b/tex.el
index 24971b8..6bd7a95 100644
--- a/tex.el
+++ b/tex.el
@@ -114,11 +114,11 @@ If nil, none is specified."
   :type 'hook
   :group 'TeX-misc)
 
-;; This is the major configuration variable.  Most sites will only
-;; need to change the second string in each entry, which is the name
-;; of a command to send to the shell.  If you use other formatters
-;; like AMSLaTeX or AMSTeX, you can add those to the list.  See
-;; TeX-expand-list for a description of the % escapes
+;; This is the major configuration variable.  Most sites will only need to
+;; change the second string in each entry, which is the name of a command to
+;; send to the shell.  If you use other formatters like AMSLaTeX or AMSTeX, you
+;; can add those to the list.  See `TeX-expand-list' and
+;; `TeX-expand-list-builtin' for a description of the % escapes
 
 (defcustom TeX-command-list
   `(("TeX" "%(PDF)%(tex) %(file-line-error) %(extraopts) 
%`%S%(PDFout)%(mode)%' %t"
@@ -132,13 +132,13 @@ If nil, none is specified."
      (texinfo-mode) :help "Run Makeinfo with Info output")
     ("Makeinfo HTML" "makeinfo %(extraopts) --html %t" TeX-run-compile nil
      (texinfo-mode) :help "Run Makeinfo with HTML output")
-    ("AmSTeX" "%(PDF)amstex %(extraopts) %`%S%(PDFout)%(mode)%' %t"
+    ("AmSTeX" "amstex %(PDFout) %(extraopts) %`%S%(mode)%' %t"
      TeX-run-TeX nil (ams-tex-mode) :help "Run AMSTeX")
     ;; support for ConTeXt  --pg
     ;; first version of ConTeXt to support nonstopmode: 2003.2.10
-    ("ConTeXt" "texexec --once --texutil %(extraopts) %(execopts)%t"
+    ("ConTeXt" "%(cntxcom) --once --texutil %(extraopts) %(execopts)%t"
      TeX-run-TeX nil (context-mode) :help "Run ConTeXt once")
-    ("ConTeXt Full" "texexec %(extraopts) %(execopts)%t"
+    ("ConTeXt Full" "%(cntxcom) %(extraopts) %(execopts)%t"
      TeX-run-TeX nil
      (context-mode) :help "Run ConTeXt until completion")
     ("BibTeX" "bibtex %s" TeX-run-BibTeX nil t :help "Run BibTeX")
@@ -150,9 +150,14 @@ If nil, none is specified."
     ("Print" "%p" TeX-run-command t t :help "Print the file")
     ("Queue" "%q" TeX-run-background nil t :help "View the printer queue"
      :visible TeX-queue-command)
-    ("File" "%(o?)dvips %d -o %f " TeX-run-command t t
+    ("File" "%(o?)dvips %d -o %f " TeX-run-dvips t t
      :help "Generate PostScript file")
-    ("Index" "makeindex %s" TeX-run-command nil t :help "Create index file")
+    ("Dvips" "%(o?)dvips %d -o %f " TeX-run-dvips nil t
+     :help "Convert DVI file to PostScript")
+    ("Ps2pdf" "ps2pdf %f" TeX-run-ps2pdf nil t
+     :help "Convert PostScript file to PDF")
+    ("Index" "makeindex %s" TeX-run-index nil t
+     :help "Run makeindex to create index file")
     ("Xindy" "texindy %s" TeX-run-command nil t
      :help "Run xindy to create index file")
     ("Check" "lacheck %s" TeX-run-compile nil (latex-mode)
@@ -426,9 +431,8 @@ string."
 ;; TeX-command-list.  Not likely to be changed, but you may e.g. want
 ;; to handle .ps files.
 
-(defcustom TeX-expand-list
-  '(("%p" TeX-printer-query)           ;%p must be the first entry
-    ("%q" (lambda ()
+(defvar TeX-expand-list-builtin
+  '(("%q" (lambda ()
            (TeX-printer-query t)))
     ("%V" (lambda ()
            (TeX-source-correlate-start-server-maybe)
@@ -445,12 +449,17 @@ string."
            (TeX-style-check LaTeX-command-style)))
     ("%(PDF)" (lambda ()
                (if (and (eq TeX-engine 'default)
-                        (or TeX-PDF-mode
-                            TeX-DVI-via-PDFTeX))
+                        (if TeX-PDF-mode
+                            (not TeX-PDF-via-dvips-ps2pdf)
+                          TeX-DVI-via-PDFTeX))
                    "pdf"
                  "")))
     ("%(PDFout)" (lambda ()
-                  (cond ((and (eq TeX-engine 'xetex)
+                  (cond ((eq major-mode 'ams-tex-mode)
+                         (if TeX-PDF-mode
+                             " -output-format=pdf"
+                           " -output-format=dvi"))
+                        ((and (eq TeX-engine 'xetex)
                               (not TeX-PDF-mode))
                          " -no-pdf")
                         ((and (eq TeX-engine 'luatex)
@@ -470,6 +479,7 @@ string."
     ("%(o?)" (lambda () (if (eq TeX-engine 'omega) "o" "")))
     ("%(tex)" (lambda () (eval (nth 2 (assq TeX-engine (TeX-engine-alist))))))
     ("%(latex)" (lambda () (eval (nth 3 (assq TeX-engine 
(TeX-engine-alist))))))
+    ("%(cntxcom)" ConTeXt-expand-command)
     ("%(execopts)" ConTeXt-expand-options)
     ("%(extraopts)" (lambda () TeX-command-extra-options))
     ("%S" TeX-source-correlate-expand-options)
@@ -539,13 +549,31 @@ string."
     ("%a" (lambda nil (prin1-to-string (expand-file-name (buffer-file-name)))))
     ;; the following is for preview-latex.
     ("%m" preview-create-subdirectory))
-  "List of expansion strings for TeX command names.
+  "List of built-in expansion strings for TeX command names.
 
-Each entry is a list with two or more elements.  The first element is
-the string to be expanded.  The second element is the name of a
-function returning the expanded string when called with the remaining
-elements as arguments.  The special value `file' will be expanded to
-the name of the file being processed, with an optional extension."
+This should not be changed by the user who can use
+`TeX-expand-list' variable.  The latter variable also contains a
+description of the data format.
+
+Programs should not use these variables directly but the function
+`TeX-expand-list'.")
+
+(defcustom TeX-expand-list nil
+  "List of expansion strings for TeX command names defined by the user.
+
+Each entry is a list with two or more elements.  The first
+element is the string to be expanded.  The second element is the
+name of a function returning the expanded string when called with
+the remaining elements as arguments.  The special value `file'
+will be expanded to the name of the file being processed, with an
+optional extension.
+
+Built-in expansions provided in `TeX-expand-list-builtin' can be
+overwritten by defining expansions strings with the same
+expander.  Only \"%p\" expander cannot be overwritten.
+
+Programs should not use these variables directly but the function
+`TeX-expand-list'."
   :group 'TeX-command
   :type '(repeat (group (string :tag "Key")
                        (sexp :tag "Expander")
@@ -553,6 +581,16 @@ the name of the file being processed, with an optional 
extension."
                                :tag "Arguments"
                                (sexp :format "%v")))))
 
+(defun TeX-expand-list ()
+  "Complete list of expansion strings for TeX command names.
+
+Concatenate `TeX-expand-list' and `TeX-expand-list-bultin' making
+sure \"%p\" is the first entry."
+  (append
+   ;; %p must be the first entry, see `TeX-print-command'.
+   '(("%p" TeX-printer-query))
+   TeX-expand-list
+   TeX-expand-list-builtin))
 
 ;; The following dependencies are not done with autoload cookies since
 ;; they are only useful when tex.el is loaded, anyway.  tex-buf.el
@@ -566,6 +604,10 @@ the name of the file being processed, with an optional 
extension."
 (autoload 'TeX-command-region "tex-buf" nil t)
 (autoload 'TeX-command-buffer "tex-buf" nil t)
 (autoload 'TeX-command-master "tex-buf" nil t)
+(autoload 'LaTeX-command-section "tex-buf" nil t)
+(autoload 'TeX-command-run-all "tex-buf" nil t)
+(autoload 'TeX-command-run-all-region "tex-buf" nil t)
+(autoload 'LaTeX-command-run-all-section "tex-buf" nil t)
 (autoload 'TeX-command "tex-buf" nil nil)
 (autoload 'TeX-kill-job "tex-buf" nil t)
 (autoload 'TeX-recenter-output-buffer "tex-buf" nil t)
@@ -578,6 +620,26 @@ the name of the file being processed, with an optional 
extension."
 
 ;;; Portability.
 
+(defmacro TeX--if-macro-fboundp (name then &rest else)
+  "Execute THEN if macro NAME is bound and ELSE otherwise.
+Essentially,
+
+  (TeX--if-macro-fboundp name then else...)
+
+is equivalent to
+
+  (if (fboundp 'name) then else...)
+
+but takes care of byte-compilation issues where the byte-code for
+the latter could signal an error if it has been compiled with
+emacs 24.1 and is then later run by emacs 24.5."
+  (declare (indent 2) (debug (symbolp form)))
+  (if (fboundp name)            ;If macro exists at compile-time, just use it.
+      then
+    `(if (fboundp ',name)       ;Else, check if it exists at run-time.
+        (eval ',then)          ;If it does, then run the then code.
+       ,@else)))                ;Otherwise, run the else code.
+
 (require 'easymenu)
 
 (eval-and-compile
@@ -716,18 +778,57 @@ overlays."
 edit-utils >= 2.32 for XEmacs.")))
 
 (if (fboundp 'completing-read-multiple)
-    (defun TeX-completing-read-multiple
-       (prompt table &optional predicate require-match initial-input
-               hist def inherit-input-method)
-      "Like `completing-read-multiple' which see.
+    (if (or (and (= emacs-major-version 24) (>= emacs-minor-version 4))
+           (>= emacs-major-version 25))
+       ;; For GNU Emacs 24.4 or later, based on `completing-read-multiple' of
+       ;; git commit b14abca9476cba2f500b5eda89441d593dd0f12b
+       ;;   2013-01-10  * lisp/emacs-lisp/crm.el: Allow any regexp for 
separators.
+       (defun TeX-completing-read-multiple
+           (prompt table &optional predicate require-match initial-input
+                   hist def inherit-input-method)
+         "Like `completing-read-multiple' which see.
+Retain zero-length substrings but ensure that empty input results
+in nil across different emacs versions."
+         (unwind-protect
+             (progn
+               (add-hook 'choose-completion-string-functions
+                         'crm--choose-completion-string)
+               (let* ((minibuffer-completion-table #'crm--collection-fn)
+                      (minibuffer-completion-predicate predicate)
+                      ;; see completing_read in src/minibuf.c
+                      (minibuffer-completion-confirm
+                       (unless (eq require-match t) require-match))
+                      (crm-completion-table table)
+                      (map (if require-match
+                               crm-local-must-match-map
+                             crm-local-completion-map))
+                      ;; If the user enters empty input, `read-from-minibuffer'
+                      ;; returns the empty string, not DEF.
+                      (input (read-from-minibuffer
+                              prompt initial-input map
+                              nil hist def inherit-input-method))
+                      result)
+                 (and def (string-equal input "") (setq input def))
+                 (if (equal (setq result (split-string input crm-separator))
+                            '(""))
+                     nil
+                   result)))
+           (remove-hook 'choose-completion-string-functions
+                        'crm--choose-completion-string)))
+      ;; For GNU Emacs <= 24.3.
+      (defun TeX-completing-read-multiple
+         (prompt table &optional predicate require-match initial-input
+                 hist def inherit-input-method)
+       "Like `completing-read-multiple' which see.
 Ensures that empty input results in nil across different emacs versions."
-      (let ((result (completing-read-multiple prompt table predicate
-                                             require-match initial-input
-                                             hist def inherit-input-method)))
-       (if (equal result '("")) nil result)))
+       (let ((result (completing-read-multiple prompt table predicate
+                                               require-match initial-input
+                                               hist def inherit-input-method)))
+         (if (equal result '("")) nil result))))
+  ;; For XEmacs.
   (defun TeX-completing-read-multiple
-    (prompt table &optional predicate require-match initial-input
-           hist def inherit-input-method)
+      (prompt table &optional predicate require-match initial-input
+             hist def inherit-input-method)
     "Poor mans implementation of Emacs' `completing-read-multiple' for XEmacs.
 The XEmacs package edit-utils-2.32 includes `crm.el'."
     (multi-prompt (if (boundp 'crm-separator) crm-separator ",") nil prompt
@@ -1276,13 +1377,6 @@ restarting Emacs."
             (repeat :tag "List of executables" (string :tag "Name"))
             (const :tag "No executable" nil)))))
 
-;; XXX: Regarding a possibility to (manually) run an update command,
-;; one could support this through `TeX-view' by letting it temporarily
-;; set a variable which is checked with a predicate in the viewer
-;; selection.  If the check is positive, the update command is run
-;; instead of the normal viewer command.  Direct support through the
-;; View command would require a predicate which knows when an update
-;; has to be done.
 (defcustom TeX-view-program-selection
   (cond
    ((eq system-type 'windows-nt)
@@ -1930,6 +2024,20 @@ already established, don't do anything."
   :group 'TeX-command
   :type 'boolean)
 
+(defcustom TeX-PDF-via-dvips-ps2pdf nil
+  "Whether to produce PDF output through the (La)TeX - dvips - ps2pdf 
sequence."
+  :group 'TeX-command
+  :type 'boolean)
+(make-variable-buffer-local 'TeX-PDF-via-dvips-ps2pdf)
+(put 'TeX-PDF-via-dvips-ps2pdf 'safe-local-variable 'booleanp)
+
+(defun TeX-toggle-PDF-via-dvips-ps2pdf ()
+  "Toggle `TeX-PDF-via-dvips-ps2pdf'."
+  (interactive)
+  (setq TeX-PDF-via-dvips-ps2pdf (not TeX-PDF-via-dvips-ps2pdf))
+  (message (concat "TeX-PDF-via-dvips-ps2pdf: "
+                  (if TeX-PDF-via-dvips-ps2pdf "on" "off"))))
+
 (define-minor-mode TeX-interactive-mode
   "Minor mode for interactive runs of TeX."
   nil nil nil
@@ -2050,7 +2158,6 @@ output files."
            (delete-file (concat master-dir file))))
       (message "No files to be deleted"))))
 
-
 ;;; Master File
 
 (defcustom TeX-master t
@@ -3362,7 +3469,7 @@ The algorithm is as follows:
                       (regexp-quote TeX-esc)
                       "\\)*\\)\\(%+ *\\)"))
                     (entry TeX-format-list)
-                    answer)
+                    answer case-fold-search)
                 (while (and entry (not answer))
                   (if (re-search-forward (nth 2 (car entry))
                                          10000 t)
@@ -3373,6 +3480,15 @@ The algorithm is as follows:
                     answer
                   TeX-default-mode))))))
 
+(when (and (boundp 'tex--prettify-symbols-alist)
+          (boundp 'prettify-symbols-compose-predicate))
+  (defun TeX--prettify-symbols-compose-p (start end match)
+    (and (tex--prettify-symbols-compose-p start end match)
+        (not (let ((face (get-text-property end 'face)))
+               (if (consp face)
+                   (memq 'font-latex-verbatim-face face)
+                 (eq face 'font-latex-verbatim-face)))))))
+
 (defun VirTeX-common-initialization ()
   "Perform basic initialization."
   (kill-all-local-variables)
@@ -3439,14 +3555,13 @@ The algorithm is as follows:
     (TeX-source-correlate-mode 1))
 
   ;; Prettify Symbols mode
-  (when (and (boundp 'tex--prettify-symbols-alist)
-            (boundp 'prettify-symbols-compose-predicate))
+  (when (fboundp 'TeX--prettify-symbols-compose-p)
     (set (make-local-variable 'prettify-symbols-alist) 
tex--prettify-symbols-alist)
-    (if (fboundp 'add-function)
+    (TeX--if-macro-fboundp add-function
        (add-function :override (local 'prettify-symbols-compose-predicate)
-                     #'tex--prettify-symbols-compose-p)
+                     #'TeX--prettify-symbols-compose-p)
       (set (make-local-variable 'prettify-symbols-compose-predicate)
-          #'tex--prettify-symbols-compose-p)))
+          #'TeX--prettify-symbols-compose-p)))
 
   ;; Let `TeX-master-file' be called after a new file was opened and
   ;; call `TeX-update-style' on any file opened.  (The addition to the
@@ -4200,10 +4315,11 @@ non-nil, remove file extension."
                   (if (string-match ";" dirs) ";" ":")))
           (unless TeX-kpathsea-path-delimiter
             (throw 'no-kpathsea nil))
-          (setq dirs (delete "" (split-string
-                                 dirs (concat "[\n\r"
-                                              TeX-kpathsea-path-delimiter
-                                              "]+"))))
+          (setq dirs (TeX-delete-duplicate-strings
+                      (delete "" (split-string
+                                  dirs (concat "[\n\r"
+                                               TeX-kpathsea-path-delimiter
+                                               "]+")))))
           (if (eq scope 'global)
               (delete "." dirs))
           (setq extensions (concat "\\." (regexp-opt extensions t) "\\'")
@@ -4667,6 +4783,7 @@ Brace insertion is only done if point is in a math 
construct and
     (define-key map "\C-c\C-r" 'TeX-command-region)
     (define-key map "\C-c\C-b" 'TeX-command-buffer)
     (define-key map "\C-c\C-c" 'TeX-command-master)
+    (define-key map "\C-c\C-a" 'TeX-command-run-all)
     (define-key map "\C-c\C-k" 'TeX-kill-job)
     (define-key map "\C-c\C-l" 'TeX-recenter-output-buffer)
     (define-key map "\C-c^" 'TeX-home-buffer)
@@ -4752,6 +4869,10 @@ Brace insertion is only done if point is in a math 
construct and
         :style toggle :selected TeX-PDF-mode
         :active (not (eq TeX-engine 'omega))
         :help "Use PDFTeX to generate PDF instead of DVI"]
+       [ "PDF via dvips + ps2pdf" TeX-toggle-PDF-via-dvips-ps2pdf
+        :style toggle :selected TeX-PDF-via-dvips-ps2pdf
+        :visible TeX-PDF-mode
+        :help "Compile with (La)TeX and convert to PDF with dvips + ps2pdf"]
        [ "Run Interactively" TeX-interactive-mode
         :style toggle :selected TeX-interactive-mode :keys "C-c C-t C-i"
         :help "Stop on errors in a TeX run"]
@@ -4763,7 +4884,9 @@ Brace insertion is only done if point is in a math 
construct and
        :help "Make \"Next Error\" show overfull and underfull boxes"]
        ["Debug Warnings" TeX-toggle-debug-warnings
        :style toggle :selected TeX-debug-warnings
-       :help "Make \"Next Error\" show warnings"])))
+       :help "Make \"Next Error\" show warnings"])
+      ["Compile and view" TeX-command-run-all
+       :help "Compile the document until it is ready and open the viewer"]))
    (let ((file 'TeX-command-on-current)) ;; is this actually needed?
      (TeX-maybe-remove-help
       (delq nil
@@ -6073,13 +6196,12 @@ NAME may be a package, a command, or a document."
          (dolist (elt docs)
            (setq completions (nconc (mapcar 'list (car elt)) completions)))
          ;; Query user.
-         (setq doc (completing-read
-                    (if contained
-                        (format "Package, command, or document (default %s): "
-                                symbol)
-                      "Package, command, or document: ")
-                    completions))
-         (setq name (if (string= doc "") symbol doc))))
+         (setq name (completing-read
+                     (if contained
+                         (format "Package, command, or document (default %s): "
+                                 symbol)
+                       "Package, command, or document: ")
+                     completions nil nil nil nil symbol))))
       (if (not name)
          (message "No documentation specified")
        ;; XXX: Provide way to choose in case a symbol can be found in



reply via email to

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