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

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

[elpa] externals/auctex 4357488 68/69: Merge branch 'master' into elpa


From: Tassilo Horn
Subject: [elpa] externals/auctex 4357488 68/69: Merge branch 'master' into elpa
Date: Sat, 26 Mar 2016 21:36:38 +0000

branch: externals/auctex
commit 4357488d261acaff048b1e7a5fbb4c64b450259b
Merge: 0a99c11 d4b0d5f
Author: Tassilo Horn <address@hidden>
Commit: Tassilo Horn <address@hidden>

    Merge branch 'master' into elpa
---
 ChangeLog.1                       |   21 ++
 Makefile.in                       |   57 +++++-
 build-aux/gitlog-to-auctexlog     |  131 +++++++++++
 doc/auctex.texi                   |  104 +++++++--
 doc/changes.texi                  |   56 +++++-
 latex.el                          |   98 ++++++---
 style/amsthm.el                   |    2 +-
 style/enumitem.el                 |   43 ++++-
 style/icelandic.el                |    2 +-
 style/longtable.el                |   12 +-
 style/newfloat.el                 |    2 +-
 style/ntheorem.el                 |    2 +-
 style/polish.el                   |    2 +-
 style/polski.el                   |    2 +-
 style/psfig.el                    |   20 +-
 style/splitidx.el                 |  309 +++++++++++++++++++++++++
 style/theorem.el                  |    2 +-
 tests/latex/latex-filling-in.tex  |    4 +
 tests/latex/latex-filling-out.tex |    4 +
 tests/tex/compilation-log.txt     |   68 ++++++
 tests/tex/error-parsing.el        |  120 ++++++++++
 tex-buf.el                        |  449 +++++++++++++++++++++++++++----------
 tex-style.el                      |   12 +
 tex.el                            |  223 +++++++++++++++----
 24 files changed, 1513 insertions(+), 232 deletions(-)

diff --git a/ChangeLog.1 b/ChangeLog.1
index dd1f90c..5d991a0 100644
--- a/ChangeLog.1
+++ b/ChangeLog.1
@@ -18315,6 +18315,27 @@
 
        * Version 9.1 released.
 
+This file records repository revisions from
+commit c865982cacab289f4480f9145b3438ec06824232 (exclusive) to
+commit df7dbbd3a029f02042b4fa01725c4a1f4502ff56 (inclusive).
+
 ;; Local Variables:
 ;; coding: iso-8859-1
 ;; End:
+
+  Copyright (C) 1994-2016 Free Software Foundation, Inc.
+
+  This file is part of GNU AUCTeX.
+
+  GNU 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 of the License, or
+  (at your option) any later version.
+
+  GNU 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 GNU AUCTeX.  If not, see <http://www.gnu.org/licenses/>.
diff --git a/Makefile.in b/Makefile.in
index ee9c122..471ff21 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -153,7 +153,8 @@ STYLESRC = style/prosper.el \
           style/vwcol.el     style/textpos.el   style/transparent.el \
           style/fontenc.el   style/Alegreya.el  style/gloss-italian.el \
           style/newfloat.el  style/subcaption.el style/AlegreyaSans.el \
-          style/hologo.el    style/theorem.el   style/ntheorem.el
+          style/hologo.el    style/theorem.el   style/ntheorem.el \
+          style/splitidx.el
 
 STYLEELC = $(STYLESRC:.el=.elc)
 
@@ -397,6 +398,60 @@ wc:
        wc $(AUCSRC) $(STYLESRC)
 
 # ----------------------------------------------------------------------
+# The targets below update the ChangeLog from git log
+# and are intended to be used only by the maintainers.
+# These rules are adapted from GNU Emacs Makefile.
+
+.PHONY: ChangeLog change-history change-history-commit change-history-nocommit
+.PHONY: preferred-branch-is-current unchanged-history-files
+
+CHANGELOG = ChangeLog
+auctexlog = build-aux/gitlog-to-auctexlog
+# The ChangeLog history files are called ChangeLog.1, ChangeLog.2, ...,
+# ChangeLog.$(CHANGELOG_HISTORY_INDEX_MAX).  $(CHANGELOG_N) stands for
+# the newest (highest-numbered) ChangeLog history file.
+CHANGELOG_HISTORY_INDEX_MAX = 1
+CHANGELOG_N = ChangeLog.$(CHANGELOG_HISTORY_INDEX_MAX)
+
+# Check that we are in a good state for changing history.
+PREFERRED_BRANCH = master
+preferred-branch-is-current:
+       git branch | grep -q '^\* $(PREFERRED_BRANCH)$$'
+unchanged-history-files:
+       x=$$(git diff-files --name-only $(CHANGELOG_N) $(auctexlog)) && \
+         test -z "$$x"
+
+# Convert git commit log to ChangeLog file.  make-dist uses this.
+# I guess this is PHONY so it always updates?
+ChangeLog:
+         ./$(auctexlog) -o $(CHANGELOG) -n $(CHANGELOG_HISTORY_INDEX_MAX)
+
+# Regular expression that matches the newest commit covered by a ChangeLog.
+new_commit_regexp = ^commit [0123456789abcdef]* (inclusive)
+
+# Copy newer commit messages to the start of the ChangeLog history file,
+# and consider them to be older.
+change-history-nocommit: #preferred-branch-is-current unchanged-history-files
+       -rm -f ChangeLog.tmp
+       $(MAKE) ChangeLog CHANGELOG=ChangeLog.tmp
+       sed '/^This file records repository revisions/,$$d' \
+         ChangeLog.tmp > $(CHANGELOG_N).tmp
+       new_commit_line=`grep --text '$(new_commit_regexp)' ChangeLog.tmp` && \
+       sed 's/$(new_commit_regexp).*/'"$$new_commit_line/" \
+         $(CHANGELOG_N) >>$(CHANGELOG_N).tmp
+       rm ChangeLog.tmp
+       mv $(CHANGELOG_N).tmp $(CHANGELOG_N)
+
+change-history: change-history-nocommit
+       $(MAKE) address@hidden
+
+# If 'make change-history' fails because the newest ChangeLog history
+# file contains invalid text, fix the file by hand and then run
+# 'make change-history-commit'.
+change-history-commit:
+       git commit -m'; make $@' $(CHANGELOG_N) $(auctexlog)
+
+# ----------------------------------------------------------------------
 # The targets below are concerned with the release process and
 # intended to be used only by the maintainers.
 
diff --git a/build-aux/gitlog-to-auctexlog b/build-aux/gitlog-to-auctexlog
new file mode 100755
index 0000000..9836713
--- /dev/null
+++ b/build-aux/gitlog-to-auctexlog
@@ -0,0 +1,131 @@
+#!/bin/sh
+
+# Convert git log output to ChangeLog format for GNU AUCTeX.
+# Adapted from build-auc/gitlog-to-emacslog script, part of GNU Emacs.
+
+# Copyright (C) 2014-2016 Free Software Foundation, Inc.
+
+# Original Author: Paul Eggert
+
+# 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
+# the Free Software Foundation, either version 3 of the License, 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.
+
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+LC_ALL=C
+export LC_ALL
+
+# The newest revision that should not appear in the generated ChangeLog.
+gen_origin=
+
+force=
+output=ChangeLog
+nmax=1
+
+while [ $# -gt 0 ]; do
+  case "$1" in
+      -g|--gen-origin) gen_origin="$2" ; shift ;;
+      -f|--force) force=1 ;;
+      -n|--nmax) nmax="$2"; shift ;;
+      -o|--output) output="$2" ; shift ;;
+      *) printf '%s\n' "Unrecognized argument: $1" >&2; exit 1 ;;
+  esac
+  shift
+done
+
+if [ ! -f ChangeLog.$nmax ]; then
+    printf '%s\n' "Can't find ChangeLog.$nmax" >&2
+    printf '%s\n' "Must be run from the top source directory" >&2
+    exit 1
+fi
+
+# If not specified in the command line, get gen_origin from the existing
+# ChangeLog file.
+[ "$gen_origin" ] || {
+    gen_origin_line=`
+      grep --text -E '^commit [0-9a-f]+ [(]inclusive[)]' ChangeLog.$nmax
+    ` || {
+       printf '%s\n' "ChangeLog.$nmax lacks a 'commit ... (inclusive)' line" 
>&2
+       exit 1
+    }
+    set $gen_origin_line
+    gen_origin=$2
+}
+
+# Get the new value for gen_origin from the latest version in the repository.
+new_origin=`git log --pretty=format:%H 'HEAD^!'` || exit
+
+if [ -f "$output" ]; then
+    [ ! "$force" ] && printf '%s\n' "$output exists" >&2 && exit 1
+    rm -f "$output" || exit 1
+fi
+
+# If this is not a Git repository, just generate an empty ChangeLog.
+test -d .git || {
+  >"$output"
+  exit
+}
+
+# Use Gnulib's packaged ChangeLog generator.
+# Maybe we should skip all "Merge branch 'master'" messages.
+# NOTE: in AUCTeX the ChangeLog is encoded with ISO-8859-1, use iconv
+# to enforce this encoding in the output file.
+./build-aux/gitlog-to-changelog \
+    --ignore-matching="^; |^Merge branch .*$|^Merge from master\.$|^Merge 
master branch\.$" \
+  --ignore-line='^; ' --format='%B' \
+  "$gen_origin..$new_origin" | iconv -f UTF-8 -t ISO-8859-1 - >"ChangeLog.tmp" 
|| exit
+
+if test -s "ChangeLog.tmp"; then
+
+  # Fix up bug references.
+  # This would be better as eg a --transform option to gitlog-to-changelog,
+  # but... effort.  FIXME does not handle rare cases like:
+  # Fixes: debbugs:19434 debbugs:19519
+  sed 's/      Fixes: \(debbugs:\|bug#\)\([0-9][0-9]*\)/       (Bug#\2)/' \
+      "ChangeLog.tmp" > "ChangeLog.tmp2"
+  mv "ChangeLog.tmp2" "ChangeLog.tmp"
+
+  # Find the years covered by the generated ChangeLog, so that
+  # a proper copyright notice can be output.
+  years=`
+    sed -n 's/^\([0-9][0-9]*\).*/\1/p' "ChangeLog.tmp" |
+    sort -nu
+  `
+  start_year=
+  end_year=
+  for year in $years; do
+    : ${start_year:=$year}
+    end_year=$year
+  done
+
+  if test "$start_year" = "$end_year"; then
+    year_range=$start_year
+  else
+    year_range=$start_year-$end_year
+  fi
+
+  # Update gen_origin and append a proper copyright notice.
+  sed -n '
+    1i\
+
+    /^This file records repository revisions/p
+    s/^commit [0-9a-f]* (exclusive)/commit '"$gen_origin"' (exclusive)/p
+    s/^commit [0-9a-f]* (inclusive)/commit '"$new_origin"' (inclusive)/p
+    /^See ChangeLog.[0-9]* for earlier/,${
+       s/ChangeLog\.[0-9]*/ChangeLog.'$nmax'/
+       s/\(Copyright[ (C)]*\)[0-9]*-[0-9]*/\1'"$year_range"'/
+       p
+    }
+  ' <ChangeLog.$nmax >>"ChangeLog.tmp" || exit
+fi
+
+# Install the generated ChangeLog.
+test "$output" = "ChangeLog.tmp" || mv "ChangeLog.tmp" "$output"
diff --git a/doc/auctex.texi b/doc/auctex.texi
index 39125c9..8c5218a 100644
--- a/doc/auctex.texi
+++ b/doc/auctex.texi
@@ -12,7 +12,7 @@ This manual is for @AUCTeX{}
 (version @value{VERSION} from @value{UPDATED}),
 a sophisticated TeX environment for Emacs.
 
-Copyright @copyright{} 1992-1995, 2001, 2002, 2004-2015
+Copyright @copyright{} 1992-1995, 2001, 2002, 2004-2016
 Free Software Foundation, Inc.
 
 @quotation
@@ -190,6 +190,7 @@ Viewing the Formatted Output
 
 Catching the errors
 
+* Ignoring warnings::           Controlling warnings to be reported
 * Error overview::              List of all errors and warnings
 
 Customization and Extension
@@ -1004,6 +1005,14 @@ at the bottom of the float.  You can specify floats 
where the caption
 should be placed at the top with @code{LaTeX-top-caption-list}.
 @vindex LaTeX-top-caption-list
 
address@hidden short caption
+If the specified caption is greater than a specific length, then a short
+caption is prompted for and it is inserted as an optional argument to
+the @samp{\caption} macro.  The length that a caption needs to be before
+prompting for a short version is controlled by
address@hidden
address@hidden LaTeX-short-caption-prompt-length
+
 @item label
 The label of this float.  The label will have a default prefix, which is
 controlled by the variables @code{LaTeX-figure-label} and
@@ -1036,6 +1045,11 @@ Prefix to use for table labels.
 List of float environments with top caption.
 @end defopt
 
address@hidden LaTeX-short-caption-prompt-length
+Number of chars a caption should be before prompting for a short
+caption.
address@hidden defopt
+
 @node Itemize-like
 @subsection Itemize-like Environments
 @cindex Itemize
@@ -3337,36 +3351,76 @@ not parse the whole output log buffer and 
@code{TeX-previous-error}
 cannot be used.
 @end defopt
 
+As default, @AUCTeX{} will display a special help buffer containing the
+error reported by @TeX{} along with the documentation.  There is however
+an `expert' option, which allows you to display the real @TeX{} output.
+
address@hidden TeX-display-help
+If t @AUCTeX{} will automatically display a help text whenever an error
+is encountered using @code{TeX-next-error} (@kbd{C-c `}).  If nil a
+terse information about the error is displayed in the echo area.  If
address@hidden @AUCTeX{} will display the output buffer with the raw
address@hidden output.
address@hidden defopt
+
address@hidden
+* Ignoring warnings::         Controlling warnings to be reported
+* Error overview::            List of all errors and warnings
address@hidden menu
+
address@hidden Ignoring warnings
address@hidden Controlling warnings to be reported
+
 Normally @AUCTeX{} will only report real errors, but you may as well
 ask it to report `bad boxes' and warnings as well.
 
 @deffn Command TeX-toggle-debug-bad-boxes
 @kindex C-c C-t C-b
address@hidden TeX-debug-bad-boxes
 (@kbd{C-c C-t C-b}) Toggle whether @AUCTeX{} should stop at bad boxes
-(i.e. overfull and underfull boxes) as well as normal errors.
+(i.e. overfull and underfull boxes) as well as normal errors.  The
+boolean option @code{TeX-debug-bad-boxes} is set accordingly.
 @end deffn
 
 @deffn Command TeX-toggle-debug-warnings
 @kindex C-c C-t C-w
address@hidden TeX-debug-warnings
 (@kbd{C-c C-t C-w}) Toggle whether @AUCTeX{} should stop at warnings as
-well as normal errors.
+well as normal errors.  The boolean option @code{TeX-debug-warnings} is
+set accordingly.
 @end deffn
 
-As default, @AUCTeX{} will display a special help buffer containing the
-error reported by @TeX{} along with the documentation.  There is however
-an `expert' option, which allows you to display the real @TeX{} output.
+While many users desire to have warnings reported after compilation,
+there are certain warnings that are considered unimportant and users
+want to ignore them.  For a more fine-grained control of what kinds of
+warnings should be shown after compilation, @AUCTeX{} provides other
+options.
 
address@hidden TeX-display-help
-If t @AUCTeX{} will automatically display a help text whenever an error
-is encountered using @code{TeX-next-error} (@kbd{C-c `}).  If nil a
-terse information about the error is displayed in the echo area.  If
address@hidden @AUCTeX{} will display the output buffer with the raw
address@hidden output.
address@hidden TeX-ignore-warnings
+Controls which warnings are to be ignored.
+
+It can be a regexp matching the message of the warnings to be ignored.
+
+More advanced users can set also this option to a symbol with the name
+of a custom function taking as arguments all the information of the
+warning listed in @code{TeX-error-list} variable, except the last one
+about whether to ignore the warning.  See the code of @code{TeX-warning}
+function and the documentation of @code{TeX-error-list} for more
+details.
 @end defopt
 
address@hidden
-* Error overview::            List of all errors and warnings
address@hidden menu
address@hidden Command TeX-toggle-suppress-ignored-warnings
address@hidden C-c C-t C-x
address@hidden TeX-suppress-ignored-warnings
+(@kbd{C-c C-t C-x}) Toggle whether @AUCTeX{} should actually hide the
+ignored warnings specified with @code{TeX-ignore-warnings}.  The boolean
+option @code{TeX-suppress-ignored-warnings} is set accordingly.  If this
+is nil, all warnings are shown, even those matched by
address@hidden, otherwise these are hidden.
+
+Note that @code{TeX-debug-warnings} takes the precedence: if it is nil,
+all warnings are hidden in any case.
address@hidden deffn
 
 @node Error overview
 @subsection List of all errors and warnings
@@ -3385,8 +3439,11 @@ In this window you can visit the error on which point is 
on by pressing
 @key{p} respectively.  A prefix argument to these keys specifies how
 many errors to move forward or backward.  You can visit an error also by
 clicking on its message.  Jump to error point in the source code with
address@hidden, and use @key{l} see the error in the log buffer.  Press @key{q}
-to quit the overview.
address@hidden, and use @key{l} see the error in the log buffer.  In addition,
+you can toggle visibility of bad boxes, generic warnings, and ignored
+warnings with @key{b}, @key{w}, and @key{x}, respectively (see
address@hidden warnings} for details).  Press @key{q} to quit the
+overview.
 @end deffn
 
 @defopt TeX-error-overview-open-after-TeX-run
@@ -3523,16 +3580,15 @@ before it is actually done.  If non-nil, ask before 
deleting files.
 @section Documentation about macros and packages
 @cindex Documentation
 
address@hidden Command TeX-doc
address@hidden Command TeX-documentation-texdoc
 @kindex C-c ?
-(@kbd{C-c ?})  Get documentation about macros, packages or @TeX{} &
-Co. in general.  The function will prompt for the name of a command or
-manual, providing a list of available keywords for completion.  If point
-is on a command or word with available documentation, this will be
+(@kbd{C-c ?})  Get documentation about the packages installed on your
+system, using @samp{texdoc} to find the manuals.  The function will
+prompt for the name of packages.  If point is on a word, this will be
 suggested as default.
 
-In case no documentation could be found, a prompt for querying the
address@hidden program is shown, should the latter be available.
+If the command is called with a prefix argument, you will be shown a
+list of manuals of the given package among to choose.
 
 The command can be invoked by the key binding mentioned above as well as
 the @samp{Find Documentation...} entry in the mode menu.
diff --git a/doc/changes.texi b/doc/changes.texi
index a48e7ab..9d39db2 100644
--- a/doc/changes.texi
+++ b/doc/changes.texi
@@ -1,5 +1,5 @@
 @c This is part of the AUCTeX manual.
address@hidden Copyright (C) 1994-2002, 2004-2010, 2012-2015 Free Software
address@hidden Copyright (C) 1994-2002, 2004-2010, 2012-2016 Free Software
 @c Foundation, Inc.
 @c See file auctex.texi for copying conditions.
 @include macros.texi
@@ -8,6 +8,56 @@
 
 @end ifset
 
address@hidden News since 11.89
+
address@hidden @bullet
address@hidden
+When inserting a new float, @AUCTeX{} will now prompt for a
+short-caption if the length of the caption provided is greater than a
+certain size.  This size is controlled via a new user option
address@hidden
+
address@hidden
+Parsing of the compilation log has been reworked.  You should encounter
+fewer mistaken files while navigating through errors and warnings.
+
address@hidden
+Two new user options, @code{TeX-ignore-warnings} and
address@hidden, allow ignoring certain warnings
+after compilation of the document.
address@hidden rawfile
address@hidden warnings}, for details.
address@hidden ifclear
+
address@hidden
+Added support for Atril viewer.  Forward and inverse search requires
+version 1.9.1 or later to work.
+
address@hidden
+Added support for dviout viewer on Windows.  Note that this setup works
+when @code{TeX-source-correlate-method} is set to use
address@hidden for @acronym{DVI}, e.g.:
address@hidden
+(setq TeX-source-correlate-method
+      '((dvi . source-specials)
+        (pdf . synctex)))
address@hidden lisp
+which is the default.
+
address@hidden
+Added support for SumatraPDF viewer on Windows.
+
address@hidden
+Added support for Zathura viewer.  Forward and inverse search requires a
+recent version of the program to work (3.4 or later).
+
address@hidden
+A new function, @code{TeX-documentation-texdoc}, for reading
+documentation with @samp{texdoc} has been added.  @code{TeX-doc} is
+still available but now @kbd{C-c ?} runs
address@hidden
address@hidden itemize
+
 @heading News in 11.89
 
 @itemize @bullet
@@ -76,10 +126,10 @@ select the Mark version to be used with new option
 messages in the output log of a Mark IV document.
 
 @item
-Support for tons of @LaTeX{} packages has been addedd.
+Support for tons of @LaTeX{} packages has been added.
 
 @item
-Numbers of bugs have been fixed, many minor features have been addedd.
+Numbers of bugs have been fixed, many minor features have been added.
 @end itemize
 
 @heading News in 11.88
diff --git a/latex.el b/latex.el
index d684120..c0b0baf 100644
--- a/latex.el
+++ b/latex.el
@@ -1032,16 +1032,35 @@ The inserted label is returned, nil if it is empty."
              label)
          nil)))))
 
+(defcustom LaTeX-short-caption-prompt-length 40
+  "The length that the caption of a figure should be before
+  propting for \\caption's optional short-version."
+  :group 'LaTeX-environment
+  :type 'integer)
+
+(defun LaTeX-compose-caption-macro (caption &optional short-caption)
+  "Return a \\caption macro for a given CAPTION as a string.
+If SHORT-CAPTION is non-nil pass it as an optional argument to
+\\caption."
+  (let ((short-caption-string
+         (if (and short-caption
+                  (not (string= short-caption "")))
+             (concat LaTeX-optop short-caption LaTeX-optcl))))
+    (concat TeX-esc "caption" short-caption-string
+            TeX-grop caption TeX-grcl)))
+
 (defun LaTeX-env-figure (environment)
   "Create ENVIRONMENT with \\caption and \\label commands."
-  (let ((float (and LaTeX-float                ; LaTeX-float can be nil, i.e.
+  (let* ((float (and LaTeX-float               ; LaTeX-float can be nil, i.e.
                                        ; do not prompt
-                   (TeX-read-string "(Optional) Float position: " 
LaTeX-float)))
-       (caption (TeX-read-string "Caption: "))
-       (center (y-or-n-p "Center? "))
-       (active-mark (and (TeX-active-mark)
-                         (not (eq (mark) (point)))))
-       start-marker end-marker)
+                     (TeX-read-string "(Optional) Float position: " 
LaTeX-float)))
+         (caption (TeX-read-string "Caption: "))
+         (short-caption (when (>= (length caption) 
LaTeX-short-caption-prompt-length)
+                          (TeX-read-string "(Optional) Short caption: ")))
+         (center (y-or-n-p "Center? "))
+         (active-mark (and (TeX-active-mark)
+                           (not (eq (mark) (point)))))
+         start-marker end-marker)
     (when active-mark
       (if (< (mark) (point))
          (exchange-point-and-mark))
@@ -1064,7 +1083,7 @@ The inserted label is returned, nil if it is empty."
       (if (member environment LaTeX-top-caption-list)
          ;; top caption
          (progn
-           (insert TeX-esc "caption" TeX-grop caption TeX-grcl)
+           (insert (LaTeX-compose-caption-macro caption short-caption))
            ;; If `auto-fill-mode' is active, fill the caption.
            (if auto-fill-function (LaTeX-fill-paragraph))
            (LaTeX-newline)
@@ -1082,7 +1101,7 @@ The inserted label is returned, nil if it is empty."
          ;; If there is an active region point is before the backslash of
          ;; "\end" macro, go one line upwards.
          (when active-mark (forward-line -1) (indent-according-to-mode))
-         (insert TeX-esc "caption" TeX-grop caption TeX-grcl)
+         (insert (LaTeX-compose-caption-macro caption short-caption))
          ;; If `auto-fill-mode' is active, fill the caption.
          (if auto-fill-function (LaTeX-fill-paragraph))
          ;; ask for a label and if necessary insert a new line between caption
@@ -1969,6 +1988,35 @@ string.  `TeX-read-label-prefix' is used as initial 
input for the
 label."
   (TeX-arg-label optional prompt t))
 
+(defun TeX-arg-default-argument-value (optional &optional prompt)
+  "Prompt for the default value for the first argument of a LaTeX macro.
+
+If OPTIONAL is non-nil, insert the resulting value as an optional
+argument, otherwise as a mandatory one.  Use PROMPT as the prompt
+string."
+  (TeX-argument-insert
+   (TeX-read-string
+    (TeX-argument-prompt optional prompt "Default value for first argument"))
+   optional))
+
+(defun TeX-arg-define-macro-arguments (optional &optional prompt)
+  "Prompt for the number of arguments for a LaTeX macro.  If this
+is non-zero, also prompt for the default value for the first
+argument.
+
+If OPTIONAL is non-nil, insert the resulting value as an optional
+argument, otherwise as a mandatory one.  Use PROMPT as the prompt
+string."
+  (let ((arg-count (TeX-read-string
+                    (TeX-argument-prompt optional prompt
+                                         "Number of arguments"
+                                         nil))))
+    (unless (or (string= arg-count "0")
+                (string= arg-count ""))
+      (TeX-argument-insert arg-count optional)
+      (unless (string-equal LaTeX-version "2")
+        (TeX-arg-default-argument-value optional)))))
+
 (defun TeX-arg-define-macro (optional &optional prompt)
   "Prompt for a TeX macro with completion.
 If OPTIONAL is non-nil, insert the resulting value as an optional
@@ -2941,9 +2989,7 @@ consideration just as is in the non-commented source 
code."
     ("equation")
     ("equation*")
     ("picture")
-    ("tabbing")
-    ("table")
-    ("table*"))
+    ("tabbing"))
     "Alist of environments with special indentation.
 The second element in each entry is the function to calculate the
 indentation level in columns."
@@ -6024,16 +6070,16 @@ i.e. you do _not_ have to cater for this yourself by 
adding \\\\' or $."
    '("label" TeX-arg-define-label)
    '("pageref" TeX-arg-ref)
    '("ref" TeX-arg-ref)
-   '("newcommand" TeX-arg-define-macro [ "Number of arguments" ] t)
-   '("renewcommand" TeX-arg-macro [ "Number of arguments" ] t)
+   '("newcommand" TeX-arg-define-macro [ TeX-arg-define-macro-arguments ] t)
+   '("renewcommand" TeX-arg-macro [ TeX-arg-define-macro-arguments ] t)
    '("newenvironment" TeX-arg-define-environment
      [ "Number of arguments"] t t)
    '("renewenvironment" TeX-arg-environment
      [ "Number of arguments"] t t)
-   '("providecommand" TeX-arg-define-macro [ "Number of arguments" ] t)
-   '("providecommand*" TeX-arg-define-macro [ "Number of arguments" ] t)
-   '("newcommand*" TeX-arg-define-macro [ "Number of arguments" ] t)
-   '("renewcommand*" TeX-arg-macro [ "Number of arguments" ] t)
+   '("providecommand" TeX-arg-define-macro [ TeX-arg-define-macro-arguments ] 
t)
+   '("providecommand*" TeX-arg-define-macro [ TeX-arg-define-macro-arguments ] 
t)
+   '("newcommand*" TeX-arg-define-macro [ TeX-arg-define-macro-arguments ] t)
+   '("renewcommand*" TeX-arg-macro [ TeX-arg-define-macro-arguments ] t)
    '("newenvironment*" TeX-arg-define-environment
      [ "Number of arguments"] t t)
    '("renewenvironment*" TeX-arg-environment
@@ -6245,21 +6291,21 @@ i.e. you do _not_ have to cater for this yourself by 
adding \\\\' or $."
     (setq TeX-font-replace-function 'TeX-font-replace-macro)
     (TeX-add-symbols
      '("newcommand" TeX-arg-define-macro
-       [ "Number of arguments" ] [ "Default value for first argument" ] t)
+       [ TeX-arg-define-macro-arguments ] t)
      '("renewcommand" TeX-arg-macro
-       [ "Number of arguments" ] [ "Default value for first argument" ] t)
+       [ TeX-arg-define-macro-arguments ] t)
      '("providecommand" TeX-arg-define-macro
-       [ "Number of arguments" ] [ "Default value for first argument" ] t)
+       [ TeX-arg-define-macro-arguments ] t)
      '("providecommand*" TeX-arg-define-macro
-       [ "Number of arguments" ] [ "Default value for first argument" ] t)
+       [ TeX-arg-define-macro-arguments ] t)
      '("newcommand*" TeX-arg-define-macro
-       [ "Number of arguments" ] [ "Default value for first argument" ] t)
+       [ TeX-arg-define-macro-arguments ] t)
      '("renewcommand*" TeX-arg-macro
-       [ "Number of arguments" ] [ "Default value for first argument" ] t)
+       [ TeX-arg-define-macro-arguments ] t)
      '("newenvironment" TeX-arg-define-environment
-       [ "Number of arguments" ] [ "Default value for first argument" ] t t)
+       [ TeX-arg-define-macro-arguments ]  t t)
      '("renewenvironment" TeX-arg-environment
-       [ "Number of arguments" ] [ "Default value for first argument" ] t t)
+       [ TeX-arg-define-macro-arguments ] t t)
      '("usepackage" LaTeX-arg-usepackage)
      '("RequirePackage" LaTeX-arg-usepackage)
      '("ProvidesPackage" (TeX-arg-file-name-sans-extension "Package name")
diff --git a/style/amsthm.el b/style/amsthm.el
index 5c83724..5deb9e3 100644
--- a/style/amsthm.el
+++ b/style/amsthm.el
@@ -119,7 +119,7 @@ make them available as new environments.  Update
                 newthmstyle)))
 
 (add-hook 'TeX-auto-prepare-hook #'LaTeX-amsthm-auto-prepare t)
-(add-hook 'TeX-auto-prepare-hook #'LaTeX-amsthm-auto-cleanup t)
+(add-hook 'TeX-auto-cleanup-hook #'LaTeX-amsthm-auto-cleanup t)
 (add-hook 'TeX-update-style-hook #'TeX-auto-parse t)
 
 (TeX-add-style-hook
diff --git a/style/enumitem.el b/style/enumitem.el
index bbbfe79..87249bc 100644
--- a/style/enumitem.el
+++ b/style/enumitem.el
@@ -1,6 +1,6 @@
 ;;; enumitem.el --- AUCTeX style for `enumitem.sty' (v3.5.2)
 
-;; Copyright (C) 2015 Free Software Foundation, Inc.
+;; Copyright (C) 2015, 2016 Free Software Foundation, Inc.
 
 ;; Author: Arash Esbati <esbati'at'gmx.de>
 ;; Maintainer: address@hidden
@@ -115,6 +115,16 @@ the ones initially available through `enumitem' package.")
   "Matches the arguments of `\\newlist' from `enumitem'
 package.")
 
+;; Setup for \SetLabelAlign:
+
+(TeX-auto-add-type "enumitem-SetLabelAlign" "LaTeX")
+
+(defvar LaTeX-enumitem-SetLabelAlign-regexp
+  '("\\\\SetLabelAlign{\\([^}]+\\)}"
+    1 LaTeX-auto-enumitem-SetLabelAlign)
+  "Matches the argument of `\\SetLabelAlign' from `enumitem'
+package.")
+
 ;; Setup for \SetEnumitemKey:
 
 (TeX-auto-add-type "enumitem-SetEnumitemKey" "LaTeX")
@@ -146,6 +156,7 @@ package.")
 (defun LaTeX-enumitem-auto-prepare ()
   "Clear various `LaTeX-enumitem-*' before parsing."
   (setq LaTeX-auto-enumitem-newlist          nil
+       LaTeX-auto-enumitem-SetLabelAlign    nil
        LaTeX-auto-enumitem-SetEnumitemKey   nil
        LaTeX-auto-enumitem-SetEnumitemValue nil))
 
@@ -203,6 +214,20 @@ key-val and the first item."
                (current-fill-column)))
     (LaTeX-fill-paragraph nil)))
 
+(defun LaTeX-arg-SetLabelAlign (optional)
+  "Ask for new type (value) for the \"align\" key and add it to
+`LaTeX-enumitem-key-val-options-local'."
+  (LaTeX-enumitem-update-key-val-options)
+  (let* ((key "align")
+        (val (TeX-read-string "Alignment: "))
+        (val-match (cdr (assoc key LaTeX-enumitem-key-val-options-local)))
+        (temp (copy-alist LaTeX-enumitem-key-val-options-local))
+        (opts (assq-delete-all (car (assoc key temp)) temp)))
+    (pushnew (list key (delete-dups (apply 'append (list val) val-match)))
+            opts :test #'equal)
+    (TeX-argument-insert val optional)
+    (LaTeX-add-enumitem-SetLabelAligns val)))
+
 (defun LaTeX-arg-SetEnumitemKey (optional)
   "Ask for a new key to be defined and add it to
 `LaTeX-enumitem-key-val-options-local'."
@@ -225,7 +250,7 @@ key-val and the first item."
   "Ask for a new value added to an existing key incl. the final
 replacement of the value."
   (LaTeX-enumitem-update-key-val-options)
-  (let* ((key (TeX-read-key-val optional LaTeX-enumitem-key-val-options-local 
"Key"))
+  (let* ((key (completing-read  "Key: " LaTeX-enumitem-key-val-options-local))
         (val (TeX-read-string "String value: "))
         ;; (key-match (car (assoc key LaTeX-enumitem-key-val-options-local)))
         (val-match (cdr (assoc key LaTeX-enumitem-key-val-options-local)))
@@ -258,6 +283,15 @@ in `enumitem'-completions."
          (pushnew (list key (delete-dups (apply 'append (list val) val-match)))
                   opts :test #'equal)
        (pushnew (list key (list val)) opts :test #'equal))
+      (setq LaTeX-enumitem-key-val-options-local (copy-alist opts))))
+  (dolist (newalign (LaTeX-enumitem-SetLabelAlign-list))
+    (let* ((key "align")
+          (val (car newalign))
+          (val-match (cdr (assoc key LaTeX-enumitem-key-val-options-local)))
+          (temp (copy-alist LaTeX-enumitem-key-val-options-local))
+          (opts (assq-delete-all (car (assoc key temp)) temp)))
+      (pushnew (list key (delete-dups (apply 'append (list val) val-match)))
+              opts :test #'equal)
       (setq LaTeX-enumitem-key-val-options-local (copy-alist opts)))))
 
 (TeX-add-style-hook
@@ -268,6 +302,7 @@ in `enumitem'-completions."
    (TeX-auto-add-regexp LaTeX-enumitem-newlist-regexp)
    (TeX-auto-add-regexp LaTeX-enumitem-SetEnumitemKey-regexp)
    (TeX-auto-add-regexp LaTeX-enumitem-SetEnumitemValue-regexp)
+   (TeX-auto-add-regexp LaTeX-enumitem-SetLabelAlign-regexp)
 
    ;; Activate the buffer-local version of key-vals.
    (setq LaTeX-enumitem-key-val-options-local
@@ -392,6 +427,9 @@ in `enumitem'-completions."
                 (pushnew env enums :test #'equal))))
           (completing-read "List name: " enums)))))
 
+    ;; "Align" is added as new value to "align" key in key-val list.
+    '("SetLabelAlign" LaTeX-arg-SetLabelAlign t)
+
     ;; "Key" will be parsed and added to key-val list.
     '("SetEnumitemKey" LaTeX-arg-SetEnumitemKey)
 
@@ -413,6 +451,7 @@ in `enumitem'-completions."
                                ("renewlist"           "{{{")
                                ("setlist"             "*[{")
                                ("AddEnumerateCounter" "*{{{")
+                               ("SetLabelAlign"       "{{")
                                ("SetEnumitemKey"      "{{" )
                                ("SetEnumitemValue"    "{{{"))
                              'function)
diff --git a/style/icelandic.el b/style/icelandic.el
index 427a88d..64507e1 100644
--- a/style/icelandic.el
+++ b/style/icelandic.el
@@ -42,7 +42,7 @@
  (lambda ()
    (set-syntax-table LaTeX-icelandic-mode-syntax-table)
    (unless (eq (car TeX-quote-language) 'override)
-     (setq TeX-quote-language '("icelandic" "\"`" "\"'" t)))
+     (setq TeX-quote-language `("icelandic" "\"`" "\"'" 
,TeX-quote-after-quote)))
    (setq LaTeX-babel-hyphen-language "icelandic")
    ;; Fontification of quotation marks.
    (when (fboundp 'font-latex-add-quotes)
diff --git a/style/longtable.el b/style/longtable.el
index 6c9aeaf..7401c8d 100644
--- a/style/longtable.el
+++ b/style/longtable.el
@@ -34,10 +34,12 @@
  (lambda ()
    (LaTeX-add-environments
     '("longtable" (lambda (environment)
-                   (let ((pos (completing-read (TeX-argument-prompt t nil 
"Position")
-                                               '(("l") ("r") ("c"))))
-                         (fmt (TeX-read-string "Format: " 
LaTeX-default-format))
-                         (caption (TeX-read-string "Caption: ")))
+                   (let* ((pos (completing-read (TeX-argument-prompt t nil 
"Position")
+                                                 '(("l") ("r") ("c"))))
+                           (fmt (TeX-read-string "Format: " 
LaTeX-default-format))
+                           (caption (TeX-read-string "Caption: "))
+                           (short-caption (when (>= (length caption) 
LaTeX-short-caption-prompt-length)
+                                            (TeX-read-string "(Optional) Short 
caption: "))))
                      (setq LaTeX-default-format fmt)
                      (LaTeX-insert-environment environment
                                                (concat
@@ -49,7 +51,7 @@
                        ;; the longtable `\caption' is equivalent to a
                        ;; `\multicolumn', so it needs a `\\' at the
                        ;; end of the line
-                       (insert TeX-esc "caption" TeX-grop caption TeX-grcl " 
\\\\")
+                       (insert (LaTeX-compose-caption-macro caption 
short-caption) "\\\\")
                        (LaTeX-newline)
                        (indent-according-to-mode)
                        ;; ask for a label and insert a new line only
diff --git a/style/newfloat.el b/style/newfloat.el
index 4cde32e..e84fad7 100644
--- a/style/newfloat.el
+++ b/style/newfloat.el
@@ -134,7 +134,7 @@ If `caption.el' is loaded, add the new floating environment 
to
         (concat "listof" flt "es"))))))
 
 (add-hook 'TeX-auto-prepare-hook #'LaTeX-newfloat-auto-prepare t)
-(add-hook 'TeX-auto-prepare-hook #'LaTeX-newfloat-auto-cleanup t)
+(add-hook 'TeX-auto-cleanup-hook #'LaTeX-newfloat-auto-cleanup t)
 (add-hook 'TeX-update-style-hook #'TeX-auto-parse t)
 
 (TeX-add-style-hook
diff --git a/style/ntheorem.el b/style/ntheorem.el
index 630c09b..068f40d 100644
--- a/style/ntheorem.el
+++ b/style/ntheorem.el
@@ -142,7 +142,7 @@ make them available as new environments.  Update
     (TeX-add-symbols (concat nthm "name"))))
 
 (add-hook 'TeX-auto-prepare-hook #'LaTeX-ntheorem-auto-prepare t)
-(add-hook 'TeX-auto-prepare-hook #'LaTeX-ntheorem-auto-cleanup t)
+(add-hook 'TeX-auto-cleanup-hook #'LaTeX-ntheorem-auto-cleanup t)
 (add-hook 'TeX-update-style-hook #'TeX-auto-parse t)
 
 (TeX-add-style-hook
diff --git a/style/polish.el b/style/polish.el
index dac3451..31397f0 100644
--- a/style/polish.el
+++ b/style/polish.el
@@ -42,7 +42,7 @@
  (lambda ()
    (set-syntax-table LaTeX-polish-mode-syntax-table)
    (unless (eq (car TeX-quote-language) 'override)
-     (setq TeX-quote-language '("polish" "\"`" "\"'" t)))
+     (setq TeX-quote-language `("polish" "\"`" "\"'" ,TeX-quote-after-quote)))
    ;; 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 ef1985b..5e51082 100644
--- a/style/polski.el
+++ b/style/polski.el
@@ -46,7 +46,7 @@
     "ppauza")
    ;; Quotation marks
    (unless (eq (car TeX-quote-language) 'override)
-     (setq TeX-quote-language '("polski" ",," "''" t)))
+     (setq TeX-quote-language `("polski" ",," "''" ,TeX-quote-after-quote)))
    ;; Fontification of quotation marks.
    (when (fboundp 'font-latex-add-quotes)
      (font-latex-add-quotes '(",," "''")))
diff --git a/style/psfig.el b/style/psfig.el
index 3d44a65..b0b6b94 100644
--- a/style/psfig.el
+++ b/style/psfig.el
@@ -44,14 +44,16 @@
 
 (defun LaTeX-env-psfigure (_environment)
   "Create  with \\label and \\caption and \\psfig commands."
-  (let ((float (TeX-read-string "Float to: " LaTeX-float))
-       (caption (TeX-read-string "Caption: "))
-       (label (TeX-read-string "Label: " LaTeX-figure-label))
-        ; gf: ask if this should be centered
-       (psfile (read-file-name "PS-file: " "" "" nil))
-       (figwidth (TeX-read-string "Figure width: "))
-       (figheight (TeX-read-string "Figure height: "))
-       )
+  (let* ((float (TeX-read-string "Float to: " LaTeX-float))
+         (caption (TeX-read-string "Caption: "))
+         (short-caption (when (>= (length caption) 
LaTeX-short-caption-prompt-length)
+                          (TeX-read-string "(Optional) Short caption: ")))
+         (label (TeX-read-string "Label: " LaTeX-figure-label))
+         ; gf: ask if this should be centered
+         (psfile (read-file-name "PS-file: " "" "" nil))
+         (figwidth (TeX-read-string "Figure width: "))
+         (figheight (TeX-read-string "Figure height: "))
+         )
 
     (setq LaTeX-float (if (zerop (length float))
                          LaTeX-float
@@ -70,7 +72,7 @@
     (if (zerop (length caption))
        ()
       (newline-and-indent)
-      (insert TeX-esc "caption" TeX-grop caption TeX-grcl))
+      (insert (LaTeX-compose-caption-macro caption short-caption)))
     (if (or (zerop (length label))
            (equal LaTeX-figure-label label))
        ()
diff --git a/style/splitidx.el b/style/splitidx.el
new file mode 100644
index 0000000..e299b5a
--- /dev/null
+++ b/style/splitidx.el
@@ -0,0 +1,309 @@
+;;; splitidx.el --- AUCTeX style for `splitidx.sty' (v1.2a)
+
+;; Copyright (C) 2016 Free Software Foundation, Inc.
+
+;; Author: Arash Esbati <esbati'at'gmx.de>
+;; Maintainer: address@hidden
+;; Created: 2015-09-19
+;; Keywords: tex
+
+;; This file is part of AUCTeX.
+
+;; AUCTeX is free software; you can redistribute it and/or modify it
+;; under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 3, or (at your option)
+;; any later version.
+
+;; AUCTeX is distributed in the hope that it will be useful, but
+;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+;; General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with AUCTeX; see the file COPYING.  If not, write to the Free
+;; Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+;; 02110-1301, USA.
+
+;;; Commentary:
+
+;; This file adds support for `splitidx.sty' (v1.2a) from 2013/04/09.
+;; `splitidx.sty' is part of TeXLive.
+
+;; The main index macro provided by `splitidx.sty' is
+;;
+;;     \sindex[<shortcut>]{<index-entry>}
+;;
+;; where <shortcut> identifies the target where <index-entry> is going
+;; into.  This style checks if RefTeX is loaded and adds "\sindex" to
+;; index macros known by RefTeX; this is described in RefTeX manual
+;; section 5.5 Defining Index Macros:
+;;
+;;     (setq reftex-index-macros '(("\\sindex[]{*}" 1 ?s "" nil t)))
+;;
+;; To make things more user friendly, this style does not hard-code
+;; the key `?s' and offers a customizable variable called
+;; `LaTeX-splitidx-sindex-reftex-quick-id-key'.  Customize this
+;; variable to another unique key if you have other preference.  Also
+;; note the integer 1 after "\\sindex[]{*}".  This tells RefTeX to
+;; look in first optional argument to find out which index the entry
+;; belongs to.  If omitted, RefTeX puts the index entry into "idx".
+
+;; `splitidx.sty' provides also the option `idxcommands' where a
+;; command with the name of the <shortcut> is defined for each
+;; declared index.  An example from splitidx.pdf:
+;;
+;;     \documentclass{article}
+;;     \usepackage[idxcommands]{splitidx}
+;;
+;;     \newindex[General Index]{idx}       % Name and shortcut of the 1st index
+;;     \newindex[Index of Animals]{ani}    % ... 2nd index
+;;     \newindex[Index of Fruits]{fru}     % ... 3rd index
+;;     \newindex[Index of Vegetables]{veg} % ... 4th index
+;;     ...
+;;
+;; Now four index commands \idx, \ani, \fru and \veg are available.
+;; This style adds these commands to AUCTeX and RefTeX (check function
+;; `LaTeX-splitidx-auto-cleanup').  The only thing missing is adding
+;; these commands to `reftex-index-macros' since the unique keys must
+;; be set by user.  To get full advantage from RefTeX, remember that
+;; ?i, ?I, and ?g are reserved and set something like this in your
+;; init-file:
+;;
+;;     (add-to-list 'reftex-index-macros '("\\idx" "idx" ?x "" nil t))
+;;     (add-to-list 'reftex-index-macros '("\\ani" "ani" ?a "" nil t))
+;;     (add-to-list 'reftex-index-macros '("\\fru" "fru" ?f "" nil t))
+;;     (add-to-list 'reftex-index-macros '("\\veg" "veg" ?v "" nil t))
+;;
+;; Or you can do this in your tex file:
+;;
+;;     %%% Local Variables:
+;;     %%% mode: latex
+;;     %%% TeX-master: t
+;;     %%% eval: (add-to-list 'reftex-index-macros '("\\idx" "idx" ?x "" nil 
t))
+;;     %%% eval: (add-to-list 'reftex-index-macros '("\\ani" "ani" ?a "" nil 
t))
+;;     %%% eval: (add-to-list 'reftex-index-macros '("\\fru" "fru" ?f "" nil 
t))
+;;     %%% eval: (add-to-list 'reftex-index-macros '("\\veg" "veg" ?v "" nil 
t))
+;;     %%% End:
+;;
+
+;;; Code:
+
+;; Needed for auto-parsing.
+(require 'tex)
+
+;; Setup parsing for \newindex:
+(TeX-auto-add-type "splitidx-newindex" "LaTeX" "splitidx-newindices")
+
+(defvar LaTeX-splitidx-newindex-regex
+  `(,(concat "\\\\new\\(?:protected\\)?index"
+            "\\(?:\\[[^}]*\\]\\)?"
+            "{\\([^}]+\\)}")
+    1 LaTeX-auto-splitidx-newindex)
+  "Matches the argument of `\\newindex' from `splitidx.sty'.")
+
+(defun LaTeX-splitidx-auto-prepare ()
+  "Clear `LaTeX-auto-splitidx-newindex' before parsing."
+  (setq LaTeX-auto-splitidx-newindex nil))
+
+(defun LaTeX-splitidx-auto-cleanup ()
+  "Process parsed results for \"splitidx.sty\"."
+  (when (LaTeX-provided-package-options-member "splitidx" "idxcommands")
+    (dolist (elt (mapcar 'car (LaTeX-splitidx-newindex-list)))
+      ;; Make every element available as a command
+      (TeX-add-symbols `(,elt TeX-arg-index))
+      ;; font-locking
+      (when (and (featurep 'font-latex)
+                (eq TeX-install-font-lock 'font-latex-setup))
+       (font-latex-add-keywords `((,elt  "{"))
+                                'reference))
+      ;; Prepare for parsing
+      (add-to-list 'LaTeX-auto-regexp-list
+                  `(,(concat
+                      "\\\\"
+                      elt
+                      "{\\([^}{]*\\({[^}{]*\\({[^}{]*\\({[^}{]*}[^}{]*\\)*"
+                      "}[^}{]*\\)*}[^}{]*\\)*\\)}")
+                    1 LaTeX-auto-index-entry))
+      ;; Cater for completion
+      (add-to-list 'TeX-complete-list
+                  `(,(concat "\\\\" elt "{\\([^{}\n\r]*\\)"
+                    1 LaTeX-index-entry-list "}"))) )))
+
+(add-hook 'TeX-auto-prepare-hook #'LaTeX-splitidx-auto-prepare t)
+(add-hook 'TeX-auto-cleanup-hook #'LaTeX-splitidx-auto-cleanup t)
+(add-hook 'TeX-update-style-hook #'TeX-auto-parse t)
+
+(TeX-add-style-hook
+ "splitidx"
+ (lambda ()
+
+   (TeX-add-symbols
+
+    ;; 3.1 Setup
+    '("newindex"
+      [ "Index name" ]
+      (TeX-arg-eval
+       (lambda ()
+        (let ((shortcut (TeX-read-string
+                         (TeX-argument-prompt optional nil "Short cut"))))
+          (LaTeX-add-splitidx-newindices shortcut)
+          (format "%s" shortcut)))))
+
+    ;; 3.2 Marking up index entries
+    '("sindex"
+      ;; I don't use `[ TeX-arg-index-tag ]' here
+      [ TeX-arg-eval completing-read
+                    (TeX-argument-prompt optional nil "Short cut")
+                    (LaTeX-splitidx-newindex-list) ]
+      TeX-arg-index)
+
+    ;; 3.4 Customizing index entries
+    '("AtWriteToIndex"
+      (TeX-arg-eval completing-read
+                   (TeX-argument-prompt optional nil "Short cut")
+                   (LaTeX-splitidx-newindex-list))
+      t)
+
+    '("AtNextWriteToIndex"
+      (TeX-arg-eval completing-read
+                   (TeX-argument-prompt optional nil "Short cut")
+                   (LaTeX-splitidx-newindex-list))
+      t)
+
+    ;; 3.6 Preventing premature expansion of index entries
+    '("newprotectedindex"
+      [ "Index name" ]
+      (TeX-arg-eval
+       (lambda ()
+        (let ((shortcut (TeX-read-string
+                         (TeX-argument-prompt optional nil "Short cut"))))
+          (LaTeX-add-splitidx-newindices shortcut)
+          (format "%s" shortcut)))))
+
+    ;; 3.7 Including the generated indices in your document
+    '("printindex"
+      [ TeX-arg-eval completing-read
+                    (TeX-argument-prompt optional nil "Short cut")
+                    (LaTeX-splitidx-newindex-list) ]
+      [ "Index name" ])
+
+    '("printindex*" 0)
+
+    '("printsubindex"
+      [ TeX-arg-eval completing-read
+                    (TeX-argument-prompt optional nil "Short cut")
+                    (LaTeX-splitidx-newindex-list) ]
+      [ "Index name" ])
+
+    '("printsubindex*" 0)
+
+    '("setindexpreamble"
+      [ TeX-arg-eval completing-read
+                    (TeX-argument-prompt optional nil "Short cut")
+                    (LaTeX-splitidx-newindex-list) ]
+      t)
+
+    '("useindexpreamble" [ TeX-arg-macro ])
+
+    '("indexshortcut" 0)
+
+    '("extendtheindex" 4) )
+
+   ;; Add splitidx to the parser.
+   (TeX-auto-add-regexp LaTeX-splitidx-newindex-regex)
+
+   ;; Borrowed from index.el
+   (add-to-list 'LaTeX-auto-regexp-list
+               `(,(concat "\\\\sindex\\(?:\\[[^{}]*\\]\\)?"
+                          "{\\([^}{]*\\({[^}{]*\\({[^}{]*\\({[^}{]*}[^}{]*\\)*"
+                          "}[^}{]*\\)*}[^}{]*\\)*\\)}")
+                 1 LaTeX-auto-index-entry))
+
+   ;; Completion for \sindex entries
+   (add-to-list 'TeX-complete-list
+               '("\\\\sindex\\(\\[[^][{}]*\\]\\)?{\\([^{}\n\r]*\\)"
+                 2 LaTeX-index-entry-list "}"))
+
+   ;; Completion for the |see macro
+   (add-to-list 'TeX-complete-list
+               '("|see{\\([^{}\n\r]*\\)" 1 LaTeX-index-entry-list))
+
+   ;; Append our defintion to `reftex-index-macros' in order not to
+   ;; override any user customizations.
+   (when (boundp 'reftex-index-macros)
+     (add-to-list 'reftex-index-macros
+                 `("\\sindex[]{*}" 1
+                   ,LaTeX-splitidx-sindex-reftex-quick-id-key "" nil t)))
+
+   ;; 3.2 Marking up index entries
+   ;; \index should be an alias for \sindex
+   (when (LaTeX-provided-package-options-member "splitidx" "useindex")
+       (TeX-add-symbols
+       '("index"
+         [TeX-arg-eval completing-read
+                       (TeX-argument-prompt optional nil "Short cut")
+                       (LaTeX-splitidx-newindex-list) ]
+         (TeX-arg-index)))
+       ;; Tell RefTeX to look in the optional arg. for the index short cut
+       (when (boundp 'reftex-index-macros)
+        (add-to-list 'reftex-index-macros
+                     '("\\index[]{*}" 1 ?i "" nil t)
+                     t))
+       (add-to-list 'LaTeX-auto-regexp-list
+                   `(,(concat
+                       "\\\\index\\(?:\\[[^{}]*\\]\\)?"
+                       "{\\([^}{]*\\({[^}{]*\\({[^}{]*\\({[^}{]*}[^}{]*\\)*"
+                       "}[^}{]*\\)*}[^}{]*\\)*\\)}")
+                     1 LaTeX-auto-index-entry))
+       (when (and (featurep 'font-latex)
+                 (eq TeX-install-font-lock 'font-latex-setup))
+        (font-latex-add-keywords '(("index" "[{"))
+                                 'reference)))
+
+   ;; 3.5 Automatic custom index commands
+   ;; With package option `idxcommands', one can write \foo{<entry>}
+   ;; instead of \sindex[foo]{<entry>}
+   (when (and (LaTeX-provided-package-options-member "splitidx" "idxcommands")
+             (LaTeX-splitidx-newindex-list))
+     (dolist (elt (mapcar 'car (LaTeX-splitidx-newindex-list)))
+       ;; Make every `foo' available as a command
+       (TeX-add-symbols `(,elt TeX-arg-index))
+       ;; Cater for font-locking
+       (when (and (featurep 'font-latex)
+                 (eq TeX-install-font-lock 'font-latex-setup))
+        (font-latex-add-keywords `((,elt  "{"))
+                                 'reference))
+       ;; Add defined <entry> to `LaTeX-index-entry-list'
+       (add-to-list 'LaTeX-auto-regexp-list
+                   `(,(concat
+                       "\\\\"
+                       elt
+                       "{\\([^}{]*\\({[^}{]*\\({[^}{]*\\({[^}{]*}[^}{]*\\)*"
+                       "}[^}{]*\\)*}[^}{]*\\)*\\)}")
+                     1 LaTeX-auto-index-entry)) ))
+
+   ;; Fontification
+   (when (and (featurep 'font-latex)
+             (eq TeX-install-font-lock 'font-latex-setup))
+     (font-latex-add-keywords '(("newindex"           "[{")
+                               ("AtWriteToIndex"     "{{")
+                               ("AtNextWriteToIndex" "{{")
+                               ("newprotectedindex"  "[{")
+                               ("setindexpreamble"   "[{")
+                               ("useindexpreamble"   "[")
+                               ("extendtheindex"     "{{{{"))
+                             'function)
+     (font-latex-add-keywords '(("sindex"             "[{"))
+                             'reference)))
+ LaTeX-dialect)
+
+(defvar LaTeX-splitidx-package-options
+  '("makeindex"
+    "useindex"
+    "allintoone"
+    "split"
+    "protected"
+    "idxcommands")
+  "Prompt for package options for the splitidx package.")
+
+;;; splitidx.el ends here
diff --git a/style/theorem.el b/style/theorem.el
index d8466f1..8b4101e 100644
--- a/style/theorem.el
+++ b/style/theorem.el
@@ -111,7 +111,7 @@ make them available as new environments."
     (LaTeX-add-environments (list newthm 'LaTeX-theorem-env-label))))
 
 (add-hook 'TeX-auto-prepare-hook #'LaTeX-theorem-auto-prepare t)
-(add-hook 'TeX-auto-prepare-hook #'LaTeX-theorem-auto-cleanup t)
+(add-hook 'TeX-auto-cleanup-hook #'LaTeX-theorem-auto-cleanup t)
 (add-hook 'TeX-update-style-hook #'TeX-auto-parse t)
 
 (TeX-add-style-hook
diff --git a/tests/latex/latex-filling-in.tex b/tests/latex/latex-filling-in.tex
index 4cc184b..6e7294a 100644
--- a/tests/latex/latex-filling-in.tex
+++ b/tests/latex/latex-filling-in.tex
@@ -1 +1,5 @@
 Lorem ipsum dolor sit amet, consectetur adipisci elit, sed eiusmod \(0 = 1\) 
tempor incidunt ut $a^{2} + b^{2} = c^{2}$ labore et dolore magna aliqua.  Ut 
enim ad minim veniam, quis nostrum exercitationem ullam corporis suscipit 
laboriosam, nisi ut aliquid ex ea commodi consequatur.
+
+\begin{tabular}{| l | l | l | l |}
+  Lorem ipsum dolor sit amet, consectetur adipisci & Lorem ipsum dolor sit 
amet, consectetur adipisci & Lorem ipsum dolor sit amet, consectetur adipisci & 
Lorem ipsum dolor sit amet, consectetur adipisci
+\end{tabular}
diff --git a/tests/latex/latex-filling-out.tex 
b/tests/latex/latex-filling-out.tex
index cdb767a..b0596f3 100644
--- a/tests/latex/latex-filling-out.tex
+++ b/tests/latex/latex-filling-out.tex
@@ -3,3 +3,7 @@ Lorem ipsum dolor sit amet, consectetur adipisci elit, sed 
eiusmod
 magna aliqua.  Ut enim ad minim veniam, quis nostrum exercitationem
 ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi
 consequatur.
+
+\begin{tabular}{| l | l | l | l |}
+  Lorem ipsum dolor sit amet, consectetur adipisci & Lorem ipsum dolor sit 
amet, consectetur adipisci & Lorem ipsum dolor sit amet, consectetur adipisci & 
Lorem ipsum dolor sit amet, consectetur adipisci
+\end{tabular}
diff --git a/tests/tex/compilation-log.txt b/tests/tex/compilation-log.txt
new file mode 100644
index 0000000..85e56c0
--- /dev/null
+++ b/tests/tex/compilation-log.txt
@@ -0,0 +1,68 @@
+(./test.tex (./nice-class.cls
+Document Class: nice-class 1970/01/01 v42 A good class
+
+Package nice-class Warning: ******************************************
+(nice-class)                * THIS IS JUST A WARNING WITH A PESKY
+(nice-class)                * UNMATCHED CLOSED PARENTHESIS :-)
+(nice-class)                ****************************************** on 
input line 32.
+
+)
+
+(/opt/texlive/2015/texmf-dist/tex/context/base/supp-pdf.mkii
+[Loading MPS to PDF converter (version 2006.09.02).]
+)
+
+./test.tex:2: Class nice-class Error: ***********************************
+(nice-class)              * This is a very bad error!
+(nice-class)              ************************************.
+
+See the suftesi class documentation for explanation.
+Type  H <return>  for immediate help.
+ ...                                              
+                                                  
+l.2 \begin{document}
+
+(/other/packages/loaded.sty)
+ABD: EveryShipout initializing macros
+
+Package foo Warning: This is a warning! on input line 3.
+
+[1{/opt/texlive/2015/texmf-var/fonts/map/pdftex/updmap/pdftex.map}] 
(./test.aux)
+
+(./secondary-file.tex [8] [9] [10 <./path/to/file>]
+Underfull \hbox (badness 6608) in paragraph at lines 131--132
+[]|\T1/jkpl/m/n/10.95 (+20) Something bla
+[11] [12])
+
+LaTeX Warning: Reference `wrong' on page 1 undefined on input line 4.
+
+LaTeX Font Warning: Font shape `OML/cmm/b/it' in size <5.5> not available
+(Font)              size <5> substituted on input line 70.
+
+[1{/opt/texlive/2015/texmf-var/fonts/map/pdftex/updmap/pdftex.map}] 
(./test.aux)
+
+(./test.lof
+Underfull \vbox (badness 1048) has occurred while \output is active [7]
+Overfull \hbox (0.93071pt too wide) detected at line 31
+ []\T1/jkpl/m/n/10.95 144
+)
+
+(./file  name/with spaces.tex
+chapter 5.
+<use image/an_image.pdf> [82] [83 <./image/an_image.pdf>] [84] [85] [86] 
(./image/another.tex
+<image/another.pdf, id=1357, 208.78pt x 146.5475pt> <use image/another.pdf>)
+<image/another2.pdf, id=1358, 542.025pt x 481.8pt> <use image/another2.pdf>
+Underfull \vbox (badness 3942) has occurred while \output is active [87 
<./image/another.pdf> <./image/another2.pdf>] [88] (./image/beta.tex
+<image/beta.pdf, id=1410, 289.08pt x 201.75375pt>
+<use image/beta.pdf>) [89] [90 <./image/beta.pdf>]
+Overfull \hbox (13.59138pt too wide) in paragraph at lines 367--368
+[]\T1/pplj/m/n/10.95 Un qua-dri-vet-to-re co-va-rian-te $\OMS/zplm/m/n/10.95 
f\OML/zplm/m/it/10.95 A[]\OMS/zplm/m/n/10.95 g$ \T1/pplj/m/n/10.95 e un 
in-sie-me di quat-tro quan-ti-ta $\OT1/zplm/m/n/10.95 (\OML/zplm/m/it/10.95 
A[]; A[]; A[]; A[]\OT1/zplm/m/n/10.95 )$
+[91] [92]
+
+[93])
+
+LaTeX Warning: Citation 'Knuth:TeXbook-1984' undefined on input line 48.
+
+LaTeX Warning: There were undefined references.
+
+)
diff --git a/tests/tex/error-parsing.el b/tests/tex/error-parsing.el
new file mode 100644
index 0000000..f15f3ac
--- /dev/null
+++ b/tests/tex/error-parsing.el
@@ -0,0 +1,120 @@
+;;; error-parsing.el --- tests for error parsing
+
+;; Copyright (C) 2016 Free Software Foundation, Inc.
+
+;; 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:
+
+(require 'ert)
+(require 'tex-buf)
+
+(defun AUCTeX-set-ert-path (&rest sym-val)
+  "Set first element of SYM-VAL to the next one, and so on.
+
+The value is the path to the test file, make sure it is expanded
+in the right directory even when the ERT test is run from the
+command line and from another directory."
+  (while sym-val
+    (set (pop sym-val)
+        (expand-file-name (pop sym-val)
+                          (when load-file-name
+                            (file-name-directory load-file-name))))))
+
+(AUCTeX-set-ert-path
+ 'TeX-test-compilation-log
+ "compilation-log.txt")
+
+(ert-deftest TeX-error-parsing ()
+  "Test error parsing functions."
+  (should (equal
+          (with-temp-buffer
+            (setq TeX-debug-warnings t
+                  TeX-debug-bad-boxes t)
+             (insert-file-contents TeX-test-compilation-log)
+             (TeX-parse-all-errors)
+            TeX-error-list)
+          '((warning
+             "./nice-class.cls" 32
+             "Package nice-class Warning: 
******************************************"
+             0
+             "Package nice-class Warning: 
******************************************
+(nice-class)                * THIS IS JUST A WARNING WITH A PESKY
+(nice-class)                * UNMATCHED CLOSED PARENTHESIS :-)
+(nice-class)                ****************************************** on 
input line 32.\n"
+             nil 32 nil 376 nil)
+            (error
+              "./test.tex" 2
+              "Class nice-class Error: ***********************************" 0
+              "\n(nice-class)              * This is a very bad error!
+(nice-class)              ************************************.
+
+See the suftesi class documentation for explanation.
+Type  H <return>  for immediate help.
+ ...                                              
+                                                  
+l.2 \\begin{document}
+
+(/other/packages/loaded.sty)
+ABD: EveryShipout initializing macros"
+              "\\begin{document}\n\n(/other/packages/loaded.sty)" nil nil 971 
nil)
+            (warning "./test.tex" 3
+              "Package foo Warning: This is a warning! on input line 3." 0
+             "Package foo Warning: This is a warning! on input line 3.\n"
+             nil 3 nil 1030 nil)
+            (bad-box
+             "./secondary-file.tex" 131
+             "Underfull \\hbox (badness 6608) in paragraph at lines 131--132"
+             0 "\n[]|\\T1/jkpl/m/n/10.95 (+20) Something bla" "bla"
+             132 t 1268 nil)
+             (warning "./test.tex" 4
+              "LaTeX Warning: Reference `wrong' on page 1 undefined on input 
line 4."
+              0
+              "LaTeX Warning: Reference `wrong' on page 1 undefined on input 
line 4.\n"
+              "wrong" 4 nil 1351 nil)
+             (warning "./test.tex" 70 "LaTeX Font Warning: Font shape 
`OML/cmm/b/it' in size <5.5> not available"
+              0 "LaTeX Font Warning: Font shape `OML/cmm/b/it' in size <5.5> 
not available
+(Font)              size <5> substituted on input line 70.\n" nil 70 nil 1485 
nil)
+             (bad-box "./test.lof" nil "Underfull \\vbox (badness 1048) has 
occurred while \\output is active [7]"
+              0 "\nUnderfull \\vbox (badness 1048) has occurred while \\output 
is active [7]"
+              nil nil t 1651 nil)
+             ;; It is possible there are two different bad box warnings in two
+             ;; consecutive lines (for example it happens if the first one is a
+             ;; vertical bad box which doesn't provide additional information),
+             ;; this test makes sure the second warning is not mistaken as
+             ;; context of the first one.
+             (bad-box "./test.lof" 31 "Overfull \\hbox (0.93071pt too wide) 
detected at line 31"
+              0 "\n []\\T1/jkpl/m/n/10.95 144" "144" 31 t 1733 nil)
+             ;; The line of this warning ends with a new file opened.  This 
test
+             ;; makes sure point stays exactly at the end of the warning so 
that
+             ;; the next the next warning in the list has the right file
+             ;; (otherwise it would be nil).
+             (bad-box "./file  name/with spaces.tex" nil "Underfull \\vbox 
(badness 3942) has occurred while \\output is active [87 <./image/another.pdf> 
<./image/another2.pdf>]"
+              0 "\nUnderfull \\vbox (badness 3942) has occurred while \\output 
is active [87 <./image/another.pdf> <./image/another2.pdf>]"
+              nil nil t 2142 nil)
+             (bad-box "./file  name/with spaces.tex" 367 "Overfull \\hbox 
(13.59138pt too wide) in paragraph at lines 367--368"
+              0 "\n[]\\T1/pplj/m/n/10.95 Un qua-dri-vet-to-re co-va-rian-te 
$\\OMS/zplm/m/n/10.95 f\\OML/zplm/m/it/10.95 A[]\\OMS/zplm/m/n/10.95 g$ 
\\T1/pplj/m/n/10.95 e un in-sie-me di quat-tro quan-ti-ta $\\OT1/zplm/m/n/10.95 
(\\OML/zplm/m/it/10.95 A[]; A[]; A[]; A[]\\OT1/zplm/m/n/10.95 )$" "$"
+              368 t 2600 nil)
+             (warning "./test.tex" 48
+              "LaTeX Warning: Citation 'Knuth:TeXbook-1984' undefined on input 
line 48." 0
+              "LaTeX Warning: Citation 'Knuth:TeXbook-1984' undefined on input 
line 48.\n"
+              "Knuth:TeXbook-1984" 48 nil 2692 nil)
+             (warning "./test.tex" nil "LaTeX Warning: There were undefined 
references."
+              0 "LaTeX Warning: There were undefined references.\n" nil nil 
nil 2741 nil)))))
+
+;;; error-parsing.el ends here
diff --git a/tex-buf.el b/tex-buf.el
index aced105..dca6614 100644
--- a/tex-buf.el
+++ b/tex-buf.el
@@ -569,9 +569,19 @@ ORIGINALS which are modified but not saved yet."
         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 (path (TeX-delete-duplicate-strings
+                  (mapcar (lambda (dir)
+                            (expand-file-name (file-name-as-directory dir)))
+                          (append
+                           TeX-check-path
+                           ;; In `TeX-command-default', this function is used 
to
+                           ;; check whether bibliography databases are newer
+                           ;; than generated *.bbl files, but bibliography
+                           ;; database are relative to `TeX-master-directory'
+                           ;; and the test can be run also from included files
+                           ;; that are in directories different from
+                           ;; `TeX-master-directory'.
+                           (list (TeX-master-directory))))))
       (dolist (orig originals)
        (dolist (ext extensions)
          (let ((filepath (concat path orig "." ext)))
@@ -1389,13 +1399,21 @@ Return nil ifs no errors were found."
       (setq TeX-command-next TeX-command-Show))
     nil))
 
+;; This regexp should catch warnings of the type
+;;   LaTeX Warning: ...
+;;   LaTeX Font Warning: ...
+;;   Package xyz123 Warning: ...
+;;   Class xyz123 Warning: ...
+(defvar LaTeX-warnings-regexp
+  "\\(?:LaTeX\\|Class\\|Package\\) [-A-Za-z0-9]* ?Warning:"
+  "Regexp matching LaTeX warnings.")
+
 (defun TeX-LaTeX-sentinel-has-warnings ()
   "Return non-nil, if the output buffer contains warnings.
 Warnings can be indicated by LaTeX or packages."
   (save-excursion
     (goto-char (point-min))
-    (re-search-forward
-     "^\\(LaTeX [A-Za-z]*\\|Package [A-Za-z0-9]+ \\)Warning:" nil t)))
+    (re-search-forward (concat "^" LaTeX-warnings-regexp) nil t)))
 
 (defun TeX-LaTeX-sentinel-has-bad-boxes ()
   "Return non-nil, if LaTeX output indicates overfull or underfull boxes."
@@ -1742,15 +1760,18 @@ command."
        (goto-char pt)
        (insert-before-markers string)
        (set-marker (process-mark process) (point))
-       ;; Remove line breaks at column 79
+       ;; Remove line breaks at columns 79 and 80
        (while (> (point) pt)
          (end-of-line 0)
-         (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.
+         (when (and (memql (- (point) (line-beginning-position)) '(79 80))
+                    ;; 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 and in the next line no
+                    ;; word char follows.
                     (not (memq (char-after (1+ (point))) '(?\n ?\()))
-                    (not (eq (char-before) ?.)))
+                    (not (and (eq (char-before) ?.)
+                              (char-after (1+ (point)))
+                              (not (eq ?w (char-syntax (char-after (1+ 
(point)))))))))
            (delete-char 1)))
        (goto-char (marker-position (process-mark process)))
        ;; Determine current page
@@ -2165,6 +2186,23 @@ If optional argument REPARSE is non-nil, reparse the 
output log."
             (process-name (TeX-active-process))
           "this")))
 
+(defun TeX-error-list-skip-warning-p (type ignore)
+  "Decide if a warning of `TeX-error-list' should be skipped.
+
+TYPE is one of the types listed in `TeX-error-list', IGNORE
+is the flag to choose if the warning should be skipped."
+  ;; The warning should be skipped if it...
+  (or
+   ;; ...is a warning and we want to ignore all warnings, or...
+   (and (null TeX-debug-warnings)
+       (equal type 'warning))
+   ;; ...is a bad-box and we want to ignore all bad-boxes, or...
+   (and (null TeX-debug-bad-boxes)
+       (equal type 'bad-box))
+   ;; ...is a warning to be ignored.
+   (and TeX-suppress-ignored-warnings
+       ignore)))
+
 (defun TeX-parse-TeX (arg reparse)
   "Find the next error produced by running TeX.
 
@@ -2185,12 +2223,23 @@ already in an Emacs buffer) and the cursor is placed at 
the error."
          (TeX-parse-reset reparse))
       (if TeX-parse-all-errors
          (progn
-           (setq max-index (length TeX-error-list)
-                 TeX-error-last-visited (+ (or arg 1) TeX-error-last-visited)
-                 item (if (natnump TeX-error-last-visited)
-                          (nth TeX-error-last-visited TeX-error-list)
-                        ;; XEmacs doesn't support `nth' with a negative index.
-                        nil))
+           (setq arg (or arg 1)
+                 max-index (length TeX-error-list))
+           ;; This loop is needed to skip ignored warnings, when
+           ;; `TeX-suppress-ignored-warnings' is non-nil and there are ignore
+           ;; warnings.
+           (while (null (zerop arg))
+             (setq TeX-error-last-visited (1+ TeX-error-last-visited)
+                   item (if (natnump TeX-error-last-visited)
+                            (nth TeX-error-last-visited TeX-error-list)
+                          ;; XEmacs doesn't support `nth' with a negative 
index.
+                          nil))
+             ;; Increase or decrease `arg' only if the warning isn't to be
+             ;; skipped.
+             (unless (TeX-error-list-skip-warning-p (nth 0 item) (nth 10 item))
+               (setq arg (if (> arg 0)
+                             (1- arg)
+                           (1+ arg)))))
            (if (< TeX-error-last-visited -1)
                (setq TeX-error-last-visited -1))
            (cond ((or (null item)
@@ -2214,9 +2263,29 @@ already in an Emacs buffer) and the cursor is placed at 
the error."
 You might want to examine and modify the free variables `file',
 `offset', `line', `string', `error', and `context' from this hook.")
 
+;; `ignore' flag should be the always the last one in the list of information
+;; for each error/warning, because it can be set within `TeX-warning' by a
+;; custom function taking as argument all information present in
+;; `TeX-error-list' but `ignore', see `TeX-ignore-warnings'.
 (defvar TeX-error-list nil
   "List of warnings and errors.
 
+Each element of the list is a list of information for a specific
+error or warning.  This is the structure of each element:
+ *  0: type (error, warning, bad-box)
+ *  1: file
+ *  2: line
+ *  3: message of the error or warning
+ *  4: offset
+ *  5: context, to be displayed in the help window
+ *  6: string to search in the buffer, in order to find location
+       of the error or warning
+ *  7: for warnings referring to multiple lines (e.g. bad boxes),
+       the last line mentioned in the warning message
+ *  8: t if it is a bad-box, nil otherwise
+ *  9: value of `TeX-error-point'
+ * 10: whether the warning should be ignored
+
 This variable is intended to be set only in output buffer so it
 will be shared among all files of the same document.")
 (make-variable-buffer-local 'TeX-error-list)
@@ -2252,25 +2321,21 @@ Return non-nil if an error or warning is found."
          ;; TeX error
          "^\\(!\\|\\(.*?\\):[0-9]+:\\) \\|"
          ;; New file
-         "(\\(\"[^\"]*?\"\\|/*\
-\\(?:\\.+[^()\r\n{} \\/]*\\|[^()\r\n{} .\\/]+\
-\\(?: [^()\r\n{} .\\/]+\\)*\\(?:\\.[-0-9a-zA-Z_.]*\\)?\\)\
-\\(?:[\\/]+\\(?:\\.+[^()\r\n{} \\/]*\\|[^()\r\n{} .\\/]+\
-\\(?: [^()\r\n{} .\\/]+\\)*\\(?:\\.[-0-9a-zA-Z_.]*\\)?\\)?\\)*\\)\
-)*\\(?: \\|\r?$\\)\\|"
-         ;; End of file.  The [^:] skips package messages like:
-         ;; Package hyperref Message: Driver (autodetected): hpdftex.
-         ;; [Loading MPS to PDF converter (version 2006.09.02).]
-         "\\()\\)[^:.]\\|"
+         "(\n?\\([^\n())]+\\)\\|"
+         ;; End of file.
+         "\\()\\)\\|"
          ;; Hook to change line numbers
          " !\\(?:offset(\\([---0-9]+\\))\\|"
          ;; Hook to change file name
          "name(\\([^)]+\\))\\)\\|"
-         ;; LaTeX bad box
-         "^\\(\\(?:Overfull\\|Underfull\\|Tight\\|Loose\\)\
- \\\\.*?[0-9]+--[0-9]+\\)\\|"
+         ;; Start of LaTeX bad box
+         "^\\(\\(?:Overfull\\|Underfull\\|Tight\\|Loose\\) "
+         ;;   Horizontal bad box
+         "\\(?:\\\\hbox.* at lines? [0-9]+\\(?:--[0-9]+\\)?$\\|"
+         ;;   Vertical bad box.  See also `TeX-warning'.
+         "\\\\vbox ([ a-z0-9]+) has occurred while \\\\output is active 
\\[[^]]+\\]\\)\\)\\|"
          ;; LaTeX warning
-         "^\\(\\(?:LaTeX [A-Za-z]*\\|Package [A-Za-z0-9]+ \\)Warning:.*\\)"))
+         "^\\(" LaTeX-warnings-regexp ".*\\)"))
        (error-found nil))
     (while
        (cond
@@ -2297,10 +2362,12 @@ Return non-nil if an error or warning is found."
            nil))
         ;; LaTeX bad box
         ((match-beginning 7)
-         (if TeX-debug-bad-boxes
+         ;; In `TeX-error-list' we collect all warnings, also if they're going
+         ;; to be actually skipped.
+         (if (or store TeX-debug-bad-boxes)
              (progn
                (setq error-found t)
-               (TeX-warning (TeX-match-buffer 7) store)
+               (TeX-warning (TeX-match-buffer 7) (match-beginning 7) t store)
                nil)
            (re-search-forward "\r?\n\
 \\(?:.\\{79\\}\r?\n\
@@ -2308,10 +2375,12 @@ Return non-nil if an error or warning is found."
            t))
         ;; LaTeX warning
         ((match-beginning 8)
-         (if TeX-debug-warnings
+         ;; In `TeX-error-list' we collect all warnings, also if they're going
+         ;; to be actually skipped.
+         (if (or store TeX-debug-warnings)
              (progn
                (setq error-found t)
-               (TeX-warning (TeX-match-buffer 8) store)
+               (TeX-warning (TeX-match-buffer 8) (match-beginning 8) nil store)
                nil)
            t))
 
@@ -2321,9 +2390,26 @@ Return non-nil if an error or warning is found."
                (end (match-end 3)))
            ;; Strip quotation marks and remove newlines if necessary
            (when (or (eq (string-to-char file) ?\")
-                     (string-match "\n" file))
-             (setq file
-                   (mapconcat 'identity (split-string file "[\"\n]+") "")))
+                     (string-match "[ \t\n]" file))
+             (setq file (mapconcat 'identity (split-string file "[\"\n]+") 
"")))
+           ;; Polish `file' string
+           (setq file
+                 (let ((string file))
+                   ;; Trim whitespaces at the front.  XXX: XEmacs doesn't
+                   ;; support character classes in regexps, like "[:space:]".
+                   (setq string
+                         (if (string-match "\\'[ \t\n\r]*" string)
+                             (replace-match "" t t string)
+                           string))
+                   ;; Sometimes `file' is something like
+                   ;;     "./path/to/file.tex [9] [10 <./path/to/file>] "
+                   ;; where "[9]" and "[10 <./path/to/file>]" are pages of the
+                   ;; output file, with path to an included file.  Remove these
+                   ;; numbers together with whitespaces at the end of the
+                   ;; string.
+                   (if (string-match "\\( *\\(\\[[^]]+\\]\\)? *\\)*\\'" string)
+                       (replace-match "" t t string)
+                     string)))
            (push file TeX-error-file)
            (push nil TeX-error-offset)
            (goto-char end))
@@ -2351,8 +2437,11 @@ Return non-nil if an error or warning is found."
     error-found))
 
 (defun TeX-find-display-help (type file line error offset context string
-                                  line-end bad-box error-point)
-  "Find the error and display the help."
+                                  line-end bad-box error-point _ignore)
+  "Find the error and display the help.
+
+For a description of arguments, see `TeX-error-list'.  IGNORE
+value is not used here."
   ;; Go back to TeX-buffer
   (let ((runbuf (TeX-active-buffer))
        (master (with-current-buffer TeX-command-buffer
@@ -2455,53 +2544,102 @@ information in `TeX-error-list' instead of displaying 
the error."
                                      context-start)))
         ;; We may use these in another buffer.
         (offset (or (car TeX-error-offset) 0))
-        (file (car TeX-error-file)))
+        (file (car TeX-error-file))
+        info-list)
 
     ;; Remember where we was.
-    (setq TeX-error-point (point))
+    (setq TeX-error-point (point)
+         info-list (list 'error file line error offset context string nil nil
+                         TeX-error-point nil))
     (if store
        ;; Store the error information.
-       (add-to-list 'TeX-error-list
-                    (list 'error file line error offset context string nil nil
-                          TeX-error-point) t)
+       (add-to-list 'TeX-error-list info-list t)
       ;; Find the error point and display the help.
-      (TeX-find-display-help
-       'error file line error offset context string nil nil TeX-error-point))))
+      (apply 'TeX-find-display-help info-list))))
 
-(defun TeX-warning (warning &optional store)
+(defun TeX-warning (warning warning-start bad-box &optional store)
   "Display a warning for WARNING.
 
+WARNING-START is the position where WARNING starts.  If BAD-BOX
+is non-nil, the warning refers to a bad-box, otherwise it is a
+generic warning.
+
 If optional argument STORE is non-nil, store the warning
 information in `TeX-error-list' instead of displaying the
 warning."
 
-  (let* ( ;; bad-box is nil if this is a "LaTeX Warning"
-        (bad-box (string-match "\\\\[vh]box.*[0-9]*--[0-9]*" warning))
-        ;; line-string: match 1 is beginning line, match 2 is end line
-        (line-string (if bad-box " \\([0-9]*\\)--\\([0-9]*\\)"
+  (let* ( ;; line-string: match 1 is beginning line, match 2 is end line
+        (line-string (if bad-box
+                         "at lines? \\([0-9]*\\)\\(?:--\\([0-9]*\\)\\)?"
                        "on input line \\([0-9]*\\)\\."))
         ;; word-string: match 1 is the word
         (word-string (if bad-box "[][\\W() ---]\\(\\w+\\)[][\\W() ---]*$"
-                       "`\\(\\w+\\)'"))
-
-        ;; Get error-line (warning).
-        (line (when (save-excursion (re-search-backward line-string nil t))
+                       ;; Match "ref" in both "Reference `ref' on page NN
+                       ;; undefined" and "Citation 'ref' on page NN undefined".
+                       "\\(?:`\\|'\\)\\([-a-zA-Z0-9:]+\\)'"))
+
+        ;; Get error-line (warning).  Don't search before `warning-start' to
+        ;; avoid catching completely unrelated line numbers.
+        (line (when (save-excursion (re-search-backward line-string
+                                                        warning-start t))
                 (string-to-number (TeX-match-buffer 1))))
-        (line-end (if bad-box (string-to-number (TeX-match-buffer 2))
+        ;; If this is a bad box and the warning ends with "...at lines MM--NN"
+        ;; we can use "NN" as `line-end', in any other case (including bad
+        ;; boxes ending with "...at line NN") just use `line'.
+        (line-end (if (and bad-box (match-beginning 2))
+                      (string-to-number (TeX-match-buffer 2))
                     line))
 
         ;; Find the context
-        (context-start (progn (if bad-box (end-of-line)
-                                (beginning-of-line))
+        (context-start (progn (cond
+                               ((and bad-box (string-match "\\\\hbox" warning))
+                                ;; Horizontal bad box
+                                (end-of-line))
+                               (bad-box
+                                ;; Vertical bad box (by exclusion), don't move
+                                ;; point.  In the output buffer, unlike in the
+                                ;; actual *.log file, these warnings do not end
+                                ;; with "...is active []", but in the same line
+                                ;; there may be something else, including a new
+                                ;; file opened.  Thus, point shouldn't move
+                                ;; from the end of the actual bad box warning.
+                                ;; This is why the corresponding regexp in
+                                ;; `TeX-parse-error' doesn't match everything
+                                ;; until the end of the line.
+                                nil)
+                               (t
+                                ;; Generic warning.
+                                (beginning-of-line)))
                               (point)))
 
-        (context (progn
-                   (forward-line 1)
-                   (end-of-line)
-                   (while (equal (current-column) 79)
-                     (forward-line 1)
-                     (end-of-line))
-                   (buffer-substring context-start (point))))
+        (context (cond ((string-match LaTeX-warnings-regexp warning)
+                        ;; The warnings matching `LaTeX-warnings-regexp' are
+                        ;; emitted by \GenericWarning macro, or macros based on
+                        ;; it (\ClassWarning, \PackageWarning, etc).  After
+                        ;; such warnings there is an empty line, just look for
+                        ;; it to find the end.
+                        (beginning-of-line)
+                        (while (null (eolp))
+                          (forward-line 1))
+                        (buffer-substring context-start (progn (end-of-line)
+                                                               (point))))
+
+                       ((and bad-box (string-match "\\\\vbox" warning))
+                        ;; Vertical bad boxes don't provide any additional
+                        ;; information.  In this case, reuse the `warning' as
+                        ;; `context' and don't move point, so that we avoid
+                        ;; eating the next line that may contain another
+                        ;; warning.  See also comment for `context-start'.
+                        (concat "\n" warning))
+
+                       (t
+                        ;; Horizontal bad boxes.
+                        (forward-line 1)
+                        (end-of-line)
+                        (while (equal (current-column) 79)
+                          (forward-line 1)
+                          (end-of-line))
+                        (buffer-substring context-start (point)))))
 
         ;; This is where we want to be.
         (error-point (point))
@@ -2513,22 +2651,50 @@ warning."
 
         ;; We might use these in another file.
         (offset (or (car TeX-error-offset) 0))
-        (file (car TeX-error-file)))
+        (file (car TeX-error-file))
+        info-list ignore)
+
+    ;; Second chance to get line number right.  If `line' is nil, check whether
+    ;; the reference to the line number is in `context'.  For example, this is
+    ;; the case for warnings emitted with \ClassWarning and \PackageWarning.
+    ;; XXX: maybe it suffices to evaluate `line' after `context' above, but I
+    ;; don't know if there are cases in which it's important to get `line'
+    ;; before `context'.
+    (and (null line)
+        (string-match line-string context)
+        (setq line-end
+              (setq line (and (match-beginning 1)
+                              (string-to-number (match-string 1 context))))))
 
     ;; This is where we start next time.
     (goto-char error-point)
     (setq TeX-error-point (point))
 
+    ;; Explanation of what follows: we add the warning to `TeX-error-list' even
+    ;; if it has to be ignored, with a flag specifying whether it is ignored.
+    ;; We do so in order to be able to change between "ignore" and 
"dont-ignore"
+    ;; behavior by just looking to the flag, without the need to reparse the
+    ;; output log.
+
+    ;; Store the list of information about the warning.
+    (setq info-list (list (if bad-box 'bad-box 'warning) file line warning
+                         offset context string line-end bad-box
+                         TeX-error-point)
+         ;; Decide whether it should be ignored.
+         ignore (and TeX-ignore-warnings
+                     (cond
+                      ((stringp TeX-ignore-warnings)
+                       (string-match TeX-ignore-warnings warning))
+                      ((fboundp TeX-ignore-warnings)
+                       (apply TeX-ignore-warnings info-list))))
+         ;; Update `info-list'.
+         info-list (append info-list (list ignore)))
+
     (if store
        ;; Store the warning information.
-       (add-to-list 'TeX-error-list
-                    (list (if bad-box 'bad-box 'warning) file line warning
-                          offset context string line-end bad-box
-                          TeX-error-point) t)
+       (add-to-list 'TeX-error-list info-list t)
       ;; Find the warning point and display the help.
-      (TeX-find-display-help (if bad-box 'bad-box 'warning) file line warning
-                            offset context string line-end bad-box
-                            TeX-error-point))))
+      (apply 'TeX-find-display-help info-list))))
 
 ;;; - Help
 
@@ -3159,42 +3325,45 @@ Write file names relative to MASTER-DIR when they are 
not absolute."
               file (nth 1 entry)
               line (nth 2 entry)
               msg  (nth 3 entry))
-        (add-to-list
-         'entries
-         (list
-          ;; ID.
-          id
-          (vector
-           ;; File.
-           (if (stringp file)
-               (if (file-name-absolute-p file)
-                   file
-                 (file-relative-name file master-dir))
-             "")
-           ;; Line.
-           (if (numberp line)
-               (number-to-string line)
-             "")
-           ;; Type.
-           (cond
-            ((equal type 'error)
-             (propertize "Error" 'font-lock-face 'TeX-error-description-error))
-            ((equal type 'warning)
-             (propertize "Warning" 'font-lock-face
-                         'TeX-error-description-warning))
-            ((equal type 'bad-box)
-             (propertize "Bad box" 'font-lock-face
-                         'TeX-error-description-warning))
-            (t
-             ""))
-           ;; Message.
-           (list (if (stringp msg) msg "")
-                 'face 'link
-                 'follow-link t
-                 'id id
-                 'action 'TeX-error-overview-goto-source)
-           )) t)
-        (setq id (1+ id))) TeX-error-list)
+        ;; Add the entry only if it isn't to be skipped.
+        (unless (TeX-error-list-skip-warning-p type (nth 10 entry))
+          (add-to-list
+           'entries
+           (list
+            ;; ID.
+            id
+            (vector
+             ;; File.
+             (if (stringp file)
+                 (if (file-name-absolute-p file)
+                     file
+                   (file-relative-name file master-dir))
+               "")
+             ;; Line.
+             (if (numberp line)
+                 (number-to-string line)
+               "")
+             ;; Type.
+             (cond
+              ((equal type 'error)
+               (propertize "Error" 'font-lock-face 
'TeX-error-description-error))
+              ((equal type 'warning)
+               (propertize "Warning" 'font-lock-face
+                           'TeX-error-description-warning))
+              ((equal type 'bad-box)
+               (propertize "Bad box" 'font-lock-face
+                           'TeX-error-description-warning))
+              (t
+               ""))
+             ;; Message.
+             (list (if (stringp msg) msg "")
+                   'face 'link
+                   'follow-link t
+                   'id id
+                   'action 'TeX-error-overview-goto-source))) t))
+        ;; Increase the `id' counter in any case.
+        (setq id (1+ id)))
+       TeX-error-list)
       entries)))
 
 (defun TeX-error-overview-next-error (&optional arg)
@@ -3233,6 +3402,36 @@ forward, if negative)."
   (let ((TeX-display-help 'expert))
     (TeX-error-overview-goto-source)))
 
+(defun TeX-error-overview-toggle-debug-bad-boxes ()
+  "Run `TeX-toggle-debug-bad-boxes' and update entries list."
+  (interactive)
+  (TeX-toggle-debug-bad-boxes)
+  (setq tabulated-list-entries
+       (TeX-error-overview-make-entries
+        (with-current-buffer TeX-command-buffer (TeX-master-directory))))
+  (tabulated-list-init-header)
+  (tabulated-list-print))
+
+(defun TeX-error-overview-toggle-debug-warnings ()
+  "Run `TeX-toggle-debug-warnings' and update entries list."
+  (interactive)
+  (TeX-toggle-debug-warnings)
+  (setq tabulated-list-entries
+       (TeX-error-overview-make-entries
+        (with-current-buffer TeX-command-buffer (TeX-master-directory))))
+  (tabulated-list-init-header)
+  (tabulated-list-print))
+
+(defun TeX-error-overview-toggle-suppress-ignored-warnings ()
+  "Toggle visibility of ignored warnings and update entries list."
+  (interactive)
+  (TeX-toggle-suppress-ignored-warnings)
+  (setq tabulated-list-entries
+       (TeX-error-overview-make-entries
+        (with-current-buffer TeX-command-buffer (TeX-master-directory))))
+  (tabulated-list-init-header)
+  (tabulated-list-print))
+
 (defun TeX-error-overview-quit ()
   "Delete the window or the frame of the error overview."
   (interactive)
@@ -3244,11 +3443,14 @@ forward, if negative)."
 (defvar TeX-error-overview-mode-map
   (let ((map (make-sparse-keymap))
        (menu-map (make-sparse-keymap)))
+    (define-key map "b"    'TeX-error-overview-toggle-debug-bad-boxes)
     (define-key map "j"    'TeX-error-overview-jump-to-source)
     (define-key map "l"    'TeX-error-overview-goto-log)
     (define-key map "n"    'TeX-error-overview-next-error)
     (define-key map "p"    'TeX-error-overview-previous-error)
     (define-key map "q"    'TeX-error-overview-quit)
+    (define-key map "w"    'TeX-error-overview-toggle-debug-warnings)
+    (define-key map "x"    
'TeX-error-overview-toggle-suppress-ignored-warnings)
     (define-key map "\C-m" 'TeX-error-overview-goto-source)
     map)
   "Local keymap for `TeX-error-overview-mode' buffers.")
@@ -3268,6 +3470,18 @@ forward, if negative)."
       :help "Move point to the error in the source"]
      ["Go to log" TeX-error-overview-goto-log
       :help "Show the error in the log buffer"]
+     "-"
+     ["Debug Bad Boxes" TeX-error-overview-toggle-debug-bad-boxes
+      :style toggle :selected TeX-debug-bad-boxes
+      :help "Show overfull and underfull boxes"]
+     ["Debug Warnings" TeX-error-overview-toggle-debug-warnings
+      :style toggle :selected TeX-debug-warnings
+      :help "Show warnings"]
+     ["Ignore Unimportant Warnings"
+      TeX-error-overview-toggle-suppress-ignored-warnings
+      :style toggle :selected TeX-suppress-ignored-warnings
+      :help "Hide specified warnings"]
+     "-"
      ["Quit" TeX-error-overview-quit
       :help "Quit"])))
 
@@ -3317,12 +3531,17 @@ forward, if negative)."
   ;; Check requirements before start.
   (if (fboundp 'tabulated-list-mode)
       (if (setq TeX-error-overview-active-buffer (TeX-active-buffer))
-         (if (with-current-buffer TeX-error-overview-active-buffer
-               TeX-error-list)
+         ;; `TeX-error-overview-list-entries' is going to be used only as value
+         ;; of `tabulated-list-entries' in `TeX-error-overview-mode'.  In
+         ;; principle, we don't need `TeX-error-overview-list-entries', but
+         ;; `tabulated-list-entries' is buffer-local and we need the list of
+         ;; entries before creating the error overview buffer in order to
+         ;; decide whether we need to show anything.
+         (if (setq TeX-error-overview-list-entries
+                   (TeX-error-overview-make-entries
+                    (TeX-master-directory)))
              (progn
-               (setq TeX-error-overview-list-entries
-                     (TeX-error-overview-make-entries (TeX-master-directory))
-                     TeX-error-overview-orig-window (selected-window)
+               (setq TeX-error-overview-orig-window (selected-window)
                      TeX-error-overview-orig-frame
                      (window-frame TeX-error-overview-orig-window))
                ;; Create the error overview buffer.  This is
diff --git a/tex-style.el b/tex-style.el
index a1ffb97..d25bccc 100644
--- a/tex-style.el
+++ b/tex-style.el
@@ -398,6 +398,18 @@ Inserting the subdirectory in the filename (as
                                         (TeX-master-directory))))
                 (function :tag "other")))
 
+;; style/splitidx.el
+
+(defcustom LaTeX-splitidx-sindex-reftex-quick-id-key ?s
+  "Unique letter identifying \"\\sindex\" macro in RefTeX.
+
+A character argument for quick identification of \"\\sindex\"
+when RefTeX inserts new index entries with `reftex-index'.  It
+must be unique.  It is initialized to ?s when added to
+`reftex-index-macros'."
+  :group 'LaTeX-style
+  :type 'character)
+
 (provide 'tex-style)
 
 ;;; tex-style.el ends here
diff --git a/tex.el b/tex.el
index 7f464b3..588848a 100644
--- a/tex.el
+++ b/tex.el
@@ -1,6 +1,6 @@
 ;;; tex.el --- Support for TeX documents.
 
-;; Copyright (C) 1985-1987, 1991, 1993-2015 Free Software Foundation, Inc.
+;; Copyright (C) 1985-1987, 1991, 1993-2016 Free Software Foundation, Inc.
 
 ;; Maintainer: address@hidden
 ;; Keywords: tex
@@ -958,6 +958,28 @@ echo area.  If `expert' display output buffer with raw 
processor output."
   :group 'TeX-output
   :type 'boolean)
 
+(defcustom TeX-ignore-warnings nil
+  "Controls which warnings are to be ignored.
+
+It can be either a regexp matching warnings to be ignored, or a
+symbol with the name of a custom function taking as arguments all
+the information of the warning listed in `TeX-error-list', except
+the last one about whether to ignore the warning.
+
+If you want to use the custom function, see how it is used in the
+code of `TeX-warning'."
+  :group 'TeX-command
+  :type '(choice (const  :tag "Do not ignore anything" nil)
+                (string :tag "Regexp")
+                (symbol :tag "Function name")))
+
+(defcustom TeX-suppress-ignored-warnings nil
+  "Whether to actually show ignored warnings.
+
+Note that `TeX-debug-warnings' always takes the precedence."
+  :group 'TeX-command
+  :type 'boolean)
+
 (defun TeX-toggle-debug-bad-boxes ()
   "Toggle if the debugger should display \"bad boxes\" too."
   (interactive)
@@ -972,6 +994,16 @@ echo area.  If `expert' display output buffer with raw 
processor output."
   (message (concat "TeX-debug-warnings: "
                   (if TeX-debug-warnings "on" "off"))))
 
+(defun TeX-toggle-suppress-ignored-warnings ()
+  "Toggle if the debugger should display ignored warnings too.
+
+See `TeX-suppress-ignored-warnings' and `TeX-ignore-warnings' for
+more details."
+  (interactive)
+  (setq TeX-suppress-ignored-warnings (not TeX-suppress-ignored-warnings))
+  (message (concat "TeX-suppress-ignored-warnings: "
+                  (if TeX-suppress-ignored-warnings "on" "off"))))
+
 ;;; Mode names.
 
 (defvar TeX-base-mode-name nil
@@ -1178,28 +1210,38 @@ The following built-in predicates are available:
   :group 'TeX-view
   :type '(alist :key-type symbol :value-type (group sexp)))
 
+;; XXX: Atril is a fork of Evince and shares an almost identical interface with
+;; it.  Instead of having different functions for each program, we keep the
+;; original *-evince-* functions and make them accept arguments to specify the
+;; actual name of the program and the desktop environment, that will be used to
+;; set up DBUS communication.
+
 ;; Require dbus at compile time to prevent errors due to `dbus-ignore-errors'
 ;; not being defined.
 (eval-when-compile (and (featurep 'dbusbind)
                        (require 'dbus nil :no-error)))
-(defun TeX-evince-dbus-p (&rest options)
-  "Return non-nil, if evince is installed and accessible via DBUS.
+(defun TeX-evince-dbus-p (de app &rest options)
+  "Return non-nil, if atril or evince are 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."
+search are checked, too.
+
+DE is the name of the desktop environment, either \"gnome\" or
+\"mate\", APP is the name of viewer, either \"evince\" or
+\"atril\"."
   (let ((dbus-debug nil))
     (and (featurep 'dbusbind)
         (require 'dbus nil :no-error)
         (dbus-ignore-errors (dbus-get-unique-name :session))
-        (dbus-ping :session "org.gnome.evince.Daemon")
-        (executable-find "evince")
+        (dbus-ping :session (format "org.%s.%s.Daemon" de app))
+        (executable-find app)
         (or (not (memq :forward options))
             (let ((spec (dbus-introspect-get-method
-                         :session "org.gnome.evince.Daemon"
-                         "/org/gnome/evince/Daemon"
-                         "org.gnome.evince.Daemon"
+                         :session (format "org.%s.%s.Daemon" de app)
+                         (format "/org/%s/%s/Daemon" de app)
+                         (format "org.%s.%s.Daemon" de app)
                          "FindDocument")))
               ;; FindDocument must exist, and its signature must be (String,
               ;; Boolean, String).  Evince versions between 2.30 and 2.91.x
@@ -1226,8 +1268,8 @@ entry in `TeX-view-program-list-builtin'."
            #'TeX-source-correlate-handle-TeX-region)
   (if (and TeX-source-correlate-mode
           (fboundp 'pdf-sync-forward-search))
-      (with-current-buffer (or (find-buffer-visiting
-                               (concat file "." TeX-default-extension))
+      (with-current-buffer (or (when TeX-current-process-region-p
+                                (get-file-buffer (TeX-region-file t)))
                               (current-buffer))
        (pdf-sync-forward-search))
     (let ((pdf (concat file "." (TeX-output-extension))))
@@ -1236,19 +1278,23 @@ entry in `TeX-view-program-list-builtin'."
 
 (defvar url-unreserved-chars)
 
-(defun TeX-evince-sync-view ()
+(defun TeX-evince-sync-view-1 (de app)
   "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."
+for the Atril or Evince entries in
+`TeX-view-program-list-builtin' if the requirements are met.
+
+DE is the name of the desktop environment, either \"gnome\" or
+\"mate\", APP is the name of viewer, either \"evince\" or
+\"atril\"."
   (require 'url-util)
   (let* ((uri (concat "file://" (url-encode-url
                                 (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"
+                :session (format "org.%s.%s.Daemon" de app)
+                (format "/org/%s/%s/Daemon" de app)
+                (format "org.%s.%s.Daemon" de app)
                 "FindDocument"
                 uri
                 t)))
@@ -1258,18 +1304,48 @@ the requirements are met."
                                 (current-buffer))
          (dbus-call-method
           :session owner
-          "/org/gnome/evince/Window/0"
-          "org.gnome.evince.Window"
+          (format "/org/%s/%s/Window/0" de app)
+          (format "org.%s.%s.Window" de app)
           "SyncView"
           (buffer-file-name)
-          (list :struct :int32 (line-number-at-pos) :int32 (1+ 
(current-column)))
+          (list :struct :int32 (line-number-at-pos)
+                :int32 (1+ (current-column)))
           :uint32 0))
-      (error "Couldn't find the Evince instance for %s" uri))))
+      (error "Couldn't find the %s instance for %s" (capitalize app) uri))))
+
+(defun TeX-atril-sync-view ()
+  "Run `TeX-evince-sync-view-1', which see, set up for Atril."
+  (TeX-evince-sync-view-1 "mate" "atril"))
+
+(defun TeX-evince-sync-view ()
+  "Run `TeX-evince-sync-view-1', which see, set up for Evince."
+  (TeX-evince-sync-view-1 "gnome" "evince"))
+
+(defun TeX-view-program-select-evince (de app)
+  "Select how to call the Evince-like viewer.
+
+DE is the name of the desktop environment, either \"gnome\" or
+\"mate\", APP is the name of viewer, either \"evince\" or
+\"atril\"."
+  (if (TeX-evince-dbus-p de app :forward)
+      (intern (format "TeX-%s-sync-view" app))
+    `(,app (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 (concat app " --help")))
+                " -i %(outpage)"
+              " -p %(outpage)")) " %o")))
 
 (defvar TeX-view-program-list-builtin
   (cond
    ((eq system-type 'windows-nt)
     '(("Yap" ("yap -1" (mode-io-correlate " -s %n%b") " %o") "yap")
+      ("dviout" ("dviout -1 %d" (mode-io-correlate "\"# %n %b\"")) "dviout")
+      ("SumatraPDF"
+       ("SumatraPDF -reuse-instance"
+       (mode-io-correlate " -forward-search \"%b\" %n") " %o")
+       "SumatraPDF")
       ("dvips and start" "dvips %d -o && start \"\" %f" "dvips")
       ("start" "start \"\" %o")))
    ((eq system-type 'darwin)
@@ -1293,18 +1369,16 @@ the requirements are met."
       ("dvips and gv" "%(o?)dvips %d -o && gv %f" ,(list "%(o?)dvips" "gv"))
       ("gv" "gv %o" "gv")
       ("xpdf" ("xpdf -remote %s -raise %o" (mode-io-correlate " %(outpage)")) 
"xpdf")
-      ("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")) "evince")
+      ("Evince" ,(TeX-view-program-select-evince "gnome" "evince") "evince")
+      ("Atril" ,(TeX-view-program-select-evince "mate" "atril") "atril")
       ("Okular" ("okular --unique %o" (mode-io-correlate "#src:%n%a")) 
"okular")
       ("xdg-open" "xdg-open %o" "xdg-open")
-      ("PDF Tools" TeX-pdf-tools-sync-view))))
+      ("PDF Tools" TeX-pdf-tools-sync-view)
+      ("Zathura"
+       ("zathura %o"
+       (mode-io-correlate
+        " --synctex-forward %n:0:%b -x \"emacsclient +%{line} %{input}\""))
+       "zathura"))))
   "Alist of built-in viewer specifications.
 This variable should not be changed by the user who can use
 `TeX-view-program-list' to add new viewers or overwrite the
@@ -1812,12 +1886,14 @@ 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)))
+  ;; Register Emacs for the SyncSource DBUS signal emitted by Evince or Atril.
+  (dolist (de-app '(("gnome" "evince") ("mate" "atril")))
+    (when (TeX-evince-dbus-p (car de-app) (cadr de-app))
+      (dbus-register-signal
+       :session nil (format "/org/%s/%s/Window/0" (car de-app) (cadr de-app))
+       (format "org.%s.%s.Window" (car de-app) (cadr de-app))
+       "SyncSource"
+       'TeX-source-correlate-sync-source))))
 
 (defalias 'TeX-source-specials-mode 'TeX-source-correlate-mode)
 (make-obsolete 'TeX-source-specials-mode 'TeX-source-correlate-mode "11.86")
@@ -4408,7 +4484,8 @@ 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))
+  (let* ((gc-cons-threshold 10000000)
+        (spec (assq filetype TeX-search-files-type-alist))
         (kpse-var (nth 1 spec))
         (rawdirs (nth 2 spec))
         (exts (nth 3 spec))
@@ -4736,7 +4813,7 @@ Brace insertion is only done if point is in a math 
construct and
     (define-key map "\C-c}"    'up-list)
     (define-key map "\C-c#"    'TeX-normal-mode)
     (define-key map "\C-c\C-n" 'TeX-normal-mode)
-    (define-key map "\C-c?"    'TeX-doc)
+    (define-key map "\C-c?"    'TeX-documentation-texdoc)
     (define-key map "\C-c\C-i" 'TeX-goto-info-page)
     (define-key map "\r"       'TeX-newline)
 
@@ -4768,6 +4845,7 @@ Brace insertion is only done if point is in a math 
construct and
     (define-key map "\C-c\C-w"       'TeX-toggle-debug-bad-boxes); to be 
removed
     (define-key map "\C-c\C-t\C-b"   'TeX-toggle-debug-bad-boxes)
     (define-key map "\C-c\C-t\C-w"   'TeX-toggle-debug-warnings)
+    (define-key map "\C-c\C-t\C-x"   'TeX-toggle-suppress-ignored-warnings)
     (define-key map "\C-c\C-v" 'TeX-view)
     ;; From tex-buf.el
     (define-key map "\C-c\C-d" 'TeX-save-document)
@@ -4959,7 +5037,7 @@ Brace insertion is only done if point is in a math 
construct and
        :help "Save and reparse the current buffer for style information"]
       ["Reset AUCTeX" (TeX-normal-mode t) :keys "C-u C-c C-n"
        :help "Reset buffer and reload AUCTeX style files"])
-     ["Find Documentation..." TeX-doc
+     ["Find Documentation..." TeX-documentation-texdoc
       :help "Get help on commands, packages, or TeX-related topics in general"]
      ["Read the AUCTeX Manual" TeX-goto-info-page
       :help "Everything worth reading"]
@@ -6094,6 +6172,71 @@ to browse existing AUCTeX bugs.
 
 ;;; Documentation
 
+(defun TeX-documentation-texdoc (&optional arg)
+  "Run texdoc to read documentation.
+
+Prompt for selection of the package of which to show the documentation.
+
+If called with a prefix argument ARG, after selecting the
+package, prompt for selection of the manual of that package to
+show."
+  (interactive "P")
+  (let ((pkg (thing-at-point 'symbol))
+       buffer list doc)
+    ;; Strip off properties.  XXX: XEmacs doesn't have
+    ;; `substring-no-properties'.
+    (set-text-properties 0 (length pkg) nil pkg)
+    (setq pkg (TeX-read-string "View documentation for: " pkg))
+    (unless (zerop (length pkg))
+      (if arg
+         ;; Called with prefix argument: run "texdoc --list --nointeract <pkg>"
+         (progn
+           ;; Create the buffer, insert the result of the command, and
+           ;; accumulate the list of manuals.
+           (with-current-buffer (get-buffer-create
+                                 (setq buffer (format "*texdoc: %s*" pkg)))
+             (erase-buffer)
+             (insert (shell-command-to-string
+                      (concat "texdoc --list --nointeract " pkg)))
+             (goto-char 1)             ; No need to use `point-min' here.
+             (save-excursion
+               (while (re-search-forward
+                       ;; XXX: XEmacs doesn't support character classes in
+                       ;; regexps, like "[:alnum:]".
+                       "^ *\\([0-9]+\\) +\\([-~/a-zA-Z0-9_.${}#%,:\\ ()]+\\)" 
nil t)
+                 (push (cons (match-string 1) (match-string 2)) list))))
+           (unwind-protect
+               (cond
+                ((null (executable-find "texdoc"))
+                 ;; Note: `shell-command-to-string' uses shell, only
+                 ;; `call-process' looks at `exec-path', thus only here makes
+                 ;; sense to use `executable-find' to test whether texdoc is
+                 ;; available.
+                 (message "texdoc not found"))
+                (list
+                 ;; Go on if there are manuals listed: show the buffer, prompt
+                 ;; for the number of the manual, then run
+                 ;;     texdoc --just-view <doc>
+                 (TeX-pop-to-buffer (get-buffer buffer))
+                 (condition-case nil
+                     (when (setq doc
+                                 (cdr (assoc (TeX-read-string "Please enter \
+the number of the file to view, anything else to skip: ") list)))
+                       (call-process "texdoc" nil 0 nil "--just-view" doc))
+                   ;; Exit gently if a `quit' signal is thrown.
+                   (quit nil)))
+                (t (message "No documentation found for %s" pkg)))
+             ;; In any case quit-and-kill the window.  XXX: XEmacs doesn't have
+             ;; `quit-window', just kill the buffer in that case.
+             (when (get-buffer-window buffer)
+               (if (fboundp 'quit-window)
+                   (quit-window t (get-buffer-window buffer))
+                 (kill-buffer buffer)))))
+       ;; Called without prefix argument: just run "texdoc --view <pkg>" and
+       ;; show the output, so that the user is warned in case it doesn't find
+       ;; the documentation or "texdoc" is not available.
+       (message (shell-command-to-string (concat "texdoc --view " pkg)))))))
+
 (defun TeX-goto-info-page ()
   "Read documentation for AUCTeX in the info system."
   (interactive)



reply via email to

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