auctex-diffs
[Top][All Lists]
Advanced

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

main baefcc7a 003/257: Sync with AUCTeX-11.87.


From: Tassilo Horn
Subject: main baefcc7a 003/257: Sync with AUCTeX-11.87.
Date: Fri, 19 Apr 2024 15:36:09 -0400 (EDT)

branch: main
commit baefcc7a81766c9ad1858f5d1408315e4a28f135
Merge: 6a8879c1 a90c0a22
Author: Stefan Monnier <monnier@iro.umontreal.ca>
Commit: Stefan Monnier <monnier@iro.umontreal.ca>

    Sync with AUCTeX-11.87.
---
 ChangeLog                        | 730 ++++++++++++++++++++++++++++
 ChangeLog-preview                |  19 +
 Makefile.in                      | 235 +++++----
 RELEASE                          |  56 +--
 autogen.sh                       |   2 +-
 configure.ac                     |   2 +-
 context-en.el                    |   4 +
 context-nl.el                    |  10 +
 context.el                       |  35 +-
 doc/auctex.texi                  | 324 ++++++++++++-
 doc/changes.texi                 |  35 +-
 doc/faq.texi                     |  65 +--
 doc/install.texi                 |  18 +-
 doc/macros.texi                  |   7 +-
 doc/preview-dtxdoc.pl            |   6 +-
 doc/preview-latex.texi           |   5 +-
 doc/quickstart.texi              |  14 +-
 doc/tex-ref.tex                  |  13 +-
 doc/wininstall.texi              |  11 +-
 font-latex.el                    |  63 ++-
 latex.el                         | 311 ++++++++----
 plain-tex.el                     | 314 ++++++++++++
 preview.el                       |  36 +-
 style/beamer.el                  |   4 +-
 style/{polski.el => biblatex.el} |  41 +-
 style/bulgarian.el               |   4 +-
 style/czech.el                   |   3 +-
 style/danish.el                  |   5 +-
 style/doc.el                     | 190 ++++----
 style/{polski.el => french.el}   |  42 +-
 style/frenchb.el                 |  13 +-
 style/german.el                  |   7 +-
 style/harvard.el                 |  31 +-
 style/icelandic.el               |   3 +-
 style/letter.el                  |  26 +-
 style/lettrine.el                |  74 +++
 style/multicol.el                |  62 +++
 style/natbib.el                  |  29 +-
 style/ngerman.el                 |   9 +-
 style/polish.el                  |   3 +-
 style/polski.el                  |   3 +-
 style/setspace.el                |  61 +++
 style/slovak.el                  |   3 +-
 style/swedish.el                 |   5 +-
 style/virtex.el                  |   5 +-
 style/{polski.el => xspace.el}   |  47 +-
 tex-buf.el                       | 184 ++++---
 tex-fold.el                      |  23 +-
 tex-fptex.el                     |  91 ----
 tex-info.el                      | 249 +++++++++-
 tex-jp.el                        | 281 +++++++++--
 tex-style.el                     |   7 +
 tex.el                           | 999 ++++++++++++++++++++-------------------
 53 files changed, 3563 insertions(+), 1256 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 365e7880..6e04837b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,733 @@
+2012-12-04  Tassilo Horn  <tsdh@gnu.org>
+
+       Merge revno 314 (Stefan Monnier) from emacs elpa branch: Shorten
+       copyright year ranges.
+
+       * context.el:
+
+       * doc/auctex.texi:
+
+       * doc/changes.texi:
+
+       * doc/install.texi:
+
+       * font-latex.el:
+
+       * latex.el:
+
+       * style/letter.el:
+
+       * tex-fold.el:
+
+       * tex-jp.el:
+
+       * tex.el:
+
+2012-11-30  Ralf Angeli <angeli@caeruleus.net>
+
+       * Version 11.87 released.
+
+2012-11-30  Ralf Angeli  <angeli@caeruleus.net>
+
+       * tex.el (TeX-evince-dbus-p): Make last change a little more
+       conventional.
+
+2012-11-30  Tassilo Horn  <tsdh@gnu.org>
+
+       * tex.el (TeX-evince-dbus-p): Check for feature emacs in order not
+       to signal an error on XEmacs.
+
+2012-11-29  Ralf Angeli  <angeli@caeruleus.net>
+
+       * RELEASE, configure.ac, doc/auctex.texi, doc/changes.texi,
+       doc/install.texi, doc/tex-ref.tex: Update for upcoming release.
+
+2012-11-26  Ralf Angeli  <angeli@caeruleus.net>
+
+       * latex.el (LaTeX-split-bibs): Add doc string and use variable for
+       Biber file extensions.
+       (LaTeX-search-files-type-alist): Add entry for Biber.
+       (BibTeX-Biber-global-files): Remove.
+       (BibTeX-global-files): Reintroduce.
+       (TeX-Biber-global-files): New variable.
+       (TeX-arg-bibliography): Check if Biber or BibTeX is used and react
+       accordingly.
+
+       * tex-buf.el (TeX-check-files): Do not check duplicate extensions.
+       (TeX-command-query, TeX-LaTeX-sentinel): Use separate variables
+       for BibTeX and Biber file extensions.
+       (TeX-synchronous-sentinel): Use `let' instead of `let*'.
+
+       * tex.el (TeX-clean-default-intermediate-suffixes): Add suffixes
+       for biblatex.
+       (TeX-auto-generate, TeX-auto-generate-global): Use separate
+       variables for BibTeX and Biber file extensions.
+       (TeX-Biber-file-extensions): New variable.
+       (BibTeX-Biber-file-extensions): Remove.
+       (BibTeX-file-extensions): Reintroduce.
+       (TeX-search-files-type-alist): Use `BibTeX-file-extensions'.
+       (TeX-normal-mode): Use separate variables for BibTeX and Biber
+       global files.
+
+2012-07-17  Vincent Bela�che  <vincentb1@users.sourceforge.net>
+
+       * tex-info.el (Texinfo-reftex-hook): Added function.
+       (TeX-texinfo-mode): Added RefTeX plugging.
+
+2012-11-23  Tassilo Horn  <tsdh@gnu.org>
+
+       * doc/quickstart.texi (Quick Start): Document that one mustn't
+       load auctex.el if AUCTeX is installed from ELPA.
+
+       * doc/install.texi (Installation): Mention installation from ELPA.
+
+2012-11-20  Davide G. M. Salvetti  <salve@debian.org>
+
+        * doc/tex-ref.tex (column{preview-latex}): Fix typo.  Reported by
+        S�bastien Villemot.  Update copyright information.
+
+2012-11-14  Ralf Angeli  <angeli@caeruleus.net>
+
+       * latex.el (LaTeX-auto-regexp-list): Remove entries for Biber.
+       (LaTeX-biber): Remove.
+       (LaTeX-listify-package-options): Rewrite so that the function can
+       deal with key=value pairs.
+       (LaTeX-always-use-Biber): Remove.
+       (LaTeX-using-Biber): Add doc string and make buffer-local.
+
+       * tex-style.el (LaTeX-biblatex-use-Biber): New variable.
+
+       * doc/auctex.texi (top): Remove reference to
+       `LaTeX-always-use-Biber'.
+       (Selecting a Command): Mention Biber and
+       `LaTeX-biblatex-use-Biber'.
+
+       * Makefile.in (STYLESRC): Add style/biblatex.el.
+
+       * style/biblatex.el: New file.
+
+2012-11-05  Tassilo Horn  <tsdh@gnu.org>
+
+       * tex.el (TeX-doc-extensions): Fix typo.  This variable was
+       formerly named TeX-doc-extenstions.
+
+2012-10-04  Masayuki Ataka  <masayuki.ataka@gmail.com>
+
+       * tex-jp.el: Repair coding from iso-2022-7bit to iso-2022-jp.
+
+2012-10-03  Ralf Angeli  <angeli@caeruleus.net>
+
+       * tex-jp.el: Repair coding.
+
+2012-10-02  Ikumi Keita         <ikumi@ikumi.que.jp>
+
+       * tex-jp.el (japanese-TeX-engine-default)
+       (TeX-engine-alist-builtin, japanese-TeX-use-kanji-opt-flag): New
+       defcustoms.
+       (japanese-TeX-coding-ejsu, japanese-TeX-get-encoding-string): New
+       functions.
+       (japanese-TeX-command-list): Support %(kanjiopt).
+       (TeX-expand-list): Support new option kanjiopt, bibtex, makeindex,
+       mendexkopt, xdvi.
+       (TeX-view-predicate-list-builtin): Judge paper.
+       (TeX-view-program-list): Support dviout paper size, and other DVI
+       previewers in Mac and others.
+       (TeX-view-program-selection): Add Dviout, TeXworks and Preview.
+       (LaTeX-command-style): Support uplatex.
+       (japanese-plain-tex-mode-initialization): Use TeX-engine-set.
+       (japanese-latex-mode-initialization): Ditto.
+
+       * tex-jp.el: Comment fix.
+       (TeX-error-description-list): Doc fix.
+
+2012-09-27  Joost Kremers  <joostkremers@fastmail.fm>  (tiny change)
+
+       * tex-buf.el (TeX-check-files): Use mapcar instead of cl's map.
+
+2012-09-16 Philip Kime  <Philip@kime.org.uk>  (tiny change)
+
+       * tex-buf.el (TeX-LaTeX-sentinel): Detect generic rerun message
+       from biblatex
+
+2012-09-14  Ken Brown  <kbrown@cornell.edu>  (tiny change)
+
+       * doc/auctex.texi (top): Mention LaTeX-always-use-Biber.
+
+       * doc/tex-ref.tex: Add Biber.
+
+2012-09-13  Tassilo Horn  <tsdh@gnu.org>
+
+       Merge Biber support developed by Philip Kime
+       <philkime@kime.org.uk>.
+       * doc/changes.texi: Mention Biber support.
+
+       * tex.el (TeX-command-list, TeX-auto-generate)
+       (TeX-auto-generate-global, TeX-search-files-type-alist)
+       (TeX-normal-mode): Adapt.
+       (TeX-command-Biber): New defcustom.
+       (BibTeX-Biber-file-extensions): Renamed from
+       BibTeX-file-extensions.
+
+       * tex-buf.el (TeX-save-document, TeX-check-files)
+       (TeX-command-query, TeX-LaTeX-sentinel): Adapt.
+       (TeX-Biber-sentinel, TeX-run-Biber): New functions.
+
+       * latex.el (LaTeX-auto-regexp-list, LaTeX-auto-cleanup)
+       (TeX-arg-bibliography, LaTeX-common-initialization): Adapt.
+       (LaTeX-biber, LaTeX-split-bibs, LaTeX-using-Biber)
+       (LaTeX-always-use-Biber): New functions and vars.
+       (BibTeX-Biber-global-files): Renamed from BibTeX-global-files.
+
+       * font-latex.el (font-latex-built-in-keyword-classes)
+       (font-latex-add-keywords): Adapt.
+
+2012-06-21  Patrice Dumas  <pertusus@free.fr>  (tiny change)
+
+       * doc/preview-latex.texi (The preview images): Place index command
+       `@pindex dvipng' on a line of its own.
+
+       * doc/macros.texi: Replace user macro `@sans' by user macro
+       `@sansserif' and make definition conditional against flag
+       no-sansserif as `@sansserif' is a Texinfo macro and does not need
+       to be redefined.
+
+       * doc/macros.texi: Suppress user macro `@LaTeX' as this macro is
+       already defined in Texinfo.
+
+       * doc/quickstart.texi (Editing Facilities): Use texinfo
+       `@sansserif' macro rather than user macro `@sans'.
+
+       * doc/auctex.texi (Font Specifiers): Use texinfo `@sansserif'
+       macro rather than user macro `@sans'.
+
+2012-08-14  Ralf Angeli  <angeli@caeruleus.net>
+
+       * tex.el (TeX-source-correlate-determine-method): Match --synctex
+       as well as -synctex.
+
+2012-07-04  Tassilo Horn  <tassilo@member.fsf.org>
+
+       * doc/changes.texi: Mention Evince forward/backward search
+       changes.
+
+2012-07-03  Tassilo Horn  <tassilo@member.fsf.org>
+
+       * font-latex.el (byte-code-function-p): Reference the generated
+       functions with font-latex-match prefix.  See Emacs bug 11837.
+
+2012-06-22  Tassilo Horn  <tassilo@member.fsf.org>
+
+       * tex.el (TeX-evince-dbus-p): Add check for
+       `dbus-register-signal', which might be unavailable if emacs was
+       configured with --without-dbus.
+
+2012-04-26  Tassilo Horn  <tassilo@member.fsf.org>
+
+       * tex.el (TeX-engine-set): Fix docstring leading to a misplaced
+       interactive spec warning.
+
+2012-04-25  Tassilo Horn  <tassilo@member.fsf.org>
+
+       * tex.el (TeX-evince-dbus-p): Improve check for emacs's dbus
+       support.
+
+2012-04-11  Tassilo Horn  <tassilo@member.fsf.org>
+
+       * tex.el (TeX-evince-sync-view): Work around emacs integer limits.
+       Also provide the current column to Evince.
+       (TeX-evince-dbus-p): Also check the signature of Evince's
+       FindDocument DBUS method, which is only stable since evince 3.0.
+
+2012-04-10  Tassilo Horn  <tassilo@member.fsf.org>
+
+       * tex.el (TeX-evince-sync-view): Fix arithmetic range error.
+       (TeX-evince-dbus-p): Add parameter to extend the check depending
+       on wanted features (e.g., forward search).
+       (TeX-view-program-list-builtin): Use it.
+
+2012-04-08  Tassilo Horn  <tassilo@member.fsf.org>
+
+       * tex.el (TeX-evince-dbus-p): New function.
+       (TeX-evince-sync-view): New function.
+       (TeX-view-program-list-builtin): Use Evince's DBUS interface for
+       forward search if available.
+       (TeX-source-correlate-mode): Use TeX-evince-dbus-p.
+
+2012-01-11  Ralf Angeli  <angeli@caeruleus.net>
+
+       * style/setspace.el ("setspace"): Correct quoting.
+
+2011-09-18  Ralf Angeli  <angeli@caeruleus.net>
+
+       * doc/auctex.texi (Marking): Make a few corrections throughout the
+       section.
+       (Adding Macros): Document special values for numbers used together
+       with `TeX-add-symbols'.
+
+2011-09-18  Vincent Bela�che  <vincentb1@users.sourceforge.net>
+
+       * doc/auctex.texi: Add documentation for functions
+       LaTeX-mark-section, LaTeX-mark-environment, Texinfo-mark-section,
+       Texinfo-mark-environment and Texinfo-mark-node.
+
+2011-08-24  Tassilo Horn  <tassilo@member.fsf.org>
+
+       * tex.el (TeX-synctex-output-page): TeXLive 2011's synctex wants
+       absolute file names with dot indicating the master, like
+       /foo/bar/./baz/chap1.tex.  So add this as another variant.
+       (TeX-view-program-list-builtin): Use evince's -i,--page-index
+       switch instead of -p,--page-label if that evince version supports
+       it (>=3.0.x).
+
+2011-08-07  Ralf Angeli  <angeli@caeruleus.net>
+
+       * latex.el (LaTeX-fill-move-to-break-point): Take characters after
+       closing dollar sign into account when deciding to break before
+       inline math.
+
+2011-07-12  Ralf Angeli  <angeli@caeruleus.net>
+
+       * tex.el (TeX-search-files-kpathsea): Check if directories are
+       accessible.
+
+2011-07-11  Vincent Bela�che  <vincentb1@users.sourceforge.net>
+
+       * tex-info.el (Texinfo-mark-environment, Texinfo-mark-section)
+       (Texinfo-mark-node): New defun.
+       (Texinfo-mode-map): added key bindings for
+       Texinfo-mark-environment, Texinfo-mark-section, and
+       Texinfo-mark-node.
+
+2011-06-19  Ralf Angeli  <angeli@caeruleus.net>
+
+       * tex.el (TeX-engine-alist-builtin): Add --jobname to luatex and
+       lualatex calls.
+       (TeX-engine-alist-builtin): Remove --jobname again for luatex but
+       not for lualatex.
+
+2011-06-05  Tassilo Horn  <tassilo@member.fsf.org>
+
+       * tex.el (TeX-source-correlate-sync-source): Restore Emacs 21
+       compatibility.
+
+2011-05-26  Tassilo Horn  <tassilo@member.fsf.org>
+
+       * tex.el (TeX-source-correlate-sync-source): Adapt to handle
+       file:// URLs.
+
+2011-05-15  Ralf Angeli  <angeli@caeruleus.net>
+
+       * Makefile.in (STYLESRC): Add style/setspace.el.
+
+       * tex.el (TeX-expand-list): Add a safeguard to the %(outpage)
+       expander for when an output page function returns nil.
+
+2011-05-09  Tassilo Horn  <tassilo@member.fsf.org>
+
+       * tex.el (TeX-synctex-output-page-1): New function for calling
+       synctex.
+       (TeX-synctex-output-page): Use it, and try relative file names
+       with and without leading ./ when calling synctex before falling
+       back to page 1.
+       (TeX-source-correlate-sync-source): Add &rest parameter, because
+       Evince 3 sends an additional (ignored) parameter via dbus.
+
+2011-05-01  Ralf Angeli  <angeli@caeruleus.net>
+
+       * tex.el (TeX-tree-expand): Use a different test to check for an
+       absolute path on Windows.
+
+       * font-latex.el (font-latex-built-in-keyword-classes): Add
+       definition for \rule and remove the one for \sbox.
+
+2011-04-25  Ralf Angeli  <angeli@caeruleus.net>
+
+       * style/setspace.el: Add support for changing \displayskipstretch.
+
+2011-04-25  Mads Jensen  <mje@inducks.org>
+
+       * style/setspace.el: New file.
+
+2011-04-25  Ralf Angeli  <angeli@caeruleus.net>
+
+       * latex.el (LaTeX-style-list): Add memoir.
+
+2011-04-20  Ralf Angeli  <angeli@caeruleus.net>
+
+       * tex-fold.el (TeX-fold-expand-spec): Make sure the expansion of a
+       placeholder is not processed again.
+
+2011-04-15  Ralf Angeli  <angeli@caeruleus.net>
+
+       * font-latex.el (font-latex-built-in-keyword-classes): Make a few
+       additions and corrections.
+
+       * latex.el (LaTeX-common-initialization): Prompt for file
+       extension instead of name when inserting \addcontentsline or
+       \addtocontents.
+
+2011-04-10  Ralf Angeli  <angeli@caeruleus.net>
+
+       * tex.el (TeX-source-correlate-mode): Check for D-Bus session.
+
+2011-04-10  Antoine Levitt  <antoine.levitt@gmail.com>  (tiny change)
+
+       * tex.el (TeX-source-correlate-sync-source): Do not use
+       `goto-line'.
+
+2011-04-03  Ralf Angeli  <angeli@caeruleus.net>
+
+       * Makefile.in (STYLESRC): Add style/xspace.el.
+
+       * style/xspace.el: Add copyright notice and license blurb.
+       Correct a few things.
+
+2011-04-03  Mads Jensen  <mje@inducks.org>
+
+       * style/xspace.el: New file.
+
+2011-03-27  Tassilo Horn  <tassilo@member.fsf.org>
+
+       * tex.el (TeX-source-correlate-mode): Add support for I/O
+       correlation mode inverse search for the Evince document viewer.
+
+2011-03-23  Ralf Angeli  <angeli@caeruleus.net>
+
+       * style/bulgarian.el, style/czech.el, style/danish.el,
+       style/frenchb.el, style/icelandic.el, style/polish.el,
+       style/polski.el, style/slovak.el, style/swedish.el: Do not set
+       `TeX-quote-language' if `override' is in effect.
+
+2011-03-20  Ralf Angeli  <angeli@caeruleus.net>
+
+       * tex-buf.el (TeX-synchronous-sentinel): Strip directory part of
+       master file because we are already in the master directory.
+
+2011-03-13  Ralf Angeli  <angeli@caeruleus.net>
+
+       * Makefile.in (STYLESRC): Add style/lettrine.el and
+       style/multicol.el.
+
+       * style/lettrine.el: Add copyright notice and license blurb.
+       Correct a few things.
+
+       * style/multicol.el: Add copyright notice and license blurb.
+       Simplify environment definitions.  Provide completion for lengths
+       the package defines.  Get rid of indentation and filling barrier.
+       Remove fontification definitions.
+
+2011-03-13  Mads Jensen  <mje@inducks.org>
+
+       * style/lettrine.el: New file.
+
+       * style/multicol.el: New file.
+
+2011-02-27  Ralf Angeli  <angeli@caeruleus.net>
+
+       * latex.el (LaTeX-common-initialization): Add support for
+       \ProvidesPackage.
+
+2011-02-06  Ralf Angeli  <angeli@caeruleus.net>
+
+       * style/letter.el (LaTeX-env-recipient): Use \renewcommand instead
+       of \def to set date.
+
+2011-01-30  Ralf Angeli  <angeli@caeruleus.net>
+
+       * tex.el (TeX-parse-macro): Do not insert braces if the argument
+       is 0 or less.
+       (TeX-parse-argument): Put both the macro and the marked region in
+       a TeX group if the argument is less than 0.
+
+       * latex.el (LaTeX-common-initialization): Give macros that change
+       font size a -1 argument so that braces are added around them if
+       if there is an active region.
+
+       * doc/auctex.texi (Adding Macros): Document special options 0 and
+       -1 for number-type specs.
+
+2011-01-29  Ralf Angeli  <angeli@caeruleus.net>
+
+       * tex.el (TeX-complete-symbol): Get rid of the window with the
+       completions when possible.
+
+2011-01-23  Ralf Angeli  <angeli@caeruleus.net>
+
+       * tex-fold.el (TeX-fold-post-command): Add `forward-char' and
+       `backward-char' to commands on which to open an overlay.
+
+       * doc/auctex.texi (Adding Macros): Mention
+       `TeX-arg-input-file-search'.
+
+2011-01-22  Ralf Angeli  <angeli@caeruleus.net>
+
+       * tex.el (TeX-tree-expand): Make `subdirs' parameter optional.  Do
+       not try to call kpsewhich with --expand-braces anymore and adapt
+       code for handling of results accordingly.
+       (TeX-doc-extenstions): New variable.
+       (TeX-tree-roots): New function.
+       (TeX-tree-roots): New user option.
+       (TeX-kpathsea-format-alist): Remove.
+       (TeX-search-files-kpathsea): Add and use `extensions' and `scope'
+       parameters.
+       (TeX-search-files): Do not call `TeX-search-files-kpathsea'
+       anymore.
+       (TeX-search-files-type-alist): New variable.
+       (TeX-search-files-by-type): New function.
+
+       * latex.el (LaTeX-arg-usepackage): Let-bind
+       `TeX-input-file-search'.
+       (LaTeX-search-files-type-alist): New user option.
+       (TeX-arg-input-file-search): Doc fix.
+       (TeX-arg-input-file, TeX-arg-bibstyle, TeX-arg-bibliography): Use
+       `TeX-search-files-by-type' instead of `TeX-search-files'.
+       (LaTeX-common-initialization): Set `TeX-search-files-type-alist'.
+
+2011-01-09  Ralf Angeli  <angeli@caeruleus.net>
+
+       * latex.el (LaTeX-common-initialization): Add support for
+       \settoheight and \settodepth.
+
+2010-12-26  Ralf Angeli  <angeli@caeruleus.net>
+
+       * doc/auctex.texi (Simple Style): Add a note about the naming of
+       the style file and the style hook.
+
+2010-12-12  Ralf Angeli  <angeli@caeruleus.net>
+
+       * latex.el (LaTeX-env-args): Add the optional argument at the
+       right position when wrapping the environment around existing text.
+
+2010-12-05  Ralf Angeli  <angeli@caeruleus.net>
+
+       * context.el: Set up abbrev table.
+       (ConTeXt-mode-common-initialization): Set `local-abbrev-table'.
+
+       * latex.el: Set up abbrev table for LaTeX and docTeX mode.
+       (docTeX-mode): Set abbrev table.
+       (LaTeX-common-initialization): Set `local-abbrev-table'.
+
+       * plain-tex.el: Set up abbrev table.
+       (plain-TeX-common-initialization): Set `local-abbrev-table'.
+
+       * tex.el (TeX-mode-prefix): Add mode parameter.
+       (VirTeX-common-initialization): Do not set `local-abbrev-table'
+       anymore.
+       (TeX-abbrev-mode-setup): New function.
+
+       * doc/changes.texi: Mention change of abbrev handling.
+
+2010-12-04  Ralf Angeli  <angeli@caeruleus.net>
+
+       * latex.el (LaTeX-verbatim-macro-boundaries): Support verbatim
+       macros with braces.
+
+2010-12-04  Augusto Ritter Stoffel  <arstoffel@inf.ufrgs.br>  (tiny change)
+
+       * latex.el (LaTeX-math-keymap): Define a key for the math prefix
+       only if it has not been used as a prefix after the prefix.
+
+2010-11-16  Ralf Angeli  <angeli@caeruleus.net>
+
+       * tex.el (TeX-view-program-list-builtin): Add Okular.
+
+2010-10-17  Ralf Angeli  <angeli@caeruleus.net>
+
+       * latex.el (TeX-arg-input-file-search): New user option.
+       (TeX-arg-input-file): Use it.
+
+2010-10-11  Ralf Angeli  <angeli@caeruleus.net>
+
+       * tex.el (TeX-synctex-output-page): Return "1" if no page number
+       can be found to prevent an infinite loop in command expansion.
+
+2010-10-02  Ralf Angeli  <angeli@caeruleus.net>
+
+       * style/beamer.el ("beamer"): Prompt for block title.
+
+2010-09-28  Ralf Angeli  <angeli@caeruleus.net>
+
+       * context.el (ConTeXt-extra-paragraph-commands): Remove.
+       (ConTeXt-language-variable-list): Add
+       `ConTeXt-extra-paragraph-commands'.
+
+       * context-en.el (ConTeXt-extra-paragraph-commands-en): New
+       variable.
+
+       * context-nl.el (ConTeXt-extra-paragraph-commands-nl): New
+       variable.
+
+2010-09-18  Ralf Angeli  <angeli@caeruleus.net>
+
+       * context.el (ConTeXt-expand-options): Eval value from engine
+       alist.
+
+2010-09-12  Ralf Angeli  <angeli@caeruleus.net>
+
+       * tex-fptex.el: Remove.
+
+       * Makefile.in (AUCSRC): Reflect removal of tex-fptex.el.
+
+       * doc/wininstall.texi: Reflect removal of tex-fptex.el.
+
+       * style/virtex.el: Mention author.  Do not unnecessarily protect
+       `lambda' with `function'.
+
+       * font-latex.el (font-latex-keyword-matcher): Refine last change
+       to work properly with lists of face symbols.
+
+2010-09-11  Ralf Angeli  <angeli@caeruleus.net>
+
+       * style/natbib.el: Update copyright information.
+
+       * style/letter.el: Update copyright information.
+
+       * style/harvard.el: Update copyright information.
+
+       * style/doc.el: Do not unnecessarily protect `lambda' with
+       `function'.
+
+2010-09-06  Arne J�rgensen  <arne@arnested.dk>
+
+       * style/danish.el: Changed font-latex-add-quotes from french to
+       german.
+
+2010-08-30  Ralf Angeli  <angeli@caeruleus.net>
+
+       * style/ngerman.el: Prevent "| from leading to color bleed.
+
+       * style/german.el: Prevent "| from leading to color bleed.
+
+2010-08-29  Ralf Angeli  <angeli@caeruleus.net>
+
+       * doc/preview-dtxdoc.pl: Use explicit variable with split instead
+       of implicit split to @_ which does not work anymore in Perl 5.12.
+
+2010-07-11  Ralf Angeli  <angeli@caeruleus.net>
+
+       * tex-info.el: Delete trailing whitespace.
+
+2010-07-04  Ralf Angeli  <angeli@caeruleus.net>
+
+       * doc/faq.texi: Update infos about Emacs versions.  Add FAQ entry
+       for file:line:error messages in case `TeX-next-error' fails due to
+       unbalanced parens.
+
+       * tex.el (TeX-print-command, TeX-queue-command)
+       (TeX-printer-list): Switch back to Berkeley-style commands.
+
+2010-06-24  Ralf Angeli  <angeli@caeruleus.net>
+
+       * doc/auctex.texi (Texinfo mode): Make a few corrections.
+
+2010-06-19  Berend de Boer  <berend@pobox.com>
+
+       * context.el: proper indent of all macros that can appear inside
+       an itemize list such as \sym.
+
+2010-06-12  Ralf Angeli  <angeli@caeruleus.net>
+
+       * tex-info.el (Texinfo-find-env-end, Texinfo-find-env-start):
+       Enable the commands to be used repeatedly without getting stuck at
+       an environment start or end respectively.
+
+2010-05-27  Ralf Angeli  <angeli@caeruleus.net>
+
+       * autogen.sh: Set LANG=C when looking into ChangeLog for
+       AUCTEXDATE.
+
+2010-05-24  Vincent Bela�che  <vincent.belaiche@gmail.com>
+
+       * doc/auctex.texi (Texinfo mode): New section.
+
+2010-05-17  Ralf Angeli  <angeli@caeruleus.net>
+
+       * tex.el (TeX-math-input-method-off-regexp): Fix regexp.
+
+2010-04-25  Ralf Angeli  <angeli@caeruleus.net>
+
+       * tex.el (TeX-print-command): Support printing of Postscript and
+       PDF files.  Doc fix.
+       (TeX-queue-command): Use lpstat instead of lpq.  Doc fix.
+       (TeX-printer-list): Support printing of Postscript and PDF files.
+       Make use of System V style commands (lp, lpstat) instead of
+       Berkeley style (lpr, lpq).
+       (TeX-printer-default): Doc fix.
+
+2010-04-17  Ralf Angeli  <angeli@caeruleus.net>
+
+       * tex-buf.el (TeX-warning): Throw an error with a sensible message
+       if the file for the warning could not be determined.
+
+2010-04-13  Ralf Angeli  <angeli@caeruleus.net>
+
+       * tex-buf.el (TeX-format-filter): Calculate the current column as
+       difference between line start and end instead of using
+       `current-column' in order to do the right thing when octal codes
+       are present.
+
+2010-04-11  Ralf Angeli  <angeli@caeruleus.net>
+
+       * font-latex.el (font-latex-keyword-matcher): Quote a list of face
+       properties but do not to quote a face symbol.
+
+2010-04-05  Ralf Angeli  <angeli@caeruleus.net>
+
+       * tex-buf.el (TeX-parse-error): Allow `TeX-error-file' to become
+       empty.
+
+2010-03-28  Ralf Angeli  <angeli@caeruleus.net>
+
+       * plain-tex.el: New file.
+
+       * tex.el: Move code related to plain TeX to plain-tex.el.
+
+       * Makefile.in (AUCSRC): Add plain-tex.el.
+
+       * context.el: Require `plain-tex'.
+
+2010-03-27  Ralf Angeli  <angeli@caeruleus.net>
+
+       * tex.el (TeX-view-program-selection): Doc fix.
+       (TeX-clean): Regexp-quote the master file name.
+
+2010-03-20  Ralf Angeli  <angeli@caeruleus.net>
+
+       * style/french.el: New file.
+
+       * Makefile.in (STYLESRC): Add style/french.el.
+
+2010-03-07  Ralf Angeli  <angeli@caeruleus.net>
+
+       * latex.el (TeX-arg-key-val): Hint at key=value format in prompt.
+       (LaTeX-fill-region-as-para-do): Match whitespace without comment
+       starter at beginning of line when dealing with code comments.
+
+2010-03-06  Ralf Angeli  <angeli@caeruleus.net>
+
+       * Makefile.in (DIST_PREFIX): Use the working directory for the
+       folder with distribution files.
+       (FTPDIR, WWWDIR): Make them subdirectories of `DIST_PREFIX'.
+       (COMMITTER_NAME, COMMITTER_EMAIL): Remove.
+       (COMMITTER): New variable.
+       (.PHONY): Update.
+       (tar-ball-clean): Use `check-tag'.
+       (check-tag): New name for `check-dist'.
+       (dist): Do not call `release-commit' anymore.
+       (snapshot): Now an alias for `dist'.
+       (release-commit): Use `COMMITTER'.
+       (release-sign): New name for `full-release' target.  Generate
+       version 1.1 directive files.
+       (xemacs-package): Depend on `check-tag'.
+       (WPACKAGEFILES): Include info files with a numerical supplement to
+       the .info extension.  Depend on `check-tag'.  Check for presence
+       of `WEMACSVER' variable.  Try to find a local AUCTeX tar ball
+       before downloading one.  Use `TAG' instead of `WAUCVER'.  Put ZIP
+       archive into `FTPDIR'.
+       (WAUCVER, WEMACSVER): Remove.
+       (release-upload): New target.
+       (www-doc): Depend on `check-tag'.  Update URLs for Emacs manuals.
+
 2010-02-21  Ralf Angeli  <angeli@caeruleus.net>
 
        * Version 11.86 released.
diff --git a/ChangeLog-preview b/ChangeLog-preview
index 57d498f9..e0d71fac 100644
--- a/ChangeLog-preview
+++ b/ChangeLog-preview
@@ -1,3 +1,22 @@
+2012-12-04  Tassilo Horn  <tsdh@gnu.org>
+
+       Merge revno 314 (Stefan Monnier) from emacs elpa branch: Shorten
+       copyright year ranges.
+
+       * preview.el:
+
+2011-01-23  Ralf Angeli  <angeli@caeruleus.net>
+
+       * preview.el (preview-auto-reveal): Add `forward-char' and
+       `backward-char' to commands on which to open an overlay.
+
+2010-10-14  Ralf Angeli  <angeli@caeruleus.net>
+
+       * preview.el (preview-gs-options): Start gs with -dDELAYSAFER
+       instead of -dSAFER.
+       (preview-prepare-fast-conversion): Add relevant files to
+       PermitFileReading list of paths.
+
 2010-02-14  Ralf Angeli  <angeli@caeruleus.net>
 
        * latex/preview.dtx: Add support for XeTeX.
diff --git a/Makefile.in b/Makefile.in
index af377a42..8cc4be3e 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -2,8 +2,8 @@
 
 # Maintainer: auctex-devel@gnu.org
 
-# Copyright (C) 2003, 2004, 2005, 2006, 2007,
-#   2008 Free Software Foundation, Inc.
+# Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2010 Free Software
+#   Foundation, Inc.
 
 # This file is part of AUCTeX.
 
@@ -67,23 +67,22 @@ SHELL = /bin/sh
 CP = cp -p
 CP_A = $(CP) -R
 
-DIST_PREFIX = /home/tmp/auctex-
-FTPDIR = $(DIST_PREFIX)ftp
-WWWDIR = $(DIST_PREFIX)www
+DIST_PREFIX=$(PWD)/auctex-dist
+FTPDIR = $(DIST_PREFIX)/ftp
+WWWDIR = $(DIST_PREFIX)/www
 XEMACS_BUILD_DIR = xemacs-build
 PREVIEW_BUILD_DIR = preview-build
-COMMITTER_NAME="David Kastrup"
-COMMITTER_EMAIL=dak@gnu.org
+COMMITTER="David Kastrup  <dak@gnu.org>"
 RPMROOT = /usr/src/redhat
 RPM_SIGN = --sign
 
 MULESRC = @MULESRC@
 MULEELC = @MULEELC@
 
-AUCSRC = tex.el tex-buf.el tex-style.el latex.el tex-info.el \
+AUCSRC = tex.el tex-buf.el tex-style.el plain-tex.el latex.el tex-info.el \
        texmathp.el multi-prompt.el tex-mik.el font-latex.el tex-font.el \
        context.el context-en.el context-nl.el tex-fold.el \
-       toolbar-x.el tex-bar.el bib-cite.el tex-fptex.el
+       toolbar-x.el tex-bar.el bib-cite.el
 AUCELC = $(AUCSRC:.el=.elc)
 
 STYLESRC = style/prosper.el \
@@ -120,7 +119,9 @@ STYLESRC = style/prosper.el \
           style/ruby.el      style/CJKutf8.el   style/tabularx.el \
           style/multido.el   style/pst-grad.el  style/pst-node.el \
           style/pst-plot.el  style/pst-slpe.el  style/shortvrb.el \
-          style/austrian.el  style/naustrian.el
+          style/austrian.el  style/naustrian.el style/french.el \
+          style/lettrine.el  style/multicol.el  style/xspace.el \
+          style/setspace.el  style/biblatex.el
 STYLEELC = $(STYLESRC:.el=.elc)
 
 CLEANFILES = $(AUCELC) $(STYLEELC) $(MULEELC)
@@ -133,12 +134,12 @@ NOSEARCH = style/.nosearch
 all: lisp docs
        $(DESCEND)
 
-.PHONY: all lisp info dvi some install install-el install-lisp \
-       docs install-docs install-auto \
-       install-metadata install-startup install-man \
-       clean distclean snapshot check-dist release-commit \
-       dist patch tar-ball rpm-packages full-release tar-ball-clean \
-       wc xemacs-package preview-ball windows-package
+.PHONY: all lisp info dvi some install install-el install-lisp docs    \
+       install-docs install-auto install-metadata install-startup      \
+       install-man clean distclean maintainer-clean extraclean         \
+       tar-ball-clean check-tag release-commit dist snapshot patch     \
+       tar-ball rpm-packages wc xemacs-package windows-package         \
+       release-sign release-upload preview-ball
 
 lisp:  tex-site.el $(AUCSRC) $(STYLESRC) $(MULESRC)
        $(ELCC) -f batch-byte-compile $(AUCSRC) $(STYLESRC) $(MULESRC)
@@ -289,7 +290,7 @@ clean:      doc/Makefile
        cd doc && $(MAKE) clean
        $(DESCEND)
 
-distclean:     doc/Makefile
+distclean: doc/Makefile
        rm -f $(CLEANFILES) $(DISTCLEANFILES)
        cd doc && $(MAKE) distclean
        $(DESCEND)
@@ -304,32 +305,55 @@ maintainer-clean: doc/Makefile
 extraclean: maintainer-clean
        rm -f *~ \#*\#
 
-tar-ball-clean:
-       @if [ "X$(TAG)" = "X" ]; then echo "*** No tag ***"; exit 1; fi
+tar-ball-clean: check-tag
        rm -rf auctex-$(TAG)/
        rm -rf $(XEMACS_BUILD_DIR)/
 
 wc:
        wc $(AUCSRC) $(STYLESRC)
 
-# The targets below are intened to be used only by the maintainers.
-
-snapshot: check-dist tar-ball
-
-dist:  check-dist release-commit tar-ball
-
-check-dist:
-       @if [ "X$(TAG)" = "X" ]; then echo "*** No tag ***"; exit 1; fi
-       if [ "X$(OLD)" = "X" ]; then echo "No patch"; exit 1; fi
-
-release-commit:
-       @echo "**********************************************************"
-       @echo "** Making distribution of auctex for release $(TAG)"
-       @echo "**********************************************************"
-       sleep 3
+# ----------------------------------------------------------------------
+# The targets below are concerned with the release process and
+# intended to be used only by the maintainers.
+
+# Steps for making a release:
+# 
+# 1) release-commit TAG=<tag> COMMITTER=<committer>
+#    Tag the release.
+#    
+# 2) dist TAG=<tag>
+#    Create the tar ball.
+#
+# 3) xemacs-package TAG=<tag>
+#    Create the precompiled XEmacs package.
+#
+# 4) windows-package WEMACSVER=<emacs-version> TAG=<tag>
+#    Create the precompiled AUCTeX package for Windows.
+# 
+# 5) release-sign
+#    Sign the tar ball and create directive files for upload.
+# 
+# 6) release-upload
+#    Upload files to GNU FTP server.
+#
+# 7) www-doc TAG=<tag> GENDOCSPATCH=<patch-file>
+#    Create documentation for AUCTeX home page.
+# 
+# 8) preview-ball TAG=<tag>
+#    Create preview package.  (Not for GNU FTP server but for CTAN.)
+
+dist: check-tag tar-ball
+
+snapshot: dist
+
+check-tag:
+       @if [ "X$(TAG)" = "X" ]; then echo "*** Error: No TAG ***"; exit 1; fi
+
+release-commit: check-tag
+       @echo "Tagging release $(TAG) in CVS ..."
+       sleep 5
        mv ChangeLog ChangeLog.old
-       echo `date "+%Y-%m-%d "` \
-            " "${COMMITTER_NAME}"  <"${COMMITTER_EMAIL}">" > ChangeLog
+       echo `date "+%Y-%m-%d "`" "${COMMITTER} > ChangeLog
        echo >> ChangeLog
        echo "  * Version" $(TAG) released. >> ChangeLog
        echo >> ChangeLog
@@ -337,7 +361,7 @@ release-commit:
        cvs commit -m 'Release_$(TAG)' ChangeLog
        cvs tag release_`echo $(TAG) | sed -e 's/[.]/_/g'`
 
-tar-ball:      doc/Makefile
+tar-ball: doc/Makefile
        test ! -d auctex-$(TAG) || rm -r auctex-$(TAG)
        mkdir auctex-$(TAG)
 # Use TAG_EXPORT if set (for snapshots)
@@ -365,92 +389,48 @@ rpm-packages:
        rpmbuild -ta $(RPM_SIGN) $(FTPDIR)/auctex-$(TAG).tar.gz
        $(CP) 
$(RPMROOT)/{RPMS/noarch/{auctex-emacs,preview-tetex},SRPMS/auctex}-$(TAG)[.-]* 
$(FTPDIR)
        @echo "If you need to prepare RPM on some other system, you need to add"
-       @echo "them in $(FTPDIR) before 'make full-release'."
+       @echo "them in $(FTPDIR) before 'make release-sign'."
        sleep 2
 
-preview-ball:
-       test ! -d $(PREVIEW_BUILD_DIR) || rm -r $(PREVIEW_BUILD_DIR)
-       mkdir $(PREVIEW_BUILD_DIR)
-# Use TAG_EXPORT if set (for snapshots)
-       cvs export -d $(PREVIEW_BUILD_DIR) \
-          `echo $${TAG_EXPORT:=$(TAG)} | \
-         sed -e '/^\([-0-9]*[0-9]\)[-a-z]*$$/s//-D \1/' \
-              -e '/[.]/{s/^/-r release_/;s/[.]/_/g}'` auctex/preview/latex
-       cd $(PREVIEW_BUILD_DIR) && make -f ../preview/latex/Makefile 
preview.ins preview.pdf
-       chmod -R go-w+rX $(PREVIEW_BUILD_DIR)
-       test -d $(FTPDIR) || mkdir -p $(FTPDIR)
-       cd $(PREVIEW_BUILD_DIR) && \
-       tar -cf - --owner=root --group=root README preview.dtx preview.ins 
preview.pdf | gzip --best > $(FTPDIR)/preview-$(TAG).tar.gz
-
-full-release:
-       rm -f $(FTPDIR)/*.{directive,asc,sig}
-       if [ "x$$GPG_AGENT_INFO" = "x" ]; then \
-         read -sp "Enter pass phrase: " phrase ; \
-         gpg_opt="--passphrase-fd 0"; \
-       else \
-         gpg_opt=""; phrase=""; \
-       fi; \
-       for i in $(FTPDIR)/*; do \
-          echo "$$phrase" | gpg --detach-sign $$gpg_opt $$i ; \
-          case $$i in *-$(TAG)*) echo "directory: auctex" >$$i.directive;; \
-             *) echo "directory: auctex/$(TAG)-extra" >$$i.directive ;; \
-          esac ; \
-          echo "$$phrase" | gpg $$gpg_opt --clearsign $$i.directive ; \
-       done
-       rm $(FTPDIR)/*.directive
-
 patch:
        diff -u auctex-$(OLD) auctex-$(TAG) | gzip --best \
                >$(FTPDIR)/auctex-$(OLD)-to-$(TAG).patch.gz
 
-xemacs-package:
+xemacs-package: check-tag
        rm -rf $(XEMACS_BUILD_DIR)
        $(CP_A) auctex-$(TAG) $(XEMACS_BUILD_DIR)
        cd $(XEMACS_BUILD_DIR) \
        && ./configure INSTALL_INFO=: TEXHASH=: --with-xemacs 
--with-packagedir=`pwd`/xemacs-package --without-texmf-dir 
--with-auto-dir=etc/auctex/auto \
        && make all install-man install && cd xemacs-package && tar -cf - 
--owner=root --group=root . | gzip --best > $(FTPDIR)/auctex-$(TAG)-pkg.tar.gz
 
-www-doc:
-       rm -rf $(WWWDIR)
-       mkdir -p $(WWWDIR)/manual
-       $(CP) auctex-$(TAG)/doc/*.texi $(WWWDIR)/manual
-       cd $(WWWDIR)/manual \
-       && wget -O gendocs.sh 
'http://cvs.savannah.gnu.org/viewvc/%2acheckout%2a/texinfo/texinfo/util/gendocs.sh'
 \
-       && patch <$(GENDOCSPATCH) \
-       && chmod u+x gendocs.sh \
-       && wget -O gendocs_template 
'http://cvs.savannah.gnu.org/viewvc/%2acheckout%2a/texinfo/texinfo/util/gendocs_template'
 \
-       && sed -i -e 's/html_node\/index\.html/%%PACKAGE%%\/index.html/' 
gendocs_template \
-       && mkdir .texinfo \
-       && echo -e "emacs split 
http://www.gnu.org/software/emacs/manual/html_node/\nemacs mono 
http://www.gnu.org/software/emacs/manual/emacs.html\nreftex split 
http://www.gnu.org/software/auctex/manual/reftex/\nreftex mono 
http://www.gnu.org/software/auctex/manual/reftex.html\n"; > 
.texinfo/htmlxref.cnf \
-       && ./gendocs.sh --texi2html auctex "AUCTeX Manual" \
-       && ./gendocs.sh --texi2html preview-latex "preview-latex Manual"
-
 # Pre-compiled AUCTeX package for Emacs on Windows
-
 WBUILDDIR=$(PWD)/windows-package
-WEMACSVER=22.1
 WEMACS=/usr/src/emacs-$(WEMACSVER)/src/emacs
-WAUCVER=11.85
-WPACKAGE=$(WBUILDDIR)/auctex-$(WAUCVER)-e$(WEMACSVER)-msw.zip
+WPACKAGE=auctex-$(TAG)-e$(WEMACSVER)-msw.zip
 WPACKAGEFILES=site-lisp/auctex site-lisp/site-start.d site-lisp/site-start.el \
-       site-lisp/tex-site.el var/auctex doc info/dir info/auctex.info \
-       info/preview-latex.info
-
-windows-package:
+       site-lisp/tex-site.el var/auctex doc info/dir info/auctex.info* \
+       info/preview-latex.info*
+windows-package: check-tag
+       @if [ "X$(WEMACSVER)" = "X" ]; then \
+         echo "*** Error: No Emacs version (WEMACSVER) ***"; \
+         exit 1; \
+       fi
 # Make sure the prerequisites are available
        test -d $(WBUILDDIR) || mkdir $(WBUILDDIR)
        test -f $(WBUILDDIR)/emacs-$(WEMACSVER)-bin-i386.zip \
        || { cd $(WBUILDDIR) \
        && wget 
http://ftp.gnu.org/gnu/emacs/windows/emacs-$(WEMACSVER)-bin-i386.zip; }
-       test -f $(WBUILDDIR)/auctex-$(WAUCVER).zip \
+       test -f $(WBUILDDIR)/auctex-$(TAG).zip \
+       || { test -f $(FTPDIR)/auctex-$(TAG).zip \
+         && $(CP) $(FTPDIR)/auctex-$(TAG).zip $(WBUILDDIR); } \
        || { cd $(WBUILDDIR) \
-       && wget http://ftp.gnu.org/gnu/auctex/auctex-$(WAUCVER).zip; }
+         && wget http://ftp.gnu.org/gnu/auctex/auctex-$(TAG).zip; }
 # Reset to clean state
        cd $(WBUILDDIR) \
        && rm -rf emacs-$(WEMACSVER) \
-       && rm -rf auctex-$(WAUCVER) \
+       && rm -rf auctex-$(TAG) \
        && unzip emacs-$(WEMACSVER)-bin-i386.zip \
-       && unzip auctex-$(WAUCVER).zip
+       && unzip auctex-$(TAG).zip
        rm -f $(WPACKAGE)
 # Create site-start.el and site-start.d
        cd $(WBUILDDIR)/emacs-$(WEMACSVER)/site-lisp \
@@ -461,7 +441,7 @@ windows-package:
 \n  (load file nil t t))" > site-start.el \
        && mkdir site-start.d
 # Build and install AUCTeX
-       cd $(WBUILDDIR)/auctex-$(WAUCVER) \
+       cd $(WBUILDDIR)/auctex-$(TAG) \
        && ./configure --prefix=$(WBUILDDIR)/emacs-$(WEMACSVER) \
          --without-texmf-dir --with-emacs=$(WEMACS) \
          --with-lispdir=$(WBUILDDIR)/emacs-$(WEMACSVER)/site-lisp \
@@ -470,5 +450,62 @@ windows-package:
        && sed -i -e 's/"\/[^\n]\+/(expand-file-name "..\/var\/auctex" 
(file-name-directory load-file-name))/' tex-site.el \
        && make install
 # Create the package
+       test -d $(FTPDIR) || mkdir -p $(FTPDIR)
        cd $(WBUILDDIR)/emacs-$(WEMACSVER) \
-       && zip -r $(WPACKAGE) $(WPACKAGEFILES)
+       && zip -r $(FTPDIR)/$(WPACKAGE) $(WPACKAGEFILES)
+
+release-sign:
+       rm -f $(FTPDIR)/*.{directive,asc,sig}
+       if [ "x$$GPG_AGENT_INFO" = "x" ]; then \
+         read -sp "Enter pass phrase: " phrase ; \
+         gpg_opt="--passphrase-fd 0"; \
+       else \
+         gpg_opt=""; phrase=""; \
+       fi; \
+       for i in $(FTPDIR)/*; do \
+          echo "$$phrase" | gpg --detach-sign $$gpg_opt $$i ; \
+          echo "version: 1.1" >$$i.directive; \
+          case $$i in *-$(TAG)*) echo "directory: auctex" >>$$i.directive;; \
+             *) echo "directory: auctex/$(TAG)-extra" >>$$i.directive ;; \
+          esac ; \
+          echo "filename: "`basename $$i` >>$$i.directive ; \
+          echo "$$phrase" | gpg $$gpg_opt --clearsign $$i.directive ; \
+       done
+       rm $(FTPDIR)/*.directive
+
+release-upload:
+       @echo "Uploading everything in FTPDIR to GNU FTP server ..."
+       @sleep 5
+       ncftpput ftp-upload.gnu.org /incoming/ftp $(FTPDIR)/*
+
+# AUCTeX and preview-latex manuals for the home page
+www-doc: check-tag
+       rm -rf $(WWWDIR)
+       mkdir -p $(WWWDIR)/manual
+       $(CP) auctex-$(TAG)/doc/*.texi $(WWWDIR)/manual
+       cd $(WWWDIR)/manual \
+       && wget -O gendocs.sh 
'http://cvs.savannah.gnu.org/viewvc/%2acheckout%2a/texinfo/texinfo/util/gendocs.sh'
 \
+       && patch <$(GENDOCSPATCH) \
+       && chmod u+x gendocs.sh \
+       && wget -O gendocs_template 
'http://cvs.savannah.gnu.org/viewvc/%2acheckout%2a/texinfo/texinfo/util/gendocs_template'
 \
+       && sed -i -e 's/html_node\/index\.html/%%PACKAGE%%\/index.html/' 
gendocs_template \
+       && mkdir .texinfo \
+       && echo -e "emacs split 
http://www.gnu.org/software/emacs/manual/html_node/emacs/\nemacs mono 
http://www.gnu.org/software/emacs/manual/html_mono/emacs.html\nreftex split 
http://www.gnu.org/software/auctex/manual/reftex/\nreftex mono 
http://www.gnu.org/software/auctex/manual/reftex.html\n"; > 
.texinfo/htmlxref.cnf \
+       && ./gendocs.sh --email bug-auctex@gnu.org --texi2html \
+         --html --use-nodes auctex "AUCTeX Manual" \
+       && ./gendocs.sh --email bug-auctex@gnu.org --texi2html \
+         --html --use-nodes preview-latex "preview-latex Manual"
+
+preview-ball: check-tag
+       test ! -d $(PREVIEW_BUILD_DIR) || rm -r $(PREVIEW_BUILD_DIR)
+       mkdir $(PREVIEW_BUILD_DIR)
+# Use TAG_EXPORT if set (for snapshots)
+       cvs export -d $(PREVIEW_BUILD_DIR) \
+          `echo $${TAG_EXPORT:=$(TAG)} | \
+         sed -e '/^\([-0-9]*[0-9]\)[-a-z]*$$/s//-D \1/' \
+              -e '/[.]/{s/^/-r release_/;s/[.]/_/g}'` auctex/preview/latex
+       cd $(PREVIEW_BUILD_DIR) && make -f ../preview/latex/Makefile 
preview.ins preview.pdf
+       chmod -R go-w+rX $(PREVIEW_BUILD_DIR)
+       test -d $(FTPDIR) || mkdir -p $(FTPDIR)
+       cd $(PREVIEW_BUILD_DIR) && \
+       tar -cf - --owner=root --group=root README preview.dtx preview.ins 
preview.pdf | gzip --best > $(FTPDIR)/preview-$(TAG).tar.gz
diff --git a/RELEASE b/RELEASE
index e459f710..93ca64f2 100644
--- a/RELEASE
+++ b/RELEASE
@@ -1,4 +1,4 @@
-Release notes for AUCTeX 11.86 with preview-latex
+Release notes for AUCTeX 11.87 with preview-latex
 =================================================
 
 AUCTeX provides by far the most wide-spread and sophisticated
@@ -17,13 +17,6 @@ One part of the preview-latex subsystem is the central 
`preview.sty'
 file that is independently useful for a number of applications and is
 available in unbundled form from CTAN.[1]
 
-Interfaces and installation procedures in this release remain a moving
-target.  If you feel you need to consult third-party installation
-instructions for some reason, be sure that they refer to the same
-version of AUCTeX as you are installing.  For installing AUCTeX
-itself, the installation instructions in the AUCTeX package should be
-preferred.
-
 AUCTeX needs volunteers in particular for non-programming tasks:
 documentation writing, tutorials, translations, reference material,
 sleuth work, testing.
@@ -32,33 +25,26 @@ sleuth work, testing.
 New features and fixed bugs in this release
 -------------------------------------------
 
-Parsing of LaTeX output was improved.  It is now less likely that
-AUCTeX opens a non-existent file upon calling `TeX-next-error'; a
-problem for example encountered when using MiKTeX 2.8.  In addition
-quoted file names as emitted by MiKTeX are now supported.
-
-A new framework for the definition and selection of viewers was
-implemented.  If you have customizations regarding viewers you will
-have to redo them in this new framework or reenable the old one.  See
-the section on viewers in the manual for details.
-
-Comprehensive editing support for PSTricks was added.
-
-Support for various LaTeX packages was added, e.g. `tabularx', `CJK',
-and `hyperref'.
+AUCTeX now supports Biber in conjunction with biblatex in addition to
+BibTeX.
 
-An easy way to switch between TeX engines (PDFTeX, LuaTeX, XeTeX,
-Omega) was added.
+Each AUCTeX mode now has its own abbrev table.  On Emacsen which
+provide the possibility to inherit abbrevs from other tables, the
+abbrevs from the Text mode abbrev table are available as well.  Newly
+defined abbrevs are written to the mode-specific tables, though.
 
-Support for SyncTeX was added.  This involves the command line options
-for LaTeX and the viewer.
+The file tex-fptex.el was removed.
 
-Folding can now be customized to use macro arguments as replacement
-text.
+Forward/backward search for Evince has been improved.  If Emacs is
+compiled with DBUS support and a recent Evince version (3.x) is
+installed, the communication goes over the desktop bus instead of the
+command line, resulting in more accurate positioning of point in Emacs
+and highlighting of the target paragraph in Evince.
 
-`preview.sty' now works with XeTeX.
+A problem where Ghostscript threw an /invalidfileaccess error when
+running preview-latex was fixed.
 
-A lot of smaller and larger bugs have been squashed.
+A lot of smaller fixes and additions have been made.
 
 
 Requirements
@@ -128,10 +114,12 @@ remains the most effective way of helping AUCTeX 
development.
 
 The following people contributed to this release series (in
 alphabetical order): Ralf Angeli, Masayuki Ataka, Thomas Baumann,
-Berend de Boer, Joshua Buhl, Miguel Frasson, Peter S. Galbraith,
-Patrick Gundlach, Yvon Hevel, Arne J�rgensen, David Kastrup, Ikumi
-Keita, Frank K�ster, Jan-�ke Larsson, Dan Nicolaescu, Piet van
-Oostrum, Davide G. M. Salvetti, Holger Sparr, Mike Sperber, Reiner
+Vincent Bela�che, Berend de Boer, Ken Brown, Joshua Buhl, Patrice
+Dumas, Miguel Frasson, Peter S. Galbraith, Patrick Gundlach, Tassilo
+Horn, Yvon Hevel, Mads Jensen, Arne J�rgensen, David Kastrup, Ikumi
+Keita, Philip Kime, Joost Kremers, Frank K�ster, Jan-�ke Larsson,
+Antoine Levitt, Dan Nicolaescu, Piet van Oostrum, Augusto Ritter
+Stoffel, Davide G. M. Salvetti, Holger Sparr, Mike Sperber, Reiner
 Steib, Christian Schlauer, Shiro Takeda, Mark Trettin (Please accept
 our apologies if we forgot somebody.)
 
diff --git a/autogen.sh b/autogen.sh
index 8245f2a6..94b39033 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -35,7 +35,7 @@ cd ..
 rm -rf autom4te.cache preview/autom4te.cache
 if test "x${AUCTEXDATE}" = x
 then
-    AUCTEXDATE=`sed -n '1s/^\([-0-9][-0-9]*\).*/\1/p' ChangeLog`
+    AUCTEXDATE=`LANG=C sed -n '1s/^\([-0-9][-0-9]*\).*/\1/p' ChangeLog`
     test "X${AUCTEXDATE}" != X || { echo "Can't find date in ChangeLog" >&2 ; 
exit 1; }
 fi
 
diff --git a/configure.ac b/configure.ac
index 4caef8a0..7add2aa7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -21,7 +21,7 @@ dnl along with AUCTeX; see the file COPYING.  If not, write 
to the Free
 dnl Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 dnl MA 02110-1301, USA.
 
-AC_INIT(auctex,11.86,bug-auctex@gnu.org)
+AC_INIT(auctex,11.87,bug-auctex@gnu.org)
 
 AC_CHECK_PROGS_REQUIRED(MAKECMD, make, [make not found, aborting!])
 AC_PROG_MAKE_SET
diff --git a/context-en.el b/context-en.el
index c331cc82..aba1d8c2 100644
--- a/context-en.el
+++ b/context-en.el
@@ -164,6 +164,10 @@
   :group 'ConTeXt-en-environment
   :type 'string)
 
+(defvar ConTeXt-extra-paragraph-commands-en
+  '("crlf" "par" "place[A-Za-z]+")
+  "List of ConTeXt macros that should have their own line.
+That is, besides the section(-block) commands.")
 
 ;; Emacs en menu names and labels should go here
 ;; to be done
diff --git a/context-nl.el b/context-nl.el
index 9369d0ee..9ddebe9a 100644
--- a/context-nl.el
+++ b/context-nl.el
@@ -88,6 +88,12 @@
     "voet" "voetnootdefinitie" "voetnoten" "voetteksten" "witruimte")
   "List of the names of ConTeXt nl interface macro's that setup things.")
 
+;; referencing in ConTeXt
+(defvar ConTeXt-referencing-list-nl
+  '("in" "op" "over" "paginareferentie" "tekstreferentie" "referentie")
+  "List of ConTeXt en macro's that are used for referencing."
+)
+
 (defvar ConTeXt-other-macro-list-nl
   '("regellinks" "regelmidden" "regelrechts" "toonexternefiguren")
   "List of ConTeXt nl interface macro's that are not an environment nor a 
setup.")
@@ -138,6 +144,10 @@
   :group 'ConTeXt-nl-environment
   :type 'string)
 
+(defvar ConTeXt-extra-paragraph-commands-nl
+  '("crlf" "par" "plaats[A-Za-z]+")
+  "List of ConTeXt macros that should have their own line.
+That is, besides the section(-block) commands.")
 
 ;; Emacs en menu names and labels should go here
 ;; to be done
diff --git a/context.el b/context.el
index f7042a69..3a2622b1 100644
--- a/context.el
+++ b/context.el
@@ -1,6 +1,7 @@
 ;;; context.el --- Support for ConTeXt documents.
 
-;; Copyright (C) 2003, 2004, 2005, 2006, 2008 Free Software Foundation, Inc.
+;; Copyright (C) 2003-2006, 2008, 2010, 2012
+;;   Free Software Foundation, Inc.
 
 ;; Maintainer: Berend de Boer <berend@pobox.com>
 ;; Keywords: tex
@@ -51,8 +52,8 @@
 
 (require 'tex-buf)
 (require 'tex)
-;; need functions like TeX-look-at and LaTeX-split-long-menu
-(require 'latex)
+(require 'latex) ; for functions like `TeX-look-at' and `LaTeX-split-long-menu'
+(require 'plain-tex) ; for `plain-TeX-common-initialization'
 
 (defgroup ConTeXt-macro nil
   "Special support for ConTeXt macros in AUCTeX."
@@ -904,10 +905,6 @@ If OPTIONAL, only insert it if not empty, and then use 
square brackets."
 (defvar ConTeXt-item-list ()
   "List of macro's considered items.")
 
-(defvar ConTeXt-extra-paragraph-commands
-  '("crlf" "par")
-  "List of ConTeXt macros that should have their own line besides the 
section(-block) commands.")
-
 (defun ConTeXt-paragraph-commands-regexp ()
   "Return a regexp matching macros that should have their own line."
   (concat
@@ -1065,7 +1062,7 @@ An optional fourth (or sixth) element means always 
replace if t."
 (defvar ConTeXt-indent-arg 2)
 (defvar ConTeXt-indent-basic 2)
 (defvar ConTeXt-indent-item ConTeXt-indent-basic)
-(defvar ConTeXt-indent-item-re "\\\\\item\\>")
+(defvar ConTeXt-indent-item-re "\\\\\\(item\\|sym\\)\\>")
 
 (defvar ConTeXt-indent-syntax-table (make-syntax-table TeX-mode-syntax-table)
   "Syntax table used while computing indentation.")
@@ -1486,7 +1483,7 @@ else.  There might be text before point."
 (defun ConTeXt-expand-options ()
   "Expand options for texexec command."
   (concat
-   (let ((engine (nth 4 (assq TeX-engine (TeX-engine-alist)))))
+   (let ((engine (eval (nth 4 (assq TeX-engine (TeX-engine-alist))))))
      (when engine
        (format "--engine=%s " engine)))
    (unless (eq ConTeXt-current-interface "en")
@@ -1505,10 +1502,16 @@ else.  There might be text before point."
 ;; They are mapped to interface specific variables
 
 (defvar ConTeXt-language-variable-list
-  '(ConTeXt-define-list ConTeXt-setup-list ConTeXt-referencing-list 
ConTeXt-other-macro-list
-          ConTeXt-project-structure-list
-          ConTeXt-section-block-list ConTeXt-section-list
-                      ConTeXt-text ConTeXt-item-list))
+  '(ConTeXt-define-list
+    ConTeXt-setup-list
+    ConTeXt-referencing-list
+    ConTeXt-other-macro-list
+    ConTeXt-project-structure-list
+    ConTeXt-section-block-list
+    ConTeXt-section-list
+    ConTeXt-text
+    ConTeXt-item-list
+    ConTeXt-extra-paragraph-commands))
 
 (defcustom ConTeXt-clean-intermediate-suffixes
   ;; See *suffixes in texutil.pl.
@@ -1530,6 +1533,8 @@ i.e. you do _not_ have to cater for this yourself by 
adding \\\\' or $."
   :type '(repeat regexp)
   :group 'TeX-command)
 
+(TeX-abbrev-mode-setup context-mode)
+
 (defun ConTeXt-mode-common-initialization ()
   "Initialization code that is common for all ConTeXt interfaces."
   ;; `plain-TeX-common-initialization' kills all local variables, but
@@ -1541,6 +1546,8 @@ i.e. you do _not_ have to cater for this yourself by 
adding \\\\' or $."
     (setq ConTeXt-current-interface save-ConTeXt-current-interface))
   (setq major-mode 'context-mode)
 
+  (setq local-abbrev-table context-mode-abbrev-table)
+
   ;; Make language specific variables buffer local
   (dolist (symbol ConTeXt-language-variable-list)
     (make-variable-buffer-local symbol))
@@ -1550,6 +1557,8 @@ i.e. you do _not_ have to cater for this yourself by 
adding \\\\' or $."
     (set symbol (symbol-value (intern (concat (symbol-name symbol) "-"
                                              ConTeXt-current-interface)))))
 
+  ;; Create certain regular expressions based on language
+  (setq ConTeXt-indent-item-re (concat "\\\\\\(" (mapconcat 'identity 
ConTeXt-item-list "\\|") "\\)\\>"))
 
   ;; What's the deepest level at we can collapse a document?
   ;; set only if user has not set it. Need to be set before menu is created.
diff --git a/doc/auctex.texi b/doc/auctex.texi
index 848cf8fd..539a6830 100644
--- a/doc/auctex.texi
+++ b/doc/auctex.texi
@@ -12,8 +12,8 @@ This manual is for @AUCTeX{}
 (version @value{VERSION} from @value{UPDATED}),
 a sophisticated TeX environment for Emacs.
 
-Copyright @copyright{} 1992, 1993, 1994, 1995, 2001, 2002, 2004, 2005,
-2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
+Copyright @copyright{} 1992-1995, 2001, 2002, 2004-2012
+Free Software Foundation, Inc.
 
 @quotation
 Permission is granted to copy, distribute and/or modify this document
@@ -126,7 +126,7 @@ sending ``subscribe'' in the subject of a mail to
 * Display::                     Controlling Screen Display
 * Processing::                  Starting Processors, Viewers and Other Programs
 * Customization::               Customization and Extension
-* Appendices::                  Copying, Changes, Development, FAQ
+* Appendices::                  Copying, Changes, Development, FAQ, Texinfo 
mode
 * Indices::                     Indices
 
 @detailmenu
@@ -220,6 +220,7 @@ Copying, Changes, Development, FAQ
 * Changes::                     
 * Development::                 
 * FAQ::                         
+* Texinfo mode::                
 
 Copying this Manual
 
@@ -320,6 +321,7 @@ indenting and filling and for navigating through the 
document.
 * Environments::                Inserting Environment Templates
 * Mathematics::                 Entering Mathematics
 * Completion::                  Completion of macros
+* Marking::                     Marking Environments, Sections, or Texinfo 
Nodes
 * Commenting::                  Commenting text
 * Indenting::                   Reflecting syntactic constructs with whitespace
 * Filling::                     Automatic and manual line breaking
@@ -478,7 +480,7 @@ Insert roman @r{\textrm@{@point{}@}} text.
 @item C-c C-f C-f
 @kindex C-c C-f C-f
 @cindex @code{\textsf}
-Insert @sans{sans serif} @samp{\textsf@{@point{}@}} text.
+Insert @sansserif{sans serif} @samp{\textsf@{@point{}@}} text.
 
 @item C-c C-f C-t
 @kindex C-c C-f C-t
@@ -1050,6 +1052,85 @@ the Bib@TeX{} files have been saved at least once after 
you enabled
 automatic parsing on save, and that the basename of the Bib@TeX{} file
 does not conflict with the basename of one of @TeX{} files.
 
+@node Marking
+@section Marking Environments, Sections, or Texinfo Nodes
+
+You can mark the current environment by typing @kbd{C-c .}, or the
+current section by typing @kbd{C-c *}.
+
+In Texinfo documents you can type @kbd{M-C-h} to mark the current node.
+
+When the region is set, the point is moved to its beginning and the mark
+to its end.
+
+@menu
+* Marking (LaTeX):: LaTeX Commands for Marking Environments and Sections
+* Marking (Texinfo):: Texinfo Commands for Marking Environments, Sections, and 
Nodes
+@end menu
+
+@node Marking (LaTeX)
+@subsection LaTeX Commands for Marking Environments and Sections
+
+@deffn Command LaTeX-mark-section
+@kindex C-c *
+(@kbd{C-c *}) Set mark at end of current logical section, and point at
+top.
+
+With a non-nil prefix argument, mark only the region from the current
+section start to the next sectioning command.  Thereby subsections are
+not being marked.  Otherwise, any included subsections are also marked
+along with current section.
+@end deffn
+
+@deffn Command LaTeX-mark-environment
+@kindex C-c .
+(@kbd{C-c .}) Set mark to the end of the current environment and point
+to the matching beginning.
+
+If a prefix argument is given, mark the respective number of enclosing
+environments.  The command will not work properly if there are
+unbalanced begin-end pairs in comments and verbatim environments.
+@end deffn
+
+@node Marking (Texinfo)
+@subsection Texinfo Commands for Marking Environments and Sections
+
+@deffn Command Texinfo-mark-section
+@kindex C-c *
+(@kbd{C-c *}) Mark the current section, with inclusion of any containing
+node.
+
+The current section is detected as starting by any of the structuring
+commands matched by the regular expression in the variable
+@code{outline-regexp} which in turn is a regular expression matching any
+element of the variable @code{texinfo-section-list}.
+
+With a non-nil prefix argument, mark only the region from the current
+section start to the next sectioning command.  Thereby subsections are
+not being marked.  Otherwise, any included subsections are also marked
+
+Note that when the current section is starting immediately after a node
+command, then the node command is also marked as part of the section.
+@end deffn
+
+@deffn Command Texinfo-mark-environment
+@kindex C-c .
+(@kbd{C-c .}) Set mark to the end of the current environment and point
+to the matching beginning.
+
+If a prefix argument is given, mark the respective number of enclosing
+environments.  The command will not work properly if there are
+unbalanced begin-end pairs in comments and verbatim environments.
+@end deffn
+
+@deffn Command Texinfo-mark-node
+@kindex M-C-h
+(@kbd{M-C-h}) Mark the current node.  This is the node in which point is
+located.  It is starting at the previous occurrence of the keyword
+@code{@@node} and ending at next occurrence of the keywords
+@code{@@node} or @code{@@bye}.
+@end deffn
+
 @node Commenting
 @section Commenting
 
@@ -2337,6 +2418,14 @@ The default command to run in this buffer.  Must be an 
entry in
 @code{TeX-command-list}.
 @end defopt
 
+@cindex Biber
+@cindex biblatex
+@vindex LaTeX-biblatex-use-Biber
+In case you use biblatex in a document, @AUCTeX{} switches from
+Bib@TeX{} to Biber for bibliography processing.  In case you want to
+keep using Bib@TeX{}, set the variable @code{LaTeX-biblatex-use-Biber}
+to nil.
+
 After confirming a command to execute, @AUCTeX{} will try to save any
 buffers related to the document, and check if the document needs to be
 reformatted.  If the variable @code{TeX-save-query} is non-nil,
@@ -3534,7 +3623,7 @@ recurse, a positive integer means go that far deep in the 
directory
 hierarchy, t means recurse indefinitely.
 @end defopt
 
-By default, @AUCTeX{} will ignore files name @file{.}, @file{..},
+By default, @AUCTeX{} will ignore files named @file{.}, @file{..},
 @file{SCCS}, @file{RCS}, and @file{CVS}.
 
 @defopt TeX-ignore-file
@@ -3697,17 +3786,22 @@ Here is a simple example of a style file.
    (LaTeX-largest-level-set "chapter")))
 @end lisp
 
-This file specifies that the largest kind of section in a @LaTeX{} document
-using the book document style is chapter.  The interesting thing to
-notice is that the style file defines an (anonymous) function, and adds it
-to the list of loaded style hooks by calling @code{TeX-add-style-hook}.
+The example is from the @AUCTeX{} sources and is loaded for any @LaTeX{}
+document using the book document class (or style before @LaTeX{}2e).
+The file specifies that the largest kind of section in such a document
+is chapter.  The interesting thing to notice is that the style file
+defines an (anonymous) function, and adds it to the list of loaded style
+hooks by calling @code{TeX-add-style-hook}.
 
-The first time the user indirectly tries to access some style specific
+The first time the user indirectly tries to access some style-specific
 information, such as the largest sectioning command available, the style
 hooks for all files directly or indirectly read by the current document
-is executed.  The actual files will only be evaluated once, but the
+are executed.  The actual files will only be evaluated once, but the
 hooks will be called for each buffer using the style file.
 
+Note that the basename of the style file and the name of the style hook
+should usually be identical.
+
 @defun TeX-add-style-hook @var{style} @var{hook}
 Add @var{hook} to the list of functions to run when we use the @TeX{}
 file @var{style}.
@@ -3774,7 +3868,10 @@ You can use the following types of specifiers for 
arguments:
 Use the string as a prompt to prompt for the argument.
 
 @item number
-Insert that many braces, leave point inside the first.
+Insert that many braces, leave point inside the first.  0 and -1 are
+special.  0 means that no braces are inserted.  -1 means that braces are
+inserted around the macro and an active region (e.g. @samp{@{\tiny
+foo@}}).  If there is no active region, no braces are inserted.
 
 @item nil
 Insert empty braces.
@@ -3842,8 +3939,11 @@ Prompt for a filename in the current directory, and use 
it without the
 extension.
 
 @item TeX-arg-input-file
+@vindex TeX-arg-input-file-search
 Prompt for the name of an input file in @TeX{}'s search path, and use it
-without the extension.  Run the style hooks for the file.
+without the extension.  Run the style hooks for the file.  (Note that
+the behavior (type of prompt and inserted file name) of the function can
+be controlled by the variable @code{TeX-arg-input-file-search}.)
 
 @item TeX-arg-define-label
 Prompt for a label completing with known labels.  Add label to list of
@@ -4172,13 +4272,14 @@ List of functions to be called after parsing a @TeX{} 
file.
 @end defvar
 
 @node Appendices
-@appendix Copying, Changes, Development, FAQ
+@appendix Copying, Changes, Development, FAQ, Texinfo Mode
 
 @menu
 * Copying this Manual::         
 * Changes::                     
 * Development::                 
 * FAQ::                         
+* Texinfo mode::                
 @end menu
 
 @node Copying this Manual
@@ -4224,6 +4325,201 @@ See the file @file{history.texi} for older changes.
 @include faq.texi
 @raisesections
 
+@node Texinfo mode
+@appendixsec Features specific to @AUCTeX{}'s Texinfo major mode
+
+@AUCTeX{} includes a major mode for editting Texinfo files.  This major
+mode is not the same mode as the native Texinfo mode (@pxref{(texinfo)
+Texinfo Mode}) of Emacs, although they have the same name.  However,
+@AUCTeX{} still relies on a number of functions from the native Texinfo
+mode.
+
+The following text describes which functionality is offered by @AUCTeX{}
+and which by the native Texinfo mode.  This should enable you to decide
+when to consult the @AUCTeX{} manual and when the manual of the native
+mode.  And in case you are a seasoned user of the native mode, the
+information should help you to swiftly get to know the
+@AUCTeX{}-specific commands.
+
+@menu
+* Exploiting::                  How @AUCTeX{} and the native mode work together
+* Superseding::                 Where the native mode is superseded
+* Mapping::                     Where key bindings are mapped to the native 
mode
+* Unbinding::                   Which native mode key bindings are missing
+@end menu
+
+@node Exploiting
+@appendixsubsec How @AUCTeX{} and the native mode work together
+
+In a nutshell the split between @AUCTeX{} Texinfo mode, and native
+Texinfo mode is as follows:
+
+@itemize
+@item
+Most of the editing (environment creation, commenting, font command
+insertions) and/or processing commands (e.g. compiling or printing)
+which are available in other @AUCTeX{} modes are also handled by
+@AUCTeX{} in Texinfo mode.
+
+@item
+Texinfo-related features (e.g. info node linkage or menu creation) rely
+on the commands provided by the native Texinfo mode.  @AUCTeX{} provides
+the key bindings to reach these functions, keeping the same keys as in
+native Texinfo whenever possible, or similar ones otherwise.
+@end itemize
+
+@node Superseding
+@appendixsubsec Where the native mode is superseded
+
+This section is directed to users of the native Texinfo mode switching
+to @AUCTeX{}.  It follows the summary of the native mode
+(@pxref{(texinfo) Texinfo Mode Summary}) and lists which of its commands
+are no longer of use.
+
+@table @asis
+@item Insert commands
+In the native Texinfo mode, frequently used Texinfo commands can be
+inserted with key bindings of the form @kbd{C-c C-c @var{k}} where
+@var{k} differs for each Texinfo command; @kbd{c} inserts @@code,
+@kbd{d} inserts @@dfn, @kbd{k} @@kbd, etc.
+
+In @AUCTeX{} commands are inserted with the key binding @kbd{C-c C-m}
+instead which prompts for the macro to be inserted.  For font selection
+commands (like @@b, @@i, or @@emph) and a few related ones (like @@var,
+@@key or @@code) there are bindings which insert the respective macros
+directly.  They have the form @code{C-c C-f @var{k}} or @code{C-c C-f
+C-@var{k}} and call the function @code{TeX-font}.  Type @kbd{C-c C-f
+@key{RET}} to get a list of supported commands.
+
+Note that the prefix argument is not handled the same way by @AUCTeX{}.
+Note also that the node insertion command from the native mode
+(@code{texinfo-insert-@@node}) can still accessed from the Texinfo menu
+in @AUCTeX{}.
+
+@item Insert braces
+In @AUCTeX{} braces can be inserted with the same key binding as in the
+native Texinfo mode: @kbd{C-c @{}.  But @AUCTeX{} uses its own function
+for the feature: @code{TeX-insert-braces}.
+
+@item Insert environments
+The native Texinfo mode does not insert full environments.  Instead, it
+provides the function @code{texinfo-insert-@@end} (mapped to @kbd{C-c
+C-c e}) for closing an open environment with a matching @@end statement.
+
+In @AUCTeX{} you can insert full environments, i.e. both the opening and
+closing statements, with the function @code{Texinfo-environment} (mapped
+to @kbd{C-c C-e}).
+
+@item Format info files with makeinfo and @TeX{}
+In the native Texinfo mode there are various functions and bindings to
+format a region or the whole buffer for info or to typeset the
+respective text.  For example, there is @code{makeinfo-buffer} (mapped
+to @kbd{C-c C-m C-b}) which runs @samp{makeinfo} on the buffer or there
+is @code{texinfo-tex-buffer} (mapped to @kbd{C-c C-t C-b}) which runs
+@TeX{} on the buffer in order to produce a @acronym{DVI} file.
+
+In @AUCTeX{} different commands for formatting or typesetting can be
+invoked through the function @code{TeX-command-master} (mapped to
+@kbd{C-c C-c}).  After typing @kbd{C-c C-c}, you can select the desired
+command, e.g @samp{Makeinfo} or @samp{TeX}, through a prompt in the mini
+buffer.  Note that you can make, say @samp{Makeinfo}, the default by
+adding this statement in your init file:
+
+@lisp
+(add-hook 'Texinfo-mode-hook 
+          (lambda () (setq TeX-command-default "Makeinfo")))
+@end lisp
+
+Note also that @kbd{C-c C-c Makeinfo @key{RET}} is not completely
+functionally equivalent to @code{makeinfo-buffer} as the latter will
+display the resulting info file in Emacs, showing the node corresponding
+to the position in the source file, just after a successful compilation.
+This is why, while using @AUCTeX{}, invoking @code{makeinfo-buffer}
+might still be more convenient.
+
+Note also that in the case of a multifile document, @kbd{C-c C-c} in
+@AUCTeX{} will work on the whole document (provided that the file
+variable @code{TeX-master} is set correctly), while
+@code{makeinfo-buffer} in the native mode will process only the current
+buffer, provided at the @code{@@setfilename} statement is provided.
+
+@item Produce indexes and print
+The native Texinfo mode provides the binding @kbd{C-c C-t C-i}
+(@code{texinfo-texindex}) for producing an index and the bindings
+@kbd{C-c C-t C-p} (@code{texinfo-tex-print}) and @kbd{C-c C-t C-q}
+(@code{tex-show-print-queue}) for printing and showing the printer
+queue.  These are superseded by the respective commands available
+through @kbd{C-c C-c} (@code{TeX-command-master}) in @AUCTeX{}: Index,
+Print, and Queue.
+
+@item Kill jobs
+The command @kbd{C-c C-t C-k} (@code{tex-kill-job}) in the native mode
+is superseded by @kbd{C-c C-k} (@code{TeX-kill-job}) in @AUCTeX{}.
+@end table
+
+@node Mapping
+@appendixsubsec Where key bindings are mapped to the native mode
+
+This node follows the native Texinfo mode summary (@pxref{(texinfo)
+Texinfo Mode Summary}) and lists only those commands to which @AUCTeX{}
+provides a keybinding.
+
+Basically all commands of the native mode related to producing menus and
+interlinking nodes are mapped to same or similar keys in @AUCTeX{},
+while a few insertion commands are mapped to @AUCTeX{}-like keys.
+
+@table @asis
+
+@item @code{@@item} insertion
+The binding @kbd{C-c C-c i} for the insertion of @code{@@item} in the
+native mode is mapped to @kbd{M-@key{RET}} or @kbd{C-c C-j} in
+@AUCTeX{}, similar to other @AUCTeX{} modes.
+
+@item @code{@@end} insertion
+The binding @kbd{C-c C-c e} for closing a @code{@@@var{foo}} command by
+a corresponding @code{@@end @var{foo}} statement in the native mode is
+mapped to @kbd{C-c C-]} in @AUCTeX{}, similar to other @AUCTeX{} modes.
+
+@item Move out of balanced braces
+The binding @kbd{C-@}} (@code{up-list}) is available both in the native
+mode and in @AUCTeX{}.  (This is because the command is not implemented
+in either mode but a native Emacs command.)  However, in @AUCTeX{}, you
+cannot use @kbd{C-]} for this, as it is used for @code{@@end} insertion.
+
+@item Update pointers
+The bindings @kbd{C-c C-u C-n} (@code{texinfo-update-node}) and @kbd{C-c
+C-u C-e} (@code{texinfo-every-node-update}) from the native mode are
+available in @AUCTeX{} as well.
+
+@item Update menus
+The bindings @kbd{C-c C-u m} (@code{texinfo-master-menu}), @kbd{C-c C-u
+C-m} (@code{texinfo-make-menu}), and @kbd{C-c C-u C-a}
+(@code{texinfo-all-menus-update}) from the native mode are available in
+@AUCTeX{} as well.  The command @code{texinfo-start-menu-description},
+bound to @kbd{C-c C-c C-d} in the native mode, is bound to @kbd{C-c C-u
+C-d} in @AUCTeX{} instead.
+@end table
+
+@node Unbinding
+@appendixsubsec Which native mode key bindings are missing
+
+The following commands from the native commands might still be useful
+when working with @AUCTeX{}, however, they are not accessible with a
+key binding any longer.
+
+@table @asis
+@item @code{@@node} insertion
+The node insertion command, mapped to @kbd{C-c C-c n} in the native
+mode, is not mapped to any key in @AUCTeX{}.  You can still access it
+through the Texinfo menu, though.  Another alternative is to use the
+@kbd{C-c C-m} binding for macro insertion in @AUCTeX{}.
+
+@item Show the section structure
+The command @code{texinfo-show-structure} (@kbd{C-c C-s}) from the
+native mode does not have a key binding in @AUCTeX{}.  The binding is
+used by @AUCTeX{} for sectioning.
+@end table
+
 @node Indices
 @unnumbered Indices
 
diff --git a/doc/changes.texi b/doc/changes.texi
index 0f429271..64954016 100644
--- a/doc/changes.texi
+++ b/doc/changes.texi
@@ -1,6 +1,5 @@
 @c This is part of the AUCTeX manual.
-@c Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-@c   2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
+@c Copyright (C) 1994-2002, 2004-2010, 2012 Free Software Foundation, Inc.
 @c See file auctex.texi for copying conditions.
 @include macros.texi
 @ifset rawfile
@@ -8,6 +7,38 @@
 
 @end ifset
 
+@heading News since 11.87
+
+@itemize @bullet
+@item
+@AUCTeX{} now supports Biber in conjunction with biblatex in addition to
+BibTeX.
+
+@item
+Each @AUCTeX{} mode now has its own abbrev table.  On Emacsen which
+provide the possibility to inherit abbrevs from other tables, the
+abbrevs from the Text mode abbrev table are available as well.  Newly
+defined abbrevs are written to the mode-specific tables, though.
+
+@item
+The file @samp{tex-fptex.el} was removed.
+
+@item
+Forward/backward search for Evince has been improved.  If Emacs is
+compiled with DBUS support and a recent Evince version (3.x) is
+installed, the communication goes over the desktop bus instead of the
+command line, resulting in more accurate positioning of point in Emacs
+and highlighting of the target paragraph in Evince.
+
+@item
+A problem where Ghostscript threw an /invalidfileaccess error when
+running @previewlatex{} was fixed.
+
+@item
+A lot of smaller fixes and additions have been made.
+@end itemize
+
+
 @heading News in 11.86
 
 @itemize @bullet
diff --git a/doc/faq.texi b/doc/faq.texi
index 60484325..f634560c 100644
--- a/doc/faq.texi
+++ b/doc/faq.texi
@@ -1,3 +1,6 @@
+@c This is part of the AUCTeX Manual.
+@c Copyright (C) 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
+@c See the file auctex.texi for copying conditions.
 @ifset rawfile
 @include macros.texi
 @chapheading Frequently Asked Questions about @AUCTeX{}
@@ -25,7 +28,7 @@ But before you do this, you can try to get more information 
about the
 problem at hand which might also help you locate the cause of the error
 yourself.
 
-First, you can try to generate a so-called backtrace which shows
+First, you can try to generate a so-called backtrace which shows the
 functions involved in a program error.  In order to do this, start Emacs
 with the command line @samp{emacs --debug-init} and/or put the line
 
@@ -42,15 +45,9 @@ it in the bug report.
 Second, you can try to figure out if something in your personal or site
 configuration triggers the error by starting Emacs without such
 customizations.  You can do this by invoking Emacs with the command line
-@samp{emacs -q -no-site-file}.  Once Emacs is running, copy the line
-
-@lisp
-(load "auctex.el" nil t t)
-@end lisp
-
-into the @samp{*scratch*} buffer and type @kbd{M-x eval-buffer RET}.
-This makes sure that @AUCTeX{} will be used for the file types it
-supports.  After you have done so, you can load the file triggering the
+@samp{emacs -q -no-site-file -l auctex}.  The @samp{-l} option
+@samp{auctex.el} which you normally do in your init file.  After you
+have started Emacs like this, you can load the file triggering the
 error.  If everything is working now, you know that you have to search
 either in the site configuration file or your personal init file for
 statements related to the problem.
@@ -63,27 +60,17 @@ versions may work but are unsupported.  Older versions of 
XEmacs might
 possibly made to work by updating the @file{xemacs-base} package through
 the XEmacs package system.  If you are looking for a recommendation, it
 would appear that the smoothest working platform on all operating
-systems at the current point of time would be @w{Emacs 22.1}.  At the
-time of this writing, however, it has not been released and is still
-under development.  The quality of the development version is quite
-solid, so we recommend giving it a try.  With a developer version, of
-course, you have to be prepared to update in case you managed to get
-your snapshot at a bad time.  The second best choice would be the latest
-released @w{Emacs 21.4}.  However, Unicode support is less good, there
-is no version for the popular GTK toolkit, and the native versions for
-Windows and MacOS don't offer toolbar and @previewlatex{} support.
-
-Our success with XEmacs has been less than convincing.  Under the
-Windows operating system, nominally the only option for a released,
-stable Emacs variant supporting toolbars and @previewlatex{} would be
-@w{XEmacs 21.4}.  However, code for core functionality like formatting
-and syntax highlighting tends to be different and often older than even
-@w{Emacs 21.4}, and Unicode support as delivered is problematic at best,
-missing on Windows.  Both @AUCTeX{} and XEmacs developers don't hear
-much from active users of the combination.  Partly for that reason,
-problems tend to go unnoticed for long amounts of time and are often
-found, if at all, after releases.  No experiences or recommendations can
-be given for beta or developer versions of XEmacs.
+systems at the current point of time would be @w{Emacs 22} or higher.
+
+Our success with XEmacs has been less than convincing.  Code for core
+functionality like formatting and syntax highlighting tends to be
+different and often older than even @w{Emacs 21.4}, and Unicode support
+as delivered is problematic at best, missing on Windows.  Both @AUCTeX{}
+and XEmacs developers don't hear much from active users of the
+combination.  Partly for that reason, problems tend to go unnoticed for
+long amounts of time and are often found, if at all, after releases.  No
+experiences or recommendations can be given for beta or developer
+versions of XEmacs.
 
 @item
 What should I do when @code{./configure} does not find programs like latex?
@@ -138,6 +125,22 @@ loudly by opening a debugging buffer as soon as an error 
occurs.  The
 information in the debugging buffer can help you find the cause of the
 error in your init file.
 
+@item
+Why does @code{TeX-next-error} (@kbd{C-c `}) fail?
+
+When writing the log file, @TeX{} puts information related to a file,
+including error messages, between a pair of parentheses.  @AUCTeX{}
+determines the file where the error happened by parsing the log file and
+counting the parentheses.  This can fail when there are other,
+unbalanced parentheses present.
+
+As a workaround you can activate so-called file:line:error messages for
+the log file.  (Those are are easier to parse, but may lack some
+details.)  Either you do this in the configuration of your @TeX{} system
+(consult its manual to see where this is) or you add a command line
+switch to the (la)tex call, e.g. by customizing
+@code{LaTeX-command-style} or @code{TeX-command-list}.
+
 @item
 What does AUC stand for?
 
diff --git a/doc/install.texi b/doc/install.texi
index f13798bb..dd3eb5ed 100644
--- a/doc/install.texi
+++ b/doc/install.texi
@@ -1,6 +1,5 @@
 @c This is part of the AUCTeX Manual.
-@c Copyright (C) 1994, 1996, 2003, 2004, 2005, 2006, 2007
-@c   Free Software Foundation, Inc.
+@c Copyright (C) 1994, 1996, 2003-2007, 2012  Free Software Foundation, Inc.
 @c See the file auctex.texi for copying conditions.
 @ifset rawfile
 @include macros.texi
@@ -13,6 +12,15 @@
 @chapter Installing @AUCTeX{}
 @end ifclear
 
+The simplest way of installing @AUCTeX{} is by using the Emacs package
+manager integrated in Emacs 24 and greater (@acronym{ELPA}).  Simply do
+@kbd{M-x package-list-packages RET}, mark the auctex package for
+installation with @kbd{i}, and hit @kbd{x} to execute the installation
+procedure.  That's all.
+
+The remainder of this section is about installing @AUCTeX{} from a
+release tarball or from a checkout of the @AUCTeX{} repository.
+
 Installing @AUCTeX{} should be simple: merely @command{./configure},
 @command{make}, and @code{make install} for a standard site-wide
 installation (most other installations can be done by specifying a
@@ -74,7 +82,7 @@ the file @file{INSTALL.windows}.
 version of @code{xemacs-base} older than 1.84 (released in sumo from
 02/02/2004).  Using @previewlatex{} requires a version of Emacs compiled
 with image support.  While the X11 version of @w{Emacs 21} will likely
-work, @w{Emacs 22} and later is the preferred platform.
+work, @w{Emacs 22} and later is preferred.
 
 @table @b
 @item Windows
@@ -84,8 +92,8 @@ Precompiled versions are available from
 For an overview of precompiled versions of Emacs for Mac OS X see for
 example @uref{http://www.emacswiki.org/cgi-bin/wiki/EmacsForMacOS}.
 @item GNU/Linux
-Most GNU/Linux distributions nowadays provide a variant of Emacs 22 or
-later via their package repositories.
+Most GNU/Linux distributions nowadays provide a recent variant of Emacs
+via their package repositories.
 @item Self-compiled
 Compiling Emacs yourself requires a C compiler and a number of tools and
 development libraries.  Details are beyond the scope of this manual.
diff --git a/doc/macros.texi b/doc/macros.texi
index 36938ff3..fdf37a07 100644
--- a/doc/macros.texi
+++ b/doc/macros.texi
@@ -7,9 +7,6 @@ AUC@TeX{}
 @macro ConTeXt {}
 Con@TeX{}t
 @end macro
-@macro LaTeX {}
-La@TeX{}
-@end macro
 @macro previewlatex {}
 preview-latex
 @end macro
@@ -41,7 +38,8 @@ font-latex
 @end macro
 @end ifset
 @end ifnottex
-@macro sans {text}@c
+@ifset no-sansserif
+@macro sansserif {text}@c
 @iftex
 {@textsf \text\}@c
 @end iftex
@@ -49,6 +47,7 @@ font-latex
 \text\@c
 @end ifnottex
 @end macro
+@end ifset
 @tex
 \global\let\savedTeX\TeX
 \gdef\TeX#1{\savedTeX#1}
diff --git a/doc/preview-dtxdoc.pl b/doc/preview-dtxdoc.pl
index 84dc450e..62d215d2 100755
--- a/doc/preview-dtxdoc.pl
+++ b/doc/preview-dtxdoc.pl
@@ -104,9 +104,9 @@ MAIN: while (<STDIN>) {
     # Braces WITHIN bars should be escaped like so: @{ @}
     # and |..| translates to @code{..} or @file{..} depending on content
     # and to .. if in {quote}
-    split /\|/;
+    @chunks = split /\|/;
     $odd=0;
-    COMMAND: foreach (@_) {
+    COMMAND: foreach (@chunks) {
        if ($odd==0) {
            $odd=1;
        } else {
@@ -122,7 +122,7 @@ MAIN: while (<STDIN>) {
            $odd=0;
        }
     }
-    $_=join("",@_);
+    $_=join("",@chunks);
     # Argh! mixed types occurs in @code{...}@var{..}@file{..}
     # Should be @file{...@var{..}..}
     s/\@code(\S*?)\}(\S*)\@file\{/\@file$1$2/g;
diff --git a/doc/preview-latex.texi b/doc/preview-latex.texi
index 35085be8..f66b914a 100644
--- a/doc/preview-latex.texi
+++ b/doc/preview-latex.texi
@@ -702,8 +702,9 @@ customizable concerning aspects of that operation, see the 
customization
 group @code{Preview Gs} for this.
 
 Another noteworthy setting of @code{preview-image-type} is
-@samp{dvipng}: in this case, the @samp{dvipng}@pindex{dvipng} program
-will get run on @acronym{DVI} output (see below for @acronym{PDF}).
+@samp{dvipng}: in this case, the @samp{dvipng}
+@pindex dvipng 
+program will get run on @acronym{DVI} output (see below for @acronym{PDF}).
 This is in general much faster than Dvips and Ghostscript.  In that
 case, the option
 
diff --git a/doc/quickstart.texi b/doc/quickstart.texi
index ceec41c4..e6fa6613 100644
--- a/doc/quickstart.texi
+++ b/doc/quickstart.texi
@@ -27,10 +27,14 @@ inserting
 
 in your user init file.@footnote{This usually is a file in your home
 directory called @file{.emacs} if you are utilizing GNU Emacs or
-@file{.xemacs/init.el} if you are using XEmacs.}  In order to get
-support for many of the @LaTeX{} packages you will use in your
-documents, you should enable document parsing as well, which can be
-achieved by putting
+@file{.xemacs/init.el} if you are using XEmacs.}  If you've installed
+@AUCTeX{} from the Emacs package manager (ELPA), you must not have this
+line in your user init file.  The installation procedure already cares
+about loading @AUCTeX{} correctly.
+
+In order to get support for many of the @LaTeX{} packages you will use
+in your documents, you should enable document parsing as well, which can
+be achieved by putting
 
 @lisp
 (setq TeX-auto-save t)
@@ -163,7 +167,7 @@ Insert roman @r{\textrm@{@point{}@}} text.
 @item C-c C-f C-f
 @kindex C-c C-f C-f
 @cindex @code{\textsf}
-Insert  @sans{sans serif} @samp{\textsf@{@point{}@}} text.
+Insert  @sansserif{sans serif} @samp{\textsf@{@point{}@}} text.
 
 @item C-c C-f C-t
 @kindex C-c C-f C-t
diff --git a/doc/tex-ref.tex b/doc/tex-ref.tex
index 858d1ec3..6c4e814e 100644
--- a/doc/tex-ref.tex
+++ b/doc/tex-ref.tex
@@ -1,4 +1,4 @@
-% Reference Card for AUCTeX version 11.86
+% Reference Card for AUCTeX version 11.87
 %**start of header
 \newcount\columnsperpage
 
@@ -42,9 +42,9 @@
 % Paul Rubin, Bob Chassell, Len Tower, and Richard Mlynarik
 % for creating the GNU Emacs Reference Card from which this was mutated
 
-\def\versionnumber{11.86}
-\def\year{2010}
-\def\version{February \year\ v\versionnumber}
+\def\versionnumber{11.87}
+\def\year{2012}
+\def\version{November \year\ v\versionnumber}
 
 \def\shortcopyrightnotice{\vskip 1ex plus 2 fill
   \centerline{\small \copyright\ \year\ Free Software Foundation, Inc.
@@ -53,7 +53,7 @@
 \def\copyrightnotice{%
 \vskip 1ex plus 2 fill\begingroup\small
 \centerline{Copyright \copyright\ 1987, 1992, 1993, 2004, 2005, 2008,}
-\centerline{2010 Free Software Foundation, Inc.}
+\centerline{2010, 2012 Free Software Foundation, Inc.}
 \centerline{for AUC\TeX\ version \versionnumber}
 
 Permission is granted to make and distribute copies of
@@ -259,6 +259,7 @@ are not available in all modes):
 \key{Appropriate previewer}{View}
 \key{Print the output}{Print}
 \key{Bib\TeX}{BibTeX}
+\key{Biber}{Biber}
 \key{MakeIndex}{Index}
 \key{LaCheck}{Check}
 \key{Make (PostScript) File}{File}
@@ -464,7 +465,7 @@ area up to the next preview.
 \key{Preview region}{C-c C-p C-r}
 \key{Preview buffer}{C-c C-p C-b}
 \key{Preview document}{C-c C-p C-d}
-\key{Remove previews at point}{C-c C-p C-c C-d}
+\key{Remove previews at point}{C-c C-p C-c C-p}
 \key{Remove previews from region}{C-c C-p C-c C-r}
 \key{Remove previews from buffer}{C-c C-p C-c C-b}
 \key{Remove previews from document}{C-c C-p C-c C-d}
diff --git a/doc/wininstall.texi b/doc/wininstall.texi
index 3aa93b23..38cb35ef 100644
--- a/doc/wininstall.texi
+++ b/doc/wininstall.texi
@@ -332,18 +332,13 @@ in either a site-wide @file{site-start.el} or your 
personal startup file
 @file{~/.xemacs/init.el} from within XEmacs).
 
 @cindex @file{tex-mik.el}
-@cindex @file{tex-fptex.el}
 The default configuration of @AUCTeX{} is probably not the best fit for
-Windows systems.  You might want to add
+Windows systems with MiK@TeX{}.  You might want to add
 @example
 (require 'tex-mik)
 @end example
-or
-@example
-(require 'tex-fptex)
-@end example
-in order to get more appropriate values for MiK@TeX{} and fp@TeX{},
-respectively after loading @file{auctex.el} and @file{preview-latex.el}.
+after loading @file{auctex.el} and @file{preview-latex.el} in order to
+get more appropriate values for some customization options.
 
 You can always use
 
diff --git a/font-latex.el b/font-latex.el
index 2b146c7a..765d6cbb 100644
--- a/font-latex.el
+++ b/font-latex.el
@@ -1,7 +1,6 @@
 ;;; font-latex.el --- LaTeX fontification for Font Lock mode.
 
-;; Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
-;;   2004, 2005, 2006, 2007, 2008 Free Software Foundation.
+;; Copyright (C) 1996-2009, 2012  Free Software Foundation, Inc.
 
 ;; Authors:    Peter S. Galbraith <psg@debian.org>
 ;;             Simon Marshall <Simon.Marshall@esrin.esa.it>
@@ -284,11 +283,43 @@ variable `font-latex-fontify-sectioning'." num)
       "appendix" "displaybreak" "allowdisplaybreaks" "include")
      'font-latex-warning-face 1 noarg)
     ("variable"
-     (("setlength" "|{\\{") ("settowidth" "|{\\{") ("setcounter" "{|{\\")
-      ("addtolength" "|{\\{") ("addtocounter" "{|{\\"))
+     (("setlength" "|{\\{") ("settowidth" "|{\\{") ("settoheight" "{{")
+      ("settodepth" "{{") ("setcounter" "{|{\\")
+      ("addtolength" "|{\\{") ("addtocounter" "{|{\\")
+      ("stepcounter" "{") ("refstepcounter" "{")
+      ("arabic" "{") ("roman" "{") ("Roman" "{") ("alph" "{") ("Alph" "{")
+      ("fnsymbol" "{"))
      'font-lock-variable-name-face 2 command)
+    ("biblatexnoarg"
+     ("newrefsegment" "mancite" "pno" "ppno" "nopp" "psq" "psqq")
+     'font-lock-variable-name-face 2 noarg)
+    ("biblatex"
+     (("newrefsection" "[") ("ExecuteBibliographyOptions" "[{")
+      ("printbibliography" "[") ("printshorthands" "[") ("printbibheading" "[")
+      ("addbibresource" "[{") ("addglobalbib" "[{") ("addsectionbib" "[{")
+      ("bibbysection" "[") ("bibbysegment" "[") ("bibbycategory" "[")
+      ("DeclareBibliographyCategory" "{") ("addtocategory" "{{") 
("defbibenvironment" "{{{{")
+      ("defbibheading" "{[{") ("defbibnote" "{{") ("defbibfilter" "{{") 
("defbibcheck" "{{")
+      ("defbibentryset" "{{") ("Cite" "[[{") ("parencite" "*[[{") ("Parencite" 
"[[{")
+      ("footcite" "[[{") ("footcitetext" "[[{") ("textcite" "[[{") ("Textcite" 
"[[{")
+      ("smartcite" "[[{") ("Smartcite" "[[{") ("supercite" "{") ("autocite" 
"*[{{")
+      ("Autocite" "*[{{") ("citeauthor" "[{{") ("Citeauthor" "[{{") 
("citetitle" "*[{{")
+      ("citeyear" "*[[{") ("citedate" "*[[{") ("citeurl" "[[{") ("parentext" 
"{")
+      ("brackettext" "{") ("fullcite" "[[{") ("fullfootcite" "[[{") ("volcite" 
"[{[[")
+      ("Volcite" "[{[[") ("pvolcite" "[{[[") ("Pvolcite" "[{[[") ("fvolcite" 
"[{[[")
+      ("ftvolcite" "[{[[") ("svolcite" "[{[[") ("Svolcite" "[{[[") ("tvolcite" 
"[{[[")
+      ("Tvolcite" "[{[[") ("avolcite" "[{[[") ("Avolcite" "[{[[") ("notecite" 
"[[{")
+      ("Notecite" "[[{") ("pnotecite" "[[{") ("Pnotecite" "[[{") ("fnotecite" 
"[[{")
+      ("citename" "[[{[{") ("citelist" "[[{[{") ("citefield" "[[{[{") 
("citereset" "*")
+      ("RN" "{") ("Rn" "{") ("DefineBibliographyStrings" "{{") 
("DefineBibliographyExtras" "{{")
+      ("UndefineBibliographyExtras" "{{") ("DefineHyphenationExceptions" "{{")
+      ("NewBibliographyString" "{") ("autocites" "(([[{") ("Autocites" "(([[{")
+      ("cites" "(([[{") ("Cites" "(([[{") ("parencites" "(([[{") ("Parencites" 
"(([[{")
+      ("footcites" "(([[{") ("footcitetexts" "(([[{") ("smartcites" "(([[{")
+      ("Smartcites" "(([[{") ("textcites" "(([[{") ("Textcites" "(([[{") 
("supercites" "(([[{"))
+     'font-lock-constant-face 2 command)
     ("reference"
-     (("nocite" "{") ("cite" "[{") ("label" "{") ("pageref" "{")
+     (("nocite" "*{") ("cite" "*[[{") ("label" "{") ("pageref" "{")
       ("vref" "{") ("eqref" "{") ("ref" "{") ("include" "{")
       ("input" "{") ("bibliography" "{") ("index" "{") ("glossary" "{")
       ("footnote" "[{") ("footnotemark" "[") ("footnotetext" "[{"))
@@ -297,12 +328,13 @@ variable `font-latex-fontify-sectioning'." num)
      (("begin" "{") ("end" "{") ("pagenumbering" "{")
       ("thispagestyle" "{") ("pagestyle" "{") ("nofiles" "")
       ("includeonly" "{") ("bibliographystyle" "{") ("documentstyle" "[{")
-      ("documentclass" "[{") ("newenvironment" "*{[[{{")
+      ("documentclass" "[{[") ("newenvironment" "*{[[{{")
       ("newcommand" "*|{\\[[{") ("newlength" "|{\\")
       ("newtheorem" "{[{[")
-      ("newcounter" "{[") ("renewenvironment" "*{[{{")
+      ("providecommand" "*|{\\[[{")
+      ("newcounter" "{[") ("renewenvironment" "*{[[{{")
       ("renewcommand" "*|{\\[[{") ("renewtheorem" "{[{[")
-      ("usepackage" "[{") ("fbox" "{") ("mbox" "{") ("sbox" "{")
+      ("usepackage" "[{[") ("fbox" "{") ("mbox" "{") ("rule" "[{{")
       ("vspace" "*{") ("hspace" "*{") ("thinspace" "") ("negthinspace" "")
       ;; XXX: Should macros without arguments rather be listed in a
       ;; separate category with 'noarg instead of 'command handling?
@@ -513,7 +545,10 @@ use."
           (7 (font-latex-matched-face 7) append t)))
        ((eq type 'noarg)
         `(,(intern (concat prefix name))
-          (0 ,face)))
+          ;; Quote a list of face properties but do not to quote a face symbol.
+          (0 ,(if (and (listp face) (not (fboundp (car face))))
+                  `',face
+                face))))
        ((eq type 'declaration)
         `(,(intern (concat prefix name))
           (0 'font-latex-warning-face t t)
@@ -787,11 +822,11 @@ Generated by `font-latex-make-user-keywords'.")))
   "Add KEYWORDS to CLASS.
 KEYWORDS is a list of keywords or keywords with syntax specs.
 CLASS corresponds to a keyword class and can be one of the
-symbols 'warning, 'variable, 'reference, 'function, sectioning-0,
-'sectioning-1, 'sectioning-2, 'sectioning-3, 'sectioning-4,
-'sectioning-5, 'slide-title, 'textual, 'bold-command,
-'italic-command, 'math-command, 'type-command, 'bold-declaration,
-'italic-declaration or 'type-declaration.
+symbols 'warning, 'variable, 'reference, 'biblatex, 'function,
+sectioning-0, 'sectioning-1, 'sectioning-2, 'sectioning-3,
+'sectioning-4, 'sectioning-5, 'slide-title, 'textual,
+'bold-command, 'italic-command, 'math-command, 'type-command,
+'bold-declaration, 'italic-declaration or 'type-declaration.
 
 The keywords will be added to the buffer-local list of keywords
 of the respective keyword class and necessary updates of the font
diff --git a/latex.el b/latex.el
index f9859a61..8bf283a7 100644
--- a/latex.el
+++ b/latex.el
@@ -1,7 +1,7 @@
 ;;; latex.el --- Support for LaTeX documents.
 
-;; Copyright (C) 1991, 1993, 1994, 1995, 1996, 1997, 1999, 2000, 2003,
-;;   2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
+;; Copyright (C) 1991, 1993-1997, 1999, 2000, 2003-2012
+;;   Free Software Foundation, Inc.
 
 ;; Maintainer: auctex-devel@gnu.org
 ;; Keywords: tex
@@ -1099,10 +1099,10 @@ Just like array and tabular."
 (defun LaTeX-env-args (environment &rest args)
   "Insert ENVIRONMENT and arguments defined by ARGS."
   (LaTeX-insert-environment environment)
-  (let ((pos (point-marker)))
-    (end-of-line 0)
-    (TeX-parse-arguments args)
-    (goto-char pos)))
+  (save-excursion
+    (LaTeX-find-matching-begin)
+    (end-of-line)
+    (TeX-parse-arguments args)))
 
 ;;; Item hooks
 
@@ -1197,27 +1197,48 @@ This is necessary since index entries may contain 
commands and stuff.")
        (1 2 3) LaTeX-auto-optional)
        (,(concat "\\\\\\(?:new\\|provide\\)command\\*?{?\\\\\\(" token 
"+\\)}?\\[\\([0-9]+\\)\\]")
        (1 2) LaTeX-auto-arguments)
-       (,(concat "\\\\\\(?:new\\|provide\\)command\\*?{?\\\\\\(" token 
"+\\)}?") 1 TeX-auto-symbol)
+       (,(concat "\\\\\\(?:new\\|provide\\)command\\*?{?\\\\\\(" token 
"+\\)}?")
+       1 TeX-auto-symbol)
        (,(concat "\\\\newenvironment\\*?{?\\(" token 
"+\\)}?\\[\\([0-9]+\\)\\]\\[")
        1 LaTeX-auto-environment)
        (,(concat "\\\\newenvironment\\*?{?\\(" token 
"+\\)}?\\[\\([0-9]+\\)\\]")
        (1 2) LaTeX-auto-env-args)
-       (,(concat "\\\\newenvironment\\*?{?\\(" token "+\\)}?") 1 
LaTeX-auto-environment)
+       (,(concat "\\\\newenvironment\\*?{?\\(" token "+\\)}?")
+       1 LaTeX-auto-environment)
        (,(concat "\\\\newtheorem{\\(" token "+\\)}") 1 LaTeX-auto-environment)
        ("\\\\input{\\(\\.*[^#}%\\\\\\.\n\r]+\\)\\(\\.[^#}%\\\\\\.\n\r]+\\)?}"
        1 TeX-auto-file)
        ("\\\\include{\\(\\.*[^#}%\\\\\\.\n\r]+\\)\\(\\.[^#}%\\\\\\.\n\r]+\\)?}"
        1 TeX-auto-file)
-       (, (concat "\\\\bibitem{\\(" token "[^, \n\r\t%\"#'()={}]*\\)}") 1 
LaTeX-auto-bibitem)
+       (, (concat "\\\\bibitem{\\(" token "[^, \n\r\t%\"#'()={}]*\\)}")
+         1 LaTeX-auto-bibitem)
        (, (concat "\\\\bibitem\\[[^][\n\r]+\\]{\\(" token "[^, 
\n\r\t%\"#'()={}]*\\)}")
          1 LaTeX-auto-bibitem)
-       ("\\\\bibliography{\\([^#}\\\\\n\r]+\\)}" 1 LaTeX-auto-bibliography)))
+       ("\\\\bibliography{\\([^#}\\\\\n\r]+\\)}" 1 LaTeX-auto-bibliography)
+       ("\\\\addbibresource\\(?:\\[[^]]+\\]\\)?{\\([^#}\\\\\n\r\.]+\\)\\..+}"
+       1 LaTeX-auto-bibliography)
+       
("\\\\add\\(?:global\\|section\\)bib\\(?:\\[[^]]+\\]\\)?{\\([^#}\\\\\n\r\.]+\\)\\(?:\\..+\\)?}"
 1 LaTeX-auto-bibliography)
+       ("\\\\newrefsection\\[\\([^]]+\\)\\]" 1 LaTeX-split-bibs)
+       ("\\\\begin{refsection}\\[\\([^]]+\\)\\]" 1 LaTeX-split-bibs)))
    LaTeX-auto-class-regexp-list
    LaTeX-auto-label-regexp-list
    LaTeX-auto-index-regexp-list
    LaTeX-auto-minimal-regexp-list)
   "List of regular expression matching common LaTeX macro definitions.")
 
+(defun LaTeX-split-bibs (match)
+  "Extract bibliography resources from MATCH.
+Split the string at commas and remove Biber file extensions."
+  (let ((bibs (TeX-split-string " *, *" (TeX-match-buffer match))))
+    (dolist (bib bibs)
+      (LaTeX-add-bibliographies (replace-regexp-in-string 
+                                (concat "\\(?:\\."
+                                        (mapconcat 'regexp-quote
+                                                   TeX-Biber-file-extensions
+                                                   "\\|\\.")
+                                        "\\)")
+                                "" bib)))))
+
 (defun LaTeX-auto-prepare ()
   "Prepare for LaTeX parsing."
   (setq LaTeX-auto-arguments nil
@@ -1231,23 +1252,47 @@ This is necessary since index entries may contain 
commands and stuff.")
 (defun LaTeX-listify-package-options (options)
   "Return a list from a comma-separated string of package OPTIONS.
 The input string may include LaTeX comments and newlines."
-  ;; FIXME: Parse key=value options like "pdftitle={A Perfect
-  ;; Day},colorlinks=false" correctly.  When this works, the check for
-  ;; "=" can be removed again.
-  (let (opts)
-    (dolist (elt (TeX-split-string "\\(,\\|%[^\n\r]*[\n\r]\\)+"
-                                  options))
-      (unless (string-match "=" elt)
-       ;; Strip whitespace.
-       (dolist (item (TeX-split-string "[ \t\r\n]+" elt))
-         (unless (string= item "")
-           (add-to-list 'opts item)))))
+  ;; We jump through all those hoops and don't just use `split-string'
+  ;; or the like in order to be able to deal with key=value package
+  ;; options which can look like this: "pdftitle={A Perfect Day},
+  ;; colorlinks=false"
+  (let (opts match start)
+    (with-temp-buffer
+      (set-syntax-table LaTeX-mode-syntax-table)
+      (insert options)
+      (newline) ; So that the last entry can be found.
+      (goto-char (point-min))
+      (setq start (point))
+      (while (re-search-forward "[{ ,%\n\r]" nil t)
+       (setq match (match-string 0))
+       (cond
+        ;; Step over groups.  (Let's hope nobody uses escaped braces.)
+        ((string= match "{")
+         (up-list))
+        ;; Get rid of whitespace.
+        ((string= match " ")
+         (delete-region (1- (point))
+                        (save-excursion
+                          (skip-chars-forward " ")
+                          (point))))
+        ;; Add entry to output.
+        ((or (string= match ",") (= (point) (point-max)))
+         (add-to-list 'opts (buffer-substring-no-properties
+                             start (1- (point))) t)
+         (setq start (point)))
+        ;; Get rid of comments.
+        ((string= match "%")
+         (delete-region (1- (point))
+                        (line-beginning-position 2)))
+        ;; Get rid of newlines.
+        ((or (string= match "\n") (string= match "\r"))
+         (delete-backward-char 1)))))
     opts))
 
 (defun LaTeX-auto-cleanup ()
   "Cleanup after LaTeX parsing."
 
-  ;; Cleanup BibTeX files
+  ;; Cleanup BibTeX/Biber files
   (setq LaTeX-auto-bibliography
        (apply 'append (mapcar (lambda (arg)
                                 (TeX-split-string "," arg))
@@ -1383,6 +1428,12 @@ regenerated by the respective menu filter."
   (setq LaTeX-environment-menu nil)
   (setq LaTeX-environment-modify-menu nil))
 
+;;; Biber support
+
+(defvar LaTeX-using-Biber nil
+  "Used to track whether Biber is in use.")
+(make-variable-buffer-local 'LaTeX-using-Biber)
+
 ;;; BibTeX
 
 ;;;###autoload
@@ -1597,6 +1648,7 @@ string."
                              ("dinbrief")
                              ("foils")
                              ("letter")
+                             ("memoir")
                              ("minimal")
                              ("prosper")
                              ("report")
@@ -1636,7 +1688,8 @@ OPTIONAL and IGNORE are ignored."
 (defun LaTeX-arg-usepackage (optional)
   "Insert arguments to usepackage.
 OPTIONAL is ignored."
-  (let ((TeX-file-extensions '("sty")))
+  (let ((TeX-file-extensions '("sty"))
+       (TeX-input-file-search t))
     (TeX-arg-input-file nil "Package")
     (save-excursion
       (search-backward-regexp "{\\(.*\\)}")
@@ -1671,9 +1724,51 @@ OPTIONAL is ignored."
          (mapc 'TeX-run-style-hooks (LaTeX-listify-package-options options))
          (TeX-argument-insert options t))))))
 
+(defcustom LaTeX-search-files-type-alist
+  '((texinputs "${TEXINPUTS.latex}" ("tex/generic/" "tex/latex/")
+              TeX-file-extensions)
+    (docs "${TEXDOCS}" ("doc/") TeX-doc-extensions)
+    (graphics "${TEXINPUTS}" ("tex/") LaTeX-includegraphics-extensions)
+    (bibinputs "${BIBINPUTS}" ("bibtex/bib/") BibTeX-file-extensions)
+    (bstinputs "${BSTINPUTS}" ("bibtex/bst/") BibTeX-style-extensions)
+    (biberinputs "${BIBINPUTS}" ("bibtex/bib/") TeX-Biber-file-extensions))
+  "Alist of filetypes with locations and file extensions.
+Each element of the alist consists of a symbol expressing the
+filetype, a variable which can be expanded on kpathsea-based
+systems into the directories where files of the given type
+reside, a list of absolute directories, relative directories
+below the root of a TDS-compliant TeX tree or a list of variables
+with either type of directories as an alternative for
+non-kpathsea-based systems and a list of extensions to be matched
+upon a file search.  Note that the directories have to end with a
+directory separator.
+
+Reset the mode for a change of this variable to take effect."
+  :group 'TeX-file
+  :type '(alist :key-type symbol
+               :value-type
+               (group (string :tag "Kpathsea variable")
+                      (choice :tag "Directories"
+                              (repeat :tag "TDS subdirectories" string)
+                              (repeat :tag "Absolute directories" directory)
+                              (repeat :tag "Variables" variable))
+                      (choice :tag "Extensions"
+                              variable (repeat string)))))
+
+(defcustom TeX-arg-input-file-search t
+  "If `TeX-arg-input-file' should search for files.
+If the value is t, files in TeX's search path are searched for
+and provided for completion.  The file name is then inserted
+without directory and extension.  If the value is nil, the file
+name can be specified manually and is inserted with a path
+relative to the directory of the current buffer's file and with
+extension.  If the value is `ask', you are asked for the method
+to use every time `TeX-arg-input-file' is called."
+  :group 'LaTeX-macro
+  :type '(choice (const t) (const nil) (const ask)))
+
 (defvar TeX-global-input-files nil
   "List of the non-local TeX input files.
-
 Initialized once at the first time you prompt for an input file.
 May be reset with `\\[universal-argument] \\[TeX-normal-mode]'.")
 
@@ -1683,28 +1778,32 @@ If OPTIONAL is non-nil, insert the resulting value as 
an optional
 argument, otherwise as a mandatory one.  PROMPT is the prompt,
 LOCAL is a flag.  If the flag is set, only complete with local
 files."
-  (unless (or TeX-global-input-files local)
-    (message "Searching for files...")
-    (setq TeX-global-input-files
-         (mapcar 'list (TeX-search-files (append TeX-macro-private
-                                                 TeX-macro-global)
-                                         TeX-file-extensions t t))))
-  (let ((file (if TeX-check-path
-                 (completing-read
-                  (TeX-argument-prompt optional prompt "File")
-                  (TeX-delete-dups-by-car
-                   (append (mapcar 'list
-                                   (TeX-search-files '("./")
-                                                     TeX-file-extensions
-                                                     t t))
-                           (unless local
-                             TeX-global-input-files))))
-               (read-file-name
-                (TeX-argument-prompt optional prompt "File")))))
-    (if (null file)
-       (setq file ""))
-    (if (not (string-equal "" file))
-       (TeX-run-style-hooks file))
+  (let ((search (if (eq TeX-arg-input-file-search 'ask)
+                   (not (y-or-n-p "Find file yourself? "))
+                 TeX-arg-input-file-search))
+       file style)
+    (if search
+       (progn
+         (unless (or TeX-global-input-files local)
+           (message "Searching for files...")
+           (setq TeX-global-input-files
+                 (mapcar 'list (TeX-search-files-by-type
+                                'texinputs 'global t t))))
+         (setq file (completing-read
+                     (TeX-argument-prompt optional prompt "File")
+                     (TeX-delete-dups-by-car
+                      (append (mapcar 'list (TeX-search-files-by-type
+                                             'texinputs 'local t t))
+                              (unless local
+                                TeX-global-input-files))))
+               style file))
+      (setq file (read-file-name
+                 (TeX-argument-prompt optional prompt "File") nil ""))
+      (unless (string-equal file "")
+       (setq file (file-relative-name file)))
+      (setq style (file-name-sans-extension (file-name-nondirectory file))))
+    (unless (string-equal "" style)
+      (TeX-run-style-hooks style))
     (TeX-argument-insert file optional)))
 
 (defvar BibTeX-global-style-files nil
@@ -1721,44 +1820,50 @@ string."
   (message "Searching for BibTeX styles...")
   (or BibTeX-global-style-files
       (setq BibTeX-global-style-files
-           (mapcar 'list
-                   (TeX-search-files (append TeX-macro-private
-                                             TeX-macro-global)
-                                     BibTeX-style-extensions t t))))
-
+           (mapcar 'list (TeX-search-files-by-type 'bstinputs 'global t t))))
   (TeX-argument-insert
    (completing-read (TeX-argument-prompt optional prompt "BibTeX style")
-                   (append (mapcar 'list
-                                   (TeX-search-files '("./")
-                                                     BibTeX-style-extensions
-                                                     t t))
+                   (append (mapcar 'list (TeX-search-files-by-type
+                                          'bstinputs 'local t t))
                            BibTeX-global-style-files))
    optional))
 
 (defvar BibTeX-global-files nil
   "Association list of BibTeX files.
 
-Initialized once at the first time you prompt for an BibTeX file.
+Initialized once at the first time you prompt for a BibTeX file.
+May be reset with `\\[universal-argument] \\[TeX-normal-mode]'.")
+
+(defvar TeX-Biber-global-files nil
+  "Association list of Biber files.
+
+Initialized once at the first time you prompt for an Biber file.
 May be reset with `\\[universal-argument] \\[TeX-normal-mode]'.")
 
 (defun TeX-arg-bibliography (optional &optional prompt)
-  "Prompt for a BibTeX database file.
+  "Prompt for a BibTeX or Biber database file.
 If OPTIONAL is non-nil, insert the resulting value as an optional
 argument, otherwise as a mandatory one.  Use PROMPT as the prompt
 string."
-  (message "Searching for BibTeX files...")
-  (or BibTeX-global-files
-      (setq BibTeX-global-files
-           (mapcar 'list (TeX-search-files nil BibTeX-file-extensions t t))))
-
-  (let ((styles (multi-prompt
-                "," t
-                (TeX-argument-prompt optional prompt "BibTeX files")
-                (append (mapcar 'list
-                                (TeX-search-files '("./")
-                                                  BibTeX-file-extensions
-                                                  t t))
-                        BibTeX-global-files))))
+  (let (name files inputs styles)
+    (if LaTeX-using-Biber
+       (progn
+         (setq name "Biber"
+               files 'TeX-Biber-global-files
+               inputs 'biberinputs))
+      (setq name "BibTeX"
+           files 'BibTeX-global-files
+           inputs 'bibinputs))
+    (message "Searching for %s files..." name)
+    (or (symbol-value files)
+       (set files (mapcar 'list (TeX-search-files-by-type
+                                 'biberinputs 'global t t))))
+    (setq styles (multi-prompt
+                 "," t
+                 (TeX-argument-prompt optional prompt (concat name " files"))
+                 (append (mapcar 'list (TeX-search-files-by-type
+                                        inputs 'local t t))
+                         (symbol-value files))))
     (apply 'LaTeX-add-bibliographies styles)
     (TeX-argument-insert (mapconcat 'identity styles ",") optional)))
 
@@ -1929,7 +2034,7 @@ alist.  The car of each element should be a string 
representing a
 key and the optional cdr should be a list with strings to be used
 as values for the key."
   (let ((options (multi-prompt-key-value
-                 (TeX-argument-prompt optional "Options" nil)
+                 (TeX-argument-prompt optional "Options (k=v)" nil)
                  (if (symbolp key-val-alist)
                      (eval key-val-alist)
                    key-val-alist))))
@@ -2041,10 +2146,22 @@ non-parenthetical delimiters, like \\verb+foo+, are 
recognized."
                   (/= (point) (line-beginning-position))))))
       ;; Search forward for the macro end, unless we failed to find a start
       (unless (bolp)
-       (let ((beg (1- (point))))
-         (goto-char (1+ (match-end 0)))
-         (skip-chars-forward (concat "^" (buffer-substring-no-properties
-                                          (1- (point)) (point))))
+       (let* ((beg (1- (point)))
+              (macro-end (match-end 0))
+              ;; XXX: Here we assume we are dealing with \verb which
+              ;; expects the delimiter right behind the command.
+              ;; However, \lstinline can also cope with whitespace as
+              ;; well as an optional argument after the command.
+              (delimiter (buffer-substring-no-properties
+                          macro-end (1+ macro-end))))
+         ;; Heuristic: If an opening brace is encountered, search for
+         ;; both the opening and the closing brace as an end marker.
+         ;; Like that the function should work for \verb|...| as well
+         ;; as for \url{...}.
+         (when (string= delimiter TeX-grop)
+           (setq delimiter (concat delimiter TeX-grcl)))
+         (goto-char (1+ macro-end))
+         (skip-chars-forward (concat "^" delimiter))
          (when (<= orig (point))
            (cons beg (1+ (point)))))))))
 
@@ -2859,8 +2976,8 @@ space does not end a sentence, so don't break a line 
there."
            (unless (or (bolp)
                        ;; Comment starters and whitespace.
                        (TeX-looking-at-backward
-                        (concat "^\\([ \t]*" TeX-comment-start-regexp
-                                "+\\)+[ \t]*")
+                        (concat "^\\([ \t]*" TeX-comment-start-regexp "+\\)*"
+                                "[ \t]*")
                         (line-beginning-position)))
              (LaTeX-fill-newline)))))
       ;; Leave point after final newline.
@@ -3114,6 +3231,7 @@ space does not end a sentence, so don't break a line 
there."
                                    ((string= match-string "$$") "$$")
                                    (t (concat TeX-esc "]")))
                              (point-max) t)
+                            (skip-chars-forward "^ \n")
                             (point))
                           (line-beginning-position))
                        fill-column)))
@@ -4318,10 +4436,7 @@ use \\[customize]."
       (read-kbd-macro LaTeX-math-abbrev-prefix)
     LaTeX-math-abbrev-prefix))
 
-(defvar LaTeX-math-keymap
-  (let ((map (make-sparse-keymap)))
-    (define-key map (LaTeX-math-abbrev-prefix) 'self-insert-command)
-    map)
+(defvar LaTeX-math-keymap (make-sparse-keymap)
   "Keymap used for `LaTeX-math-mode' commands.")
 
 (defvar LaTeX-math-menu
@@ -4394,7 +4509,10 @@ the sequence by initializing this variable.")
                                  (list menu (vector (concat prefix value)
                                                     name t))
                                (vector menu name t))
-                             (cdr parent))))))))))
+                             (cdr parent)))))))))
+  ;; Make the math prefix char available if it has not been used as a prefix.
+  (unless (lookup-key map (LaTeX-math-abbrev-prefix))
+    (define-key map (LaTeX-math-abbrev-prefix) 'self-insert-command)))
 
 (define-minor-mode LaTeX-math-mode
   "A minor mode with easy access to TeX math macros.
@@ -4901,6 +5019,8 @@ This happens when \\left is inserted."
   :type 'hook
   :group 'LaTeX)
 
+(TeX-abbrev-mode-setup latex-mode)
+
 ;;;###autoload
 (add-to-list 'auto-mode-alist '("\\.drv\\'" . latex-mode))
 
@@ -4933,6 +5053,8 @@ of `LaTeX-mode-hook'."
           filladapt-mode)
       (turn-off-filladapt-mode)))
 
+(TeX-abbrev-mode-setup doctex-mode)
+
 ;;;###autoload
 (add-to-list 'auto-mode-alist '("\\.dtx\\'" . doctex-mode))
 
@@ -4941,6 +5063,7 @@ of `LaTeX-mode-hook'."
   "Major mode in AUCTeX for editing .dtx files derived from `LaTeX-mode'.
 Runs `LaTeX-mode', sets a few variables and
 runs the hooks in `docTeX-mode-hook'."
+  :abbrev-table doctex-mode-abbrev-table
   (setq major-mode 'doctex-mode)
   (set (make-local-variable 'LaTeX-insert-into-comments) t)
   (set (make-local-variable 'LaTeX-syntactic-comments) t)
@@ -5012,6 +5135,8 @@ i.e. you do _not_ have to cater for this yourself by 
adding \\\\' or $."
   (make-local-variable 'indent-line-function)
   (setq indent-line-function 'LaTeX-indent-line)
 
+  (setq local-abbrev-table latex-mode-abbrev-table)
+
   ;; Filling
   (make-local-variable 'paragraph-ignore-fill-prefix)
   (setq paragraph-ignore-fill-prefix t)
@@ -5051,6 +5176,8 @@ i.e. you do _not_ have to cater for this yourself by 
adding \\\\' or $."
   (setq TeX-verbatim-p-function 'LaTeX-verbatim-p)
   (setq TeX-search-forward-comment-start-function
        'LaTeX-search-forward-comment-start)
+  (set (make-local-variable 'TeX-search-files-type-alist)
+       LaTeX-search-files-type-alist)
 
   (make-local-variable 'LaTeX-item-list)
   (setq LaTeX-item-list '(("description" . LaTeX-item-argument)
@@ -5199,6 +5326,7 @@ i.e. you do _not_ have to cater for this yourself by 
adding \\\\' or $."
    '("nocite" TeX-arg-cite)
    '("bibliographystyle" TeX-arg-bibstyle)
    '("bibliography" TeX-arg-bibliography)
+   '("addbibresource" TeX-arg-bibliography)
    '("footnote"
      (TeX-arg-conditional TeX-arg-footnote-number-p ([ "Number" ]) nil)
      t)
@@ -5211,6 +5339,8 @@ i.e. you do _not_ have to cater for this yourself by 
adding \\\\' or $."
    '("setlength" TeX-arg-macro "Length")
    '("addtolength" TeX-arg-macro "Length")
    '("settowidth" TeX-arg-macro t)
+   '("settoheight" TeX-arg-macro t)
+   '("settodepth" TeX-arg-macro t)
    '("\\" [ "Space" ])
    '("\\*" [ "Space" ])
    '("hyphenation" t)
@@ -5257,11 +5387,11 @@ i.e. you do _not_ have to cater for this yourself by 
adding \\\\' or $."
    '("include" (TeX-arg-input-file "File" t))
    '("includeonly" t)
    '("input" TeX-arg-input-file)
-   '("addcontentsline" TeX-arg-file
-     (TeX-arg-eval
-      completing-read "Numbering style: " LaTeX-section-list)
-     t)
-   '("addtocontents" TeX-arg-file t)
+   '("addcontentsline"
+     (TeX-arg-eval completing-read "File: " '(("toc") ("lof") ("lot")))
+     (TeX-arg-eval completing-read "Numbering style: " LaTeX-section-list) t)
+   '("addtocontents"
+     (TeX-arg-eval completing-read "File: " '(("toc") ("lof") ("lot"))) t)
    '("typeout" t)
    '("typein" [ TeX-arg-define-macro ] t)
    '("verb" TeX-arg-verb)
@@ -5289,8 +5419,9 @@ i.e. you do _not_ have to cater for this yourself by 
adding \\\\' or $."
    "clearpage" "cleardoublepage" "twocolumn" "onecolumn"
 
    "maketitle" "tableofcontents" "listoffigures" "listoftables"
-   "tiny" "scriptsize" "footnotesize" "small"
-   "normalsize" "large" "Large" "LARGE" "huge" "Huge"
+   '("tiny" -1) '("scriptsize" -1) '("footnotesize" -1) '("small" -1)
+   '("normalsize" -1) '("large" -1) '("Large" -1) '("LARGE" -1) '("huge" -1)
+   '("Huge" -1)
    "pounds" "copyright"
    "hfil" "hfill" "vfil" "vfill" "hrulefill" "dotfill"
    "indent" "noindent" "today"
@@ -5346,6 +5477,7 @@ i.e. you do _not_ have to cater for this yourself by 
adding \\\\' or $."
        [ "Number of arguments" ] [ "Default value for first argument" ] t)
      '("usepackage" LaTeX-arg-usepackage)
      '("RequirePackage" LaTeX-arg-usepackage)
+     '("ProvidesPackage" "Name" [ "Version" ])
      '("documentclass" TeX-arg-document)))
 
   (TeX-add-style-hook "latex2e"
@@ -5390,6 +5522,7 @@ i.e. you do _not_ have to cater for this yourself by 
adding \\\\' or $."
        'LaTeX-imenu-create-index-function)
 
   (use-local-map LaTeX-mode-map)
+
   ;; Calling `easy-menu-add' may result in the menu filters being
   ;; executed which call `TeX-update-style'.  So this is placed very
   ;; late in mode initialization to assure that all relevant variables
diff --git a/plain-tex.el b/plain-tex.el
new file mode 100644
index 00000000..476976be
--- /dev/null
+++ b/plain-tex.el
@@ -0,0 +1,314 @@
+;;; plain-tex.el --- Support for plain TeX documents.
+
+;; Copyright (C) 2010 Free Software Foundation, Inc.
+
+;; Maintainer: auctex-devel@gnu.org
+;; 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 provides support for plain TeX in AUCTeX.
+
+;;; Code:
+
+(require 'tex)
+(require 'tex-buf)
+
+;;; Tool bar
+
+(defcustom plain-TeX-enable-toolbar t
+  "Enable TeX tool bar in plain TeX mode."
+  :group 'TeX-tool-bar
+  :type 'boolean)
+
+(defun plain-TeX-maybe-install-toolbar ()
+  "Conditionally install tool bar buttons for plain TeX mode.
+Install tool bar if `plain-TeX-enable-toolbar' is non-nil."
+  (when plain-TeX-enable-toolbar
+    ;; Defined in `tex-bar.el':
+    (TeX-install-toolbar)))
+
+
+;;; Keymap and menu
+
+(defvar plain-TeX-mode-map
+  (let ((map (make-sparse-keymap)))
+    (set-keymap-parent map TeX-mode-map)
+    map)
+  "Keymap used in plain TeX mode.")
+
+(defvar plain-TeX-menu-entries
+  (TeX-menu-with-help
+   `(["Macro..." TeX-insert-macro
+      :help "Insert a macro and possibly arguments"]
+     ["Complete" TeX-complete-symbol
+      :help "Complete the current macro"]
+     "-"
+     ("Insert Font"
+      ["Emphasize"  (TeX-font nil ?\C-e) :keys "C-c C-f C-e"]
+      ["Bold"       (TeX-font nil ?\C-b) :keys "C-c C-f C-b"]
+      ["Typewriter" (TeX-font nil ?\C-t) :keys "C-c C-f C-t"]
+      ["Small Caps" (TeX-font nil ?\C-c) :keys "C-c C-f C-c"]
+      ["Sans Serif" (TeX-font nil ?\C-f) :keys "C-c C-f C-f"]
+      ["Italic"     (TeX-font nil ?\C-i) :keys "C-c C-f C-i"]
+      ["Slanted"    (TeX-font nil ?\C-s) :keys "C-c C-f C-s"]
+      ["Roman"      (TeX-font nil ?\C-r) :keys "C-c C-f C-r"]
+      ["Calligraphic" (TeX-font nil ?\C-a) :keys "C-c C-f C-a"])
+     ("Replace Font"
+      ["Emphasize"  (TeX-font t ?\C-e) :keys "C-u C-c C-f C-e"]
+      ["Bold"       (TeX-font t ?\C-b) :keys "C-u C-c C-f C-b"]
+      ["Typewriter" (TeX-font t ?\C-t) :keys "C-u C-c C-f C-t"]
+      ["Small Caps" (TeX-font t ?\C-c) :keys "C-u C-c C-f C-c"]
+      ["Sans Serif" (TeX-font t ?\C-f) :keys "C-u C-c C-f C-f"]
+      ["Italic"     (TeX-font t ?\C-i) :keys "C-u C-c C-f C-i"]
+      ["Slanted"    (TeX-font t ?\C-s) :keys "C-u C-c C-f C-s"]
+      ["Roman"      (TeX-font t ?\C-r) :keys "C-u C-c C-f C-r"]
+      ["Calligraphic" (TeX-font t ?\C-a) :keys "C-u C-c C-f C-a"])
+     ["Delete Font" (TeX-font t ?\C-d) :keys "C-c C-f C-d"]
+     "-"
+     ["Comment or Uncomment Region" TeX-comment-or-uncomment-region
+      :help "Comment or uncomment the currently selected region"]
+     ["Comment or Uncomment Paragraph" TeX-comment-or-uncomment-paragraph
+      :help "Comment or uncomment the paragraph containing point"]
+     ,TeX-fold-menu
+     "-" . ,TeX-common-menu-entries)))
+
+(easy-menu-define plain-TeX-mode-command-menu
+    plain-TeX-mode-map
+    "Command menu used in TeX mode."
+    (TeX-mode-specific-command-menu 'plain-tex-mode))
+
+(easy-menu-define plain-TeX-mode-menu
+    plain-TeX-mode-map
+    "Menu used in plain TeX mode."
+    (cons "TeX" plain-TeX-menu-entries))
+
+
+;;; The mode
+
+(defcustom plain-TeX-mode-hook nil
+  "A hook run in plain TeX mode buffers."
+  :type 'hook
+  :group 'TeX-misc)
+
+(TeX-abbrev-mode-setup plain-tex-mode)
+
+;;;###autoload
+(defun TeX-plain-tex-mode ()
+  "Major mode in AUCTeX for editing plain TeX files.
+See info under AUCTeX for documentation.
+
+Special commands:
+\\{plain-TeX-mode-map}
+
+Entering `plain-tex-mode' calls the value of `text-mode-hook',
+then the value of `TeX-mode-hook', and then the value
+of plain-TeX-mode-hook."
+  (interactive)
+  (plain-TeX-common-initialization)
+  (setq major-mode 'plain-tex-mode)
+  (use-local-map plain-TeX-mode-map)
+  (easy-menu-add plain-TeX-mode-menu plain-TeX-mode-map)
+  (easy-menu-add plain-TeX-mode-command-menu plain-TeX-mode-map)
+  (setq TeX-base-mode-name "TeX")
+  (setq TeX-command-default "TeX")
+  (setq TeX-sentinel-default-function 'TeX-TeX-sentinel)
+  (add-hook 'tool-bar-mode-on-hook 'plain-TeX-maybe-install-toolbar nil t)
+  (when (if (featurep 'xemacs)
+           (featurep 'toolbar)
+         (and (boundp 'tool-bar-mode) tool-bar-mode))
+    (plain-TeX-maybe-install-toolbar))
+  (TeX-run-mode-hooks 'text-mode-hook 'TeX-mode-hook 'plain-TeX-mode-hook)
+  (TeX-set-mode-name))
+
+(defun plain-TeX-common-initialization ()
+  "Common initialization for plain TeX like modes."
+  (VirTeX-common-initialization)
+  (set-syntax-table TeX-mode-syntax-table)
+  (setq local-abbrev-table latex-mode-abbrev-table)
+  (setq paragraph-start
+       (concat
+        "\\(^[ \t]*$"
+        "\\|" (regexp-quote TeX-esc) "par\\|"
+        "^[ \t]*"
+        (regexp-quote TeX-esc)
+        "\\("
+        "begin\\|end\\|part\\|chapter\\|"
+        "section\\|subsection\\|subsubsection\\|"
+        "paragraph\\|include\\|includeonly\\|"
+        "tableofcontents\\|appendix\\|label\\|caption\\|"
+        "\\[\\|\\]"                    ; display math delimitors
+        "\\)"
+        "\\|"
+        "^[ \t]*\\$\\$"                ; display math delimitor
+        "\\)" ))
+  (setq paragraph-separate
+       (concat
+        "[ \t]*"
+        "\\("
+        (regexp-quote TeX-esc) "par\\|"
+        "%\\|"
+        "$\\|"
+        "\\$\\$\\|"
+        (regexp-quote TeX-esc)
+        "\\("
+        "begin\\|end\\|label\\|caption\\|part\\|chapter\\|"
+        "section\\|subsection\\|subsubsection\\|"
+        "paragraph\\|include\\|includeonly\\|"
+        "tableofcontents\\|appendix\\|" (regexp-quote TeX-esc)
+        "\\)"
+        "\\)"))
+  (setq TeX-header-end (regexp-quote "%**end of header"))
+  (setq TeX-trailer-start (regexp-quote (concat TeX-esc "bye")))
+  (TeX-add-symbols
+   ;; From the TeX Book, Appendix B
+   ;;
+   ;; XXX: This should be refined and extended by somebody who is
+   ;; familiar with plain TeX.
+   "dag"
+   "ddag"
+   "copyright"
+   "TeX"
+   "dots"
+   "break"
+   "nobreak"
+   "allowbreak"
+   "hbox"
+   "slash"
+   "enskip"
+   "quad"
+   "qquad"
+   "enspace"
+   "thinspace"
+   "negthinspace"
+   "smallskip"
+   "medskip"
+   "bigskip"
+   "eject"
+   "supereject"
+   "goodbreak"
+   "filbreak"
+   "smallbreak"
+   "medbreak"
+   "bigbreak"
+   "hrulefill"
+   "dotfill"
+   "rightarrowfill"
+   "leftarrowfill"
+   "upbracefill"
+   "downbracefill"
+   "halign"
+   "valign"
+   "omit"
+   "span"
+   "multispan"
+   "centerline"
+   "rightline"
+   "leftline"
+   "line"
+   "par"
+   "noindent"
+   "frenchspacing"
+   "nonfrenchspacing"
+   "llap"
+   "rlap"
+   "raggedright"
+   "ttraggedright"
+   "raggedbottom"
+   "normalbottom"
+   "obeylines"
+   "obeyspaces"
+   "hsize"
+   "vsize"
+   "hoffset"
+   "voffset"
+   "tolerance"
+   "looseness"
+   "parindent"
+   "baselineskip"
+   "parskip")
+  (TeX-run-style-hooks "TEX"))
+
+
+;;; Miscellaneous
+
+(defcustom plain-TeX-clean-intermediate-suffixes
+  TeX-clean-default-intermediate-suffixes
+  "List of regexps matching suffixes of intermediate files to be deleted.
+The regexps will be anchored at the end of the file name to be matched,
+i.e. you do _not_ have to cater for this yourself by adding \\\\' or $."
+  :type '(repeat regexp)
+  :group 'TeX-command)
+
+(defcustom plain-TeX-clean-output-suffixes TeX-clean-default-output-suffixes
+  "List of regexps matching suffixes of output files to be deleted.
+The regexps will be anchored at the end of the file name to be matched,
+i.e. you do _not_ have to cater for this yourself by adding \\\\' or $."
+  :type '(repeat regexp)
+  :group 'TeX-command)
+
+
+;;; AmSTeX
+
+(defvar AmSTeX-mode-map
+  (let ((map (make-sparse-keymap)))
+    (set-keymap-parent map TeX-mode-map)
+    map)
+  "Keymap used in `AmSTeX-mode'.")
+
+;; Menu for AmSTeX mode
+(easy-menu-define AmSTeX-mode-command-menu
+    AmSTeX-mode-map
+    "Command menu used in AmsTeX mode."
+    (TeX-mode-specific-command-menu 'ams-tex-mode))
+
+(easy-menu-define AmSTeX-mode-menu
+  AmSTeX-mode-map
+  "Menu used in AMS-TeX mode."
+  (cons "AmS-TeX" plain-TeX-menu-entries))
+
+;;;###autoload
+(defun ams-tex-mode ()
+  "Major mode in AUCTeX for editing AmS-TeX files.
+See info under AUCTeX for documentation.
+
+Special commands:
+\\{AmSTeX-mode-map}
+
+Entering AmS-tex-mode calls the value of `text-mode-hook',
+then the value of `TeX-mode-hook', and then the value
+of `AmS-TeX-mode-hook'."
+  (interactive)
+  (plain-TeX-common-initialization)
+  (setq major-mode 'ams-tex-mode)
+  (use-local-map AmSTeX-mode-map)
+
+  ;; Menu
+  (easy-menu-add AmSTeX-mode-menu AmSTeX-mode-map)
+  (easy-menu-add AmSTeX-mode-command-menu AmSTeX-mode-map)
+
+  (setq TeX-base-mode-name "AmS-TeX")
+  (setq TeX-command-default "AmSTeX")
+  (TeX-run-mode-hooks 'text-mode-hook 'TeX-mode-hook 'AmS-TeX-mode-hook)
+  (TeX-set-mode-name))
+
+(provide 'plain-tex)
+
+;;; plain-tex.el ends here
diff --git a/preview.el b/preview.el
index df963ee9..39f1c49a 100644
--- a/preview.el
+++ b/preview.el
@@ -1,7 +1,6 @@
 ;;; preview.el --- embed preview LaTeX images in source buffer
 
-;; Copyright (C) 2001, 2002, 2003, 2004, 2005,
-;;               2006  Free Software Foundation, Inc.
+;; Copyright (C) 2001-2006, 2010, 2012  Free Software Foundation, Inc.
 
 ;; Author: David Kastrup
 ;; Keywords: tex, wp, convenience
@@ -23,7 +22,7 @@
 
 ;;; Commentary:
 
-;; $Id: preview.el,v 1.284 2009-06-18 19:20:46 angeli Exp $
+;; $Id: preview.el,v 1.287 2012-12-04 08:01:34 tsdh Exp $
 ;;
 ;; This style is for the "seamless" embedding of generated images
 ;; into LaTeX source code.  Please see the README and INSTALL files
@@ -355,7 +354,7 @@ LIST consists of TeX dimensions in sp (1/65536 TeX point)."
   :group 'preview-gs
   :type 'string)
 
-(defcustom preview-gs-options '("-q" "-dSAFER" "-dNOPAUSE"
+(defcustom preview-gs-options '("-q" "-dDELAYSAFER" "-dNOPAUSE"
                                "-DNOPLATFONTS" "-dPrinted"
                                "-dTextAlphaBits=4"
                                "-dGraphicsAlphaBits=4")
@@ -1066,14 +1065,21 @@ NONREL is not NIL."
 
 (defun preview-prepare-fast-conversion ()
   "This fixes up all parameters for fast conversion."
-  (let ((file (if (consp (car preview-ps-file))
-                 (if (consp (caar preview-ps-file))
-                     (car (last (caar preview-ps-file)))
-                   (caar preview-ps-file))
-               (car preview-ps-file))))
+  (let* ((file (if (consp (car preview-ps-file))
+                  (if (consp (caar preview-ps-file))
+                      (car (last (caar preview-ps-file)))
+                    (caar preview-ps-file))
+                (car preview-ps-file)))
+        (all-files (if (and (consp (car preview-ps-file))
+                            (consp (caar preview-ps-file)))
+                       (caar preview-ps-file)
+                     (list file))))
     (setq preview-gs-dsc (preview-dsc-parse file))
     (setq preview-gs-init-string
-         (concat preview-gs-init-string
+         (concat (format "{<</PermitFileReading[%s]>> setuserparams \
+.locksafe} stopped pop "
+                         (mapconcat 'preview-ps-quote-filename all-files ""))
+                 preview-gs-init-string
                  (format "[%s(r)file]aload exch %s .runandhide aload pop "
                          (preview-ps-quote-filename file)
                          (preview-gs-dsc-cvx 0 preview-gs-dsc))))))
@@ -1456,9 +1462,9 @@ numbers (can be float if available)."
 Fallback to :inherit and 'default implemented."
   :group 'preview-appearance)
 
-(defcustom preview-auto-reveal '(eval (preview-arrived-via
-                                      (key-binding [left])
-                                      (key-binding [right])))
+(defcustom preview-auto-reveal
+  '(eval (preview-arrived-via (key-binding [left]) (key-binding [right])
+                             'backward-char 'forward-char))
   "*Cause previews to open automatically when entered.
 Possibilities are:
 T autoopens,
@@ -3512,7 +3518,7 @@ internal parameters, STR may be a log to insert into the 
current log."
 
 (defconst preview-version (eval-when-compile
   (let ((name "$Name:  $")
-       (rev "$Revision: 1.284 $"))
+       (rev "$Revision: 1.287 $"))
     (or (when (string-match "\\`[$]Name: *release_\\([^ ]+\\) *[$]\\'" name)
          (setq name (match-string 1 name))
          (while (string-match "_" name)
@@ -3526,7 +3532,7 @@ If not a regular release, CVS revision of `preview.el'.")
 
 (defconst preview-release-date
   (eval-when-compile
-    (let ((date "$Date: 2009-06-18 19:20:46 $"))
+    (let ((date "$Date: 2012-12-04 08:01:34 $"))
       (string-match
        "\\`[$]Date: *\\([0-9]+\\)/\\([0-9]+\\)/\\([0-9]+\\)"
        date)
diff --git a/style/beamer.el b/style/beamer.el
index 7b911cd4..cd4fa095 100644
--- a/style/beamer.el
+++ b/style/beamer.el
@@ -119,7 +119,9 @@
     '("actionenv")
     '("alertblock" 1)
     '("beamerboxesrounded" 1)
-    '("block" 1)
+    '("block" (lambda (env &rest ignore)
+               (LaTeX-insert-environment
+                env (format "{%s}" (read-string "Title: ")))))
     '("column" "Width")
     "columns"
     "columnsonlytextwidth"
diff --git a/style/polski.el b/style/biblatex.el
similarity index 54%
copy from style/polski.el
copy to style/biblatex.el
index 1f5d62ed..3a66cff8 100644
--- a/style/polski.el
+++ b/style/biblatex.el
@@ -1,10 +1,10 @@
-;;; polski.el --- AUCTeX style for `polski.sty'.
+;;; biblatex.el --- AUCTeX style for `biblatex.sty'
 
-;; Copyright (C) 2007 Free Software Foundation, Inc.
+;; Copyright (C) 2012 Free Software Foundation, Inc.
 
 ;; Author: Ralf Angeli <angeli@caeruleus.net>
 ;; Maintainer: auctex-devel@gnu.org
-;; Created: 2007-01-11
+;; Created: 2012-11-14
 ;; Keywords: tex
 
 ;; This file is part of AUCTeX.
@@ -26,29 +26,22 @@
 
 ;;; Commentary:
 
-;; Set up AUCTeX for editing Polish text in connection with
-;; `polski.sty'.
+;; This file adds support for `biblatex.sty'.
 
 ;;; Code:
 
-(defvar LaTeX-polski-package-options
-  '("plmath" "nomathsymbols" "MeX" "T1" "QX" "OT1" "OT4" "prefixinginverb"
-    "noprefixinginverb" "roku" "r." "noroku")
-  "Package options for polski.sty.")
-
 (TeX-add-style-hook
- "polski"
+ "biblatex"
  (lambda ()
-   (TeX-add-symbols
-    ;; Dashes
-    "dywiz"
-    "pauza"
-    "ppauza")
-   ;; Quotation marks
-   (setq TeX-quote-language '("polski" ",," "''" t))
-   ;; Fontification of quotation marks.
-   (when (fboundp 'font-latex-add-quotes)
-     (font-latex-add-quotes '(",," "''")))
-   (run-hooks 'TeX-language-pl-hook)))
-
-;;; polski.el ends here
+   ;; Unfortunately `(member "backend=biber" TeX-active-styles)' does
+   ;; not work as a test because "backend=biber" is added to
+   ;; `TeX-active-styles' after "biblatex".  So we check the value of
+   ;; `LaTeX-biblatex-use-biber' and let the user set it if desired.
+   (when LaTeX-biblatex-use-Biber
+     (setq LaTeX-using-Biber t))))
+
+;; TODO: Add package options.
+(defvar LaTeX-biblatex-package-options nil
+  "Package options for the biblatex package.")
+
+;;; biblatex.el ends here
diff --git a/style/bulgarian.el b/style/bulgarian.el
index 3eb0144b..77cb2b28 100644
--- a/style/bulgarian.el
+++ b/style/bulgarian.el
@@ -41,7 +41,9 @@
  "bulgarian"
  (lambda ()
    (set-syntax-table LaTeX-bulgarian-mode-syntax-table)
-   (setq TeX-quote-language `("bulgarian" "\"`" "\"'" ,TeX-quote-after-quote))
+   (unless (eq (car TeX-quote-language) 'override)
+     (setq TeX-quote-language
+          `("bulgarian" "\"`" "\"'" ,TeX-quote-after-quote)))
    (setq LaTeX-babel-hyphen-language "bulgarian")
    ;; Fontification of quotation marks.
    (when (fboundp 'font-latex-add-quotes)
diff --git a/style/czech.el b/style/czech.el
index 4d8eb0b2..61681890 100644
--- a/style/czech.el
+++ b/style/czech.el
@@ -3,5 +3,6 @@
 (TeX-add-style-hook
  "czech"
  (lambda ()
-   (setq TeX-quote-language `("czech" "\\uv{" "}" ,TeX-quote-after-quote))
+   (unless (eq (car TeX-quote-language) 'override)
+     (setq TeX-quote-language `("czech" "\\uv{" "}" ,TeX-quote-after-quote)))
    (run-hooks 'TeX-language-cz-hook)))
diff --git a/style/danish.el b/style/danish.el
index 77a01642..775fee04 100644
--- a/style/danish.el
+++ b/style/danish.el
@@ -5,12 +5,13 @@
 (TeX-add-style-hook
  "danish"
  (lambda ()
-   (setq TeX-quote-language `("danish" "\"`" "\"'" ,TeX-quote-after-quote))
+   (unless (eq (car TeX-quote-language) 'override)
+     (setq TeX-quote-language `("danish" "\"`" "\"'" ,TeX-quote-after-quote)))
    (setq LaTeX-babel-hyphen-language "danish")
    ;; Fontification of quotation marks.
    (when (fboundp 'font-latex-add-quotes)
      (font-latex-add-quotes '("\"`" "\"'"))
-     (font-latex-add-quotes '("\"<" "\">" french)))
+     (font-latex-add-quotes '("\">" "\"<" german)))
    (run-hooks 'TeX-language-dk-hook)))
 
 ;;; danish.el ends here
diff --git a/style/doc.el b/style/doc.el
index 3c702201..b342d87c 100644
--- a/style/doc.el
+++ b/style/doc.el
@@ -57,101 +57,101 @@
 
 (TeX-add-style-hook
  "doc"
- (function
-  (lambda ()
-    (add-to-list (make-local-variable 'LaTeX-indent-environment-list)
-                '("macrocode" current-indentation))
-    (add-to-list 'LaTeX-indent-environment-list
-                '("macrocode*" current-indentation))
-    (add-hook 'LaTeX-after-insert-env-hooks 'LaTeX-doc-after-insert-macrocode
-             nil t)
-    (LaTeX-add-environments
-     "theglossary"
-     '("macrocode" LaTeX-env-no-comment)
-     '("macrocode*" LaTeX-env-no-comment)
-     '("macro" "Macro"))
-    (TeX-add-symbols
-     "EnableCrossrefs"
-     "DisableCrossrefs"
-     "DoNotIndex"
-     "DontCheckModules"
-     "CheckModules"
-     "Module"
-     '("DescribeMacro" "Macro")
-     '("DescribeEnv" "Environment")
-     "verbatim"
-     "verb"
-     "parg"
-     "oarg"
-     "marg"
-     "meta"
-     "cmd"
-     "makelabel"
-     "MacroFont"
-     "MacroFont"
-     "AltMacroFont"
-     "AltMacroFont"
-     "PrintMacroName"
-     "PrintDescribeMacro"
-     "PrintDescribeEnv"
-     "PrintEnvName"
-     "MakePrivateLetters"
-     "actualchar"
-     "quotechar"
-     "levelchar"
-     "encapchar"
-     "verbatimchar"
-     "SpecialIndex"
-     "SpecialMainIndex"
-     "SpecialMainEnvIndex"
-     "SpecialUsageIndex"
-     "SpecialEnvIndex"
-     "SortIndex"
-     "LeftBraceIndex"
-     "RightBraceIndex"
-     "PercentIndex"
-     "OldMakeindex"
-     "PercentIndex"
-     "IndexPrologue"
-     "IndexParms"
-     "subitem"
-     "subsubitem"
-     "indexspace"
-     "efill"
-     "pfill"
-     "PrintIndex"
-     '("changes" "version" "date (YYYY/MM/DD)")
-     "generalname"
-     "RecordChanges"
-     "GlossaryPrologue"
-     "GlossaryParms"
-     "PrintChanges"
-     "AlsoImplementation"
-     "StopEventually"
-     "OnlyDescription"
-     "Finale"
-     "IndexInput"
-     "maketitle"
-     "MakeShortVerb"
-     "DeleteShortVerb"
-     "MakeShortverb"
-     "DeleteShortverb"
-     "CheckSum"
-     "CharacterTable"
-     "CharTableChanges"
-     "CodelineNumbered"
-     "CodelineIndex"
-     "PageIndex"
-     "theCodelineNo"
-     "theCodelineNo"
-     "DocstyleParms"
-     "MakePercentIgnore"
-     "MakePercentComment"
-     "DocInput"
-     "DocInclude"
-     "GetFileInfo"
-     "filename"
-     "fileinfo"))))
+ (lambda ()
+   (add-to-list (make-local-variable 'LaTeX-indent-environment-list)
+               '("macrocode" current-indentation))
+   (add-to-list 'LaTeX-indent-environment-list
+               '("macrocode*" current-indentation))
+   (add-hook 'LaTeX-after-insert-env-hooks 'LaTeX-doc-after-insert-macrocode
+            nil t)
+   (LaTeX-add-environments
+    "theglossary"
+    '("macrocode" LaTeX-env-no-comment)
+    '("macrocode*" LaTeX-env-no-comment)
+    '("macro" "Macro"))
+   (TeX-add-symbols
+    "EnableCrossrefs"
+    "DisableCrossrefs"
+    "DoNotIndex"
+    "DontCheckModules"
+    "CheckModules"
+    "Module"
+    '("DescribeMacro" "Macro")
+    '("DescribeEnv" "Environment")
+    "verbatim"
+    "verb"
+    "parg"
+    "oarg"
+    "marg"
+    "meta"
+    "cmd"
+    "makelabel"
+    "MacroFont"
+    "MacroFont"
+    "AltMacroFont"
+    "AltMacroFont"
+    "PrintMacroName"
+    "PrintDescribeMacro"
+    "PrintDescribeEnv"
+    "PrintEnvName"
+    "MakePrivateLetters"
+    "actualchar"
+    "quotechar"
+    "levelchar"
+    "encapchar"
+    "verbatimchar"
+    "SpecialIndex"
+    "SpecialMainIndex"
+    "SpecialMainEnvIndex"
+    "SpecialUsageIndex"
+    "SpecialEnvIndex"
+    "SortIndex"
+    "LeftBraceIndex"
+    "RightBraceIndex"
+    "PercentIndex"
+    "OldMakeindex"
+    "PercentIndex"
+    "IndexPrologue"
+    "IndexParms"
+    "subitem"
+    "subsubitem"
+    "indexspace"
+    "efill"
+    "pfill"
+    "PrintIndex"
+    '("changes" "version" "date (YYYY/MM/DD)")
+    "generalname"
+    "RecordChanges"
+    "GlossaryPrologue"
+    "GlossaryParms"
+    "PrintChanges"
+    "AlsoImplementation"
+    "StopEventually"
+    "OnlyDescription"
+    "Finale"
+    "IndexInput"
+    "maketitle"
+    "MakeShortVerb"
+    "DeleteShortVerb"
+    "MakeShortverb"
+    "DeleteShortverb"
+    "CheckSum"
+    "CharacterTable"
+    "CharTableChanges"
+    "CodelineNumbered"
+    "CodelineIndex"
+    "PageIndex"
+    "theCodelineNo"
+    "theCodelineNo"
+    "DocstyleParms"
+    "MakePercentIgnore"
+    "MakePercentComment"
+    "DocInput"
+    "DocInclude"
+    "GetFileInfo"
+    "filename"
+    "fileinfo")
+   (TeX-run-style-hooks "shortvrb")))
 
 ;; Local Variables:
 ;; coding: iso-8859-1
diff --git a/style/polski.el b/style/french.el
similarity index 54%
copy from style/polski.el
copy to style/french.el
index 1f5d62ed..31a468a9 100644
--- a/style/polski.el
+++ b/style/french.el
@@ -1,10 +1,10 @@
-;;; polski.el --- AUCTeX style for `polski.sty'.
+;;; french.el --- AUCTeX style for the `french' babel option.
 
-;; Copyright (C) 2007 Free Software Foundation, Inc.
+;; Copyright (C) 2010 Free Software Foundation, Inc.
 
 ;; Author: Ralf Angeli <angeli@caeruleus.net>
 ;; Maintainer: auctex-devel@gnu.org
-;; Created: 2007-01-11
+;; Created: 2010-03-20
 ;; Keywords: tex
 
 ;; This file is part of AUCTeX.
@@ -26,29 +26,23 @@
 
 ;;; Commentary:
 
-;; Set up AUCTeX for editing Polish text in connection with
-;; `polski.sty'.
+;; Set up AUCTeX for editing French text in connection with the
+;; `french' babel option.  The file basically loads the style file for
+;; the `frenchb' babel option.
+;; 
+;; Support for the FrenchPro package by Bernard Gaulle is _not_
+;; included.  If the presence of FrenchPro is detected, the `frenchb'
+;; support is not loaded.
 
 ;;; Code:
 
-(defvar LaTeX-polski-package-options
-  '("plmath" "nomathsymbols" "MeX" "T1" "QX" "OT1" "OT4" "prefixinginverb"
-    "noprefixinginverb" "roku" "r." "noroku")
-  "Package options for polski.sty.")
-
 (TeX-add-style-hook
- "polski"
+ "french"
  (lambda ()
-   (TeX-add-symbols
-    ;; Dashes
-    "dywiz"
-    "pauza"
-    "ppauza")
-   ;; Quotation marks
-   (setq TeX-quote-language '("polski" ",," "''" t))
-   ;; Fontification of quotation marks.
-   (when (fboundp 'font-latex-add-quotes)
-     (font-latex-add-quotes '(",," "''")))
-   (run-hooks 'TeX-language-pl-hook)))
-
-;;; polski.el ends here
+   (when (and (member "babel" TeX-active-styles)
+             (not (member "frenchpro" TeX-active-styles))
+             (not (member "frenchle" TeX-active-styles))
+             (not (member "mlp" TeX-active-styles)))
+     (TeX-run-style-hooks "frenchb"))))
+
+;;; french.el ends here
diff --git a/style/frenchb.el b/style/frenchb.el
index fcef8a1d..83f90024 100644
--- a/style/frenchb.el
+++ b/style/frenchb.el
@@ -66,12 +66,13 @@
      "ThinSpaceInFrenchNumbers"
      "FrenchLayout"
      "StandardLayout")
-   (setq TeX-quote-language
-        `("french" "\\og "
-          (lambda ()
-            (concat "\\fg"
-                    (unless (member "xspace" TeX-active-styles) "{}")))
-          ,TeX-quote-after-quote))
+   (unless (eq (car TeX-quote-language) 'override)
+     (setq TeX-quote-language
+          `("french" "\\og "
+            (lambda ()
+              (concat "\\fg"
+                      (unless (member "xspace" TeX-active-styles) "{}")))
+            ,TeX-quote-after-quote)))
    (run-hooks 'TeX-language-fr-hook)))
 
 ;;; frenchb.el ends here
diff --git a/style/german.el b/style/german.el
index 3676176d..d1acbbfe 100644
--- a/style/german.el
+++ b/style/german.el
@@ -38,9 +38,12 @@
             `("german" ,open-quote ,close-quote ,q-after-q))))
    (setq LaTeX-babel-hyphen-language "german")
    ;; Fontification of quotation marks.
-   (when (fboundp 'font-latex-add-quotes)
+   (when (and (eq TeX-install-font-lock 'font-latex-setup)
+             (featurep 'font-latex))
      (font-latex-add-quotes '("\"`" "\"'"))
-     (font-latex-add-quotes '("\">" "\"<" german)))
+     (font-latex-add-quotes '("\">" "\"<" german))
+     ;; Prevent "| from leading to color bleed.
+     (font-latex-add-to-syntax-alist (list (cons ?\" "\\"))))
    (run-hooks 'TeX-language-de-hook)))
 
 ;;; german.el ends here
diff --git a/style/harvard.el b/style/harvard.el
index 480c303f..83463ea7 100644
--- a/style/harvard.el
+++ b/style/harvard.el
@@ -1,26 +1,27 @@
 ;;; harvard.el --- Support for Harvard Citation style package for AUCTeX.
 
-;; Copyright (C) 1994,1997,2005,2012  Free Software Foundation, Inc.
+;; Copyright (C) 1994, 1997, 2005, 2012 Free Software Foundation, Inc.
 
-;; Harvard citation style is from Peter Williams
-;; available on the CTAN servers
+;; Author: Berwin Turlach <statba@nus.edu.sg>
+;; Maintainer: auctex-devel@gnu.org
+;; Keywords: tex
 
-;; Author: Berwin Turlach <berwin.turlach@anu.edu.au>
-;; Version: $Id: harvard.el,v 1.10 2008-02-03 14:53:30 angeli Exp $
+;; This file is part of AUCTeX.
 
-;; This program is free software; you can redistribute it and/or modify
-;; it under the terms of the GNU General Public License as published by
+;; 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.
-;; 
-;; This program 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.
-;; 
+
+;; 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 this program; if not, write to the Free Software Foundation,
-;; Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+;; 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.
 
 ;;; Code:
 
diff --git a/style/icelandic.el b/style/icelandic.el
index 6f4a9a12..f7750dd1 100644
--- a/style/icelandic.el
+++ b/style/icelandic.el
@@ -41,7 +41,8 @@
  "icelandic"
  (lambda ()
    (set-syntax-table LaTeX-icelandic-mode-syntax-table)
-   (setq TeX-quote-language '("icelandic" "\"`" "\"'" t))
+   (unless (eq (car TeX-quote-language) 'override)
+     (setq TeX-quote-language '("icelandic" "\"`" "\"'" t)))
    (setq LaTeX-babel-hyphen-language "icelandic")
    ;; Fontification of quotation marks.
    (when (fboundp 'font-latex-add-quotes)
diff --git a/style/letter.el b/style/letter.el
index c3024bec..fa269a4b 100644
--- a/style/letter.el
+++ b/style/letter.el
@@ -1,6 +1,27 @@
 ;;; letter.el - Special code for letter style.
 
-;; $Id: letter.el,v 1.4 2008-05-25 06:50:33 angeli Exp $
+;; Copyright (C) 1993, 2012  Free Software Foundation, Inc.
+
+;; Author: Per Abrahamsen <abraham@dina.kvl.dk>
+;; Maintainer: auctex-devel@gnu.org
+;; 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.
 
 ;;; Code:
 
@@ -46,7 +67,8 @@
          (newline-and-indent)))
     (if (not (zerop (length date)))
        (progn
-         (insert TeX-esc "def" TeX-esc "today" TeX-grop date TeX-grcl)
+         (insert TeX-esc "renewcommand" TeX-grop TeX-esc "today" TeX-grcl
+                 TeX-grop date TeX-grcl)
          (newline-and-indent)))
     (newline-and-indent)
 
diff --git a/style/lettrine.el b/style/lettrine.el
new file mode 100644
index 00000000..f595c43c
--- /dev/null
+++ b/style/lettrine.el
@@ -0,0 +1,74 @@
+;;; lettrine.el --- AUCTeX style for `lettrine.sty'
+
+;; Copyright (C) 2011 Free Software Foundation, Inc.
+
+;; Author: Mads Jensen <mje@inducks.org>
+;; 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 `lettrine.sty'.
+
+;;; Code:
+
+(defvar LaTeX-lettrine-key-val-options
+  '(("lines")
+    ("lhang")
+    ("loversize")
+    ("lraise")
+    ("findent")
+    ("nindent")
+    ("slope")
+    ("ante")
+    ("image" ("true")))
+  "Key=value options for \\lettrine")
+
+(TeX-add-style-hook
+ "lettrine"
+ (lambda ()
+   (TeX-add-symbols
+    '("lettrine" [ TeX-arg-key-val LaTeX-lettrine-key-val-options ]
+      "Letter" "Text")
+    '("LettrineImageFalse" 0)
+    ;; all of the below can be configured with either \setlength or
+    ;; \renewcommand
+    '("LettrineFont" 0)
+    '("LettrineFontHook" 0)
+    '("LettrineTextFont" 0)
+    '("LettrineWidth" 0)
+    '("DefaultLhang" 0)
+    '("DefaultLoversize" 0)
+    '("DefaultLraise" 0)
+    '("DefaultFindent" 0)
+    '("DefaultNindent" 0)
+    '("DefaultSlope" 0)
+    ;; above settings can also be input a file, and pointed to with
+    ;; \renewcommand
+    '("DefaultOptionsFile" 0))
+
+   ;; Fontification
+   (when (and (fboundp 'font-latex-add-keywords)
+              (eq TeX-install-font-lock 'font-latex-setup))
+     (font-latex-add-keywords '(("lettrine" "[{{")) 'textual))))
+
+(defvar LaTeX-lettrine-package-options nil
+  "Package options for the lettrine package.")
+
+;;; lettrine.el ends here
diff --git a/style/multicol.el b/style/multicol.el
new file mode 100644
index 00000000..5d732219
--- /dev/null
+++ b/style/multicol.el
@@ -0,0 +1,62 @@
+;;; multicol.el --- AUCTeX style for `multicol.sty'
+
+;; Copyright (C) 2011 Free Software Foundation, Inc.
+
+;; Author: Mads Jensen <mje@inducks.org>
+;; Maintainer: auctex-devel@gnu.org
+;; Created: 2011-01-24
+;; 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 `multicol.sty'.
+
+;;; Code:
+
+(TeX-add-style-hook
+ "multicol"
+ (lambda ()
+   (LaTeX-add-environments
+    '("multicols" "Number of columns" [ "Text across columns" ]
+      [ "Local value for \\premulticols" ])
+    '("multicols*" "Number of columns" [ "Text across columns" ]
+      [ "Local value for \\premulticols" ]))
+
+   (TeX-add-symbols
+    '("multicoltolerance" 0)
+    '("multicolpretolerance" 0)
+    '("premulticols" 0)
+    '("postmulticols" 0)
+    '("multicolsep" 0)
+    '("multicolbaselineskip" 0)
+    '("multicolovershoot" 0)
+    '("multicolundershoot" 0)
+    '("columnsep" 0)
+    '("columnseprule" 0)
+    '("columnseprulecolor" 0)
+    '("raggedcolumns" 0)
+    '("flushcolumns" 0)
+    "columnbreak")))
+
+(defvar LaTeX-multicol-package-options
+  '("errorshow" "infoshow" "balancingshow" "markshow" "debugshow" "grid")
+  "Package options for the multicol package.")
+
+;;; multicol.el ends here
diff --git a/style/natbib.el b/style/natbib.el
index 31243065..bf9971e2 100644
--- a/style/natbib.el
+++ b/style/natbib.el
@@ -1,7 +1,28 @@
-;;; natbib.el --- Style hook for the NatBib package
-;;;
-;;; AUTHOR: Carsten Dominik <dominik@strw.leidenuniv.nl>
-;;;         building on older code from Berwin Turlach
+;;; natbib.el --- Style hook for the natbib package
+
+;; Copyright (C) 1997, 1998, 2004, 2007 Free Software Foundation, Inc.
+
+;; Authors: Berwin Turlach <statba@nus.edu.sg>
+;;          Carsten Dominik <dominik@strw.leidenuniv.nl>
+;; Maintainer: auctex-devel@gnu.org
+;; 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.
 
 ;;; Code:
 
diff --git a/style/ngerman.el b/style/ngerman.el
index d6b972ac..8acd2f56 100644
--- a/style/ngerman.el
+++ b/style/ngerman.el
@@ -37,10 +37,13 @@
        (setq TeX-quote-language
             `("ngerman" ,open-quote ,close-quote ,q-after-q))))
    (setq LaTeX-babel-hyphen-language "ngerman")
-   ;; Fontification of quotation marks.
-   (when (fboundp 'font-latex-add-quotes)
+   ;; Fontification
+   (when (and (eq TeX-install-font-lock 'font-latex-setup)
+             (featurep 'font-latex))
      (font-latex-add-quotes '("\"`" "\"'"))
-     (font-latex-add-quotes '("\">" "\"<" german)))
+     (font-latex-add-quotes '("\">" "\"<" german))
+     ;; Prevent "| from leading to color bleed.
+     (font-latex-add-to-syntax-alist (list (cons ?\" "\\"))))
    (run-hooks 'TeX-language-de-hook)))
 
 ;;; ngerman.el ends here
diff --git a/style/polish.el b/style/polish.el
index 312274af..1538f9c2 100644
--- a/style/polish.el
+++ b/style/polish.el
@@ -41,7 +41,8 @@
  "polish"
  (lambda ()
    (set-syntax-table LaTeX-polish-mode-syntax-table)
-   (setq TeX-quote-language '("polish" "\"`" "\"'" t))
+   (unless (eq (car TeX-quote-language) 'override)
+     (setq TeX-quote-language '("polish" "\"`" "\"'" t)))
    ;; Fontification of quotation marks.
    (when (fboundp 'font-latex-add-quotes)
      (font-latex-add-quotes '("\"`" "\"'"))
diff --git a/style/polski.el b/style/polski.el
index 1f5d62ed..7b6fcfc0 100644
--- a/style/polski.el
+++ b/style/polski.el
@@ -45,7 +45,8 @@
     "pauza"
     "ppauza")
    ;; Quotation marks
-   (setq TeX-quote-language '("polski" ",," "''" t))
+   (unless (eq (car TeX-quote-language) 'override)
+     (setq TeX-quote-language '("polski" ",," "''" t)))
    ;; Fontification of quotation marks.
    (when (fboundp 'font-latex-add-quotes)
      (font-latex-add-quotes '(",," "''")))
diff --git a/style/setspace.el b/style/setspace.el
new file mode 100644
index 00000000..07db8caf
--- /dev/null
+++ b/style/setspace.el
@@ -0,0 +1,61 @@
+;;; setspace.el --- AUCTeX style for `setspace.sty'
+
+;; Copyright (C) 2011 Free Software Foundation, Inc.
+
+;; Author: Mads Jensen <mje@inducks.org>
+;; Created: 2011-04-16
+;; 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 `setspace.sty'.
+
+;;; Code:
+
+(TeX-add-style-hook
+ "setspace"
+ (lambda ()
+   (TeX-add-symbols
+    '("setstretch" "Stretch")
+    '("setdisplayskipstretch" "Stretch")
+    '("SetSinglespace" "Stretch")
+    '("onehalfspacing" 0)
+    '("doublespacing" 0)
+    '("singlespacing" 0))
+
+   (LaTeX-add-environments 
+    '("spacing" "Stretch")
+    "singlespace"
+    "singlespace*"
+    "onehalfspace"
+    "doublespace")
+
+   (when (and (featurep 'font-latex)
+              (eq TeX-install-font-lock 'font-latex-setup))
+     (font-latex-add-keywords '(("singlespacing" "")
+                               ("doublespacing" "")
+                               ("onehalfspacing" ""))
+                              'function))))
+
+(defvar LaTeX-setspace-package-options 
+  '("doublespacing" "onehalfspacing" "singlespacing" "nodisplayskipstretch")
+  "Package options for the setspace package.")
+
+;;; setspace.el ends here
diff --git a/style/slovak.el b/style/slovak.el
index 57083a49..d1475731 100644
--- a/style/slovak.el
+++ b/style/slovak.el
@@ -3,7 +3,8 @@
 (TeX-add-style-hook
  "slovak"
  (lambda ()
-   (setq TeX-quote-language `("slovak" "\\uv{" "}" ,TeX-quote-after-quote))
+   (unless (eq (car TeX-quote-language) 'override)
+     (setq TeX-quote-language `("slovak" "\\uv{" "}" ,TeX-quote-after-quote)))
    (when (fboundp 'font-latex-add-quotes)
      (font-latex-add-quotes '("\"`" "\"'"))
      (font-latex-add-quotes '("\"<" "\">" french)))
diff --git a/style/swedish.el b/style/swedish.el
index 01016328..75f63379 100644
--- a/style/swedish.el
+++ b/style/swedish.el
@@ -7,7 +7,8 @@
 (TeX-add-style-hook
  "swedish"
  (lambda ()
-   (setq TeX-quote-language
-        `("swedish" "''" ,TeX-close-quote ,TeX-quote-after-quote))
+   (unless (eq (car TeX-quote-language) 'override)
+     (setq TeX-quote-language
+          `("swedish" "''" ,TeX-close-quote ,TeX-quote-after-quote)))
    (setq LaTeX-babel-hyphen-language "swedish")
    (run-hooks 'TeX-language-sv-hook)))
diff --git a/style/virtex.el b/style/virtex.el
index b821eb99..18f58bc2 100644
--- a/style/virtex.el
+++ b/style/virtex.el
@@ -1,11 +1,10 @@
 ;;; virtex.el - Common code for all TeX formats.
 
-;; $Id: virtex.el,v 1.1 1994-01-23 08:14:44 amanda Exp $
+;; Author: Per Abrahamsen <abraham@dina.kvl.dk>
 
 ;;; Code:
 
 (TeX-add-style-hook "virtex"
- (function
   (lambda ()
     (TeX-add-symbols "/" "above" "abovedisplayshortskip"
                     "abovedisplayskip" "abovewithdelims" "accent"
@@ -78,6 +77,6 @@
                     "vcenter" "vfil" "vfill" "vfilneg" "vfuzz"
                     "voffset" "vrule" "vsize" "vskip" "vss" "vtop"
                     "wd" "widowpenalty" "write" "xdef" "xleaders"
-                    "xspaceskip" "year"))))
+                    "xspaceskip" "year")))
 
 ;;; virtex.el ends here
diff --git a/style/polski.el b/style/xspace.el
similarity index 51%
copy from style/polski.el
copy to style/xspace.el
index 1f5d62ed..15f92167 100644
--- a/style/polski.el
+++ b/style/xspace.el
@@ -1,10 +1,9 @@
-;;; polski.el --- AUCTeX style for `polski.sty'.
+;;; xspace.el --- AUCTeX style for `xspace.sty'
 
-;; Copyright (C) 2007 Free Software Foundation, Inc.
+;; Copyright (C) 2011 Free Software Foundation, Inc.
 
-;; Author: Ralf Angeli <angeli@caeruleus.net>
-;; Maintainer: auctex-devel@gnu.org
-;; Created: 2007-01-11
+;; Author: Mads Jensen <mje@inducks.org>
+;; Created: 2011-02-01
 ;; Keywords: tex
 
 ;; This file is part of AUCTeX.
@@ -26,29 +25,27 @@
 
 ;;; Commentary:
 
-;; Set up AUCTeX for editing Polish text in connection with
-;; `polski.sty'.
+;; This file adds support for `xspace.sty'.
 
 ;;; Code:
 
-(defvar LaTeX-polski-package-options
-  '("plmath" "nomathsymbols" "MeX" "T1" "QX" "OT1" "OT4" "prefixinginverb"
-    "noprefixinginverb" "roku" "r." "noroku")
-  "Package options for polski.sty.")
-
 (TeX-add-style-hook
- "polski"
+ "xspace"
  (lambda ()
    (TeX-add-symbols
-    ;; Dashes
-    "dywiz"
-    "pauza"
-    "ppauza")
-   ;; Quotation marks
-   (setq TeX-quote-language '("polski" ",," "''" t))
-   ;; Fontification of quotation marks.
-   (when (fboundp 'font-latex-add-quotes)
-     (font-latex-add-quotes '(",," "''")))
-   (run-hooks 'TeX-language-pl-hook)))
-
-;;; polski.el ends here
+    '("xspace" 0)
+    "xspaceaddexception"
+    "xspaceremoveexception")
+
+   ;; Fontification
+   (when (and (featurep 'font-latex)
+             (eq TeX-install-font-lock 'font-latex-setup))
+     (font-latex-add-keywords '(("xspace" "")
+                               ("xspaceaddexception" "{")
+                               ("xspaceremoveexception" "{"))
+                             'function))))
+
+(defvar LaTeX-xspace-package-options nil
+  "Package options for the xspace package.")
+
+;;; xspace.el ends here
diff --git a/tex-buf.el b/tex-buf.el
index c1b7665b..07f0502a 100644
--- a/tex-buf.el
+++ b/tex-buf.el
@@ -76,7 +76,7 @@
 
 (defun TeX-save-document (name)
   "Save all files belonging to the current document.
-Return non-nil if document need to be re-TeX'ed."
+Return non-nil if document needs to be re-TeX'ed."
   (interactive (list (TeX-master-file)))
   (if (string-equal name "")
       (setq name (TeX-master-file)))
@@ -366,36 +366,38 @@ without further expansion."
   command)
 
 (defun TeX-check-files (derived originals extensions)
-  "Check that DERIVED is newer than any of the ORIGINALS.
+  "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'."
-  (let ((found nil)
-       (regexp (concat "\\`\\("
-                       (mapconcat (lambda (dir)
-                                    (regexp-quote
-                                     (expand-file-name
-                                      (file-name-as-directory dir))))
-                                  TeX-check-path "\\|")
-                       "\\).*\\("
-                       (mapconcat 'regexp-quote originals "\\|")
-                       "\\)\\.\\("
-                       (mapconcat 'regexp-quote extensions "\\|")
-                       "\\)\\'"))
-       (buffers (buffer-list)))
+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
+       (extensions (TeX-delete-duplicate-strings extensions))
+        (buffers (buffer-list)))
+    (dolist (path (mapcar (lambda (dir)
+                           (expand-file-name (file-name-as-directory dir)))
+                         TeX-check-path))
+      (dolist (orig originals)
+       (dolist (ext extensions)
+         (let ((filepath (concat path orig "." ext)))
+           (if (file-exists-p filepath)
+                (setq existingoriginals (cons filepath existingoriginals)))))))
     (while buffers
       (let* ((buffer (car buffers))
-            (name (buffer-file-name buffer)))
-       (setq buffers (cdr buffers))
-       (if (and name (string-match regexp name))
-           (progn
-             (and (buffer-modified-p buffer)
-                  (or (not TeX-save-query)
-                      (y-or-n-p (concat "Save file "
-                                        (buffer-file-name buffer)
-                                        "? ")))
-                  (save-excursion (set-buffer buffer) (save-buffer)))
-             (if (file-newer-than-file-p name derived)
-                 (setq found t))))))
+             (name (buffer-file-name buffer)))
+        (setq buffers (cdr buffers))
+        (if (and name (member name existingoriginals))
+            (progn
+              (and (buffer-modified-p buffer)
+                   (or (not TeX-save-query)
+                       (y-or-n-p (concat "Save file "
+                                         (buffer-file-name buffer)
+                                         "? ")))
+                   (save-excursion (set-buffer buffer) (save-buffer)))))))
+    (dolist (eo existingoriginals)
+      (if (file-newer-than-file-p eo derived)
+          (setq found t)))
     found))
 
 (defcustom TeX-save-query t
@@ -407,34 +409,38 @@ in `TeX-check-path'."
 
 (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))
-                             (TeX-check-files (concat name ".bbl")
-                                              (mapcar 'car
-                                                      
(LaTeX-bibliography-list))
-                                              BibTeX-file-extensions))
-                        ;; We should check for bst files here as well.
-                        TeX-command-BibTeX)
-                       ((TeX-process-get-variable name
-                                                  'TeX-command-next
-                                                  TeX-command-Show))
-                       (TeX-command-Show)))
-        (completion-ignore-case t)
-        (answer (or TeX-command-force
-                    (completing-read
-                     (concat "Command: (default " default ") ")
-                     (TeX-mode-specific-command-list major-mode) nil t
-                     nil 'TeX-command-history))))
-    ;; If the answer "latex" it will not be expanded to "LaTeX"
+  (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)))
+         (completion-ignore-case t)
+         (answer (or TeX-command-force
+                     (completing-read
+                      (concat "Command: (default " default ") ")
+                      (TeX-mode-specific-command-list major-mode) nil t
+                      nil 'TeX-command-history))))
+    ;; If the answer is "latex" it will not be expanded to "LaTeX"
     (setq answer (car-safe (TeX-assoc answer TeX-command-list)))
     (if (and answer
-            (not (string-equal answer "")))
-       answer
+             (not (string-equal answer "")))
+        answer
       default)))
 
 (defvar TeX-command-next nil
@@ -673,6 +679,14 @@ run of `TeX-run-TeX', use
        process
       (TeX-synchronous-sentinel name file process))))
 
+(defun TeX-run-Biber (name command file)
+  "Create a process for NAME using COMMAND to format FILE with Biber." 
+  (let ((process (TeX-run-command name command file)))
+    (setq TeX-sentinel-function 'TeX-Biber-sentinel)
+    (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."
   (compile command))
@@ -796,7 +810,7 @@ reasons.  Use `TeX-run-function' instead."
 
 (defun TeX-synchronous-sentinel (name file result)
   "Process TeX command output buffer after the process dies."
-  (let* ((buffer (TeX-process-buffer file)))
+  (let ((buffer (TeX-process-buffer (file-name-nondirectory file))))
     (save-excursion
       (set-buffer buffer)
 
@@ -938,6 +952,21 @@ Warnings can be indicated by LaTeX or packages."
 (defun TeX-LaTeX-sentinel (process name)
   "Cleanup TeX output buffer after running LaTeX."
   (cond ((TeX-TeX-sentinel-check process name))
+       ((and (save-excursion
+               (re-search-forward
+                "^Package biblatex Warning: Please (re)run Biber on the file"
+                nil t))
+             (with-current-buffer TeX-command-buffer
+               (and (LaTeX-bibliography-list)
+                    (TeX-check-files (TeX-master-file "bbl")
+                                     (TeX-style-list)
+                                     (append TeX-file-extensions
+                                             BibTeX-file-extensions
+                                             TeX-Biber-file-extensions)))))
+        (message "%s%s" "You should run Biber to get citations right, "
+                 (TeX-current-pages))
+        (setq TeX-command-next (with-current-buffer TeX-command-buffer
+                                 TeX-command-Biber)))
        ((and (save-excursion
                (re-search-forward
                 "^\\(?:LaTeX\\|Package natbib\\) Warning: Citation" nil t))
@@ -946,11 +975,19 @@ Warnings can be indicated by LaTeX or packages."
                     (TeX-check-files (TeX-master-file "bbl")
                                      (TeX-style-list)
                                      (append TeX-file-extensions
-                                             BibTeX-file-extensions)))))
+                                             BibTeX-file-extensions
+                                             TeX-Biber-file-extensions)))))
         (message "%s%s" "You should run BibTeX to get citations right, "
                  (TeX-current-pages))
         (setq TeX-command-next (with-current-buffer TeX-command-buffer
                                  TeX-command-BibTeX)))
+  ((re-search-forward "Package biblatex Warning: Please rerun LaTeX" nil t)
+        (message "%s%s" "You should run LaTeX again, " (TeX-current-pages))
+        (setq TeX-command-next TeX-command-default))
+       ((re-search-forward "^(biblatex)\\W+Page breaks have changed" nil t)
+        (message "%s%s" "You should run LaTeX again - page breaks have 
changed, "
+                 (TeX-current-pages))
+        (setq TeX-command-next TeX-command-default))
        ((re-search-forward "^\\(?:LaTeX Warning: Label(s)\\|\
 Package natbib Warning: Citation(s)\\)" nil t)
         (message "%s%s" "You should run LaTeX again to get references right, "
@@ -1008,8 +1045,32 @@ changed\\. Rerun LaTeX\\." nil t)
              "\\<TeX-mode-map>\\[TeX-recenter-output-buffer]")))
    (t
     (message (concat "BibTeX finished successfully. "
-                    "Run LaTeX again to get citations right."))))
-  (setq TeX-command-next TeX-command-default))
+                    "Run LaTeX again to get citations right."))
+  (setq TeX-command-next TeX-command-default))))
+
+(defun TeX-Biber-sentinel (process name)
+  "Cleanup TeX output buffer after running Biber."
+  (goto-char (point-max))
+  (cond
+   ((re-search-backward (concat
+                         "^INFO - \\(WARNINGS\\|ERRORS\\): \\([0-9]+\\)") nil 
t)
+    (message (concat "Biber finished with %s %s. "
+                     "Type `%s' to display output.")
+             (match-string 2) (downcase (match-string 1))
+             (substitute-command-keys
+              "\\<TeX-mode-map>\\[TeX-recenter-output-buffer]"))
+    (setq TeX-command-next TeX-command-default))
+   ((re-search-backward (concat
+                         "^FATAL") nil t)
+    (message (concat "Biber had a fatal error and did not finish! "
+                     "Type `%s' to display output.")
+             (substitute-command-keys
+              "\\<TeX-mode-map>\\[TeX-recenter-output-buffer]"))
+    (setq TeX-command-next TeX-command-Biber))
+   (t
+    (message (concat "Biber finished successfully. "
+                     "Run LaTeX again to get citations right."))
+    (setq TeX-command-next TeX-command-default))))
 
 ;;; Process Control
 
@@ -1114,7 +1175,7 @@ command."
        ;; Remove line breaks at column 79
        (while (> (point) pt)
          (end-of-line 0)
-         (when (and (= (current-column) 79)
+         (when (and (= (- (point) (line-beginning-position)) 79)
                     ;; Heuristic: Don't delete the linebreak if the
                     ;; next line is empty or starts with an opening
                     ;; parenthesis or if point is located after a period.
@@ -1491,7 +1552,7 @@ You might want to examine and modify the free variables 
`file',
         
         ;; End of file -- Pop from stack
         ((match-beginning 4)
-         (when (> (length TeX-error-file) 1)
+         (when (> (length TeX-error-file) 0)
            (pop TeX-error-file)
            (pop TeX-error-offset))
          (goto-char (match-end 4))
@@ -1634,6 +1695,9 @@ You might want to examine and modify the free variables 
`file',
     (goto-char error-point)
     (setq TeX-error-point (point))
 
+    (unless file
+      (error "Could not determine file for warning"))
+
     ;; Go back to TeX-buffer
     (let ((runbuf (current-buffer))
          (master (with-current-buffer
diff --git a/tex-fold.el b/tex-fold.el
index 0b8de3a0..05bd61a7 100644
--- a/tex-fold.el
+++ b/tex-fold.el
@@ -1,6 +1,7 @@
 ;;; tex-fold.el --- Fold TeX macros.
 
-;; Copyright (C) 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2011-2012
+;;   Free Software Foundation, Inc.
 
 ;; Author: Ralf Angeli <angeli@caeruleus.net>
 ;; Maintainer: auctex-devel@gnu.org
@@ -763,21 +764,21 @@ Return non-nil if a removal happened, nil otherwise."
 Replace them with the respective macro argument."
   (let ((spec-list (split-string spec "||"))
        (delims '((?{ . ?}) (?[ . ?]) (?< . ?>) (?\( . ?\))))
-       match-end success)
+       index success)
     (catch 'success
       ;; Iterate over alternatives.
       (dolist (elt spec-list)
-       (setq spec elt)
+       (setq spec elt
+             index nil)
        ;; Find and expand every placeholder.
-       (while (and (string-match "\\([[{<]\\)\\([1-9]\\)\\([]}>]\\)" elt
-                                 match-end)
-                   ;; Does the closing delim fit to the opening one?
+       (while (and (string-match "\\([[{<]\\)\\([1-9]\\)\\([]}>]\\)" elt index)
+                   ;; Does the closing delim match the opening one?
                    (string-equal
                     (match-string 3 elt)
                     (char-to-string
                      (cdr (assq (string-to-char (match-string 1 elt))
                                 delims)))))
-         (setq match-end (match-beginning 0))
+         (setq index (match-end 0))
          (let ((arg (car (save-match-data
                            ;; Get the argument.
                            (TeX-fold-macro-nth-arg
@@ -788,6 +789,7 @@ Replace them with the respective macro argument."
            (when arg (setq success t))
            ;; Replace the placeholder in the string.
            (setq elt (replace-match (or arg TeX-fold-ellipsis) nil t elt)
+                 index (+ index (- (length elt) (length spec)))
                  spec elt)))
        (when success (throw 'success nil))))
     spec))
@@ -882,9 +884,10 @@ Remove the respective properties from the overlay OV."
                        (and (boundp 'global-disable-point-adjustment)
                             global-disable-point-adjustment)
                        ;; See preview.el on how to make this configurable.
-                       (memq this-command (list (key-binding [left])
-                                                (key-binding [right])
-                                                'mouse-set-point)))
+                       (memq this-command
+                             (list (key-binding [left]) (key-binding [right])
+                                   'backward-char 'forward-char
+                                   'mouse-set-point)))
                ;; Open new overlays.
                (dolist (ol (nconc (when (and TeX-fold-unfold-around-mark
                                              (boundp 'mark-active)
diff --git a/tex-fptex.el b/tex-fptex.el
deleted file mode 100644
index b00ed6df..00000000
--- a/tex-fptex.el
+++ /dev/null
@@ -1,91 +0,0 @@
-;;; tex-fptex.el --- fpTeX support for AUCTeX.
-
-;; Copyright (C) 2000, 2004, 2012 Free Software Foundation, Inc.
-
-;; Author: Fabrice Popineau <Fabrice.Popineau@supelec.fr>
-;; Maintainer: auctex-devel@gnu.org
-;; 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 contains variables customized for fpTeX.
-
-;;; Code:
-
-(defmacro parent-directory (f)
-  "Return safe parent directory of the directory given as argument."
-  `(directory-file-name
-    (file-name-directory
-     (directory-file-name ,f))))
-
-(unless (get 'TeX-lisp-directory 'saved-value)
-  (setq-default TeX-lisp-directory
-               (concat (parent-directory (invocation-directory))
-                       "/site-lisp/auctex")))
-
-  ;; Remove the Queue entry from the default, and make a non-Unix
-  ;; specific print entry, assuming that dvips will print by default.
-(unless (get 'TeX-queue-command 'saved-value)
-  (setq TeX-queue-command nil))
-
-(unless (get 'TeX-printer-list 'saved-value)
-  (setq TeX-printer-list nil))
-
-(unless (get 'TeX-print-command 'saved-value)
-  (setq TeX-print-command
-       "dvips %d"))
-
-(unless (get 'TeX-view-style 'saved-value)
-  (setq TeX-view-style '(("^a5\\(?:comb\\|paper\\)?$" "windvi %d -qpaper a5")
-                        ("^landscape$" "windvi %d -qpaper a4r -s 4")
-                        ("^epsf$" "start \"\" %f")
-                        ("." "windvi %d"))))
-
-(unless (get 'TeX-output-view-style 'saved-value)
-  (setq TeX-output-view-style
-       '(("^dvi$" "^pstricks$\\|^pst-\\|^psfrag$" "dvips %d -o && start \"\" 
%f")
-         ("^dvi$" ("^a5\\(?:comb\\|paper\\)$" "^landscape$")
-          "windvi %d %dS -qpaper a5r -s 0")
-         ("^dvi$" "^a5\\(?:comb\\|paper\\)$" "windvi %d %dS -qpaper a5")
-         ("^dvi$" "^b5paper$" "windvi %d %dS -qpaper b5")
-         ("^dvi$" ("^landscape$" "^pstricks$\\|^psfrag$")
-          "dvips -t landscape %d -o && start \"\" %f")
-         ("^dvi$" "^letterpaper$" "windvi %d %dS -qpaper us")
-         ("^dvi$" "^legalpaper$" "windvi %d %dS -qpaper legal")
-         ("^dvi$" "^executivepaper$" "windvi %d %dS -qpaper 7.25x10.5in")
-         ("^dvi$" "^landscape$" "windvi %d %dS -qpaper a4r")
-         ("^dvi$" "." "windvi %d %dS")
-         ("^pdf$" "." "start \"\" %o")
-         ("^html?$" "." "start \"\" %o"))))
-
-;; WinDVI does not support source specials?
-(unless (get 'TeX-source-specials-view-position-flags 'saved-value)
-  (setq TeX-source-specials-view-position-flags ""))
-
-(unless (get 'TeX-source-specials-view-editor-flags 'saved-value)
-  (setq TeX-source-specials-view-editor-flags ""))
-
-(unless (get 'TeX-kpathsea-path-delimiter 'saved-value)
-  (setq TeX-kpathsea-path-delimiter ";"))
-
-(provide 'tex-fptex)
-(require 'tex-site)
-
-;;; tex-fptex.el ends here
diff --git a/tex-info.el b/tex-info.el
index 6f7b8497..6649b408 100644
--- a/tex-info.el
+++ b/tex-info.el
@@ -1,7 +1,7 @@
 ;;; tex-info.el --- Support for editing Texinfo source.
 
-;; Copyright (C) 1993, 1994, 1997, 2000, 2001,
-;;               2004, 2005, 2006 Free Software Foundation, Inc.
+;; Copyright (C) 1993, 1994, 1997, 2000, 2001, 2004, 2005, 2006, 2011
+;;   Free Software Foundation, Inc.
 
 ;; Maintainer: auctex-devel@gnu.org
 ;; Keywords: tex
@@ -49,7 +49,7 @@
     ("ifxml") ("ignore") ("itemize") ("lisp") ("macro") ("menu")
     ("multitable") ("quotation") ("smalldisplay") ("smallexample")
     ("smallformat") ("smalllisp") ("table") ("tex") ("titlepage")
-    ("verbatim") ("vtable")) 
+    ("verbatim") ("vtable"))
   "Alist of Texinfo environments.")
 
 (defconst texinfo-environment-regexp
@@ -112,14 +112,18 @@ With optional ARG, modify current environment."
   (let* ((envs (mapcar 'car Texinfo-environment-list))
         (regexp (concat "^[ \t]*" (regexp-quote TeX-esc) "\\(end \\)*"
                         (regexp-opt envs t) "\\b"))
+        (orig-pos (point))
         (level 1)
         case-fold-search)
     (save-restriction
       (save-excursion
        (save-excursion
          (beginning-of-line)
+         ;; Stop if point is inside of an @end <env> command, but not
+         ;; if it is behind it.
          (when (and (looking-at regexp)
-                    (match-string 1))
+                    (match-string 1)
+                    (> (match-end 0) orig-pos))
            (setq level 0)))
        (while (and (> level 0) (re-search-forward regexp nil t))
          (if (match-string 1)
@@ -128,30 +132,163 @@ With optional ARG, modify current environment."
       (if (= level 0)
          (goto-char (match-end 0))
        (error "Can't locate end of current environment")))))
-      
+
 (defun Texinfo-find-env-start ()
   "Move point to the start of the current environment."
   (interactive)
   (let* ((envs (mapcar 'car Texinfo-environment-list))
-        (regexp (concat "^[ \t]*" (regexp-quote TeX-esc) "\\(end \\)*"
+        (regexp (concat "^[ \t]*\\(" (regexp-quote TeX-esc) "\\)\\(end \\)*"
                         (regexp-opt envs t) "\\b"))
         (level 1)
+        (orig-pos (point))
         case-fold-search)
     (save-restriction
       (save-excursion
        (save-excursion
          (beginning-of-line)
+         ;; Stop if point is inside of an @<env> command, but not if
+         ;; it is before it.
          (when (and (looking-at regexp)
-                    (not (match-string 1)))
+                    (not (match-string 2))
+                    (< (match-beginning 1) orig-pos))
            (setq level 0)))
        (while (and (> level 0) (re-search-backward regexp nil t))
-         (if (match-string 1)
+         (if (match-string 2)
              (setq level (1+ level))
            (setq level (1- level)))))
       (if (= level 0)
          (goto-char (match-beginning 0))
        (error "Can't locate start of current environment")))))
 
+(defun Texinfo-mark-environment (&optional count)
+  "Set mark to end of current environment and point to the matching begin.
+If prefix argument COUNT is given, mark the respective number of
+enclosing environments.  The command will not work properly if
+there are unbalanced begin-end pairs in comments and verbatim
+environments."
+  ;; TODO:
+  ;; This is identical to the LaTeX counterpart but for the find begin/end
+  ;; functions. So some day the implemenation should be factorized.
+  (interactive "p")
+  (setq count (if count (abs count) 1))
+  (let ((cur (point)) beg end)
+    ;; Only change point and mark after beginning and end were found.
+    ;; Point should not end up in the middle of nowhere if the search fails.
+    (save-excursion
+      (dotimes (c count)
+       (Texinfo-find-env-end))
+      (setq end (line-beginning-position 2))
+      (goto-char cur)
+      (dotimes (c count)
+       (Texinfo-find-env-start)
+       (unless (= (1+ c) count)
+         (beginning-of-line 0)))
+      (setq beg (point)))
+    (set-mark end)
+    (goto-char beg)
+    (TeX-activate-region)))
+
+(defun Texinfo-mark-section (&optional no-subsection)
+  "Mark current section, with inclusion of any containing node.
+
+The current section is detected as starting by any of the
+structuring commands matched by regexp in variable
+`outline-regexp' which in turn is a regexp matching any element
+of variable `texinfo-section-list'.
+
+If optional argument NO-SUBSECTION is set to any integer or is a
+non nil empty argument (i.e. `C-u \\[Texinfo-mark-section]'),
+then mark the current section with exclusion of any subsections.
+
+Otherwise, any included subsections are also marked along with
+current section.
+
+Note that when current section is starting immediatley after a
+node commande, then the node command is also marked as part as
+the section."
+  (interactive "P")
+  (let (beg end is-beg-section is-end-section
+           (section-re (concat "^\\s-*" outline-regexp)))
+    (if (and (consp no-subsection) (eq (car no-subsection) 4))
+       ;; section with exclusion of any subsection
+       (setq beg (save-excursion
+                   (unless (looking-at section-re)
+                     (end-of-line))
+                   (re-search-backward section-re nil t))
+             is-beg-section t
+             end (save-excursion
+                   (beginning-of-line)
+                   (when
+                       (re-search-forward (concat section-re
+                                                  "\\|^\\s-*@bye\\_>" ) nil t)
+                     (save-match-data
+                       (beginning-of-line)
+                       (point))))
+             is-end-section (match-string 1))
+      ;; full section without exclusion of any subsection
+      (let (section-command-level)
+       (setq beg
+             (save-excursion
+               (end-of-line)
+               (re-search-backward section-re nil t)))
+       (when beg
+         (setq is-beg-section t
+               section-command-level
+               (cadr (assoc (match-string 1) texinfo-section-list))
+               end
+               (save-excursion
+                 (beginning-of-line)
+                 (while
+                     (and (re-search-forward
+                           (concat section-re "\\|^\\s-*@bye\\_>" ) nil t)
+                          (or (null (setq is-end-section  (match-string 1)))
+                              (> (cadr (assoc is-end-section
+                                              texinfo-section-list))
+                                 section-command-level))))
+                 (when (match-string 0)
+                   (beginning-of-line)
+                   (point)))))));  (if ...)
+    (when (and beg end)
+      ;; now take also enclosing node of beg and end
+      (dolist
+         (boundary '(beg end))
+       (when (symbol-value (intern (concat "is-" (symbol-name boundary)
+                                           "-section")))
+         (save-excursion
+           (goto-char (symbol-value boundary))
+           (while
+               (and
+                (null (bobp))
+                (progn
+                  (beginning-of-line 0)
+                  (looking-at "^\\s-*\\($\\|@\\(c\\|comment\\)\\_>\\)"))))
+           (when  (looking-at "^\\s-*@node\\_>")
+             (set boundary (point))))))
+
+      (set-mark end)
+      (goto-char beg)
+      (TeX-activate-region) )))
+
+(defun Texinfo-mark-node ()
+  "Mark the current node.  \
+This is the node in which the pointer is.  It is starting at
+previous beginning of keyword `@node' and ending at next
+beginning of keyword `@node' or `@bye'."
+  (interactive)
+  (let ((beg (save-excursion
+              (unless (looking-at "^\\s-*@\\(?:node\\)\\_>")
+                (end-of-line))
+              (re-search-backward "^\\s-*@\\(?:node\\)\\_>" nil t )))
+       (end (save-excursion
+              (beginning-of-line)
+              (and (re-search-forward "^\\s-*@\\(?:node\\|bye\\)\\_>" nil t )
+                   (progn (beginning-of-line) (point))))))
+
+    (when (and beg end)
+      (set-mark end)
+      (goto-char beg)
+      (TeX-activate-region) )))
+
 (defun Texinfo-insert-node ()
   "Insert a Texinfo node in the current buffer.
 That means, insert the string `@node' and prompt for current,
@@ -206,6 +343,70 @@ for @node."
              (progn (skip-chars-forward "^,") (forward-char 2))
            (throw 'break nil)))))))
 
+;; Silence the byte-compiler from warnings for variables and functions declared
+;; in reftex.
+(eval-when-compile
+  (defvar reftex-section-levels-all)
+  (defvar reftex-level-indent)
+  (defvar reftex-label-menu-flags)
+  (defvar reftex-tables-dirty)
+
+  (when (fboundp 'declare-function)
+    (declare-function reftex-match-string "reftex" (n))
+    (declare-function reftex-section-number "reftex-parse" (&optional level 
star))
+    (declare-function reftex-nicify-text "reftex" (text))
+    (declare-function reftex-ensure-compiled-variables "reftex" ())))
+
+(defun Texinfo-reftex-section-info (file)
+  ;; Return a section entry for the current match.
+  ;; Carefull: This function expects the match-data to be still in place!
+  (let* ((marker (set-marker (make-marker) (1- (match-beginning 3))))
+         (macro (reftex-match-string 3))
+         (level-exp (cdr (assoc macro reftex-section-levels-all)))
+         (level (if (symbolp level-exp)
+                    (save-match-data (funcall level-exp))
+                  level-exp))
+         (unnumbered  (< level 0))
+         (level (abs level))
+         (section-number (reftex-section-number level unnumbered))
+         (text1 (save-match-data
+                  (save-excursion
+                   (buffer-substring-no-properties (point) (progn 
(end-of-line) (point))))))
+         (literal (buffer-substring-no-properties
+                   (1- (match-beginning 3))
+                   (min (point-max) (+ (match-end 0) (length text1) 1))))
+         ;; Literal can be too short since text1 too short. No big problem.
+         (text (reftex-nicify-text text1)))
+
+    ;; Add section number and indentation
+    (setq text
+          (concat
+           (make-string (* reftex-level-indent level) ?\ )
+           (if (nth 1 reftex-label-menu-flags) ; section number flag
+               (concat section-number " "))
+           text))
+    (list 'toc "toc" text file marker level section-number
+          literal (marker-position marker))))
+
+(defun Texinfo-reftex-hook ()
+  "Hook function to plug Texinfo into RefTeX."
+  ;; force recompilation of variables
+  (when (string= TeX-base-mode-name "Texinfo")
+    (dolist (v `((reftex-section-pre-regexp . "@")
+                ; section post-regexp must contain exactly one group
+                (reftex-section-post-regexp . "\\([ \t]+\\)")
+                (reftex-section-info-function . Texinfo-reftex-section-info)
+              (reftex-section-levels
+               . ,(mapcar
+                   (lambda (x)
+                     (if (string-match 
"\\(\\`unnumbered\\)\\|\\(heading\\'\\)\\|\\(\\`top\\'\\)"
+                                       (car x))
+                         (cons (car x) (- (cadr x)))
+                       (cons (car x) (cadr x))))
+                   texinfo-section-list))))
+      (set (make-local-variable (car v) ) (cdr v)))
+    (setq reftex-tables-dirty t)
+    (reftex-ensure-compiled-variables)))
 
 ;;; Keymap:
 
@@ -223,6 +424,9 @@ for @node."
 
     ;; Simulating LaTeX-mode
     (define-key map "\C-c\C-e" 'Texinfo-environment)
+    (define-key map "\C-c." 'Texinfo-mark-environment)
+    (define-key map "\C-c*" 'Texinfo-mark-section)
+    (define-key map "\M-\C-h" 'Texinfo-mark-node)
     (define-key map "\C-c\n"   'texinfo-insert-@item)
     (or (key-binding "\e\r")
        (define-key map "\e\r" 'texinfo-insert-@item)) ;*** Alias
@@ -310,7 +514,7 @@ for @node."
     (?C    "@cite{" "}")
     (?\C-d "" "" t))
   "Font commands used in Texinfo mode.  See `TeX-font-list'.")
-  
+
 ;;; Mode:
 
 ;;;###autoload
@@ -334,10 +538,10 @@ value of `Texinfo-mode-hook'."
   (use-local-map Texinfo-mode-map)
   (set-syntax-table texinfo-mode-syntax-table)
   (make-local-variable 'page-delimiter)
-  (setq page-delimiter 
-       (concat 
-        "^@node [ \t]*[Tt]op\\|^@\\(" 
-        texinfo-chapter-level-regexp 
+  (setq page-delimiter
+       (concat
+        "^@node [ \t]*[Tt]op\\|^@\\("
+        texinfo-chapter-level-regexp
         "\\)"))
   (make-local-variable 'require-final-newline)
   (setq require-final-newline t)
@@ -376,13 +580,13 @@ value of `Texinfo-mode-hook'."
       ;; This was included in 19.31.
       ()
     (make-local-variable 'outline-regexp)
-    (setq outline-regexp 
+    (setq outline-regexp
          (concat "@\\("
                  (mapconcat 'car texinfo-section-list "\\>\\|")
                  "\\>\\)"))
     (make-local-variable 'outline-level)
     (setq outline-level 'texinfo-outline-level))
-  
+
   ;; Mostly AUCTeX stuff
   (easy-menu-add Texinfo-mode-menu Texinfo-mode-map)
   (easy-menu-add Texinfo-command-menu Texinfo-mode-map)
@@ -401,7 +605,7 @@ value of `Texinfo-mode-hook'."
   (setq TeX-command-default "TeX")
   (setq TeX-header-end "%*end")
   (setq TeX-trailer-start (regexp-quote (concat TeX-esc "bye")))
-  
+
   (make-local-variable 'TeX-complete-list)
   (setq TeX-complete-list
        (list (list "@\\([a-zA-Z]*\\)" 1 'TeX-symbol-list nil)
@@ -411,7 +615,7 @@ value of `Texinfo-mode-hook'."
   (setq TeX-font-list Texinfo-font-list)
   (make-local-variable 'TeX-font-replace-function)
   (setq TeX-font-replace-function 'TeX-font-replace-macro)
-  
+
   (add-hook 'find-file-hooks (lambda ()
                               (unless (file-exists-p (buffer-file-name))
                                 (TeX-master-file nil nil t))) nil t)
@@ -540,7 +744,12 @@ value of `Texinfo-mode-hook'."
    '("vskip" (TeX-arg-literal " ") (TeX-arg-free "Amount"))
    '("w" "Text")
    '("xref" "Node name"))
-  
+
+  ;; RefTeX plugging
+  (add-hook 'reftex-mode-hook 'Texinfo-reftex-hook)
+  (if (and (boundp 'reftex-mode) reftex-mode)
+      (Texinfo-reftex-hook))
+
   (TeX-run-mode-hooks 'text-mode-hook 'Texinfo-mode-hook)
   (TeX-set-mode-name))
 
@@ -560,7 +769,7 @@ The regexps will be anchored at the end of the file name to 
be matched,
 i.e. you do _not_ have to cater for this yourself by adding \\\\' or $."
   :type '(repeat regexp)
   :group 'TeX-command)
-  
+
 (provide 'tex-info)
-  
+
 ;;; tex-info.el ends here
diff --git a/tex-jp.el b/tex-jp.el
index d2778b35..9486c7a0 100644
--- a/tex-jp.el
+++ b/tex-jp.el
@@ -40,14 +40,20 @@
   "Japanese support in AUCTeX."
   :group 'AUCTeX)
 
-;; TeX-format-list need to be set in tex.el, not tex-jp.el.
-;(setq TeX-format-list
-;      (append '(("JLATEX" japanese-latex-mode
-;                 
"\\\\\\(documentstyle\\|documentclass\\)[^%\n]*{\\(j[s-]?\\|t\\)\\(article\\|report\\|book\\|slides\\)")
-;              ("JTEX" japanese-plain-tex-mode
-;               "-- string likely in Japanese TeX --"))
-;            TeX-format-list))
+(defcustom japanese-TeX-engine-default 'ptex
+  "Default TeX engine for Japanese TeX."
+  :group 'AUCTeX-jp
+  :type '(choice (const :tag "pTeX" ptex)
+                (const :tag "jTeX" jtex)
+                (const :tag "upTeX" uptex)))
+
+(setq TeX-engine-alist-builtin
+      (append TeX-engine-alist-builtin
+             '((ptex "pTeX" "ptex %(kanjiopt)" "platex %(kanjiopt)" "eptex")
+               (jtex "jTeX" "jtex" "jlatex" nil)
+               (uptex "upTeX" "euptex" "uplatex" "euptex"))))
 
+;; $B=gD4$K9T$1$PITMW$K$J$k!#(B
 (defcustom japanese-TeX-command-list
   ;; Changed to double quotes for Windows afflicted people.  I don't
   ;; use the %(latex) and %(tex) shorthands here because I have not
@@ -56,14 +62,15 @@
      TeX-run-TeX nil (plain-tex-mode) :help "Run NTT jTeX")
     ("jLaTeX" "%(PDF)jlatex %`%S%(PDFout)%(mode)%' %t"
      TeX-run-TeX nil (latex-mode) :help "Run NTT jLaTeX")
-    ("pTeX" "%(PDF)ptex %`%S%(PDFout)%(mode)%' %t"
+    ("pTeX" "%(PDF)ptex %(kanjiopt)%`%S%(PDFout)%(mode)%' %t"
      TeX-run-TeX nil (plain-tex-mode) :help "Run ASCII pTeX")
-    ("pLaTeX" "%(PDF)platex %`%S%(PDFout)%(mode)%' %t"
+    ("pLaTeX" "%(PDF)platex %(kanjiopt)%`%S%(PDFout)%(mode)%' %t"
      TeX-run-TeX nil (latex-mode) :help "Run ASCII pLaTeX")
-    ("Mendex" "mendex %s" TeX-run-command nil t :help "Create index file with 
mendex")
-    ("jBibTeX" "jbibtex %s" TeX-run-BibTeX nil t :help "Run jBibTeX"))
+    ("Mendex" "mendex %(mendexkopt)%s" TeX-run-command nil t :help "Create 
index file with mendex")
+    ("jBibTeX" "jbibtex %s" TeX-run-BibTeX nil t :help "Run jBibTeX")
+    ("pBibTeX" "pbibtex %(kanjiopt)%s" TeX-run-BibTeX nil t :help "Run 
pBibTeX"))
   "Additional list of commands, especially for Japanese.
-For detail, see `TeX-command-list', which this list is appended to."
+For detail, see `TeX-command-list', to which this list is appended."
   :group 'AUCTeX-jp
   :type '(repeat (group :value ("" "" TeX-run-command nil t)
                        (string :tag "Name")
@@ -82,6 +89,7 @@ For detail, see `TeX-command-list', which this list is 
appended to."
                                (function-item TeX-run-silent)
                                (function-item TeX-run-discard-foreground)
                                (function-item TeX-run-function)
+                               (function-item TeX-run-discard-or-function)
                                (function :tag "Other"))
                        (boolean :tag "Prompt")
                        (choice :tag "Modes"
@@ -94,16 +102,155 @@ For detail, see `TeX-command-list', which this list is 
appended to."
                                     (const :tag "AmSTeX" ams-tex-mode)))
                        (repeat :tag "Menu elements" :inline t sexp))))
 
+;; $B=gD4$K9T$1$PITMW$K$J$k!#(B
 (setq TeX-command-list
       (append japanese-TeX-command-list
              '(("-" "" ignore nil t)) ;; separator for command menu
              TeX-command-list))
 
+;; $B;CDj=hCV!#(Btex.el $B$K<h$j9~$s$G$b$i$($k$H$h$$!#(B
+(setcar (cdr (assoc "BibTeX" TeX-command-list)) "%(bibtex) %s")
+(setcar (cdr (assoc "Index" TeX-command-list)) "%(makeindex) %s")
+
+;; $B;CDj=hCV!#(Btex.el $B$K<h$j9~$s$G$b$i$($k$H$h$$!#(B
+(setq TeX-expand-list
+      (append
+       TeX-expand-list
+       '(
+        ;; -kanji $B%*%W%7%g%s$NJ8;zNs$r:n$k!#(B
+        ("%(kanjiopt)" (lambda ()
+                         (if (and
+                              ;; non-mule $B$J(B emacsen 
$B$O$=$b$=$bF|K\8l(B
+                              ;; $BJ8=q$r(B typeset 
$B$9$k$3$H$O9M$($J$/$F$b(B
+                              ;; $B$$$$$@$m$&!"$H$O;W$&$1$I0l1~!D!#(B
+                              (featurep 'mule)
+                              japanese-TeX-use-kanji-opt-flag)
+                             (let ((str (japanese-TeX-get-encoding-string)))
+                               (if str (format " -kanji=%s " str) ""))
+                           "")))
+        ;; pbibtex, jbibtex, upbibtex, bibtex 
$B$NCf$+$iE,@Z$J$b$N$rA*Br$9$k!#(B
+        ("%(bibtex)" (lambda ()
+                       (cond
+                        ((eq TeX-engine 'ptex)
+                         ;; pLaTeX $BMQF|K\8l(B BibTeX $B$,(B pbibtex 
$B$K$J$C$?(B
+                         ;; $B$N$OHf3SE*:G6a$J$N$G!"$^$@(B jbibtex 
$B$N?M$b$=(B
+                         ;; $B$l$J$j$K$$$k$@$m$&!#(B
+                         (if (executable-find "pbibtex")
+                             "pbibtex %(kanjiopt)" "jbibtex"))
+                        ((eq TeX-engine 'jtex) "jbibtex")
+                        ((eq TeX-engine 'uptex) "upbibtex")
+                        (t "bibtex"))))
+        ;; mendex $B$H(B makeindex $B$NE,@Z$JJ}$rA*Br$9$k!#(B
+        ("%(makeindex)" (lambda ()
+                          (if (memq TeX-engine '(ptex uptex))
+                              "mendex %(mendexkopt)" "makeindex")))
+        ;; mendex $BMQF|K\8l%3!<%I%*%W%7%g%s!#(B
+        ("%(mendexkopt)" (lambda ()
+                           (if (and (featurep 'mule)
+                                    japanese-TeX-use-kanji-opt-flag)
+                               (let ((str (japanese-TeX-get-encoding-string)))
+                                 ;; $B#1J8;zL\$rBgJ8;z$K!#(B
+                                 (if str (format " -%c " (upcase (aref str 0)))
+                                   ""))
+                             "")))
+        ;; pxdvi $B$H(B %(o?)xdvi $B$NE,@Z$JJ}$rA*Br$9$k!#(B
+        ("%(xdvi)" (lambda ()
+                     ;; pxdvi $B$O(B ptex, jtex $B6&MQ$J$N$G!"(B
+                     ;; japanese mode $B$+$I$&$+$GH=Dj$9$l$P(B OK$B!#(B
+                     (if (and japanese-TeX-mode (executable-find "pxdvi"))
+                         "pxdvi" "%(o?)xdvi"))))))
+
+;;; Viewing (new implementation)
+
+(unless (get 'TeX-view-predicate-list 'saved-value)
+  (setq TeX-view-predicate-list
+       '((paper-a4
+          (TeX-match-style
+           "\\`\\(a4j\\|a4paper\\|a4dutch\\|a4wide\\|sem-a4\\)\\'"))
+         (paper-a5
+          (TeX-match-style
+           "\\`\\(a5j\\|a5paper\\|a5comb\\)\\'"))
+         ;; jarticle $B$J$I$@$H(B b4paper, b5paper $B$O(B JIS B 
$B7ONs!#(B
+         ;; j-article $B$J$I$NJ}$K$O(B a4j, b5j 
$B$H$$$C$?%*%W%7%g%s$O$J$$!#(B
+         (paper-b5    ; ISO B5
+          (and (TeX-match-style "\\`b5paper\\'")
+               (not (memq TeX-engine '(ptex uptex)))))
+         (paper-b5jis ; JIS B5
+          (or (TeX-match-style "\\`b5j\\'")
+              (and (TeX-match-style "\\`b5paper\\'")
+                   (memq TeX-engine '(ptex uptex)))))
+         ;; article $B$J$I$K$O(B b4paper $B$H$$$&%*%W%7%g%s$O$J$$!#(B
+         ;; b4paper $B$H$$$&%*%W%7%g%s$,$"$C$?$i(B JIS B4 $B$H8+$J$9!#(B
+         (paper-b4jis
+          (TeX-match-style "\\`\\(b4j\\|b4paper\\)\\'")))))
+;; jsarticle $B$@$HB>$K$b$b$C$HH=7?$N%*%W%7%g%s$,$"$k$,!"(B
+;; $BA4ItLLE]8+$F$k$H%-%j$,$J$$$N$G!"$3$l$/$i$$$G$$$$$@$m$&!#(B
+;; jsarticle.el $B$d(B jsbook.el 
$B$GDI2CJ,$N=hM}$r;E9~$a$P$$$$$N$+$bCN$l$J$$!#(B
+
+;; $B;CDj=hCV!#(Btex.el $B$K<h$j9~$s$G$b$i$($k$H$h$$!#(B
+(unless (get 'TeX-view-program-list 'saved-value)
+  (setq TeX-view-program-list
+       (cond
+        ;; http://oku.edu.mie-u.ac.jp/~okumura/texwiki/?AUCTeX
+        ;; $B$r;29M$K$7$F$_$?!#(B
+        ((eq system-type 'windows-nt)
+         '(("Dviout" ("dviout -1 "
+                      ((paper-a4 paper-portrait) " -y=A4 ")
+                      ((paper-a4 paper-landscape) " -y=A4L ")
+                      ((paper-a5 paper-portrait) " -y=A5 ")
+                      ((paper-a5 paper-landscape) " -y=A5L ")
+                      ((paper-b5 paper-portrait) " -y=E5 ")
+                      ((paper-b5 paper-landscape) " -y=E5L ")
+                      ((paper-b4jis paper-portrait) " -y=B4 ")
+                      ((paper-b4jis paper-landscape) " -y=B4L ")
+                      ((paper-b5jis paper-portrait) " -y=B5 ")
+                      ((paper-b5jis paper-landscape) " -y=B5L ")
+                      (paper-legal " -y=Legal ")
+                      (paper-letter " -y=Letter ")
+                      (paper-executive " -y=Exective ")
+                      "%o" (mode-io-correlate " \"# %n '%b'\"")))
+           ("TeXworks" "TeXworks %o")
+           ("SumatraPDF" "SumatraPDF -reuse-instance %o"
+            (mode-io-correlate " -forward-search \"%b\" %n"))
+           ("MuPDF" "mupdf %o")))
+        ;; $B$3$l$G$$$$$N$+$I$&$+$OIT0B!#(B
+        ((eq system-type 'darwin)
+         '(("Preview" "open -a Preview.app %o")
+           ("TeXShop" "open -a TeXShop.app %o")
+           ("TeXworks" "open -a TeXworks.app %o")
+           ("Skim" "open -a Skim.app %o")
+           ("displayline" "displayline %n %o %b")
+           ("PictPrinter" "open -a PictPrinter.app %d")
+           ("Mxdvi" "open -a Mxdvi.app %d")
+           ("open" "open %o")))
+        (t
+         (setcar (cadr (assoc "xdvi" TeX-view-program-list-builtin))
+                 "%(xdvi) -unique")
+         '(("TeXworks" "texworks %o")
+           ("zathura" "zathura %o")
+           ("MuPDF" "mupdf %o"))))))
+
+;; $B$3$l$O(B tex.el $B$K<h$jF~$l$F$b$i$&$N$OFq$7$$$+!)(B
+;; tex-jp.el $B$,FI$_9~$^$l$k$@$1$G!"(Bdvi viewer $B$N%G%U%)%k%H$,(B 
dviout $B$K(B
+;; $B$J$C$F$7$^$&$N$ODq93$,Bg$-$$$+$b!#(B
+(unless (get 'TeX-view-program-selection 'saved-value)
+  (setq TeX-view-program-selection
+       (append
+        (cond
+         ((eq system-type 'windows-nt)
+          '((output-dvi "Dviout")
+            (output-pdf "TeXworks")))
+         ((eq system-type 'darwin)
+          '((output-pdf "Preview")))
+         (t
+          nil))
+        TeX-view-program-selection)))
+
 (mapc (lambda (dir) (add-to-list 'TeX-macro-global dir t))
       (or (TeX-tree-expand
           '("$SYSTEXMF" "$TEXMFLOCAL" "$TEXMFMAIN" "$TEXMFDIST")
-          "platex" '("/ptex/" "/jbibtex/bst/"))
-         '("/usr/share/texmf/ptex/" "/usr/share/texmf/jbibtex/bst/")))
+          "platex" '("/ptex/" "/pbibtex/bst/"))
+         '("/usr/share/texmf/ptex/" "/usr/share/texmf/pbibtex/bst/")))
 
 (mapc (lambda (dir) (add-to-list 'TeX-macro-global dir t))
       (or (TeX-tree-expand
@@ -111,23 +258,14 @@ For detail, see `TeX-command-list', which this list is 
appended to."
           "jlatex" '("/jtex/" "/jbibtex/bst/"))
          '("/usr/share/texmf/jtex/" "/usr/share/texmf/jbibtex/bst/")))
 
-;; Menus
-
-;; (easy-menu-define plain-TeX-mode-command-menu
-;;   plain-TeX-mode-map
-;;   "Command menu used in TeX mode."
-;;   (TeX-mode-specific-command-menu 'plain-tex-mode))
-
-;; (easy-menu-define LaTeX-mode-command-menu
-;;   LaTeX-mode-map
-;;   "Command menu used in LaTeX mode."
-;;   (TeX-mode-specific-command-menu 'latex-mode))
-
+;; $B=gD4$K9T$1$PITMW$K$J$k!#(B
 (setq LaTeX-command-style
-      (append '(("^j-\\(article\\|report\\|book\\)$"
-                "%(PDF)jlatex %S%(PDFout)")
-               ("^[jt]s?\\(article\\|report\\|book\\)$"
-                "%(PDF)platex %S%(PDFout)"))
+      (append '(("\\`u[jt]\\(article\\|report\\|book\\)\\'\\|\\`uplatex\\'"
+                "%(PDF)uplatex %(kanjiopt)%S%(PDFout)")
+               ("\\`[jt]s?\\(article\\|report\\|book\\)\\'"
+                "%(PDF)platex %(kanjiopt)%S%(PDFout)")
+               ("\\`j-\\(article\\|report\\|book\\)\\'"
+                "%(PDF)jlatex %(kanjiopt)%S%(PDFout)"))
              LaTeX-command-style))
 
 (defcustom japanese-TeX-error-messages t
@@ -138,7 +276,7 @@ For detail, see `TeX-command-list', which this list is 
appended to."
 (when (featurep 'mule)
 
 ;; FIX-ME (2007-02-09) The default coding system in recent Unix (like Fedora 
and
-;; Ubuntu) is utf-8.  But Japanese TeX system is not support utf-8 yet
+;; Ubuntu) is utf-8.  But Japanese TeX system does not support utf-8 yet
 ;; (platex-utf is under development, may be alpha phase).  So,
 ;; process-coding-system for Japanese TeX is not defined from
 ;; default-coding-system.  When platex-utf is out, we should look this setting,
@@ -162,12 +300,14 @@ For detail, see `TeX-command-list', which this list is 
appended to."
 
 )
 
+;; $B=gD4$K9T$1$PITMW$K$J$k!#(B
 (defcustom japanese-TeX-command-default "pTeX"
   "*The default command for `TeX-command' in the japanese-TeX mode."
   :group 'AUCTeX-jp
   :type 'string)
   (make-variable-buffer-local 'japanese-TeX-command-default)
 
+;; $B=gD4$K9T$1$PITMW$K$J$k!#(B
 (defcustom japanese-LaTeX-command-default "LaTeX"
   "*The default command for `TeX-command' in the japanese-LaTeX mode."
   :group 'AUCTeX-jp
@@ -211,6 +351,55 @@ For detail, see `TeX-command-list', which this list is 
appended to."
                                 TeX-japanese-process-input-coding-system)))
 (setq TeX-after-start-process-function
       'japanese-TeX-set-process-coding-system)
+
+(defcustom japanese-TeX-use-kanji-opt-flag t
+  "Add kanji option to Japanese pTeX family if non-nil."
+  :group 'AUCTeX-jp
+  :type 'boolean)
+
+(defun japanese-TeX-coding-ejsu (coding-system)
+  "Convert japanese CODING-SYSTEM to mnemonic string.
+euc-jp:    \"euc\"
+jis:       \"jis\"
+shift_jis: \"sjis\"
+utf-8:     \"utf8\"
+Return nil otherwise."
+  (let ((base (coding-system-base coding-system)))
+    (cdr (assq base
+              '((japanese-iso-8bit . "euc")
+                (iso-2022-jp . "jis")
+                (japanese-shift-jis . "sjis")
+                (utf-8 . "utf8")
+
+                ;; xemacs $B$@$H0J2<$NL>A0$O0c$&$+$b!D!#(B
+                (euc-jis-2004 . "euc")
+                (iso-2022-jp-2004 . "jis")
+                (japanese-shift-jis-2004 . "sjis")
+
+                (japanese-cp932 . "sjis")
+                (eucjp-ms . "euc"))))))
+
+(defun japanese-TeX-get-encoding-string ()
+  "Return coding option string for Japanese pTeX family.
+For inappropriate encoding, nil instead."
+  (or (japanese-TeX-coding-ejsu buffer-file-coding-system)
+
+      ;; $BJ#?t%U%!%$%k$KJ,3d$7$?J8=q$N>l9g!"(Bemacs 
$B$G3+$$$?%U%!%$%k$,F|K\(B
+      ;; $B8l$r#1;z$b4^$^$J$$$3$H$,$"$k!#$3$N$?$a!"$=$N%U%!%$%k$N(B
+      ;; buffer-file-coding-system $B$OF|K\8l%3!<%I$,ITDj$KN1$^$C$F(B
+      ;; $B$7$^$&2DG=@-$,$"$k!#$=$N$h$&$J>l9g!"(Bmaster file $B$N(B
+      ;; buffer-file-coding-system $B$r;H$&!#(B
+      (if (stringp TeX-master) ; $B<+J,$,;R%U%!%$%k$N$H$-(B
+         (let ((buf (get-file-buffer (TeX-master-file t))))
+           (if buf
+               (japanese-TeX-coding-ejsu
+                (with-current-buffer buf buffer-file-coding-system)))))
+
+      ;; $B$=$l$G$b7h$a$i$l$J$$>l9g$O(B buffer-file-coding-system $B$N(B
+      ;; default $BCM$r;H$&!#(B
+      (japanese-TeX-coding-ejsu
+       (default-value 'buffer-file-coding-system))))
+
 )
 
 ;;; Japanese TeX modes
@@ -231,7 +420,8 @@ Set `japanese-TeX-mode' to t, and enter 
`TeX-plain-tex-mode'."
 (defun japanese-plain-tex-mode-initialization ()
   "Japanese plain-TeX specific initializations."
   (when japanese-TeX-mode
-    (setq TeX-command-default japanese-TeX-command-default)))
+;    (setq TeX-command-default japanese-TeX-command-default)
+    (TeX-engine-set japanese-TeX-engine-default)))
 
 (add-hook 'plain-TeX-mode-hook 'japanese-plain-tex-mode-initialization)
 
@@ -246,9 +436,24 @@ Set `japanese-TeX-mode' to t, and enter `TeX-latex-mode'."
 (defun japanese-latex-mode-initialization ()
   "Japanese LaTeX specific initializations."
   (when japanese-TeX-mode
-    (setq TeX-command-default japanese-LaTeX-command-default)
+;    (setq TeX-command-default japanese-LaTeX-command-default)
+    (TeX-engine-set
+     ;; class file $BL>$KMj$k$N$O@5$7$$$N$+!)(B
+     ;; jLaTeX $B$K$b(B jarticle $B$O0l1~$"$k$7!"(BpLaTeX $B$G$b<+J,$G(B 
j-article $B$r(B
+     ;; $B%$%s%9%H!<%k$7$F;H$C$F$$$1$J$$K!$O$J$$!#(B
+     (cond
+      ((TeX-match-style 
"\\`u[jt]\\(article\\|report\\|book\\)\\'\\|\\`uplatex\\'")
+       'uptex)
+      ((TeX-match-style "\\`[jt]s?\\(article\\|report\\|book\\)\\'")
+       'ptex)
+      ((TeX-match-style "\\`j-\\(article\\|report\\|book\\)\\'")
+       'jtex)
+      (t japanese-TeX-engine-default)))
     (setq LaTeX-default-style japanese-LaTeX-default-style)
-    (setq TeX-command-BibTeX "jBibTeX")))
+;    (setq TeX-command-BibTeX
+;        (if (and (eq TeX-engine 'ptex) (executable-find "pbibtex"))
+;            "pBibTeX" "jBibTeX"))
+))
 
 (add-hook 'LaTeX-mode-hook 'japanese-latex-mode-initialization)
 
@@ -394,10 +599,10 @@ 
thebibliography$B4D6-$G0z?t$rK:$l$?>l9g$K$b@8$8$^$9!%(B")
 $B$K@8$8$^$9!%$3$NLdBj$O4D6-$N$&$A$N$$$/$D$+$rJ8=q$N=*$o$j$NJ}$K0\F0$9$l(B
 
$B$P2r7h$G$-$^$9!%$^$?!$$3$N%(%i!<$O(B``logjam''$B$K$h$C$F@8$8$k$3$H$b$"$j$^(B
 
$B$9!%(B``logjam''$B$H$O!$(BLaTeX$B$,=P8==g=xDL$j$K$7$+?^I=$r=PNO$G$-$J$$$;$$$G!$(B
-$B$D$^$C$F$$$k8e$m$N?^I=$N$?$a$KA0$N?^I=$r=PNO$G$-$J$/$J$k$3$H$r$$$$$^$9!%(B
-$B$3$N%8%c%`$N860x$O!$Bg$-$9$.$F(B1$B%Z!<%8$J$$$7$O;XDj$5$l$?NN0h$K<}$^$i$J(B
-$B$$$h$&$J?^$dI=$G$"$k2DG=@-$,$"$j$^$9!%$3$l$O!$0z?t$K(Bp$B%*%W%7%g%s$,;XDj(B
-$B$5$l$F$$$J$$$H5/$-$d$9$/$J$j$^$9!%(B")
+$B?^I=$N=PNO$,(B1$B%v=j$G$b$D$^$k$H$=$N8e$m$N?^I=$,8.JB$_$9$Y$F$D$C$+$($F$7$^(B
+$B$&$3$H$r$$$$$^$9!%$3$N%8%c%`$N860x$O!$Bg$-$9$.$F(B1$B%Z!<%8$J$$$7$O%*%W%7%g(B
+$B%s0z?t$G;XDj$5$l$?0LCV$K<}$^$i$J$$$h$&$J?^$dI=$G$"$k2DG=@-$,$"$j$^$9!%$3(B
+$B$l$O!$0z?t$K(Bp$B%*%W%7%g%s$,;XDj$5$l$F$$$J$$$H5/$-$d$9$/$J$j$^$9!%(B")
 
     ("Undefined tab position." .
 
"\\>$B!&(B\\+$B!&(B\\-$B$^$?$O(B\\<$BL?Na$G!$B8:_$7$J$$%?%V0LCV!$$9$J$o$A(B\\=$BL?Na$GDj(B
diff --git a/tex-style.el b/tex-style.el
index 781aa113..1c911688 100644
--- a/tex-style.el
+++ b/tex-style.el
@@ -213,6 +213,13 @@ It can be a list of themes or a function.  If it is the 
symbol
             :tag "Other"
             (string)))))
 
+;; style/biblatex.el
+
+(defcustom LaTeX-biblatex-use-Biber t
+  "Whether to use Biber with biblatex."
+  :type 'boolean
+  :group 'LaTeX-style)
+
 ;; style/comment.el
 
 (defcustom LaTeX-comment-env-list '("comment")
diff --git a/tex.el b/tex.el
index 0ff821ce..3fde81e7 100644
--- a/tex.el
+++ b/tex.el
@@ -1,6 +1,6 @@
 ;;; tex.el --- Support for TeX documents.
 
-;; Copyright (C) 1985-1987, 1991, 1993, 1994, 1996, 1997, 1999-2013
+;; Copyright (C) 1985-1987, 1991, 1993, 1994, 1996, 1997, 1999-2012
 ;;   Free Software Foundation, Inc.
 
 ;; Maintainer: auctex-devel@gnu.org
@@ -25,9 +25,7 @@
 
 ;;; Commentary:
 
-;; This file provides AUCTeX support for plain TeX as well as basic
-;; functions used by other AUCTeX modes (e.g. for LaTeX, Texinfo and
-;; ConTeXt).
+;; This file provides basic functions used by the AUCTeX modes.
 
 ;;; Code:
 
@@ -65,32 +63,7 @@
 ;;; Site Customization
 ;;
 ;; The following variables are likely to need to be changed for your
-;; site.  You should do this with customize.  Here is the beef: If you
-;; want to print, TeX-print-command must be non-nil (if it is nil,
-;; you'll get a complaint when using the print menu).  If you want to
-;; view the queue, TeX-queue-command needs to be non-nil (if it is
-;; nil, it won't get mentioned in the menu).  If TeX-printer-list is
-;; nil, nothing else gets asked: the menu entries lead directly to the
-;; respective commands.  If those commands contain %p, the value of
-;; TeX-printer-default gets inserted there, no questions asked.  Now
-;; if TeX-printer-list is non-nil, you'll always get asked which
-;; printer you want to use.  You can enter a configured printer from
-;; TeX-printer-list, or an unknown one.  The respective menus will
-;; show all configured printers.  Since you can enter unknown
-;; printers, the printer name _must_ be set with %p in
-;; TeX-print-command.
-
-;; How to print.
-
-(defcustom TeX-print-command "%(o?)dvips -P%p %r %s"
-  "*Command used to print a file.
-
-First `%p' is expanded to the printer name, then ordinary expansion is
-performed as specified in `TeX-expand-list'.  If it is nil,
-then customization is requested."
-  :group 'TeX-command
-  :type '(choice (string :tag "Print command")
-                (const :tag "No print command customized" nil)))
+;; site.  You should do this with customize.
 
 (defcustom TeX-command "tex"
   "Command to run plain TeX."
@@ -129,16 +102,6 @@ If nil, none is specified."
 (TeX--call-3/2 #'make-obsolete-variable 'ConTeXt-Omega-engine
                'TeX-engine-alist "before 11.86")
 
-(defcustom TeX-queue-command "lpq -P%p"
-  "*Command used to show the status of a printer queue.
-
-First `%p' is expanded to the printer name, then ordinary expansion is
-performed as specified in `TeX-expand-list'.  If this is nil,
-the printer has no corresponding command."
-  :group 'TeX-command
-  :type '(choice (string :tag "Queue check command")
-                (const :tag "No such command" nil)))
-
 (defcustom TeX-mode-hook nil
   "A hook run in TeX mode buffers."
   :type 'hook
@@ -177,6 +140,7 @@ the printer has no corresponding command."
      TeX-run-TeX nil
      (context-mode) :help "Run ConTeXt until completion")
     ("BibTeX" "bibtex %s" TeX-run-BibTeX nil t :help "Run BibTeX")
+    ("Biber" "biber %s" TeX-run-Biber nil t :help "Run Biber")
     ,(if (or window-system (getenv "DISPLAY"))
        '("View" "%V" TeX-run-discard-or-function t t :help "Run Viewer")
        '("View" "dvi2tty -q -w 132 %s" TeX-run-command t t
@@ -221,6 +185,8 @@ TeX-run-interactive: Run TeX or LaTeX interactively.
 
 TeX-run-BibTeX: For BibTeX output.
 
+TeX-run-Biber: For Biber output.
+
 TeX-run-compile: Use `compile' to run the process.
 
 TeX-run-shell: Use `shell-command' to run the process.
@@ -269,6 +235,7 @@ Any additional elements get just transferred to the 
respective menu entries."
                                (function-item TeX-run-TeX)
                                (function-item TeX-run-interactive)
                                (function-item TeX-run-BibTeX)
+                               (function-item TeX-run-Biber)
                                (function-item TeX-run-compile)
                                (function-item TeX-run-shell)
                                (function-item TeX-run-discard)
@@ -349,11 +316,52 @@ string."
   :type '(repeat (group :value ("" "")
                        regexp (string :tag "Style"))))
 
+;; Printing: If you want to print, TeX-print-command must be non-nil
+;; (if it is nil, you'll get a complaint when using the print menu).
+;; If you want to view the queue, TeX-queue-command needs to be
+;; non-nil (if it is nil, it won't get mentioned in the menu).  If
+;; TeX-printer-list is nil, nothing else gets asked: the menu entries
+;; lead directly to the respective commands.  If those commands
+;; contain %p, the value of TeX-printer-default gets inserted there,
+;; no questions asked.  Now if TeX-printer-list is non-nil, you'll
+;; always get asked which printer you want to use.  You can enter a
+;; configured printer from TeX-printer-list, or an unknown one.  The
+;; respective menus will show all configured printers.  Since you can
+;; enter unknown printers, the printer name _must_ be set with %p in
+;; TeX-print-command.
+
+(defcustom TeX-print-command
+  "{ test -e %s.dvi && %(o?)dvips -P%p %r %s; } || lpr -P%p %o"
+  "Command used to print a file.
+
+First `%p' is expanded to the printer name, then ordinary expansion is
+performed as specified in `TeX-expand-list'.  If it is nil,
+then customization is requested."
+  :group 'TeX-command
+  :type '(choice (string :tag "Print command")
+                (const :tag "No print command customized" nil)))
+
+(defcustom TeX-queue-command "lpq -P%p"
+  "Command used to show the status of a printer queue.
+
+First `%p' is expanded to the printer name, then ordinary expansion is
+performed as specified in `TeX-expand-list'.  If this is nil,
+the printer has no corresponding command."
+  :group 'TeX-command
+  :type '(choice (string :tag "Queue check command")
+                (const :tag "No such command" nil)))
+
 ;; Enter the names of the printers available at your site, or nil if
 ;; you only have one printer.
 
 (defcustom TeX-printer-list
-  '(("Default" "%(o?)dvips -f %s | lpr" "lpq"))
+  '(("Default"
+     ;; Print to the (unnamed) default printer.  If there is a DVI
+     ;; file print via Dvips.  If not, pass the output file (which
+     ;; should then be a Postscript or PDF file) directly to lpr.
+     "{ test -e %s.dvi && %(o?)dvips -f %r %s | lpr; } || lpr %o"
+     ;; Show the queue for the (unnamed) default printer.
+     "lpq"))
   "List of available printers.
 
 The first element of each entry is the printer name.
@@ -388,7 +396,7 @@ get consulted."
                                   (and TeX-printer-list
                                        (car (car TeX-printer-list)))
                                   "lp")
-  "*Default printer to use with `TeX-command'."
+  "Default printer to use with `TeX-command'."
   :group 'TeX-command
   :type 'string)
 
@@ -454,9 +462,9 @@ string."
     ("%dS" TeX-source-specials-view-expand-options)
     ("%cS" TeX-source-specials-view-expand-client)
     ("%(outpage)" (lambda ()
-                   (if TeX-source-correlate-output-page-function
-                       (funcall TeX-source-correlate-output-page-function)
-                     "1")))
+                   (or (when TeX-source-correlate-output-page-function
+                         (funcall TeX-source-correlate-output-page-function))
+                       "1")))
     ;; `file' means to call `TeX-master-file' or `TeX-region-file'
     ("%s" file nil t)
     ("%t" file t t)
@@ -850,13 +858,14 @@ If RESET is non-nil, `TeX-command-next' is reset to
                                      'TeX-command-next TeX-command-default))
          (set-buffer-modified-p (buffer-modified-p))))))
 
-(defun TeX-mode-prefix ()
-  "Return the prefix of the current mode as string."
-  (cdr (assoc major-mode '((plain-tex-mode . "plain-TeX")
-                          (latex-mode . "LaTeX")
-                          (doctex-mode . "docTeX")
-                          (texinfo-mode . "Texinfo")
-                          (context-mode . "ConTeXt")))))
+(defun TeX-mode-prefix (&optional mode)
+  "Return the prefix for the symbol MODE as string.
+If no mode is given the current major mode is used."
+  (cdr (assoc (or mode major-mode) '((plain-tex-mode . "plain-TeX")
+                                    (latex-mode . "LaTeX")
+                                    (doctex-mode . "docTeX")
+                                    (texinfo-mode . "Texinfo")
+                                    (context-mode . "ConTeXt")))))
 
 ;;; Viewing
 
@@ -1003,6 +1012,72 @@ The following built-in predicates are available:
   :group 'TeX-view
   :type '(alist :key-type symbol :value-type (group sexp)))
 
+(defun TeX-evince-dbus-p (&rest options)
+  "Return non-nil, if evince is installed and accessible via DBUS.
+Additional OPTIONS may be given to extend the check.  If none are
+given, only the minimal requirements needed by backward search
+are checked.  If OPTIONS include `:forward', which is currently
+the only option, then additional requirements needed by forward
+search are checked, too."
+  (and (not (featurep 'xemacs)) ; XEmacs 21.4 has no `require' with
+                               ; arity 3, and no dbus support anyway.
+       (require 'dbus nil :no-error)
+       (functionp 'dbus-register-signal)
+       (getenv "DBUS_SESSION_BUS_ADDRESS")
+       (executable-find "evince")
+       (or (not (memq :forward options))
+          (let ((spec (dbus-introspect-get-method
+                       :session "org.gnome.evince.Daemon"
+                       "/org/gnome/evince/Daemon"
+                       "org.gnome.evince.Daemon"
+                       "FindDocument")))
+            ;; FindDocument must exist, and its signature must be (String,
+            ;; Boolean, String).  Evince versions between 2.30 and 2.91.x
+            ;; didn't have the Boolean spawn argument we need to start evince
+            ;; initially.
+            (and spec
+                 (equal '("s" "b" "s")
+                        (delq nil (mapcar (lambda (elem)
+                                            (when (and (listp elem)
+                                                       (eq (car elem) 'arg))
+                                              (cdr (caar (cdr elem)))))
+                                          spec))))))))
+
+(defun TeX-evince-sync-view ()
+  "Focus the focused page/paragraph in Evince with the position
+of point in emacs by using Evince's DBUS API.  Used by default
+for the Evince viewer entry in `TeX-view-program-list-builtin' if
+the requirements are met."
+  (let* ((uri (concat "file://" (expand-file-name
+                                (concat file "." (TeX-output-extension)))))
+        (owner (dbus-call-method
+                :session "org.gnome.evince.Daemon"
+                "/org/gnome/evince/Daemon"
+                "org.gnome.evince.Daemon"
+                "FindDocument"
+                uri
+                t)))
+    (if owner
+       (dbus-call-method
+        :session owner
+        "/org/gnome/evince/Window/0"
+        "org.gnome.evince.Window"
+        "SyncView"
+        (buffer-file-name)
+        (list :struct :int32 (line-number-at-pos) :int32 (1+ (current-column)))
+        :uint32 (let ((time (float-time)))
+                  ;; FIXME: Evince wants a timestamp as UInt32, but POSIX time
+                  ;; is too large for emacs integers on 32 bit systems.  Emacs
+                  ;; 24.2 will allow providing DBUS ints as floats, and this
+                  ;; dbus version will be identifiable by its new variables
+                  ;; `dbus-compiled-version' and `dbus-runtime-version'.  But
+                  ;; it seems providing just 1 as timestamp has no negative
+                  ;; consequences, anyway.
+                  (if (> most-positive-fixnum time)
+                      (round time)
+                    1)))
+      (error "Couldn't find the Evince instance for %s" uri))))
+
 (defvar TeX-view-program-list-builtin
   (cond
    ((eq system-type 'windows-nt)
@@ -1017,7 +1092,7 @@ The following built-in predicates are available:
 ;;       ("displayline" "displayline %n %o %b")
 ;;       ("open" "open %o")))
    (t
-    '(("xdvi" ("%(o?)xdvi"
+    `(("xdvi" ("%(o?)xdvi"
               (mode-io-correlate " -sourceposition \"%n %b\" -editor \"%cS\"")
               ((paper-a4 paper-portrait) " -paper a4")
               ((paper-a4 paper-landscape) " -paper a4r")
@@ -1031,7 +1106,16 @@ The following built-in predicates are available:
       ("dvips and gv" "%(o?)dvips %d -o && gv %f")
       ("gv" "gv %o")
       ("xpdf" ("xpdf -remote %s -raise %o" (mode-io-correlate " %(outpage)")))
-      ("Evince" ("evince" (mode-io-correlate " -p %(outpage)") " %o"))
+      ("Evince" ,(if (TeX-evince-dbus-p :forward)
+                    'TeX-evince-sync-view
+                  `("evince" (mode-io-correlate
+                              ;; With evince 3, -p N opens the page *labeled* 
N,
+                              ;; and -i,--page-index the physical page N.
+                              ,(if (string-match "--page-index"
+                                                 (shell-command-to-string 
"evince --help"))
+                                   " -i %(outpage)"
+                                 " -p %(outpage)")) " %o")))
+      ("Okular" ("okular --unique %o" (mode-io-correlate "#src:%n%b")))
       ("xdg-open" "xdg-open %o"))))
   "Alist of built-in viewer specifications.
 This variable should not be changed by the user who can use
@@ -1131,6 +1215,9 @@ defined in `TeX-view-predicate-list' or
 `TeX-view-predicate-list-builtin'.  The second element is a
 string referring to the name of a viewer as defined in
 `TeX-view-program-list' or `TeX-view-program-list-builtin'.
+\(Note: Viewers added to `TeX-view-program-list' in the current
+Emacs session will not show up in the customization interface of
+`TeX-view-program-selection' until you restart Emacs.)
 
 When a viewer is called for, the entries are evaluated in turn
 and the viewer related to the first entry all predicates of which
@@ -1221,7 +1308,9 @@ predicates are true, nil otherwise."
 (defvar TeX-engine-alist-builtin
   '((default "Default" TeX-command LaTeX-command ConTeXt-engine)
     (xetex "XeTeX" "xetex" "xelatex" "xetex")
-    (luatex "LuaTeX" "luatex" "lualatex" "luatex")
+    ;; Some lualatex versions before 0.71 would use "texput" as file
+    ;; name if --jobname were not supplied
+    (luatex "LuaTeX" "luatex" "lualatex --jobname=%s" "luatex")
     (omega "Omega" TeX-Omega-command LaTeX-Omega-command ConTeXt-Omega-engine))
   "Alist of built-in TeX engines and associated commands.
 For a description of the format see `TeX-engine-alist'.")
@@ -1269,10 +1358,8 @@ It should be one of the following symbols:\n\n"
      (lambda (arg) (memq arg (mapcar 'car TeX-engine-alist-builtin))))
 
 (defun TeX-engine-set (type)
-  (concat "Set TeX engine to TYPE.
-TYPE can be one of the following symbols:\n"
-         (mapconcat (lambda (x) (format "* `%s'" (car x)))
-                    (TeX-engine-alist) "\n"))
+  "Set TeX engine to TYPE.
+For available TYPEs, see variable `TeX-engine'."
   (interactive (list (completing-read "Engine: "
                                      (mapcar (lambda (x)
                                                (symbol-name (car x)))
@@ -1380,7 +1467,7 @@ This is the case if 
`TeX-source-correlate-start-server-flag' is non-nil."
                    (call-process LaTeX-command
                                  nil (list standard-output nil) nil "--help"))
                (error ""))))
-    (if (string-match "^[ ]*-synctex" help)
+    (if (string-match "^[ ]*-?-synctex" help)
        'synctex
       'source-specials)))
 
@@ -1410,6 +1497,36 @@ If this is nil, an empty string will be returned."
   "Keymap for `TeX-source-correlate-mode'.
 You could use this for unusual mouse bindings.")
 
+(defun TeX-source-correlate-sync-source (file linecol &rest ignored)
+  "Show TeX FILE with point at LINECOL.
+This function is called when emacs receives a SyncSource signal
+emitted from the Evince document viewer.  IGNORED absorbs an
+unused id field accompanying the DBUS signal sent by Evince-3.0.0
+or newer."
+  ;; FILE may be given as relative path to the TeX-master root document or as
+  ;; absolute file:// URL.  In the former case, the tex file has to be already
+  ;; opened.
+  (let ((buf (let ((f (condition-case nil
+                         (progn
+                           (require 'url-parse)
+                           (aref (url-generic-parse-url file) 6))
+                       ;; For Emacs 21 compatibility, which doesn't have the
+                       ;; url package.
+                       (file-error (replace-regexp-in-string "^file://" "" 
file)))))
+              (if (file-name-absolute-p f)
+                  (find-file f)
+                (get-buffer (file-name-nondirectory file)))))
+        (line (car linecol))
+        (col (cadr linecol)))
+    (if (null buf)
+        (message "No buffer for %s." file)
+      (switch-to-buffer buf)
+      (push-mark (point) 'nomsg)
+      (goto-char (point-min))
+      (forward-line (1- line))
+      (unless (= col -1)
+        (move-to-column col)))))
+
 (define-minor-mode TeX-source-correlate-mode
   "Minor mode for forward and inverse search.
 
@@ -1431,6 +1548,12 @@ SyncTeX are recognized."
                                       TeX-source-correlate-map))
   (TeX-set-mode-name 'TeX-source-correlate-mode t t)
   (setq TeX-source-correlate-start-server-flag TeX-source-correlate-mode)
+  ;; Register Emacs for the SyncSource DBUS signal emitted by Evince.
+  (when (TeX-evince-dbus-p)
+    (dbus-register-signal
+     :session nil "/org/gnome/evince/Window/0"
+     "org.gnome.evince.Window" "SyncSource"
+     'TeX-source-correlate-sync-source))
   (unless TeX-source-correlate-method-active
     (setq TeX-source-correlate-method-active
          (if (eq TeX-source-correlate-method 'auto)
@@ -1539,8 +1662,8 @@ returned."
 (defvar TeX-synctex-tex-flags "--synctex=1"
   "Extra flags to pass to TeX commands to enable SyncTeX.")
 
-(defun TeX-synctex-output-page ()
-  "Return the page corresponding to the current source position.
+(defun TeX-synctex-output-page-1 (file)
+  "Return the page corresponding to the current position in FILE.
 This method assumes that the document was compiled with SyncTeX
 enabled and the `synctex' binary is available."
   (let ((synctex-output
@@ -1548,16 +1671,30 @@ enabled and the `synctex' binary is available."
           (call-process "synctex" nil (list standard-output nil) nil "view"
                         "-i" (format "%s:%s:%s" (line-number-at-pos)
                                      (current-column)
-                                     ;; The file name relative to the
-                                     ;; directory of the master file.
-                                     (file-relative-name
-                                      (buffer-file-name)
-                                      (file-name-directory
-                                       (TeX-active-master))))
+                                     file)
                         "-o" (TeX-active-master (TeX-output-extension))))))
     (when (string-match "Page:\\([0-9]+\\)" synctex-output)
       (match-string 1 synctex-output))))
 
+(defun TeX-synctex-output-page ()
+  "Return the page corresponding to the position in the current buffer.
+This method assumes that the document was compiled with SyncTeX
+enabled and the `synctex' binary is available."
+  (let* ((file (file-relative-name (buffer-file-name)
+                                  (file-name-directory
+                                   (TeX-active-master))))
+        (abs-file (concat (expand-file-name (or (file-name-directory 
(TeX-active-master))
+                                                (file-name-directory 
(buffer-file-name))))
+                          "./" file)))
+    ;; It's known that depending on synctex version one of
+    ;; /absolute/path/./foo/bar.tex, foo/bar.tex, or ./foo/bar.tex (relative to
+    ;; TeX-master, and the "." in the absolute path is important) are needed.
+    ;; So try all variants before falling back to page 1.
+    (or (TeX-synctex-output-page-1 abs-file)
+       (TeX-synctex-output-page-1 file)
+       (TeX-synctex-output-page-1 (concat "./" file))
+       "1")))
+
 ;;; Miscellaneous minor modes
 
 (defvar TeX-mode-p nil
@@ -1657,6 +1794,12 @@ already established, don't do anything."
   :type 'string)
   (make-variable-buffer-local 'TeX-command-BibTeX)
 
+(defcustom TeX-command-Biber "Biber"
+  "*The name of the Biber entry in `TeX-command-list'."
+  :group 'TeX-command-name
+  :type 'string)
+  (make-variable-buffer-local 'TeX-command-Biber)
+
 (defcustom TeX-command-Show "View"
   "*The default command to show (view or print) a TeX file.
 Must be the car of an entry in `TeX-command-list'."
@@ -1695,7 +1838,8 @@ Must be the car of an entry in `TeX-command-list'."
   '("\\.aux" "\\.bbl" "\\.blg" "\\.brf" "\\.fot"
     "\\.glo" "\\.gls" "\\.idx" "\\.ilg" "\\.ind"
     "\\.lof" "\\.log" "\\.lot" "\\.nav" "\\.out"
-    "\\.snm" "\\.toc" "\\.url" "\\.synctex\\.gz")
+    "\\.snm" "\\.toc" "\\.url" "\\.synctex\\.gz"
+    "\\.bcf" "\\.run\\.xml")
   "List of regexps matching suffixes of files to be cleaned.
 Used as a default in TeX, LaTeX and docTeX mode.")
 
@@ -1727,7 +1871,7 @@ output files."
         (master (TeX-active-master))
         (master-dir (file-name-directory master))
         (regexp (concat "\\("
-                        (file-name-nondirectory master) "\\|"
+                        (regexp-quote (file-name-nondirectory master)) "\\|"
                         (TeX-region-file nil t)
                         "\\)"
                         "\\("
@@ -2060,43 +2204,23 @@ If REGEXP is nil, or \"\", an error will occur."
          (setq answers (cons entry answers))))
     answers))
 
-(defun TeX-macro-global ()
-  "Return directories containing the site's TeX macro and style files."
-  (or (TeX-tree-expand '("$SYSTEXMF" "$TEXMFLOCAL" "$TEXMFMAIN" "$TEXMFDIST")
-                      "latex" '("/tex/" "/bibtex/bst/"))
-      '("/usr/share/texmf/tex/" "/usr/share/texmf/bibtex/bst/")))
-
-(defun TeX-macro-private ()
-  "Return directories containing the user's TeX macro and style files."
-  (TeX-tree-expand '("$TEXMFHOME") "latex" '("/tex/" "/bibtex/bst/")))
-
-(defun TeX-tree-expand (trees program subdirs)
-  "Return directories corresponding to the TeX trees TREES.
-This is done calling `kpsewhich' where PROGRAM is passed as the
-parameter for --progname.  SUBDIRS are subdirectories which are
-appended to the directories of the TeX trees."
+(defun TeX-tree-expand (vars program &optional subdirs)
+  "Return directories corresponding to the kpathsea variables VARS.
+This is done calling `kpsewhich --expand-path' for each variable.
+PROGRAM is passed as the parameter for --progname.  SUBDIRS are
+subdirectories which are appended to the directories of the TeX
+trees.  Only existing directories are returned."
   (let (path-list path exit-status input-dir-list)
     (condition-case nil
-       (catch 'success
-         (dotimes (i (safe-length trees))
-           (setq path (with-output-to-string
-                        (setq exit-status
-                              (call-process
-                               "kpsewhich"  nil
-                               (list standard-output nil) nil
-                               "--progname" program
-                               "--expand-braces" (nth i trees)))))
-           (if (zerop exit-status)
-               (progn (add-to-list 'path-list path)
-                      (when (zerop i) (throw 'success nil)))
-             (setq path (with-output-to-string
-                          (setq exit-status
-                                (call-process
-                                 "kpsewhich"  nil
-                                 (list standard-output nil) nil
-                                 "--progname" program
-                                 "--expand-path" (nth i trees)))))
-             (when (zerop exit-status) (add-to-list 'path-list path)))))
+       (dolist (var vars)
+         (setq path (with-output-to-string
+                      (setq exit-status (call-process
+                                         "kpsewhich"  nil
+                                         (list standard-output nil) nil
+                                         "--progname" program
+                                         "--expand-path" var))))
+         (when (zerop exit-status)
+           (add-to-list 'path-list path t)))
       (error nil))
     (dolist (elt path-list)
       (let ((separators (if (string-match "^[A-Za-z]:" elt)
@@ -2106,15 +2230,26 @@ appended to the directories of the TeX trees."
                          (split-string elt separators t)
                        ;; COMPATIBILITY for XEmacs <= 21.4.15
                        (error (delete "" (split-string elt separators)))))
-         (when (string-match "^!+" item)
-           (setq item (substring item (match-end 0) (length item))))
-         (when (string-match "/+$" item)
-           (setq item (substring item 0 (match-beginning 0))))
-         (dolist (subdir subdirs)
-           (when (file-exists-p (file-name-as-directory (concat item subdir)))
-             (add-to-list 'input-dir-list (concat item subdir)))))))
+         (if subdirs
+             (dolist (subdir subdirs)
+               (setq path (file-name-as-directory (concat item subdir)))
+               (when (file-exists-p path)
+                 (add-to-list 'input-dir-list path t)))
+           (setq path (file-name-as-directory item))
+           (when (file-exists-p path)
+             (add-to-list 'input-dir-list path t))))))
     input-dir-list))
 
+(defun TeX-macro-global ()
+  "Return directories containing the site's TeX macro and style files."
+  (or (TeX-tree-expand '("$SYSTEXMF" "$TEXMFLOCAL" "$TEXMFMAIN" "$TEXMFDIST")
+                      "latex" '("/tex/" "/bibtex/bst/"))
+      '("/usr/share/texmf/tex/" "/usr/share/texmf/bibtex/bst/")))
+
+(defun TeX-macro-private ()
+  "Return directories containing the user's TeX macro and style files."
+  (TeX-tree-expand '("$TEXMFHOME") "latex" '("/tex/" "/bibtex/bst/")))
+
 (defcustom TeX-macro-global (TeX-macro-global)
   "Directories containing the site's TeX macro and style files."
   :group 'TeX-file
@@ -2362,18 +2497,6 @@ FORCE is not nil."
 (defvar TeX-grcl "}" "The TeX group closing character.")
  (make-variable-buffer-local 'TeX-grcl)
 
-(defcustom plain-TeX-enable-toolbar t
-  "Enable TeX tool bar in plain TeX mode."
-  :group 'TeX-tool-bar
-  :type 'boolean)
-
-(defun plain-TeX-maybe-install-toolbar ()
-  "Conditionally install tool bar buttons for plain TeX mode.
-Install tool bar if `plain-TeX-enable-toolbar' is non-nil."
-  (when plain-TeX-enable-toolbar
-    ;; Defined in `tex-bar.el':
-    (TeX-install-toolbar)))
-
 ;;; Symbols
 
 ;; Must be before keymaps.
@@ -2420,11 +2543,14 @@ Or alternatively:
               (pattern (TeX-match-buffer 0))
               (symbol (buffer-substring begin end))
               (list (funcall (nth 2 entry)))
-              (completion (try-completion symbol list)))
+              (completion (try-completion symbol list))
+              (buf-name "*Completions*"))
          (cond ((eq completion t)
                 (and close
                      (not (looking-at (regexp-quote close)))
-                     (insert close)))
+                     (insert close))
+                (let ((window (get-buffer-window buf-name)))
+                  (when window (delete-window window))))
                ((null completion)
                 (error "Can't find completion for \"%s\"" pattern))
                ((not (string-equal symbol completion))
@@ -2433,13 +2559,19 @@ Or alternatively:
                 (and close
                      (eq (try-completion completion list) t)
                      (not (looking-at (regexp-quote close)))
-                     (insert close)))
+                     (insert close))
+                (let ((window (get-buffer-window buf-name)))
+                  (when window (delete-window window))))
                (t
-                (message "Making completion list...")
-                (let ((list (all-completions symbol list nil)))
-                  (with-output-to-temp-buffer "*Completions*"
-                    (display-completion-list list)))
-                (message "Making completion list...done"))))
+                (if (fboundp 'completion-in-region)
+                    (completion-in-region begin end
+                                          (all-completions symbol list nil))
+                  (message "Making completion list...")
+                  (let ((list (all-completions symbol list nil)))
+                    (with-output-to-temp-buffer buf-name
+                      (display-completion-list list)))
+                  (set-window-dedicated-p (get-buffer-window buf-name) 'soft)
+                  (message "Making completion list...done")))))
       (funcall (nth 1 entry)))))
 
 (defcustom TeX-default-macro "ref"
@@ -2577,10 +2709,10 @@ type of ARGS:
           (goto-char (marker-position exit-mark))
           (set-marker exit-mark nil))
          ((and TeX-insert-braces
-               ;; Do not add braces for macros defined as `("foo" 0)'
+               ;; Do not add braces if the argument is 0 or -1.
                (not (and (= (safe-length args) 1)
                          (numberp (car args))
-                         (= (car args) 0)))
+                         (<= (car args) 0)))
                (equal position (point))
                (string-match "[a-zA-Z]+" symbol)
                (not (texmathp)))
@@ -2645,11 +2777,25 @@ See `TeX-parse-macro' for details."
           (TeX-arg-string optional arg)
           (setq insert-flag t))
          ((numberp arg)
-          (unless (< arg 1)
-            (TeX-parse-argument optional t)
-            (while (> arg 1)
-              (TeX-parse-argument optional nil)
-              (setq arg (- arg 1)))))
+          (cond ((< arg 0)
+                 (when (TeX-active-mark)
+                   ;; Put both the macro and the marked region in a TeX group.
+                   (let ((beg (min (point) (mark)))
+                         (end (set-marker (make-marker) (max (point) (mark)))))
+                     (insert " ")
+                     (goto-char beg)
+                     (skip-chars-backward "^\\\\")
+                     (backward-char)
+                     (insert TeX-arg-opening-brace)
+                     (goto-char (marker-position end))
+                     (insert TeX-arg-closing-brace)
+                     (setq insert-flag t))))
+                ((= arg 0)) ; nop for clarity
+                ((> arg 0)
+                 (TeX-parse-argument optional t)
+                 (while (> arg 1)
+                   (TeX-parse-argument optional nil)
+                   (setq arg (- arg 1))))))
          ((null arg)
           (insert TeX-arg-opening-brace)
           (when (and (not optional) (TeX-active-mark))
@@ -2843,7 +2989,6 @@ The algorithm is as follows:
   (kill-all-local-variables)
   (setq TeX-mode-p t)
   (setq TeX-output-extension (if TeX-PDF-mode "pdf" "dvi"))
-  (setq local-abbrev-table text-mode-abbrev-table)
   (setq indent-tabs-mode nil)
 
   ;; Ispell support
@@ -2935,95 +3080,6 @@ The algorithm is as follows:
                (TeX-master-file nil nil t))
              (TeX-update-style t)) nil t))
 
-;;; Plain TeX mode
-
-(defcustom plain-TeX-clean-intermediate-suffixes
-  TeX-clean-default-intermediate-suffixes
-  "List of regexps matching suffixes of intermediate files to be deleted.
-The regexps will be anchored at the end of the file name to be matched,
-i.e. you do _not_ have to cater for this yourself by adding \\\\' or $."
-  :type '(repeat regexp)
-  :group 'TeX-command)
-
-(defcustom plain-TeX-clean-output-suffixes TeX-clean-default-output-suffixes
-  "List of regexps matching suffixes of output files to be deleted.
-The regexps will be anchored at the end of the file name to be matched,
-i.e. you do _not_ have to cater for this yourself by adding \\\\' or $."
-  :type '(repeat regexp)
-  :group 'TeX-command)
-
-(defcustom plain-TeX-mode-hook nil
-  "A hook run in plain TeX mode buffers."
-  :type 'hook
-  :group 'TeX-misc)
-
-;;;###autoload
-(defun TeX-plain-tex-mode ()
-  "Major mode in AUCTeX for editing plain TeX files.
-See info under AUCTeX for documentation.
-
-Special commands:
-\\{plain-TeX-mode-map}
-
-Entering `plain-tex-mode' calls the value of `text-mode-hook',
-then the value of `TeX-mode-hook', and then the value
-of plain-TeX-mode-hook."
-  (interactive)
-  (plain-TeX-common-initialization)
-  (setq major-mode 'plain-tex-mode)
-  (use-local-map plain-TeX-mode-map)
-  (easy-menu-add plain-TeX-mode-menu plain-TeX-mode-map)
-  (easy-menu-add plain-TeX-mode-command-menu plain-TeX-mode-map)
-  (setq TeX-base-mode-name "TeX")
-  (setq TeX-command-default "TeX")
-  (setq TeX-sentinel-default-function 'TeX-TeX-sentinel)
-  (add-hook 'tool-bar-mode-on-hook 'plain-TeX-maybe-install-toolbar nil t)
-  (when (if (featurep 'xemacs)
-           (featurep 'toolbar)
-         (and (boundp 'tool-bar-mode) tool-bar-mode))
-    (plain-TeX-maybe-install-toolbar))
-  (TeX-run-mode-hooks 'text-mode-hook 'TeX-mode-hook 'plain-TeX-mode-hook)
-  (TeX-set-mode-name))
-
-(defun plain-TeX-common-initialization ()
-  "Common initialization for plain TeX like modes."
-  (VirTeX-common-initialization)
-  (set-syntax-table TeX-mode-syntax-table)
-  (setq paragraph-start
-       (concat
-        "\\(^[ \t]*$"
-        "\\|" (regexp-quote TeX-esc) "par\\|"
-        "^[ \t]*"
-        (regexp-quote TeX-esc)
-        "\\("
-        "begin\\|end\\|part\\|chapter\\|"
-        "section\\|subsection\\|subsubsection\\|"
-        "paragraph\\|include\\|includeonly\\|"
-        "tableofcontents\\|appendix\\|label\\|caption\\|"
-        "\\[\\|\\]"                    ; display math delimitors
-        "\\)"
-        "\\|"
-        "^[ \t]*\\$\\$"                ; display math delimitor
-        "\\)" ))
-  (setq paragraph-separate
-       (concat
-        "[ \t]*"
-        "\\("
-        (regexp-quote TeX-esc) "par\\|"
-        "%\\|"
-        "$\\|"
-        "\\$\\$\\|"
-        (regexp-quote TeX-esc)
-        "\\("
-        "begin\\|end\\|label\\|caption\\|part\\|chapter\\|"
-        "section\\|subsection\\|subsubsection\\|"
-        "paragraph\\|include\\|includeonly\\|"
-        "tableofcontents\\|appendix\\|" (regexp-quote TeX-esc)
-        "\\)"
-        "\\)"))
-  (setq TeX-header-end (regexp-quote "%**end of header"))
-  (setq TeX-trailer-start (regexp-quote (concat TeX-esc "bye")))
-  (TeX-run-style-hooks "TEX"))
 
 ;;; Hilighting
 
@@ -3203,6 +3259,24 @@ Generated by `TeX-auto-add-type'.")
   :group 'TeX-file
   :type 'directory)
 
+(defcustom TeX-ignore-file
+  "\\(^\\|[/\\]\\)\\(\\.\\|\\.\\.\\|RCS\\|SCCS\\|CVS\\|babel\\..*\\)$"
+  "Regular expression matching file names to ignore.
+
+These files or directories will not be considered when searching for
+TeX files in a directory."
+  :group 'TeX-parse
+  :type 'regexp)
+
+(defcustom TeX-file-recurse t
+  "Whether to search TeX directories recursively.
+nil means do not recurse, a positive integer means go that far deep in the
+directory hierarchy, t means recurse indefinitely."
+  :group 'TeX-parse
+  :type '(choice (const :tag "On" t)
+                (const :tag "Off" nil)
+                (integer :tag "Depth" :value 1)))
+
 ;;;###autoload
 (defun TeX-auto-generate (tex auto)
   "Generate style file for TEX and store it in AUTO.
@@ -3238,8 +3312,10 @@ If TEX is a directory, generate style files for all 
files in the directory."
               (concat (file-name-as-directory auto)
                       (TeX-strip-extension tex TeX-all-extensions t)
                       ".el"))))
-       ((TeX-match-extension tex (append TeX-file-extensions
-                                         BibTeX-file-extensions))
+       ((TeX-match-extension tex (TeX-delete-duplicate-strings
+                                  (append TeX-file-extensions
+                                          BibTeX-file-extensions
+                                          TeX-Biber-file-extensions)))
         (save-excursion
           (set-buffer (let (enable-local-eval)
                         (find-file-noselect tex)))
@@ -3259,7 +3335,8 @@ If TEX is a directory, generate style files for all files 
in the directory."
   (unless (file-directory-p TeX-auto-global)
     (make-directory TeX-auto-global))
   (let ((TeX-file-extensions '("cls" "sty"))
-       (BibTeX-file-extensions nil))
+       (BibTeX-file-extensions nil)
+       (TeX-Biber-file-extensions nil))
     (mapc (lambda (macro) (TeX-auto-generate macro TeX-auto-global))
          TeX-macro-global))
   (byte-recompile-directory TeX-auto-global 0))
@@ -3316,6 +3393,22 @@ If SKIP is not-nil, don't insert code for SKIP."
     "theenumv" "document" "par" "do" "expandafter")
   "List of symbols to ignore when scanning a TeX style file.")
 
+(defcustom TeX-auto-regexp-list 'TeX-auto-full-regexp-list
+  "List of regular expressions used for parsing the current file."
+  :type '(radio (variable-item TeX-auto-empty-regexp-list)
+               (variable-item TeX-auto-full-regexp-list)
+               (variable-item plain-TeX-auto-regexp-list)
+               (variable-item LaTeX-auto-minimal-regexp-list)
+               (variable-item LaTeX-auto-label-regexp-list)
+               (variable-item LaTeX-auto-regexp-list)
+               (symbol :tag "Other")
+               (repeat :tag "Specify"
+                       (group (regexp :tag "Match")
+                              (sexp :tag "Groups")
+                              symbol)))
+  :group 'TeX-parse)
+  (make-variable-buffer-local 'TeX-auto-regexp-list)
+
 (defun TeX-auto-add-regexp (regexp)
   "Add REGEXP to `TeX-auto-regexp-list' if not already a member."
   (if (symbolp TeX-auto-regexp-list)
@@ -3339,17 +3432,21 @@ alter the numbering of any ordinary, non-shy groups.")
 
 (defvar plain-TeX-auto-regexp-list
   (let ((token TeX-token-char))
-    `((,(concat "\\\\def\\\\\\(" token "+\\)[^a-zA-Z@]") 1 
TeX-auto-symbol-check)
-      (,(concat "\\\\let\\\\\\(" token "+\\)[^a-zA-Z@]") 1 
TeX-auto-symbol-check)
+    `((,(concat "\\\\def\\\\\\(" token "+\\)[^a-zA-Z@]")
+       1 TeX-auto-symbol-check)
+      (,(concat "\\\\let\\\\\\(" token "+\\)[^a-zA-Z@]")
+       1 TeX-auto-symbol-check)
       (,(concat "\\\\font\\\\\\(" token "+\\)[^a-zA-Z@]") 1 TeX-auto-symbol)
       (,(concat "\\\\chardef\\\\\\(" token "+\\)[^a-zA-Z@]") 1 TeX-auto-symbol)
-      (,(concat "\\\\new\\(?:count\\|dimen\\|muskip\\|skip\\)\\\\\\(" token 
"+\\)[^a-zA-Z@]")
+      (,(concat "\\\\new\\(?:count\\|dimen\\|muskip\\|skip\\)\\\\\\(" token
+               "+\\)[^a-zA-Z@]")
        1 TeX-auto-symbol)
       (,(concat "\\\\newfont{?\\\\\\(" token "+\\)}?") 1 TeX-auto-symbol)
       (,(concat "\\\\typein\\[\\\\\\(" token "+\\)\\]") 1 TeX-auto-symbol)
       ("\\\\input +\\(\\.*[^#%\\\\\\.\n\r]+\\)\\(\\.[^#%\\\\\\.\n\r]+\\)?"
        1 TeX-auto-file)
-      (,(concat "\\\\mathchardef\\\\\\(" token "+\\)[^a-zA-Z@]") 1 
TeX-auto-symbol)))
+      (,(concat "\\\\mathchardef\\\\\\(" token "+\\)[^a-zA-Z@]")
+       1 TeX-auto-symbol)))
   "List of regular expression matching common LaTeX macro definitions.")
 
 (defvar TeX-auto-full-regexp-list plain-TeX-auto-regexp-list
@@ -3512,26 +3609,8 @@ Check for potential LaTeX environments."
            (add-to-list 'TeX-auto-symbol elt))
        (add-to-list 'TeX-auto-symbol symbol)))))
 
-;;; Utilities
-;;
-;; Some of these functions has little to do with TeX, but nonetheless we
-;; should use the "TeX-" prefix to avoid name clashes.
 
-(defcustom TeX-auto-regexp-list 'TeX-auto-full-regexp-list
-  "*List of regular expressions used for parsing the current file."
-  :type '(radio (variable-item TeX-auto-empty-regexp-list)
-               (variable-item TeX-auto-full-regexp-list)
-               (variable-item plain-TeX-auto-regexp-list)
-               (variable-item LaTeX-auto-minimal-regexp-list)
-               (variable-item LaTeX-auto-label-regexp-list)
-               (variable-item LaTeX-auto-regexp-list)
-               (symbol :tag "Other")
-               (repeat :tag "Specify"
-                       (group (regexp :tag "Match")
-                              (sexp :tag "Groups")
-                              symbol)))
-  :group 'TeX-parse)
-  (make-variable-buffer-local 'TeX-auto-regexp-list)
+;;; File Extensions
 
 (defgroup TeX-file-extension nil
   "File extensions recognized by AUCTeX."
@@ -3554,6 +3633,11 @@ Check for potential LaTeX environments."
 
   (make-variable-buffer-local 'TeX-default-extension)
 
+(defvar TeX-doc-extensions
+  '("dvi" "pdf" "ps" "txt" "html" "dvi.gz" "pdf.gz" "ps.gz" "txt.gz" "html.gz"
+    "dvi.bz2" "pdf.bz2" "ps.bz2" "txt.bz2" "html.bz2")
+  "File extensions of documentation files.")
+
 (defcustom docTeX-default-extension "dtx"
   "*Default extension for docTeX files."
   :group 'TeX-file-extension
@@ -3567,6 +3651,11 @@ Access to the value should be through the function 
`TeX-output-extension'.")
 
   (make-variable-buffer-local 'TeX-output-extension)
 
+(defcustom TeX-Biber-file-extensions '("bib" "ris" "xml")
+  "Valid file extensions for Biber files."
+  :group 'TeX-file-extension
+  :type '(repeat (string :format "%v")))
+
 (defcustom BibTeX-file-extensions '("bib")
   "Valid file extensions for BibTeX files."
   :group 'TeX-file-extension
@@ -3577,23 +3666,6 @@ Access to the value should be through the function 
`TeX-output-extension'.")
   :group 'TeX-file-extension
   :type '(repeat (string :format "%v")))
 
-(defcustom TeX-ignore-file 
"\\(^\\|[/\\]\\)\\(\\.\\|\\.\\.\\|RCS\\|SCCS\\|CVS\\|babel\\..*\\)$"
-  "Regular expression matching file names to ignore.
-
-These files or directories will not be considered when searching for
-TeX files in a directory."
-  :group 'TeX-parse
-  :type 'regexp)
-
-(defcustom TeX-file-recurse t
-  "*Whether to search TeX directories recursively.
-nil means do not recurse, a positive integer means go that far deep in the
-directory hierarchy, t means recurse indefinitely."
-  :group 'TeX-parse
-  :type '(choice (const :tag "On" t)
-                (const :tag "Off" nil)
-                (integer :tag "Depth" :value 1)))
-
 (defun TeX-match-extension (file &optional extensions)
   "Return non-nil if FILE has one of EXTENSIONS.
 
@@ -3636,6 +3708,23 @@ EXTENSIONS defaults to `TeX-file-extensions'."
        (file-name-nondirectory strip)
       strip)))
 
+
+;;; File Searching
+
+(defun TeX-tree-roots ()
+  "Return a list of available TeX tree roots."
+  (let (list)
+    (dolist (dir (TeX-tree-expand '("$TEXMFHOME" "$TEXMFMAIN" "$TEXMFLOCAL"
+                                   "$TEXMFDIST") "latex"))
+      (when (file-readable-p dir)
+       (add-to-list 'list dir t)))
+    list))
+
+(defcustom TeX-tree-roots (TeX-tree-roots)
+  "List of all available TeX tree root directories."
+  :group 'TeX-file
+  :type '(repeat directory))
+
 (defcustom TeX-kpathsea-path-delimiter t
   "Path delimiter for kpathsea output.
 t means autodetect, nil means kpathsea is disabled."
@@ -3645,78 +3734,46 @@ t means autodetect, nil means kpathsea is disabled."
                 (const :tag "Autodetect" t)
                 (const :tag "Off" nil)))
 
-(defcustom TeX-kpathsea-format-alist
-  '(("tex" "${TEXINPUTS.latex}" TeX-file-extensions)
-    ("sty" "${TEXINPUTS.latex}" '("sty"))
-    ("dvi" "${TEXDOCS}" '("dvi" "pdf" "ps" "txt" "html"
-                         "dvi.gz" "pdf.gz" "ps.gz" "txt.gz" "html.gz"
-                         "dvi.bz2" "pdf.bz2" "ps.bz2" "txt.bz2" "html.bz2"))
-    ("eps" "${TEXINPUTS}" LaTeX-includegraphics-extensions)
-    ("pdf" "${TEXINPUTS}" LaTeX-includegraphics-extensions)
-    ("png" "${TEXINPUTS}" LaTeX-includegraphics-extensions)
-    ("jpg" "${TEXINPUTS}" LaTeX-includegraphics-extensions)
-    ("jpeg" "${TEXINPUTS}" LaTeX-includegraphics-extensions)
-    ("bib" "$BIBINPUTS" BibTeX-file-extensions)
-    ("bst" "$BSTINPUTS" BibTeX-style-extensions))
-  "Formats to search for expansion using kpathsea.
-The key of the alist represents the name of the format.  The
-first element of the cdr of the alist is string to expand by the
-respective kpathsea program and the second element is a list of
-file extensions to match."
-  :group 'TeX-file
-  :type '(alist :key-type string :value-type (group string sexp)))
-
-;; FIXME: Despite the first parameter named `extensions',
-;; `TeX-search-files-kpathsea' basically treats this as a format
-;; specifier.  Only the first element in the respective list will be
-;; used to determine the search paths and file extensions with the
-;; help of `TeX-kpathsea-format-alist'.  Out of these differences
-;; arises a need to unify the behavior of `TeX-search-files' and
-;; `TeX-search-files-kpathsea' and their treatment of parameters.
-;; Additionally `TeX-search-files-kpathsea' should be made more
-;; general to work with other platforms and TeX systems as well.
-(defun TeX-search-files-kpathsea (extensions nodir strip)
-  "The kpathsea-enabled version of `TeX-search-files'.
-Except for DIRECTORIES (a kpathsea string), the arguments for
-EXTENSIONS, NODIR and STRIP are explained there."
+;; We keep this function in addition to `TeX-search-files' because it
+;; is faster.  Since it does not look further into subdirectories,
+;; this comes at the price of finding a smaller number of files.
+(defun TeX-search-files-kpathsea (var extensions scope nodir strip)
+  "Return a list of files in directories determined by expanding VAR.
+Only files which match EXTENSIONS are returned.  SCOPE defines
+the scope for the search and can be `local' or `global' besides
+nil.  If NODIR is non-nil, remove directory part.  If STRIP is
+non-nil, remove file extension."
   (and TeX-kpathsea-path-delimiter
        (catch 'no-kpathsea
-        (let* ((format-spec (assoc (car extensions)
-                                   TeX-kpathsea-format-alist))
-               (dirs (with-output-to-string
-                       (unless (zerop
-                                (call-process
-                                 "kpsewhich" nil (list standard-output nil)
-                                 nil
-                                 (concat
-                                  "-expand-path="
-                                  (nth 1 format-spec))))
-                        (if (eq TeX-kpathsea-path-delimiter t)
-                            (throw 'no-kpathsea
-                                   (setq TeX-kpathsea-path-delimiter nil))
-                          (error "kpsewhich error")))))
-              result)
+        (let* ((dirs (if (eq scope 'local)
+                         "."
+                       (with-output-to-string
+                         (unless (zerop (call-process
+                                         "kpsewhich" nil
+                                         (list standard-output nil) nil
+                                         (concat "-expand-path=" var)))
+                           (if (eq TeX-kpathsea-path-delimiter t)
+                               (throw 'no-kpathsea
+                                      (setq TeX-kpathsea-path-delimiter nil))
+                             (error "kpsewhich error"))))))
+               result)
           (when (eq TeX-kpathsea-path-delimiter t)
             (setq TeX-kpathsea-path-delimiter
-                  (cond ((string-match ";" dirs)
-                         ";")
-                        ((string-match ":" dirs)
-                         ":"))))
+                  (if (string-match ";" dirs) ";" ":")))
           (unless TeX-kpathsea-path-delimiter
             (throw 'no-kpathsea nil))
-          (setq dirs (split-string dirs (concat "[\n\r"
-                                                TeX-kpathsea-path-delimiter
-                                                "]+")))
-          (setq extensions (concat "\\."
-                                   (regexp-opt (eval (nth 2 format-spec)) t)
-                                   "\\'"))
-          (setq result
-                (apply #'append
-                       (mapcar
-                        (lambda(x) (directory-files x
-                                                    (not nodir)
-                                                    extensions))
-                        dirs)))
+          (setq dirs (delete "" (split-string
+                                 dirs (concat "[\n\r"
+                                              TeX-kpathsea-path-delimiter
+                                              "]+"))))
+          (if (eq scope 'global)
+              (delete "." dirs))
+          (setq extensions (concat "\\." (regexp-opt extensions t) "\\'")
+                result (apply #'append (mapcar (lambda (x)
+                                                 (when (file-readable-p x)
+                                                   (directory-files
+                                                    x (not nodir) extensions)))
+                                               dirs)))
           (if strip
               (mapcar (lambda(x)
                         (if (string-match extensions x)
@@ -3732,46 +3789,117 @@ If optional argument STRIP is set, remove file 
extension.
 If optional argument DIRECTORIES is set, search in those directories.
 Otherwise, search in all TeX macro directories.
 If optional argument EXTENSIONS is not set, use `TeX-file-extensions'"
-  (if (null extensions)
-      (setq extensions TeX-file-extensions))
-  (or (TeX-search-files-kpathsea extensions nodir strip)
-      (progn
-       (if (null directories)
-           (setq directories
-                 (cons "./" (append TeX-macro-private TeX-macro-global))))
-       (let (match
-             (TeX-file-recurse (cond ((symbolp TeX-file-recurse)
-                                      TeX-file-recurse)
-                                     ((zerop TeX-file-recurse)
-                                      nil)
-                                     ((1- TeX-file-recurse)))))
-         (while directories
-           (let* ((directory (car directories))
-                  (content (and directory
-                                (file-readable-p directory)
-                                (file-directory-p directory)
-                                (directory-files directory))))
-             (setq directories (cdr directories))
-             (while content
-               (let ((file (concat directory (car content))))
-                 (setq content (cdr content))
-                 (cond ((string-match TeX-ignore-file file))
-                       ((not (file-readable-p file)))
-                       ((file-directory-p file)
-                        (if TeX-file-recurse
-                            (setq match
-                                  (append match
-                                          (TeX-search-files
-                                           (list (file-name-as-directory file))
-                                           extensions
-                                           nodir strip)))))
-                       ((TeX-match-extension file extensions)
-                        (setq match (cons (TeX-strip-extension file
-                                                               extensions
-                                                               nodir
-                                                               (not strip))
-                                          match))))))))
-         match))))
+  (when (null extensions)
+    (setq extensions TeX-file-extensions))
+  (when (null directories)
+    (setq directories (cons "./" (append TeX-macro-private TeX-macro-global))))
+  (let (match
+       (TeX-file-recurse (cond ((symbolp TeX-file-recurse)
+                                TeX-file-recurse)
+                               ((zerop TeX-file-recurse)
+                                nil)
+                               ((1- TeX-file-recurse)))))
+    (while directories
+      (let* ((directory (car directories))
+            (content (and directory
+                          (file-readable-p directory)
+                          (file-directory-p directory)
+                          (directory-files directory))))
+       (setq directories (cdr directories))
+       (while content
+         (let ((file (concat directory (car content))))
+           (setq content (cdr content))
+           (cond ((string-match TeX-ignore-file file))
+                 ((not (file-readable-p file)))
+                 ((file-directory-p file)
+                  (if TeX-file-recurse
+                      (setq match
+                            (append match
+                                    (TeX-search-files
+                                     (list (file-name-as-directory file))
+                                     extensions nodir strip)))))
+                 ((TeX-match-extension file extensions)
+                  (setq match (cons (TeX-strip-extension
+                                     file extensions nodir (not strip))
+                                    match))))))))
+    match))
+
+;; The variables `TeX-macro-private' and `TeX-macro-global' are not
+;; used for specifying the directories because the number of
+;; directories to be searched should be limited as much as possible
+;; and the TeX-macro-* variables are just too broad for this.
+(defvar TeX-search-files-type-alist
+  '((texinputs "${TEXINPUTS}" ("tex/") TeX-file-extensions)
+    (docs "${TEXDOCS}" ("doc/") TeX-doc-extensions)
+    (graphics "${TEXINPUTS}" ("tex/") LaTeX-includegraphics-extensions)
+    (bibinputs "${BIBINPUTS}" ("bibtex/bib/") BibTeX-file-extensions)
+    (bstinputs "${BSTINPUTS}" ("bibtex/bst/") BibTeX-style-extensions))
+  "Alist of filetypes with locations and file extensions.
+Each element of the alist consists of a symbol expressing the
+filetype, a variable which can be expanded on kpathsea-based
+systems into the directories where files of the given type
+reside, a list of absolute directories, relative directories
+below the root of a TDS-compliant TeX tree or a list of variables
+with either type of directories as an alternative for
+non-kpathsea-based systems and a list of extensions to be matched
+upon a file search.  Note that the directories have to end with a
+directory separator.
+
+Each AUCTeX mode should set the variable buffer-locally with a
+more specific value.  See `LateX-search-files-type-alist' for an
+example.")
+
+(defun TeX-search-files-by-type (filetype &optional scope nodir strip)
+  "Return a list of files in TeX's search path with type FILETYPE.
+FILETYPE is a symbol used to choose the search paths and
+extensions.  See `TeX-search-file-type-alist' for supported
+symbols.
+
+The optional argument SCOPE sets the scope for the search.
+Besides nil the symbols `local' and `global' are accepted.
+`local' means to search in the current directory only, `global'
+in the global directories only and nil in both.
+
+If optional argument NODIR is non-nil, remove directory part.
+
+If optional argument STRIP is non-nil, remove file extension."
+  (let* ((spec (assq filetype TeX-search-files-type-alist))
+        (kpse-var (nth 1 spec))
+        (rawdirs (nth 2 spec))
+        (exts (nth 3 spec))
+        expdirs dirs local-files)
+    (setq exts (if (symbolp exts) (eval exts) exts))
+    (or (TeX-search-files-kpathsea kpse-var exts scope nodir strip)
+       (progn
+         (unless (eq scope 'global)
+           (setq local-files
+                 (let ((TeX-file-recurse nil))
+                   (TeX-search-files '("./") exts nodir strip))))
+         (if (eq scope 'local)
+             local-files
+           (if (null TeX-tree-roots)
+               (error "No TeX trees available; configure `TeX-tree-roots'")
+             ;; Expand variables.
+             (dolist (rawdir rawdirs)
+               (if (symbolp rawdir)
+                   (setq expdirs (append expdirs (eval rawdir)))
+                 (add-to-list 'expdirs rawdir t)))
+             (delete-dups expdirs)
+             ;; Assumption: Either all paths are absolute or all are relative.
+             (if (file-name-absolute-p (car expdirs))
+                 (setq dirs expdirs)
+               ;; Append relative TDS subdirs to all TeX tree roots.
+               (dolist (root TeX-tree-roots)
+                 (dolist (dir expdirs)
+                   (add-to-list 'dirs (concat (file-name-as-directory root)
+                                              dir) t)))))
+           (append local-files (TeX-search-files dirs exts nodir strip)))))))
+
+
+;;; Utilities
+;;
+;; Some of these functions has little to do with TeX, but nonetheless we
+;; should use the "TeX-" prefix to avoid name clashes.
 
 (defun TeX-car-string-lessp (s1 s2)
   "Compare the cars of S1 and S2 in lexicographic order.
@@ -4076,12 +4204,6 @@ Brace insertion is only done if point is in a math 
construct and
     map)
   "Keymap for common TeX and LaTeX commands.")
 
-(defvar plain-TeX-mode-map
-  (let ((map (make-sparse-keymap)))
-    (set-keymap-parent map TeX-mode-map)
-    map)
-  "Keymap used in plain TeX mode.")
-
 (defun TeX-mode-specific-command-menu (mode)
   "Return a Command menu specific to the major MODE."
   ;; COMPATIBILITY for Emacs < 21
@@ -4221,13 +4343,6 @@ Brace insertion is only done if point is in a math 
construct and
       :help "Hide or show the item containing point"]))
    "Menu definition for commands from tex-fold.el.")
 
-
-;;; Menus for plain TeX mode
-(easy-menu-define plain-TeX-mode-command-menu
-    plain-TeX-mode-map
-    "Command menu used in TeX mode."
-    (TeX-mode-specific-command-menu 'plain-tex-mode))
-
 (defvar TeX-customization-menu nil)
 
 (defvar TeX-common-menu-entries
@@ -4266,91 +4381,6 @@ Brace insertion is only done if point is in a math 
construct and
       :help ,(format "Problems with AUCTeX %s? Mail us!"
                     AUCTeX-version)])))
 
-(defvar plain-TeX-menu-entries
-  (TeX-menu-with-help
-   `(["Macro..." TeX-insert-macro
-      :help "Insert a macro and possibly arguments"]
-     ["Complete" TeX-complete-symbol
-      :help "Complete the current macro"]
-     "-"
-     ("Insert Font"
-      ["Emphasize"  (TeX-font nil ?\C-e) :keys "C-c C-f C-e"]
-      ["Bold"       (TeX-font nil ?\C-b) :keys "C-c C-f C-b"]
-      ["Typewriter" (TeX-font nil ?\C-t) :keys "C-c C-f C-t"]
-      ["Small Caps" (TeX-font nil ?\C-c) :keys "C-c C-f C-c"]
-      ["Sans Serif" (TeX-font nil ?\C-f) :keys "C-c C-f C-f"]
-      ["Italic"     (TeX-font nil ?\C-i) :keys "C-c C-f C-i"]
-      ["Slanted"    (TeX-font nil ?\C-s) :keys "C-c C-f C-s"]
-      ["Roman"      (TeX-font nil ?\C-r) :keys "C-c C-f C-r"]
-      ["Calligraphic" (TeX-font nil ?\C-a) :keys "C-c C-f C-a"])
-     ("Replace Font"
-      ["Emphasize"  (TeX-font t ?\C-e) :keys "C-u C-c C-f C-e"]
-      ["Bold"       (TeX-font t ?\C-b) :keys "C-u C-c C-f C-b"]
-      ["Typewriter" (TeX-font t ?\C-t) :keys "C-u C-c C-f C-t"]
-      ["Small Caps" (TeX-font t ?\C-c) :keys "C-u C-c C-f C-c"]
-      ["Sans Serif" (TeX-font t ?\C-f) :keys "C-u C-c C-f C-f"]
-      ["Italic"     (TeX-font t ?\C-i) :keys "C-u C-c C-f C-i"]
-      ["Slanted"    (TeX-font t ?\C-s) :keys "C-u C-c C-f C-s"]
-      ["Roman"      (TeX-font t ?\C-r) :keys "C-u C-c C-f C-r"]
-      ["Calligraphic" (TeX-font t ?\C-a) :keys "C-u C-c C-f C-a"])
-     ["Delete Font" (TeX-font t ?\C-d) :keys "C-c C-f C-d"]
-     "-"
-     ["Comment or Uncomment Region" TeX-comment-or-uncomment-region
-      :help "Comment or uncomment the currently selected region"]
-     ["Comment or Uncomment Paragraph" TeX-comment-or-uncomment-paragraph
-      :help "Comment or uncomment the paragraph containing point"]
-     ,TeX-fold-menu
-     "-" . ,TeX-common-menu-entries)))
-
-(easy-menu-define plain-TeX-mode-menu
-    plain-TeX-mode-map
-    "Menu used in plain TeX mode."
-    (cons "TeX" plain-TeX-menu-entries))
-
-;;; AmSTeX
-
-(defvar AmSTeX-mode-map
-  (let ((map (make-sparse-keymap)))
-    (set-keymap-parent map TeX-mode-map)
-    map)
-  "Keymap used in `AmSTeX-mode'.")
-
-;; Menu for AmSTeX mode
-(easy-menu-define AmSTeX-mode-command-menu
-    AmSTeX-mode-map
-    "Command menu used in AmsTeX mode."
-    (TeX-mode-specific-command-menu 'ams-tex-mode))
-
-(easy-menu-define AmSTeX-mode-menu
-  AmSTeX-mode-map
-  "Menu used in AMS-TeX mode."
-  (cons "AmS-TeX" plain-TeX-menu-entries))
-
-;;;###autoload
-(defun ams-tex-mode ()
-  "Major mode in AUCTeX for editing AmS-TeX files.
-See info under AUCTeX for documentation.
-
-Special commands:
-\\{AmSTeX-mode-map}
-
-Entering AmS-tex-mode calls the value of `text-mode-hook',
-then the value of `TeX-mode-hook', and then the value
-of `AmS-TeX-mode-hook'."
-  (interactive)
-  (plain-TeX-common-initialization)
-  (setq major-mode 'ams-tex-mode)
-  (use-local-map AmSTeX-mode-map)
-
-  ;; Menu
-  (easy-menu-add AmSTeX-mode-menu AmSTeX-mode-map)
-  (easy-menu-add AmSTeX-mode-command-menu AmSTeX-mode-map)
-
-  (setq TeX-base-mode-name "AmS-TeX")
-  (setq TeX-command-default "AmSTeX")
-  (TeX-run-mode-hooks 'text-mode-hook 'TeX-mode-hook 'AmS-TeX-mode-hook)
-  (TeX-set-mode-name))
-
 
 ;;; Verbatim constructs
 
@@ -5137,7 +5167,7 @@ sign.  With optional ARG, insert that many dollar signs."
   (TeX-math-input-method-off))
 
 (defvar TeX-math-input-method-off-regexp
-  "^\\(chinese\\|japanese\\|korean\\bulgarian\\russian\\)"
+  "^\\(chinese\\|japanese\\|korean\\|bulgarian\\|russian\\)"
   "Regexp matching input methods to be deactivated when entering math mode.")
 
 (defun TeX-math-input-method-off ()
@@ -5160,6 +5190,7 @@ With optional argument ARG, also reload the style hooks."
       (setq TeX-style-hook-list nil
            BibTeX-global-style-files nil
            BibTeX-global-files nil
+           TeX-Biber-global-files nil
            TeX-global-input-files nil))
   (let ((TeX-auto-save t))
     (if (buffer-modified-p)
@@ -5577,6 +5608,20 @@ NAME may be a package, a command, or a document."
              ispell-tex-major-modes))
 
 
+;;; Abbrev mode
+
+(defmacro TeX-abbrev-mode-setup (mode)
+  "Set up the abbrev table and variable for MODE."
+  (let ((symbol (intern (concat (symbol-name mode) "-abbrev-table")))
+       (name (TeX-mode-prefix mode)))
+    `(progn
+       (defvar ,symbol nil
+        ,(format "Abbrev table for %s mode." name))
+       (define-abbrev-table ',symbol nil)
+       (when (fboundp 'abbrev-table-put)
+        (abbrev-table-put ,symbol :parents (list text-mode-abbrev-table))))))
+
+
 ;;; Special provisions for other modes and libraries
 
 ;; desktop-locals-to-save is broken by design.  Don't have



reply via email to

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