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

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

[elpa] externals/auctex f761ab4 48/48: Merge branch 'master' into extern


From: Tassilo Horn
Subject: [elpa] externals/auctex f761ab4 48/48: Merge branch 'master' into externals/auctex
Date: Sun, 16 Sep 2018 01:47:28 -0400 (EDT)

branch: externals/auctex
commit f761ab401f5ca6455f050588edb40bdc0e14b425
Merge: 0e878e9 a7cde09
Author: Tassilo Horn <address@hidden>
Commit: Tassilo Horn <address@hidden>

    Merge branch 'master' into externals/auctex
---
 COPYING                         |   6 +-
 Makefile.in                     |  15 +-
 RELEASE                         |   8 +-
 auctex.spec                     |  15 +-
 bib-cite.el                     |  12 +-
 build-aux/gitlog-to-auctexlog   |   2 +-
 build-aux/gitlog-to-changelog   |   6 +-
 doc/auctex.texi                 |  16 +--
 doc/changes.texi                |  43 ++++--
 doc/fdl.texi                    |   4 +-
 doc/install.texi                |   8 +-
 doc/intro.texi                  |   6 +-
 doc/preview-latex.texi          |  20 ++-
 doc/preview-readme.texi         |   8 +-
 doc/wininstall.texi             |  18 +--
 latex.el                        |   7 +-
 latex/README                    |   6 +-
 latex/preview.dtx               |   2 +-
 multi-prompt.el                 |   9 +-
 plain-tex.el                    |  26 +++-
 preview.el                      | 124 +++++++----------
 prv-emacs.el                    |   8 +-
 style/amsmath.el                |  77 ++++++-----
 style/comment.el                |   4 +-
 style/floatrow.el               |   4 +-
 style/foils.el                  |   2 +-
 style/geometry.el               |  16 +--
 style/graphicx.el               | 135 +++++++++++-------
 style/hyperref.el               |   6 +-
 style/ifluatex.el               |   2 +-
 style/latexinfo.el              |   9 +-
 style/lettrine.el               |  47 ++++---
 style/luatextra.el              |   2 +-
 style/marginnote.el             |  64 +++++++++
 style/mathtools.el              |   2 +-
 style/ocg-p.el                  | 190 +++++++++++++++++++++++++
 style/ocgx.el                   |  68 +++++++++
 style/pstricks.el               |  10 +-
 style/thm-restate.el            | 115 ++++++++++++++++
 style/thmtools.el               | 299 ++++++++++++++++++++++++++++++++++++++++
 tests/Makefile                  |   2 +-
 tests/japanese/preview-latex.el |  94 ++++++-------
 tests/latex/latex-test.el       |  95 +++++++++++++
 tests/tex/command-expansion.el  |  59 +++++++-
 tex-buf.el                      | 211 ++++++++++++++++++++--------
 tex-fold.el                     |  29 ++--
 tex-jp.el                       |  98 +++----------
 tex-site.el.in                  |   4 +-
 tex.el                          |  98 +++++++------
 toolbar-x.el                    |   6 +-
 50 files changed, 1572 insertions(+), 545 deletions(-)

diff --git a/COPYING b/COPYING
index 94a9ed0..335f658 100644
--- a/COPYING
+++ b/COPYING
@@ -1,7 +1,7 @@
                     GNU GENERAL PUBLIC LICENSE
                        Version 3, 29 June 2007
 
- Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
+ Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
  Everyone is permitted to copy and distribute verbatim copies
  of this license document, but changing it is not allowed.
 
@@ -664,11 +664,11 @@ might be different; for a GUI interface, you would use an 
"about box".
   You should also get your employer (if you work as a programmer) or school,
 if any, to sign a "copyright disclaimer" for the program, if necessary.
 For more information on this, and how to apply and follow the GNU GPL, see
-<http://www.gnu.org/licenses/>.
+<https://www.gnu.org/licenses/>.
 
   The GNU General Public License does not permit incorporating your program
 into proprietary programs.  If your program is a subroutine library, you
 may consider it more useful to permit linking proprietary applications with
 the library.  If this is what you want to do, use the GNU Lesser General
 Public License instead of this License.  But first, please read
-<http://www.gnu.org/philosophy/why-not-lgpl.html>.
+<https://www.gnu.org/philosophy/why-not-lgpl.html>.
diff --git a/Makefile.in b/Makefile.in
index 5a61a37..6c80882 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -168,7 +168,8 @@ STYLESRC = style/prosper.el \
           style/csquotes.el  style/babel.el     style/dk-bib.el \
           style/floatrow.el  style/moodle.el    style/canadian.el \
           style/arabxetex.el style/australian.el style/newzealand.el \
-          style/xltabular.el
+          style/xltabular.el style/marginnote.el style/thmtools.el \
+          style/ocg-p.el     style/ocgx.el      style/thm-restate.el
 
 STYLEELC = $(STYLESRC:.el=.elc)
 
@@ -619,12 +620,12 @@ windows-package: check-tag
        test -d $(WBUILDDIR) || mkdir $(WBUILDDIR)
        test -f $(WBUILDDIR)/$(WEMACSPACKAGE) \
        || { cd $(WBUILDDIR) \
-       && wget http://ftp.gnu.org/gnu/emacs/windows/$(WEMACSPACKAGE); }
+       && wget https://ftp.gnu.org/gnu/emacs/windows/$(WEMACSPACKAGE); }
        test -f $(WBUILDDIR)/auctex-$(TAG).zip \
        || { test -f $(FTPDIR)/auctex-$(TAG).zip \
          && $(CP) $(FTPDIR)/auctex-$(TAG).zip $(WBUILDDIR); } \
        || { cd $(WBUILDDIR) \
-         && wget http://ftp.gnu.org/gnu/auctex/auctex-$(TAG).zip; }
+         && wget https://ftp.gnu.org/gnu/auctex/auctex-$(TAG).zip; }
 # Reset to clean state
        cd $(WBUILDDIR) \
        && rm -rf emacs-$(WEMACSVER) \
@@ -685,14 +686,14 @@ www-doc: check-tag
        mkdir -p $(WWWDIR)/manual
        $(CP) auctex-$(TAG)/doc/*.texi $(WWWDIR)/manual
        cd $(WWWDIR)/manual \
-       && wget -O gendocs.sh 
'http://cvs.savannah.gnu.org/viewvc/%2acheckout%2a/texinfo/texinfo/util/gendocs.sh'
 \
-       && wget -O gendocs.sh.patch 
'http://git.savannah.gnu.org/gitweb/?p=auctex.git;a=blob_plain;f=gendocs.sh.patch;hb=gendocspatch'
 \
+       && wget -O gendocs.sh 
'https://cvs.savannah.gnu.org/viewvc/%2acheckout%2a/texinfo/texinfo/util/gendocs.sh'
 \
+       && wget -O gendocs.sh.patch 
'https://git.savannah.gnu.org/gitweb/?p=auctex.git;a=blob_plain;f=gendocs.sh.patch;hb=gendocspatch'
 \
        && patch <gendocs.sh.patch \
        && chmod u+x gendocs.sh \
-       && wget -O gendocs_template 
'http://cvs.savannah.gnu.org/viewvc/%2acheckout%2a/texinfo/texinfo/util/gendocs_template'
 \
+       && wget -O gendocs_template 
'https://cvs.savannah.gnu.org/viewvc/%2acheckout%2a/texinfo/texinfo/util/gendocs_template'
 \
        && sed -i -e 's/html_node\/index\.html/%%PACKAGE%%\/index.html/' 
gendocs_template \
        && mkdir .texinfo \
-       && echo -e "emacs split 
http://www.gnu.org/software/emacs/manual/html_node/emacs/\nemacs mono 
http://www.gnu.org/software/emacs/manual/html_mono/emacs.html\nreftex split 
http://www.gnu.org/software/auctex/manual/reftex/\nreftex mono 
http://www.gnu.org/software/auctex/manual/reftex.html\n"; > 
.texinfo/htmlxref.cnf \
+       && echo -e "emacs split 
https://www.gnu.org/software/emacs/manual/html_node/emacs/\nemacs mono 
https://www.gnu.org/software/emacs/manual/html_mono/emacs.html\nreftex split 
https://www.gnu.org/software/auctex/manual/reftex/\nreftex mono 
https://www.gnu.org/software/auctex/manual/reftex.html\n"; > 
.texinfo/htmlxref.cnf \
        && ./gendocs.sh --email address@hidden --texi2html \
          --html --use-nodes auctex "AUCTeX Manual" \
        && ./gendocs.sh --email address@hidden --texi2html \
diff --git a/RELEASE b/RELEASE
index 7d540e4..c64bf1f 100644
--- a/RELEASE
+++ b/RELEASE
@@ -48,7 +48,7 @@ Availability
 The easiest way for getting AUCTeX is installing it with GNU ELPA, see
 <URL:https://elpa.gnu.org/packages/auctex.html> for more information.
 Other download options are available at
-<URL:ftp://ftp.gnu.org/gnu/auctex/>.  At release time, we provide the
+<URL:https://ftp.gnu.org/gnu/auctex/>.  At release time, we provide the
 source tarball.  You can also use versions of Emacs that already
 include AUCTeX or a software package management system for your
 operating system which provides you with the latest release.
@@ -59,7 +59,7 @@ The download area is mirrored to the directory support/auctex 
on CTAN.
 AUCTeX is licensed under the GNU General Public License version 3.
 
 You'll find more information at the web site of AUCTeX
-<URL:http://www.gnu.org/software/auctex/>, including its mailing list
+<URL:https://www.gnu.org/software/auctex/>, including its mailing list
 addresses.
 
 Future development and additional information
@@ -95,7 +95,7 @@ we forgot somebody.)
 
 Footnotes:
 
-[1]  <URL:ftp://ftp.dante.de/tex-archive/macros/latex/contrib/preview/>
+[1]  <URL:https://www.ctan.org/pkg/preview>
 
 [2]  dvipng is available via its project page
-<URL:http://savannah.nongnu.org/projects/dvipng> and from CTAN.
+<URL:https://savannah.nongnu.org/projects/dvipng> and from CTAN.
diff --git a/auctex.spec b/auctex.spec
index a482661..286dd4b 100644
--- a/auctex.spec
+++ b/auctex.spec
@@ -2,7 +2,7 @@
 
 # Maintainer: address@hidden
 
-# Copyright (C) 2002, 2004, 2005, 2006 Free Software Foundation, Inc.
+# Copyright (C) 2002, 2004-2006, 2018 Free Software Foundation, Inc.
 
 # This file is part of AUCTeX.
 
@@ -27,22 +27,20 @@
 %define distri       .suse
 %define commongroup  Productivity/Editors/Emacs
 %define texgroup     Productivity/Publishing/TeX/Utilities
-%define xemacspkgdir %{_datadir}/xemacs/xemacs-packages
 %else
 %define distri       .fedora
 %define commongroup  Applications/Editors
 %define texgroup     Applications/Publishing
-%define xemacspkgdir %{_datadir}/xemacs/site-packages
 %endif
 
 Summary:       Enhanced TeX modes for Emacsen
 Name:          auctex
-Version:       11.86
+Version:       12.1
 Release:       1%{distri}
 License:       GPL
 Group:                 %{commongroup}
-URL:           http://www.gnu.org/software/auctex/
-Source0:        ftp://ftp.gnu.org/pub/gnu/auctex/%{name}-%{version}.tar.gz
+URL:           https://www.gnu.org/software/auctex/
+Source0:        https://ftp.gnu.org/pub/gnu/auctex/%{name}-%{version}.tar.gz
 BuildArchitectures: noarch
 BuildRoot:     %{_tmppath}/%{name}-root
 
@@ -63,7 +61,7 @@ source buffer.
 %package emacs
 Summary:       Enhanced TeX modes for GNU Emacs
 Group:          %{commongroup}
-Requires:      emacs >= 21
+Requires:      emacs >= 24
 Obsoletes:      ge_auc emacs-auctex auctex preview-latex-emacs
 Conflicts:      emacspeak < 18
 Provides:       auctex
@@ -78,8 +76,7 @@ Texinfo and basic support for ConTeXt.  Documentation can be 
found under
 manual is available in Emacs info (C-h i d m AUCTeX RET).  On the AUCTeX home
 page, we provide manuals in various formats.
 
-This package is for GNU Emacs.  XEmacs users should use the package system for
-installation.
+This package is for GNU Emacs.  XEmacs is no longer supported.
 
 The package enables AUCTeX modes system-wide.  The README file
 contains information how users may override this choice.
diff --git a/bib-cite.el b/bib-cite.el
index 5cb8a1d..2a7e74c 100644
--- a/bib-cite.el
+++ b/bib-cite.el
@@ -37,9 +37,9 @@
 ;; associated with \cite commands, or matching \ref and \label commands.
 
 ;; New versions of this package (if they exist) may be found at:
-;;   http://people.debian.org/~psg/elisp/bib-cite.el
+;;   https://people.debian.org/~psg/elisp/bib-cite.el
 ;; and in AUCTeX's Git archive at
-;;   http://git.savannah.gnu.org/cgit/auctex.git
+;;   https://git.savannah.gnu.org/cgit/auctex.git
 
 ;; Operating Systems:
 ;;  Works in unix, DOS and OS/2.  Developped under Linux.
@@ -47,10 +47,10 @@
 ;; AUCTeX users:
 ;;  AUCTeX is a super-charged LaTeX mode for emacs. Get it at:
 ;;
-;;    ftp://ftp.gnu.org/pub/gnu/auctex/
+;;    https://ftp.gnu.org/pub/gnu/auctex/
 ;;
 ;;  WWW users may want to check out the AUCTeX page at
-;;    http://www.gnu.org/software/auctex/
+;;    https://www.gnu.org/software/auctex/
 ;;
 ;;  bib-cite.el is included in the AUCTeX distribution.  Therefore, if
 ;;  you use AUCTeX and didn't obtained bib-cite.el separately, make sure
@@ -73,7 +73,7 @@
 ;;  Multifile documents are supported by bib-cite by using etags (TAGS files)
 ;;  which contains a bug for MSDOS (at least for emacs 19.27 it does).
 ;;  Get the file
-;;    http://people.debian.org/~psg/elisp/bib-cite.etags-bug-report
+;;    https://people.debian.org/~psg/elisp/bib-cite.etags-bug-report
 ;;  to see what patches to make to etags.c to fix it.
 
 ;; Description:
@@ -219,7 +219,7 @@
 ;; Installation instructions:
 ;; ~~~~~~~~~~~~~~~~~~~~~~~~~
 ;;  bib-cite is a minor-mode, so you could invoke it in a LaTeX-mode hook.
-;;  e.g. If you are using AUCTeX (http://www.gnu.org/software/auctex/), you
+;;  e.g. If you are using AUCTeX (https://www.gnu.org/software/auctex/), you
 ;;  could use:
 ;;
 ;;   (autoload 'turn-on-bib-cite "bib-cite")
diff --git a/build-aux/gitlog-to-auctexlog b/build-aux/gitlog-to-auctexlog
index 1159748..808597d 100755
--- a/build-aux/gitlog-to-auctexlog
+++ b/build-aux/gitlog-to-auctexlog
@@ -18,7 +18,7 @@
 # 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/>.
+# along with this program.  If not, see <https://www.gnu.org/licenses/>.
 
 LC_ALL=C
 export LC_ALL
diff --git a/build-aux/gitlog-to-changelog b/build-aux/gitlog-to-changelog
index a0e0a05..bb989fb 100755
--- a/build-aux/gitlog-to-changelog
+++ b/build-aux/gitlog-to-changelog
@@ -22,7 +22,7 @@ my $VERSION = '2015-06-11 01:03'; # UTC
 # 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/>.
+# along with this program.  If not, see <https://www.gnu.org/licenses/>.
 
 # Written by Jim Meyering
 
@@ -33,7 +33,7 @@ use POSIX qw(strftime);
 
 (my $ME = $0) =~ s|.*/||;
 
-# use File::Coda; # http://meyering.net/code/Coda/
+# use File::Coda; # https://meyering.net/code/Coda/
 END {
   defined fileno STDOUT or return;
   close STDOUT and return;
@@ -484,7 +484,7 @@ sub git_dir_option($)
 # Local Variables:
 # mode: perl
 # indent-tabs-mode: nil
-# eval: (add-hook 'write-file-hooks 'time-stamp)
+# eval: (add-hook 'before-save-hook 'time-stamp nil t)
 # time-stamp-start: "my $VERSION = '"
 # time-stamp-format: "%:y-%02m-%02d %02H:%02M"
 # time-stamp-time-zone: "UTC"
diff --git a/doc/auctex.texi b/doc/auctex.texi
index e861a75..9761ba7 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-2017
+Copyright @copyright{} 1992-1995, 2001, 2002, 2004-2018
 Free Software Foundation, Inc.
 
 @quotation
@@ -3237,6 +3237,7 @@ be the default command to convert the @acronym{PS} file to
 @code{"Dvipdfmx"}: the @acronym{DVI} file is converted to @acronym{PDF}
 with @command{dvipdfmx}.
 @end itemize
+(case is significant; note the uppercase ``D'' in both strings)
 When the @acronym{PDF} file is finally ready, the next suggested command
 will be to open the viewer.
 
@@ -3861,9 +3862,9 @@ Each of the two utilities @code{lacheck} and 
@code{chktex} will find
 some errors the other doesn't, but @code{chktex} is more configurable,
 allowing you to create your own errors.  You may need to install the
 programs before using them.  You can get @code{lacheck} from
address@hidden<URL:ftp://ftp.ctan.org/tex-archive/support/lacheck/>} and
address@hidden<URL:https://www.ctan.org/pkg/lacheck>} and
 @code{chktex} from
address@hidden<URL:ftp://ftp.ctan.org/tex-archive/support/chktex/>}.
address@hidden<URL:https://www.ctan.org/pkg/chktex>}.
 
 @node Control
 @section Controlling the output
@@ -4714,16 +4715,13 @@ If non-nil, used for decoding output from Japanese 
@TeX{} process.
 When @code{nil}, @AUCTeX{} tries to choose suitable coding system.
 @end defopt
 
-The former customize options @code{japanese-TeX-command-default} and
address@hidden are removed from @AUCTeX{}.  Use
+The former customize options @code{japanese-TeX-command-default},
address@hidden and
address@hidden are removed from @AUCTeX{}.  Use
 @code{japanese-TeX-engine-default} instead.  If you need to customize
 the executable file name such as @samp{"latex"}, the options for them,
 or both, customize @code{TeX-engine-alist}.
 
-Also, the option @code{japanese-TeX-command-list} is considered as
-semi-obsolete.  It still functions as before, but in theory, it is not
-required anymore in normal use.
-
 The following two additional font commands are available in
 @LaTeX{} mode buffer.
 
diff --git a/doc/changes.texi b/doc/changes.texi
index bddec6a..3e3f417 100644
--- a/doc/changes.texi
+++ b/doc/changes.texi
@@ -8,18 +8,10 @@
 
 @end ifset
 
address@hidden News in 12.1
address@hidden News in 12.2
 
 @itemize @bullet
 @item
address@hidden now requires GNU Emacs 24 or higher.  Support for XEmacs has
-been dropped.
-
address@hidden
-Besides the change in the supported version of Emacs, there has been no
-functional change in this release, which is equivalent to version 11.92.
-
address@hidden
 @AUCTeX{} has support for the Flymake package in Emacs 26 or newer.  To
 enable, call @kbd{M-x flymake-mode RET} or add this to your
 @file{.emacs} file:
@@ -27,6 +19,39 @@ enable, call @kbd{M-x flymake-mode RET} or add this to your
 (add-hook 'LaTeX-mode-hook #'flymake-mode)
 @end lisp
 
address@hidden
+The way the option @code{TeX-record-buffer} is used was corrected.  It
+was used in just the opposite way as the document says.  Erase the
+customization if you have customized this option since it now acts in
+reverse to your expectation.
+
address@hidden
+A former customize option @code{japanese-TeX-command-list} is removed.
+Use @code{japanese-TeX-engine-default}, or if it's really necessary,
+customize @code{TeX-command-list} directly if the task which the option
+used to carry is required.
+
address@hidden
+Support for standard @LaTeX{} without address@hidden extension is now very
+limited.  It doesn't work if raw @TeX{} code is put on the command line
+to invoke latex command.  It also fails for region compilation (@kbd{C-c
+C-r} and so on) with documents of non-ascii file name.  In addition, it
+no longer works with @previewlatex{}.  We consider this incompatibility
+is permissible because address@hidden extension is enabled for standard
address@hidden by default long ago.  @LaTeX{} variants such as address@hidden 
and
address@hidden are not affected.
address@hidden itemize
+
address@hidden News in 12.1
+
address@hidden @bullet
address@hidden
address@hidden now requires GNU Emacs 24 or higher.  Support for XEmacs has
+been dropped.
+
address@hidden
+Besides the change in the supported version of Emacs, there has been no
+functional change in this release, which is equivalent to version 11.92.
 @end itemize
 
 @heading News in 11.92
diff --git a/doc/fdl.texi b/doc/fdl.texi
index ca18562..d30721c 100644
--- a/doc/fdl.texi
+++ b/doc/fdl.texi
@@ -6,7 +6,7 @@
 
 @display
 Copyright @copyright{} 2000, 2001, 2002, 2007, 2008 Free Software
-Foundation, Inc.  @uref{http://fsf.org/}
+Foundation, Inc.  @uref{https://fsf.org/}
 
 Everyone is permitted to copy and distribute verbatim copies
 of this license document, but changing it is not allowed.
@@ -414,7 +414,7 @@ The Free Software Foundation may publish new, revised 
versions
 of the GNU Free Documentation License from time to time.  Such new
 versions will be similar in spirit to the present version, but may
 differ in detail to address new problems or concerns.  See
address@hidden://www.gnu.org/copyleft/}.
address@hidden://www.gnu.org/licenses/}.
 
 Each version of the License is given a distinguishing version number.
 If the Document specifies that a particular numbered version of this
diff --git a/doc/install.texi b/doc/install.texi
index 8b9c1d0..d45d1d2 100644
--- a/doc/install.texi
+++ b/doc/install.texi
@@ -1,6 +1,6 @@
 @c This is part of the AUCTeX Manual.
 @c Copyright (C) 1994, 1996, 2003-2007, 2012-2013,
address@hidden               2015, 2017  Free Software Foundation, Inc.
address@hidden               2015, 2017, 2018  Free Software Foundation, Inc.
 @c See the file auctex.texi for copying conditions.
 @ifset rawfile
 @include macros.texi
@@ -93,10 +93,10 @@ support.
 @table @b
 @item Windows
 Precompiled versions are available from
address@hidden://ftp.gnu.org/gnu/emacs/windows/}.
address@hidden://ftp.gnu.org/gnu/emacs/windows/}.
 @item Mac OS X
 For an overview of precompiled versions of Emacs for Mac OS X see for
-example @uref{http://www.emacswiki.org/cgi-bin/wiki/EmacsForMacOS}.
+example @uref{https://www.emacswiki.org/emacs/EmacsForMacOS}.
 @item GNU/Linux
 Most GNU/Linux distributions nowadays provide a recent variant of Emacs
 via their package repositories.
@@ -297,7 +297,7 @@ into system directories.
 
 You can detect the successful activation of @AUCTeX{} and
 @previewlatex{} in the menus after loading a @LaTeX{} file like
address@hidden/circ.tex}: @AUCTeX{} then gives you a @samp{Command} menu,
address@hidden: @AUCTeX{} then gives you a @samp{Command} menu,
 and @previewlatex{} gives you a @samp{Preview} menu.
 
 @cindex @file{auctex.el}
diff --git a/doc/intro.texi b/doc/intro.texi
index 4a173c3..0bbf739 100644
--- a/doc/intro.texi
+++ b/doc/intro.texi
@@ -4,7 +4,7 @@
 This is the README file for the AUCTeX distribution.
 
 @quotation
-Copyright (C) 2008, 2017 Free Software Foundation, Inc.
+Copyright (C) 2008, 2017, 2018 Free Software Foundation, Inc.
 
 Copying and distribution of this file, with or without modification, are
 permitted in any medium without royalty provided the copyright notice
@@ -68,10 +68,10 @@ add new features for your own needs.  It is a GNU project 
and
 distributed under the `GNU General Public License Version 3'.
 
 The most recent version is always available at
address@hidden://ftp.gnu.org/pub/gnu/auctex/}.
address@hidden://ftp.gnu.org/pub/gnu/auctex/}.
 
 WWW users may want to check out the @AUCTeX{} page at
address@hidden://www.gnu.org/software/auctex/}.
address@hidden://www.gnu.org/software/auctex/}.
 
 For comprehensive information about how to install @AUCTeX{}
 @ifset rawfile
diff --git a/doc/preview-latex.texi b/doc/preview-latex.texi
index 39eed39..2d4941c 100644
--- a/doc/preview-latex.texi
+++ b/doc/preview-latex.texi
@@ -10,7 +10,7 @@ This manual is for preview-latex, a @LaTeX{} preview mode for 
@AUCTeX{}
 (version @value{VERSION} from @value{UPDATED}).
 
 Copyright @copyright{} 2001, 2002, 2003,
-2004, 2005, 2006, 2017 Free Software Foundation, Inc.
+2004, 2005, 2006, 2017, 2018 Free Software Foundation, Inc.
 
 @quotation
 Permission is granted to copy, distribute and/or modify this document
@@ -295,6 +295,18 @@ done from within Emacs, but it will not notice if the 
preamble
 effectively changes because some included file or style file is
 tampered with.
 
+Note that support for preamble cache is limited for @LaTeX{} variants.
+c.f. @file{<URL:https://github.com/davidcarlisle/dpctex/issues/15>}
address@hidden @bullet
address@hidden
address@hidden cannot use preamble cache at all.  The reason is intrinsic in
address@hidden, so @previewlatex{} can't help.
address@hidden
address@hidden works with preamble cache only when the preamble is simple
+enough, i.e., when it doesn't load opentype fonts and it doesn't use lua
+codes in preamble.
address@hidden itemize
+
 @item @kbd{C-c C-p C-c C-f}
 @itemx @code{preview-cache-preamble-off}
 @itemx Preview/Turn preamble cache off
@@ -710,6 +722,12 @@ if the @acronym{DVI} file contains PostScript specials in 
which case the
 affected images will get run through Dvips and Ghostscript once
 @samp{dvipng} finishes.
 
+Note for address@hidden and address@hidden users: It is known that 
@code{dvipng}
+is not compatible with address@hidden and address@hidden  If
address@hidden is set to @samp{dvipng} and (u)address@hidden is
+used, @samp{dvipng} just fails and @previewlatex{} falls back on Dvips
+and Ghostscript.
+
 @item preview-gs-options
 Most interesting to the user perhaps is the setting of this variable.
 It contains the default antialiasing settings @option{-dTextAlphaBits=4}
diff --git a/doc/preview-readme.texi b/doc/preview-readme.texi
index 2f2227f..26f8fa1 100644
--- a/doc/preview-readme.texi
+++ b/doc/preview-readme.texi
@@ -135,7 +135,7 @@ converting @acronym{DVI} files and Ghostscript (with a 
@samp{PNG}
 device) for converting @acronym{PDF} files.  @samp{dvipng} is much
 faster than the combination of Dvips and Ghostscript.  You can get
 downloads, access to its @acronym{CVS} archive and further information
-from its @uref{http://savannah.nongnu.org/projects/dvipng, project
+from its @uref{https://savannah.nongnu.org/projects/dvipng, project
 site}.
 
 @node More documentation, Availability, Basic modes of operation, Introduction
@@ -191,9 +191,9 @@ will display it.
 @cindex @sc{git} access
 
 The @previewlatex{} project is now part of @AUCTeX{} and accessible as
-part of the @uref{http://savannah.gnu.org/projects/auctex,@AUCTeX{}
+part of the @uref{https://savannah.gnu.org/projects/auctex,@AUCTeX{}
 project page}.  You can get its files from the
address@hidden://ftp.gnu.org/pub/gnu/auctex,@AUCTeX{} download area}.  As of
address@hidden://ftp.gnu.org/pub/gnu/auctex/,@AUCTeX{} download area}.  As of
 @address@hidden 11.81}, @previewlatex{} should already be integrated into
 @AUCTeX{}, so no separate download will be necessary.
 
@@ -212,7 +212,7 @@ bugs to @email{bug-auctex@@gnu.org}.
 
 There is a general discussion list for @AUCTeX{} which also
 covers @previewlatex{}, look at
address@hidden://lists.gnu.org/mailman/listinfo/auctex}.  For more
address@hidden://lists.gnu.org/mailman/listinfo/auctex}.  For more
 information on the mailing list, send a message with just the word
 ``help'' as subject or body to @email{auctex-request@@gnu.org}.  For the
 developers, there is the @email{auctex-devel@@gnu.org} list; it would
diff --git a/doc/wininstall.texi b/doc/wininstall.texi
index f29f413..f91f0ef 100644
--- a/doc/wininstall.texi
+++ b/doc/wininstall.texi
@@ -1,5 +1,5 @@
 @c This is part of the AUCTeX Manual.
address@hidden Copyright (C) 2003, 2004, 2005, 2006, 2007, 2009
address@hidden Copyright (C) 2003-2007, 2009, 2018
 @c   Free Software Foundation, Inc.
 @c See the file auctex.texi for copying conditions.
 @ifset rawfile
@@ -138,7 +138,7 @@ should provide you with a working @samp{unzip} command.
 @item
 The installation of @AUCTeX{} will require the MSYS tool set from
 @uref{http://www.mingw.org/} or the Cygwin tool set from
address@hidden://cygwin.com/}.  The latter is slower and larger (the download
address@hidden://cygwin.com/}.  The latter is slower and larger (the download
 size of the base system is about 15 MB) but comes with a package manager
 that allows for updating the tool set and installing additional packages
 like, for example, the spell checker @w{aspell}.
@@ -150,16 +150,16 @@ headaches, @emph{if} things don't work out.
 
 @item
 Install a current version of @w{Emacs} from
address@hidden://ftp.gnu.org/gnu/emacs/windows/}.
address@hidden://ftp.gnu.org/gnu/emacs/windows/}.
 
 @item
 You need a working @TeX{} installation.  One popular installation under
-Windows is @uref{http://www.miktex.org,address@hidden  Another much more
-extensive system is @uref{http://www.tug.org/texlive,@address@hidden Live}}
+Windows is @uref{https://miktex.org/,address@hidden  Another much more
+extensive system is @uref{https://www.tug.org/texlive/,@address@hidden Live}}
 which is rather close to its Unix cousins.
 
 @item
-A working copy of @uref{http://www.cs.wisc.edu/~ghost/,Ghostscript} is
+A working copy of @uref{https://www.ghostscript.com/,Ghostscript} is
 required for @previewlatex{} operation.  Examining the output from
 @example
 gswin32c -h
@@ -169,7 +169,7 @@ supports the @code{png16m} device needed for @acronym{PNG} 
support.
 MiKTeX apparently comes with its own Ghostscript called @samp{mgs.exe}.
 
 @item
address@hidden://www.perl.org,Perl} is needed for rebuilding the
address@hidden://www.perl.org/,Perl} is needed for rebuilding the
 documentation if you are working with a copy from @acronym{Git} or have
 touched documentation source files in the @previewlatex{} part.  If the
 line endings of the file @file{preview/latex/preview.dtx} don't
@@ -333,8 +333,8 @@ choose another image format to be used by @previewlatex{}.
 
 Adding support for an image format usually involves the installation of
 a library, e.g. from @uref{http://gnuwin32.sf.net/}.  If you got your
-Emacs from @uref{http://www.gnu.org} you might want to check its
address@hidden://ftp.gnu.org/gnu/emacs/windows/README,README file} for
+Emacs from @uref{https://www.gnu.org/} you might want to check its
address@hidden://ftp.gnu.org/gnu/emacs/windows/README,README file} for
 details.
 
 A different image format can be chosen by setting the variable
diff --git a/latex.el b/latex.el
index 9df3d52..3315614 100644
--- a/latex.el
+++ b/latex.el
@@ -1626,7 +1626,7 @@ Split the string at commas and remove Biber file 
extensions."
     (dolist (bib bibs)
       (LaTeX-add-bibliographies (TeX-replace-regexp-in-string
                                 (concat "\\(?:\\."
-                                        (mapconcat #'regexp-quote
+                                        (mapconcat #'identity
                                                    TeX-Biber-file-extensions
                                                    "\\|\\.")
                                         "\\)")
@@ -1932,7 +1932,10 @@ defined and ask user for confirmation before proceeding."
                  (assoc label (LaTeX-label-list)))
             (ding)
             (when (y-or-n-p
-                   (format-message "Label `%s' exists. Use anyway? " label))
+                   ;; Emacs 24 compatibility
+                   (if (fboundp 'format-message)
+                       (format-message "Label `%s' exists. Use anyway? " label)
+                     (format "Label `%s' exists. Use anyway? " label)))
               (setq valid t)))
            (t
             (setq valid t))))
diff --git a/latex/README b/latex/README
index 0d0e8a8..772f7b6 100644
--- a/latex/README
+++ b/latex/README
@@ -22,13 +22,13 @@ Availability
 
 The preview package is being developed along and distributed with
 AUCTeX.  It can therefore be obtained as part of AUCTeX distribution
-files available at <URL:ftp://ftp.gnu.org/pub/gnu/auctex/> or its
+files available at <URL:https://ftp.gnu.org/pub/gnu/auctex/> or its
 mirror at <CTAN:support/auctex>.  CTAN also provides a standalone
 version at <CTAN:macros/latex/contrib/preview>.  The project page at
-<URL:http://savannah.gnu.org/projects/auctex/> offers downloads and
+<URL:https://savannah.gnu.org/projects/auctex/> offers downloads and
 anonymous CVS access for cutting edge versions.  For more information
 about the preview package please refer to the home page of AUCTeX at
-<URL:http://www.gnu.org/software/auctex/>.
+<URL:https://www.gnu.org/software/auctex/>.
 
 Installation
 ------------
diff --git a/latex/preview.dtx b/latex/preview.dtx
index a0d8b6f..b6f109f 100644
--- a/latex/preview.dtx
+++ b/latex/preview.dtx
@@ -1,6 +1,6 @@
 % \iffalse
 %%    The preview style for extracting previews from LaTeX documents.
-%%    Developed as part of AUCTeX <URL:http://www.gnu.org/software/auctex>.
+%%    Developed as part of AUCTeX <URL:https://www.gnu.org/software/auctex/>.
 %
 %     Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006,
 %                   2010, 2017 Free Software Foundation
diff --git a/multi-prompt.el b/multi-prompt.el
index 66072c6..8337ebc 100644
--- a/multi-prompt.el
+++ b/multi-prompt.el
@@ -11,15 +11,16 @@
 ;; it under the terms of the GNU General Public License as published by
 ;; the Free Software Foundation; either version 3, or (at your option)
 ;; any later version.
-;; 
+;;
 ;; This program is distributed in the hope that it will be useful,
 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 ;; GNU General Public License for more details.
-;; 
+;;
 ;; You should have received a copy of the GNU General Public License
-;; along with this program; if not, write to the Free Software
-;; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+;; along with AUCTeX; see the file COPYING.  If not, write to the Free
+;; Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+;; MA 02110-1301 USA.
 
 ;;; Commentary:
 
diff --git a/plain-tex.el b/plain-tex.el
index 99df58a..4c26abf 100644
--- a/plain-tex.el
+++ b/plain-tex.el
@@ -1,6 +1,6 @@
 ;;; plain-tex.el --- Support for plain TeX documents.
 
-;; Copyright (C) 2010, 2013, 2016-2017  Free Software Foundation, Inc.
+;; Copyright (C) 2010, 2013, 2016-2018  Free Software Foundation, Inc.
 
 ;; Maintainer: address@hidden
 ;; Keywords: tex
@@ -282,14 +282,19 @@ i.e. you do _not_ have to cater for this yourself by 
adding \\\\' or $."
 ;; Menu for AmSTeX mode
 (easy-menu-define AmSTeX-mode-command-menu
     AmSTeX-mode-map
-    "Command menu used in AmsTeX mode."
+    "Command menu used in AmSTeX mode."
     (TeX-mode-specific-command-menu 'ams-tex-mode))
 
 (easy-menu-define AmSTeX-mode-menu
   AmSTeX-mode-map
-  "Menu used in AMS-TeX mode."
+  "Menu used in AmSTeX mode."
   (cons "AmS-TeX" plain-TeX-menu-entries))
 
+(defcustom AmS-TeX-mode-hook nil
+  "A hook run in AmS-TeX mode buffers."
+  :type 'hook
+  :group 'TeX-misc)
+
 ;;;###autoload
 (defun ams-tex-mode ()
   "Major mode in AUCTeX for editing AmS-TeX files.
@@ -315,6 +320,21 @@ of `AmS-TeX-mode-hook'."
   (TeX-run-mode-hooks 'text-mode-hook 'TeX-mode-hook 'AmS-TeX-mode-hook)
   (TeX-set-mode-name))
 
+(defcustom AmSTeX-clean-intermediate-suffixes
+  TeX-clean-default-intermediate-suffixes
+  "List of regexps matching suffixes of intermediate files to be deleted.
+The regexps will be anchored at the end of the file name to be matched,
+i.e. you do _not_ have to cater for this yourself by adding \\\\' or $."
+  :type '(repeat regexp)
+  :group 'TeX-command)
+
+(defcustom AmSTeX-clean-output-suffixes TeX-clean-default-output-suffixes
+  "List of regexps matching suffixes of output files to be deleted.
+The regexps will be anchored at the end of the file name to be matched,
+i.e. you do _not_ have to cater for this yourself by adding \\\\' or $."
+  :type '(repeat regexp)
+  :group 'TeX-command)
+
 (provide 'plain-tex)
 
 ;;; plain-tex.el ends here
diff --git a/preview.el b/preview.el
index 06736a0..63c9dee 100644
--- a/preview.el
+++ b/preview.el
@@ -1,6 +1,7 @@
 ;;; preview.el --- embed preview LaTeX images in source buffer
 
-;; Copyright (C) 2001-2006, 2010-2015, 2017  Free Software Foundation, Inc.
+;; Copyright (C) 2001-2006, 2010-2015,
+;;               2017, 2018  Free Software Foundation, Inc.
 
 ;; Author: David Kastrup
 ;; Keywords: tex, wp, convenience
@@ -61,7 +62,7 @@ preview-latex's bug reporting commands will probably not 
work.")))
   :prefix "preview-"
   :link '(custom-manual "(preview-latex)Top")
   :link '(info-link "(preview-latex)The Emacs interface")
-  :link '(url-link :tag "Homepage" "http://www.gnu.org/software/auctex/";))
+  :link '(url-link :tag "Homepage" "https://www.gnu.org/software/auctex/";))
 
 (defgroup preview-gs nil "Preview's Ghostscript renderer."
   :group 'preview
@@ -286,9 +287,6 @@ If `preview-fast-conversion' is set, this option is not
   :group 'preview-gs
   :type 'number)
 
-(defvar preview-coding-system nil
-  "Proper coding system to decode output from LaTeX process.")
-(make-variable-buffer-local 'preview-coding-system)
 (defvar preview-parsed-font-size nil
   "Font size as parsed from the log of LaTeX run.")
 (make-variable-buffer-local 'preview-parsed-font-size)
@@ -524,7 +522,7 @@ an explicit list of elements in the CDR, or a symbol to
 be consulted recursively.")
 
 (defcustom preview-dvipng-command
-  "dvipng -picky -noghostscript %d -o \"%m/prev%%03d.png\""
+  "dvipng -picky -noghostscript %d -o %m/prev%%03d.png"
   "*Command used for converting to separate PNG images.
 
 You might specify options for converting to other image types,
@@ -798,13 +796,13 @@ Pure borderless black-on-white will return an empty 
string."
        (border (aref colors 3)))
     (concat
      (and bg
-         (format "--bg 'rgb %s' "
+         (format "--bg \"rgb %s\" "
                  (mapconcat #'preview-gs-color-value bg " ")))
      (and fg
-         (format "--fg 'rgb %s' "
+         (format "--fg \"rgb %s\" "
                  (mapconcat #'preview-gs-color-value fg " ")))
      (and mask border
-         (format "--bd 'rgb %s' "
+         (format "--bd \"rgb %s\" "
                  (mapconcat #'preview-gs-color-value mask " ")))
      (and border
          (format "--bd %d" (max 1 (round (/ (* res border) 72.0))))))))
@@ -2219,7 +2217,14 @@ list of LaTeX commands is inserted just before 
\\begin{document}."
 (defcustom preview-LaTeX-command '("%`%l \"\\nonstopmode\\nofiles\
 \\PassOptionsToPackage{" ("," . preview-required-option-list) "}{preview}\
 \\AtBeginDocument{\\ifx\\ifPreview\\undefined"
-preview-default-preamble "\\fi}\"%' %t")
+preview-default-preamble "\\fi}\"%' \"{\\detokenize{\" %t \"}}\"")
+  ;; Since TeXLive 2018, the default encoding for LaTeX files has been
+  ;; changed to UTF-8 if used with classic TeX or pdfTeX.  I.e.,
+  ;; \usepackage[utf8]{inputenc} is enabled by default in (pdf)latex.
+  ;; c.f. LaTeX News issue 28
+  ;; Due to this change, \detokenize is required to recognize
+  ;; non-ascii characters in the file name when \input is supplemented
+  ;; implicitly by %`-%' pair.
   "*Command used for starting a preview.
 See description of `TeX-command-list' for details."
   :group 'preview-latex
@@ -2599,14 +2604,11 @@ later while in use."
     ("Tightpage" preview-parsed-tightpage
      "\\` *\\(-?[0-9]+ *\\)\\{4\\}\\'" 0 preview-parse-tightpage)))
 
-(defun preview-error-quote (string run-coding-system)
+(defun preview-error-quote (string)
   "Turn STRING with potential ^^ sequences into a regexp.
 To preserve sanity, additional ^ prefixes are matched literally,
 so the character represented by ^^^ preceding extended characters
-will not get matched, usually.
-
-If decoding the process output was suppressed during receiving,
-decode first with RUN-CODING-SYSTEM."
+will not get matched, usually."
   (let (output case-fold-search)
     ;; Some coding systems (e.g. japanese-shift-jis) use regexp meta
     ;; characters on encoding.  Such meta characters would be
@@ -2614,19 +2616,12 @@ decode first with RUN-CODING-SYSTEM."
     ;; "encoding entire string beforehand and decoding it at the last
     ;; stage" does not work for such coding systems.
     ;; Rather, we work consistently with decoded text.
-    (if (and (featurep 'mule)
-            (not (eq run-coding-system
-                     (preview-buffer-recode-system run-coding-system))))
-       (setq string
-             (decode-coding-string string run-coding-system)))
-
-    ;; Next, bytes with value from 0x80 to 0xFF represented with ^^
-    ;; form are converted to byte sequence, and decoded by the file
-    ;; coding system.
+
+    ;; Bytes with value from 0x80 to 0xFF represented with ^^ form are
+    ;; converted to byte sequence, and decoded by the file coding
+    ;; system.
     (setq string
-         (preview--decode-^^ab string
-                               (if (featurep 'mule)
-                                   buffer-file-coding-system nil)))
+         (preview--decode-^^ab string buffer-file-coding-system))
 
     ;; Then, control characters are taken into account.
     (while (string-match "\\^\\{2,\\}\\(address@hidden)" string)
@@ -2665,9 +2660,7 @@ Return a new string."
                           (save-match-data
                             (preview--convert-^^ab
                              (match-string 0 string)))))
-                     (if (featurep 'mule)
-                         (decode-coding-string text coding-system)
-                       text)))
+                     (decode-coding-string text coding-system)))
            string (substring string (match-end 0))))
     (setq result (concat result string))
     result))
@@ -2686,12 +2679,7 @@ Return a new string."
                                 (substring string
                                            (+ (match-beginning 0) 2)
                                            (match-end 0)) 16)))
-                     ;; `char-to-string' is not appropriate in
-                     ;; Emacs >= 23 because it converts #xAB into
-                     ;; "\u00AB" (multibyte string), not "\xAB"
-                     ;; (raw 8bit unibyte string).
-                     (if (fboundp 'byte-to-string)
-                         (byte-to-string byte) (char-to-string byte))))
+                     (byte-to-string byte)))
            string (substring string (match-end 0))))
     (setq result (concat result string))
     result))
@@ -2712,7 +2700,6 @@ call, and in its CDR the final stuff for the placement 
hook."
          offset
          parsestate (case-fold-search nil)
          (run-buffer (current-buffer))
-         (run-coding-system preview-coding-system)
          (run-directory default-directory)
          tempdir
          close-data
@@ -2956,13 +2943,11 @@ name(\\([^)]+\\))\\)\\|\
                         (concat "\\("
                                 (setq string
                                       (preview-error-quote
-                                       string
-                                       run-coding-system))
+                                       string))
                                 "\\)"
                                 (setq after-string
                                       (preview-error-quote
-                                       after-string
-                                       run-coding-system)))
+                                       after-string)))
                         (line-end-position) t)
                        (goto-char (match-end 1)))
                       ((search-forward-regexp
@@ -3283,9 +3268,11 @@ This is passed through `preview-do-replacements'."
 
 (defcustom preview-dump-replacements
   '(preview-LaTeX-command-replacements
+  ;; If -kanji option exists, pick it up as the second match.
+  ;; Discard all other options.
     ("\\`\\([^ ]+\\)\
-\\(\\( +-\\([^ \\\\\"]\\|\\\\\\.\\|\"[^\"]*\"\\)*\\)*\\)\\(.*\\)\\'"
-     . ("\\1 -ini -interaction=nonstopmode \"&\\1\" " preview-format-name 
".ini \\5")))
+\\(?: +\\(?:\\(--?kanji[= ][^ ]+\\)\\|-\\(?:[^ 
\\\"]\\|\\\\.\\|\"[^\"]*\"\\)*\\)\\)*\\(.*\\)\\'"
+     . ("\\1 -ini \\2 -interaction=nonstopmode \"&\\1\" " preview-format-name 
".ini \\3")))
   "Generate a dump command from the usual preview command."
   :group 'preview-latex
   :type '(repeat
@@ -3293,9 +3280,16 @@ This is passed through `preview-do-replacements'."
                  (cons string (repeat (choice symbol string))))))
 
 (defcustom preview-undump-replacements
+  ;; If -kanji option exists, pick it up as the second match.
+  ;; Discard all other options.
   '(("\\`\\([^ ]+\\)\
- .*? \"\\\\input\" \\(.*\\)\\'"
-     . ("\\1 -interaction=nonstopmode \"&" preview-format-name "\" \\2")))
+\\(?: +\\(?:\\(--?kanji[= ][^ ]+\\)\\|-\\(?:[^ 
\\\"]\\|\\\\.\\|\"[^\"]*\"\\)*\\)\\)*.*\
+ \"\\\\input\" \"{\\\\detokenize{\" \\(.*\\) \"}}\"\\'"
+     . ("\\1 \\2 -interaction=nonstopmode -file-line-error "
+       preview-format-name " \"/AUCTEXINPUT{\" \\3 \"}\"")))
+  ;; See the ini file code below in `preview-cache-preamble' for the
+  ;; weird /AUCTEXINPUT construct.  In short, it is crafted so that
+  ;; dumped format file can read file of non-ascii name.
   "Use a dumped format for reading preamble."
   :group 'preview-latex
   :type '(repeat
@@ -3337,10 +3331,13 @@ If FORMAT-CONS is non-nil, a previous format may get 
reused."
        (push format-cons preview-dumped-alist))
       ;; mylatex.ltx expects a file name to follow.  Bad. `.tex'
       ;; in the tools bundle is an empty file.
-      (write-region "\\ifx\\pdfoutput\\undefined\\else\
-\\let\\PREVIEWdump\\dump\\def\\dump{%
-\\edef\\next{{\\catcode`\\ 9 \\pdfoutput=\\the\\pdfoutput\\relax\
-\\the\\everyjob}}\\everyjob\\next\\catcode`\\ 10 
\\let\\dump\\PREVIEWdump\\dump}\\fi\\input mylatex.ltx \\relax\n" nil dump-file)
+      (write-region "\\let\\PREVIEWdump\\dump\\def\\dump{%
+\\edef\\next{{\\ifx\\pdfoutput\\undefined\\else\
+\\pdfoutput=\\the\\pdfoutput\\relax\\fi\
+\\the\\everyjob}}\\everyjob\\next\\catcode`\\ 10 %
+\\catcode`/ 0 %
+\\def\\AUCTEXINPUT##1{\\catcode`/ 12\\relax\\catcode`\\ 
9\\relax\\input\\detokenize{##1}\\relax}%
+\\let\\dump\\PREVIEWdump\\dump}\\input mylatex.ltx \\relax%\n" nil dump-file)
       (TeX-save-document master)
       (prog1
          (preview-generate-preview
@@ -3527,8 +3524,9 @@ internal parameters, STR may be a log to insert into the 
current log."
   (set-buffer commandbuff)
   (let*
       ((preview-format-name (shell-quote-argument
-                            (preview-dump-file-name
-                             (file-name-nondirectory master))))
+                            (concat "&"
+                                    (preview-dump-file-name
+                                     (file-name-nondirectory master)))))
        (process-environment (copy-sequence process-environment))
        (process
        (progn
@@ -3541,15 +3539,7 @@ internal parameters, STR may be a log to insert into the 
current log."
           (if (consp (cdr dumped-cons))
               (preview-do-replacements
                command
-               (append preview-undump-replacements
-                       ;; Since the command options provided in
-                       ;; (TeX-engine-alist) are dropped, give them
-                       ;; back.
-                       (list (list "\\`\\([^ ]+\\)"
-                                   (TeX-command-expand "%(PDF)%(latex)"
-                                                       (if 
TeX-current-process-region-p
-                                                           #'TeX-region-file
-                                                         
#'TeX-master-file))))))
+               preview-undump-replacements)
             command) file))))
     (condition-case err
        (progn
@@ -3562,20 +3552,6 @@ internal parameters, STR may be a log to insert into the 
current log."
          (preview-set-geometry geometry)
          (setq preview-gs-file pr-file)
          (setq TeX-sentinel-function 'preview-TeX-inline-sentinel)
-         ;; Postpone decoding of process output for xemacs 21.4,
-         ;; which is rather bad at preserving incomplete multibyte
-         ;; characters.
-         (when (featurep 'mule)
-           ;; Get process coding system set in `TeX-run-command'.
-           (setq preview-coding-system (process-coding-system process))
-           ;; Substitute coding system for decode with `raw-text' if
-           ;; necessary and save the original coding system for
-           ;; decode for later use in `preview-error-quote'.
-           (set-process-coding-system process
-                                      (preview-buffer-recode-system
-                                       (car preview-coding-system))
-                                      (cdr preview-coding-system))
-           (setq preview-coding-system (car preview-coding-system)))
          (TeX-parse-reset)
          (setq TeX-parse-function 'TeX-parse-TeX)
          (if TeX-process-asynchronous
diff --git a/prv-emacs.el b/prv-emacs.el
index 9f40736..fe0f8f9 100644
--- a/prv-emacs.el
+++ b/prv-emacs.el
@@ -1,6 +1,6 @@
 ;;; prv-emacs.el --- GNU Emacs specific code for preview.el
 
-;; Copyright (C) 2001, 02, 03, 04, 05  Free Software Foundation, Inc.
+;; Copyright (C) 2001-2005, 2018  Free Software Foundation, Inc.
 
 ;; Author: David Kastrup
 ;; Keywords: convenience, tex, wp
@@ -369,12 +369,6 @@ purposes."
           event
         (posn-window (event-start event))))))
 
-(defsubst preview-buffer-recode-system (base)
-  "This is supposed to translate unrepresentable base encodings
-into something that can be used safely for byte streams in the
-run buffer.  A noop for Emacs."
-  base)
-
 (defun preview-mode-setup ()
   "Setup proper buffer hooks and behavior for previews."
   (set (make-local-variable 'desktop-save-buffer)
diff --git a/style/amsmath.el b/style/amsmath.el
index 7495d67..4a2a399 100644
--- a/style/amsmath.el
+++ b/style/amsmath.el
@@ -98,36 +98,35 @@
      '("lvert" TeX-arg-insert-right-brace-maybe)
      '("lVert" TeX-arg-insert-right-brace-maybe)
      "rvert" "rVert"
-     "iint" "iiint" "iiiint" "idotsint"
-     )
+     "iint" "iiint" "iiiint" "idotsint")
     
-    (setq  LaTeX-item-list 
-          (append '(("split"    . LaTeX-item-equation)
-                    ("multline" . LaTeX-item-equation)
-                    ("multline*" . LaTeX-item-equation)
-                    ("gather"   . LaTeX-item-equation)
-                    ("gather*"  . LaTeX-item-equation)
-                    ("gathered" . LaTeX-item-equation)
-                    ("align"    . LaTeX-item-equation)
-                    ("align*"   . LaTeX-item-equation)
-                    ("aligned"  . LaTeX-item-equation)
-                    ("alignat"  . LaTeX-item-equation-alignat)
-                    ("alignat*" . LaTeX-item-equation-alignat)
-                    ("xalignat"  . LaTeX-item-equation-alignat)
-                    ("xalignat*" . LaTeX-item-equation-alignat)
-                    ("xxalignat" . LaTeX-item-equation-alignat)
-                    ("alignedat" . LaTeX-item-equation-alignat)
-                    ("flalign"  . LaTeX-item-equation)
-                    ("flalign*" . LaTeX-item-equation)
-                    ("matrix" .  LaTeX-item-equation)
-                    ("pmatrix" .  LaTeX-item-equation)
-                    ("bmatrix" .  LaTeX-item-equation)
-                    ("Bmatrix" .  LaTeX-item-equation)
-                    ("vmatrix" .  LaTeX-item-equation)
-                    ("Vmatrix" .  LaTeX-item-equation)
-                    ("subarray" . LaTeX-item-equation)
-                    ("cases"    . LaTeX-item-equation))
-                  LaTeX-item-list))
+    (setq LaTeX-item-list
+         (append '(("split"    . LaTeX-item-equation)
+                   ("multline" . LaTeX-item-equation)
+                   ("multline*" . LaTeX-item-equation)
+                   ("gather"   . LaTeX-item-equation)
+                   ("gather*"  . LaTeX-item-equation)
+                   ("gathered" . LaTeX-item-equation)
+                   ("align"    . LaTeX-item-equation)
+                   ("align*"   . LaTeX-item-equation)
+                   ("aligned"  . LaTeX-item-equation)
+                   ("alignat"  . LaTeX-item-equation-alignat)
+                   ("alignat*" . LaTeX-item-equation-alignat)
+                   ("xalignat"  . LaTeX-item-equation-alignat)
+                   ("xalignat*" . LaTeX-item-equation-alignat)
+                   ("xxalignat" . LaTeX-item-equation-alignat)
+                   ("alignedat" . LaTeX-item-equation-alignat)
+                   ("flalign"  . LaTeX-item-equation)
+                   ("flalign*" . LaTeX-item-equation)
+                   ("matrix" .  LaTeX-item-equation)
+                   ("pmatrix" .  LaTeX-item-equation)
+                   ("bmatrix" .  LaTeX-item-equation)
+                   ("Bmatrix" .  LaTeX-item-equation)
+                   ("vmatrix" .  LaTeX-item-equation)
+                   ("Vmatrix" .  LaTeX-item-equation)
+                   ("subarray" . LaTeX-item-equation)
+                   ("cases"    . LaTeX-item-equation))
+                 LaTeX-item-list))
 
     ;; When `LaTeX-amsmath-label' is nil, use value of LaTeX-equation-label:
     (unless LaTeX-amsmath-label
@@ -156,9 +155,25 @@
     ;; So we run their hooks, too.
     (TeX-run-style-hooks "amstext" "amsbsy" "amsopn")
 
-    ;; If RefTeX is loaded, make it recognize the amsmath environments.
+    ;; RefTeX support: Tell RefTeX about amsmath environments.
     (when (fboundp 'reftex-add-to-label-alist)
-      (reftex-add-to-label-alist '(AMSTeX)))))
+      (reftex-add-to-label-alist '(AMSTeX)))
+
+    ;; Add \eqref to `reftex-ref-style-alist' and associate it to `e'
+    (when (and (boundp 'reftex-ref-style-alist)
+              ;; check if Emacs is already equipped with this
+              (not (assoc "AMSmath" reftex-ref-style-alist)))
+      ;; Append it to a local version in order to avoid a clash with
+      ;; user settings
+      (add-to-list (make-local-variable 'reftex-ref-style-alist)
+                  '("AMSmath" "amsmath" (("\\eqref" ?e)))
+                  t))
+
+    ;; Activate `AMSmath' when `LaTeX-reftex-ref-style-auto-activate'
+    ;; is non-nil
+    (and LaTeX-reftex-ref-style-auto-activate
+        (fboundp 'reftex-ref-style-activate)
+        (reftex-ref-style-activate "AMSmath"))))
  LaTeX-dialect)
 
 (defun LaTeX-amsmath-env-alignat (env)
diff --git a/style/comment.el b/style/comment.el
index 46054ca..d6ba12d 100644
--- a/style/comment.el
+++ b/style/comment.el
@@ -21,8 +21,8 @@
 
 ;; 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., 59 Temple Place - Suite 330, Boston, MA
-;; 02111-1307, USA.
+;; Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+;; MA 02110-1301 USA.
 
 ;;; Commentary:
 
diff --git a/style/floatrow.el b/style/floatrow.el
index bc358d1..4adc052 100644
--- a/style/floatrow.el
+++ b/style/floatrow.el
@@ -311,8 +311,8 @@
                            (setq temp (assq-delete-all (car (assoc x temp)) 
temp)))
                          temp)
                         ((string= key "floatrowsep")
-                         (setq temp (dolist (x sep-keys)
-                                      (assq-delete-all (car (assoc x temp)) 
temp)))
+                         (dolist (x sep-keys)
+                           (setq temp (assq-delete-all (car (assoc x temp)) 
temp)))
                          temp)
                         (t
                          (assq-delete-all (car (assoc key temp)) temp)))))
diff --git a/style/foils.el b/style/foils.el
index d450090..299e3af 100644
--- a/style/foils.el
+++ b/style/foils.el
@@ -19,7 +19,7 @@
 ;; for more details.
 
 ;; You should have received a copy of the GNU General Public License
-;; along with AUCTeX.  If not, see <http://www.gnu.org/licenses/>.
+;; along with AUCTeX.  If not, see <https://www.gnu.org/licenses/>.
 
 ;;; Code:
 
diff --git a/style/geometry.el b/style/geometry.el
index 85be57c..7e59fe0 100644
--- a/style/geometry.el
+++ b/style/geometry.el
@@ -58,30 +58,28 @@
              "c1paper" "c2paper" "c3paper" "c4paper" "c5paper"
              "c6paper" "b0j" "b1j" "b2j" "b3j" "b4j" "b5j" "b6j"
              "ansiapaper" "ansibpaper" "ansicpaper" "ansidpaper"
-             "ansiepaper" "ansiapaper" "ansibpaper" "ansicpaper"
-             "ansidpaper" "ansiepaper"))
+             "ansiepaper"))
     ("papername" ("a0paper" "a1paper" "a2paper" "a3paper" "a4paper"
                  "a5paper" "a6paper" "b0paper" "b1paper" "b2paper"
                  "b3paper" "b4paper" "b5paper" "b6paper" "c0paper"
                  "c1paper" "c2paper" "c3paper" "c4paper" "c5paper"
                  "c6paper" "b0j" "b1j" "b2j" "b3j" "b4j" "b5j" "b6j"
                  "ansiapaper" "ansibpaper" "ansicpaper" "ansidpaper"
-                 "ansiepaper" "ansiapaper" "ansibpaper" "ansicpaper"
-                 "ansidpaper" "ansiepaper"))
+                 "ansiepaper"))
     ("a0paper") ("a1paper") ("a2paper") ("a3paper") ("a4paper") ("a5paper")
     ("a6paper") ("b0paper") ("b1paper") ("b2paper") ("b3paper") ("b4paper")
     ("b5paper") ("b6paper") ("c0paper") ("c1paper") ("c2paper") ("c3paper")
     ("c4paper") ("c5paper") ("c6paper") ("b0j") ("b1j") ("b2j") ("b3j")
     ("b4j") ("b5j") ("b6j") ("ansiapaper") ("ansibpaper") ("ansicpaper")
-    ("ansidpaper") ("ansiepaper") ("ansiapaper") ("ansibpaper") ("ansicpaper")
     ("ansidpaper") ("ansiepaper") ("screen") ("paperwidth") ("paperheight")
     ("papersize") ("landscape") ("portrait")
-    ("driver" ("dvips" "dvipdfm" "pdftex" "vtex" "xetex" "auto" "none"))
-    ("dvips") ("dvipdfm") ("pdftex") ("xetex") ("vtex") ("verbose")
-    ("reset") ("mag") ("truedimen") ("pass") ("showframe") ("showcrop"))
+    ("driver" ("dvips" "dvipdfm" "dvipdfmx" "xdvipdfmx"
+              "pdftex" "luatex" "vtex" "xetex" "auto" "none"))
+    ("dvips") ("dvipdfm") ("dvipdfmx") ("xdvipdfmx") ("pdftex") ("luatex")
+    ("xetex") ("vtex") ("verbose") ("reset")
+    ("mag") ("truedimen") ("pass") ("showframe") ("showcrop"))
   "Key=value options allowed only in the preamble for geometry macros.")
 
-
 ;; Needed for auto-parsing.
 (require 'tex)
 
diff --git a/style/graphicx.el b/style/graphicx.el
index 08dbf75..bb89b13 100644
--- a/style/graphicx.el
+++ b/style/graphicx.el
@@ -105,65 +105,94 @@ key-val's."
                         LaTeX-graphicx-key-val-options))
      optional)))
 
+(defun LaTeX-includegraphics-extensions-list ()
+  "Return appropriate extensions for input files to \\includegraphics.
+Return value is a list of regexps."
+  (let ((temp (copy-sequence LaTeX-includegraphics-extensions)))
+    (cond (;; 'default TeX-engine:
+          (eq TeX-engine 'default)
+          (if ;; we want to produce a pdf
+              (if TeX-PDF-mode
+                  ;; Return t if default compiler produces PDF,
+                  ;; nil for "Dvips" or "Dvipdfmx"
+                  (not (TeX-PDF-from-DVI))
+                ;; t if pdftex is used in dvi-mode
+                TeX-DVI-via-PDFTeX)
+              ;; We're using pdflatex in pdf-mode
+              (TeX-delete-duplicate-strings
+               (append LaTeX-includegraphics-pdftex-extensions
+                       temp))
+            ;; We're generating a .dvi to process with dvips or dvipdfmx
+            (progn
+              ;; dvipdfmx can handle jpeg, pdf and png for image formats.
+              (unless (and TeX-PDF-mode
+                           (string= (TeX-PDF-from-DVI) "Dvipdfmx"))
+                (dolist (x '("jpe?g" "pdf" "png"))
+                  (setq temp (delete x temp))))
+              (TeX-delete-duplicate-strings
+               (append LaTeX-includegraphics-dvips-extensions
+                       temp)))))
+         ;; Running luatex in pdf or dvi-mode:
+         ((eq TeX-engine 'luatex)
+          (if TeX-PDF-mode
+              (TeX-delete-duplicate-strings
+               (append LaTeX-includegraphics-pdftex-extensions
+                       temp))
+            (progn
+              (dolist (x '("jpe?g" "pdf" "png"))
+                (setq temp (delete x temp)))
+              (TeX-delete-duplicate-strings
+               (append LaTeX-includegraphics-dvips-extensions
+                       temp)))))
+         ;; Running xetex in any mode:
+         ((eq TeX-engine 'xetex)
+          (TeX-delete-duplicate-strings
+           (append LaTeX-includegraphics-xetex-extensions
+                   temp)))
+         ;; For anything else
+         (t
+          (if (and TeX-PDF-mode
+                   (string= (TeX-PDF-from-DVI) "Dvipdfmx"))
+              ;; dvipdfmx can handle the same image formats as dvips.
+              (TeX-delete-duplicate-strings
+               (append LaTeX-includegraphics-dvips-extensions
+                       temp))
+            temp)))))
+
 (defun LaTeX-includegraphics-extensions (&optional list)
-  "Return appropriate extensions for input files to \\includegraphics."
-  (let* ((temp (copy-sequence LaTeX-includegraphics-extensions))
-        (LaTeX-includegraphics-extensions
-         (cond (;; 'default TeX-engine:
-                (eq TeX-engine 'default)
-                (if ;; we want to produce a pdf
-                    (if TeX-PDF-mode
-                        ;; Return t if default compiler produces PDF,
-                        ;; nil for "Dvips" or "Dvipdfmx"
-                        (not (TeX-PDF-from-DVI))
-                      ;; t if pdftex is used in dvi-mode
-                      TeX-DVI-via-PDFTeX)
-                    ;; We're using pdflatex in pdf-mode
-                    (TeX-delete-duplicate-strings
-                     (append LaTeX-includegraphics-pdftex-extensions
-                             temp))
-                  ;; We're generating a .dvi to process with dvips or dvipdfmx
-                  (progn
-                    (dolist (x '("jpe?g" "pdf" "png"))
-                      (setq temp (delete x temp)))
-                    (TeX-delete-duplicate-strings
-                     (append LaTeX-includegraphics-dvips-extensions
-                             temp)))))
-               ;; Running luatex in pdf or dvi-mode:
-               ((eq TeX-engine 'luatex)
-                (if TeX-PDF-mode
-                    (TeX-delete-duplicate-strings
-                     (append LaTeX-includegraphics-pdftex-extensions
-                             temp))
-                  (progn
-                    (dolist (x '("jpe?g" "pdf" "png"))
-                      (setq temp (delete x temp)))
-                    (TeX-delete-duplicate-strings
-                     (append LaTeX-includegraphics-dvips-extensions
-                             temp)))))
-               ;; Running xetex in any mode:
-               ((eq TeX-engine 'xetex)
-                (TeX-delete-duplicate-strings (append 
LaTeX-includegraphics-xetex-extensions
-                                     temp)))
-               ;; For anything else
-               (t
-                temp))))
-    (concat "\\."
-           (mapconcat 'identity
-                      (or list LaTeX-includegraphics-extensions)
-                      "$\\|\\.")
-           "$")))
+  "Return appropriate extensions for input files to \\includegraphics.
+Return value is a single regexp.
+Optional argument LIST if non-nil is used as list of regexps of
+extensions to be matched."
+  (unless list
+    (setq list (LaTeX-includegraphics-extensions-list)))
+  (concat "\\." (mapconcat #'identity list "$\\|\\.") "$"))
+
+(defvar LaTeX-includegraphics-global-files nil
+  "List of the non-local graphic files to include in LaTeX documents.
+Initialized once at the first time you prompt for an input file.
+May be reset with `\\[universal-argument] \\[TeX-normal-mode]'.")
 
 (defun LaTeX-includegraphics-read-file-TeX ()
   "Read image file for \\includegraphics.
 Offers all graphic files found in the TeX search path.  See
 `LaTeX-includegraphics-read-file' for more."
-  (completing-read
-   "Image file: "
-   (TeX-delete-dups-by-car
-    (mapcar 'list
-           (TeX-search-files nil LaTeX-includegraphics-extensions t t)))
-   nil nil nil))
+  (let ((LaTeX-includegraphics-extensions
+        (LaTeX-includegraphics-extensions-list)))
+    (unless LaTeX-includegraphics-global-files
+      (message "Searching for graphic files...")
+      (setq LaTeX-includegraphics-global-files
+           (TeX-search-files-by-type
+            'graphics 'global t
+            LaTeX-includegraphics-strip-extension-flag))
+      (message "Searching for graphic files...done"))
+    (completing-read
+     "Image file: "
+     (append
+      (TeX-search-files-by-type 'graphics 'local t
+                               LaTeX-includegraphics-strip-extension-flag)
+      LaTeX-includegraphics-global-files)
+     nil nil nil)))
 
 (defun LaTeX-includegraphics-read-file-relative ()
   "Read image file for \\includegraphics.
diff --git a/style/hyperref.el b/style/hyperref.el
index 973796a..87ab1d8 100644
--- a/style/hyperref.el
+++ b/style/hyperref.el
@@ -31,7 +31,7 @@
 ;;; Code:
 
 (defvar LaTeX-hyperref-package-options-list
-  '(;; See http://www.tug.org/applications/hyperref/manual.html#x1-40003
+  '(;; See https://www.tug.org/applications/hyperref/manual.html#x1-40003
     ;; General options
     ("draft" ("true" "false"))
     ("final" ("true" "false"))
@@ -153,7 +153,7 @@
     ("nextactionraw"))
   "Key=value options for href macro of the hyperref package.")
 
-;; See http://www.tug.org/applications/hyperref/ftp/doc/manual.html#x1-220006.2
+;; See 
https://www.tug.org/applications/hyperref/ftp/doc/manual.html#x1-220006.2
 
 (defvar LaTeX-hyperref-forms-options
   '(("accesskey")
@@ -262,7 +262,7 @@
     '("MakeButtonField" "Text"))
 
    ;; Form fields must be inside a "Form"-env, one per file is allowed, cf.
-   ;; http://www.tug.org/applications/hyperref/ftp/doc/manual.html#x1-200006
+   ;; https://www.tug.org/applications/hyperref/ftp/doc/manual.html#x1-200006
    ;; It is up to user to insert [<options>] after \begin{Form}
    (LaTeX-add-environments
     '("Form"))
diff --git a/style/ifluatex.el b/style/ifluatex.el
index cddd9fd..923b554 100644
--- a/style/ifluatex.el
+++ b/style/ifluatex.el
@@ -21,7 +21,7 @@
 
 ;; You should have received a copy of the GNU General Public License
 ;; along with AUCTeX; see the file COPYING.  If not, see
-;; <http://www.gnu.org/licenses/>.
+;; <https://www.gnu.org/licenses/>.
 
 ;;; Commentary:
 
diff --git a/style/latexinfo.el b/style/latexinfo.el
index f08c079..bbe6e6c 100644
--- a/style/latexinfo.el
+++ b/style/latexinfo.el
@@ -8,15 +8,16 @@
 ;; it under the terms of the GNU General Public License as published by
 ;; the Free Software Foundation; either version 3, or (at your option)
 ;; any later version.
-;; 
+;;
 ;; This program is distributed in the hope that it will be useful,
 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 ;; GNU General Public License for more details.
-;; 
+;;
 ;; You should have received a copy of the GNU General Public License
-;; along with this program; if not, write to the Free Software
-;; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+;; along with AUCTeX; see the file COPYING.  If not, write to the Free
+;; Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+;; MA 02110-1301 USA.
 
 ;;; Code:
 
diff --git a/style/lettrine.el b/style/lettrine.el
index ed32a70..111f7b3 100644
--- a/style/lettrine.el
+++ b/style/lettrine.el
@@ -1,8 +1,9 @@
-;;; lettrine.el --- AUCTeX style for `lettrine.sty'
+;;; lettrine.el --- AUCTeX style for `lettrine.sty' (v2.21)
 
-;; Copyright (C) 2011 Free Software Foundation, Inc.
+;; Copyright (C) 2011, 2018 Free Software Foundation, Inc.
 
 ;; Author: Mads Jensen <address@hidden>
+;; Maintainer: address@hidden
 ;; Keywords: tex
 
 ;; This file is part of AUCTeX.
@@ -24,12 +25,13 @@
 
 ;;; Commentary:
 
-;; This file adds support for `lettrine.sty'.
+;; This file adds support for `lettrine.sty' (v2.21) from 2018/08/28.
 
 ;;; Code:
 
 (defvar LaTeX-lettrine-key-val-options
   '(("lines")
+    ("depth")
     ("lhang")
     ("loversize")
     ("lraise")
@@ -37,8 +39,12 @@
     ("nindent")
     ("slope")
     ("ante")
-    ("image" ("true")))
-  "Key=value options for \\lettrine")
+    ("image" ("true"))
+    ("grid" ("true"))
+    ("novskip")
+    ("realheight" ("true"))
+    ("refstring"))
+  "Key=value options for \\lettrine marco.")
 
 (TeX-add-style-hook
  "lettrine"
@@ -46,26 +52,35 @@
    (TeX-add-symbols
     '("lettrine" [ TeX-arg-key-val LaTeX-lettrine-key-val-options ]
       "Letter" "Text")
+    '("DefaultLoversize" 0)
+    '("DefaultLraise" 0)
+    '("DefaultLhang" 0)
     '("LettrineImageFalse" 0)
-    ;; all of the below can be configured with either \setlength or
-    ;; \renewcommand
+    '("LettrineOnGridfalse" 0)
+    '("LettrineRealHeightfalse" 0)
+    '("LettrineSelfReffalse" 0)
     '("LettrineFont" 0)
     '("LettrineFontHook" 0)
     '("LettrineTextFont" 0)
-    '("LettrineWidth" 0)
-    '("DefaultLhang" 0)
-    '("DefaultLoversize" 0)
-    '("DefaultLraise" 0)
-    '("DefaultFindent" 0)
-    '("DefaultNindent" 0)
-    '("DefaultSlope" 0)
     ;; above settings can also be input a file, and pointed to with
     ;; \renewcommand
-    '("DefaultOptionsFile" 0))
+    '("DefaultOptionsFile" TeX-arg-file-name))
+
+   ;; Counters:
+   (LaTeX-add-counters "DefaultLines" "DefaultDepth")
+
+   ;; Lengths and dimensions:
+   (LaTeX-add-lengths "DefaultFindent"
+                     "DefaultNindent"
+                     "DefaultSlope"
+                     "DiscardVskip"
+                     "LettrineWidth"
+                     "LettrineHeight"
+                     "LettrineDepth")
 
    ;; Fontification
    (when (and (fboundp 'font-latex-add-keywords)
-              (eq TeX-install-font-lock 'font-latex-setup))
+             (eq TeX-install-font-lock 'font-latex-setup))
      (font-latex-add-keywords '(("lettrine" "[{{")) 'textual)))
  LaTeX-dialect)
 
diff --git a/style/luatextra.el b/style/luatextra.el
index 6dda102..4286979 100644
--- a/style/luatextra.el
+++ b/style/luatextra.el
@@ -21,7 +21,7 @@
 
 ;; You should have received a copy of the GNU General Public License
 ;; along with AUCTeX; see the file COPYING.  If not, see
-;; <http://www.gnu.org/licenses/>.
+;; <https://www.gnu.org/licenses/>.
 
 ;;; Commentary:
 
diff --git a/style/marginnote.el b/style/marginnote.el
new file mode 100644
index 0000000..706182f
--- /dev/null
+++ b/style/marginnote.el
@@ -0,0 +1,64 @@
+;;; marginnote.el --- AUCTeX style for `marginnote.sty' (v1.4)
+
+;; Copyright (C) 2018 Free Software Foundation, Inc.
+
+;; Author: Arash Esbati <address@hidden>
+;; Maintainer: address@hidden
+;; Created: 2018-07-07
+;; 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 `marginnote.sty' (v1.4) from 2018/07/01.
+;; `marginnote.sty' is part of TeXLive.
+
+;;; Code:
+
+(TeX-add-style-hook
+ "marginnote"
+ (lambda ()
+
+   (TeX-add-symbols
+    '("marginnote" [ "Left margin text" ] "Text"
+      [ TeX-arg-length "Vertical offset" ] )
+
+    '("marginnotetextwidth" 0)
+
+    '("marginnotevadjust" 0)
+
+    '("raggedleftmarginnote" 0)
+
+    '("raggedrightmarginnote" 0)
+
+    '("marginfont" 0))
+
+   ;; Fontification
+   (when (and (featurep 'font-latex)
+             (eq TeX-install-font-lock 'font-latex-setup))
+     (font-latex-add-keywords '(("marginnote"  "[{["))
+                             'reference)))
+ LaTeX-dialect)
+
+(defvar LaTeX-marginnote-package-options
+  '("fulladjust" "heightadjust" "depthadjust" "noadjust"
+    "parboxrestore" "noparboxrestore")
+  "Package options for the marginnote package.")
+
+;;; marginnote.el ends here
diff --git a/style/mathtools.el b/style/mathtools.el
index 025feca..f36a13d 100644
--- a/style/mathtools.el
+++ b/style/mathtools.el
@@ -32,7 +32,7 @@
 ;;; This package serves as a wrapper for amsmath, adding more features
 ;;; and fixing a few bugs in amsmath.  The mathstyle argument for many
 ;;; of the macros is discussed at
-;;; <http://www.tug.org/TUGboat/Articles/tb22-4/tb72perlS.pdf>
+;;; <https://www.tug.org/TUGboat/Articles/tb22-4/tb72perlS.pdf>
 
 ;;; Code:
 
diff --git a/style/ocg-p.el b/style/ocg-p.el
new file mode 100644
index 0000000..099a7f3
--- /dev/null
+++ b/style/ocg-p.el
@@ -0,0 +1,190 @@
+;;; ocg-p.el --- AUCTeX style for `ocg-p.sty' (v0.4)
+
+;; Copyright (C) 2018 Free Software Foundation, Inc.
+
+;; Author: Arash Esbati <address@hidden>
+;; Maintainer: address@hidden
+;; Created: 2018-08-05
+;; 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 `ocg-p.sty' v0.4 from 2013/01/10.
+;; `ocg-p.sty' is part of TeXLive.
+
+;;; Code:
+
+;; Needed for auto-parsing.
+(require 'tex)
+
+;; Setup for layer id's defined with
+;; \begin{ocg}[<opt-arg>]{<layer name>}{<layer id>}{<initial visibility>}:
+
+(TeX-auto-add-type "ocgp-ocg-layer-id" "LaTeX")
+
+(defvar LaTeX-ocgp-ocg-layer-id-regexp
+  `(,(concat "\\\\begin{ocg}"
+            "[ \t\n\r%]*"
+            "\\(?:\\[[^]]*\\]\\)?"
+            "[ \t\n\r%]*"
+            "\\(?:{[^}]+}\\)"
+            "[ \t\n\r%]*"
+            "{\\([^}]+\\)}")
+    1 LaTeX-auto-ocgp-ocg-layer-id))
+
+(defun LaTeX-ocgp-auto-prepare ()
+  "Clear `LaTeX-auto-ocgp-ocg-layer-id' before parsing."
+  (setq LaTeX-auto-ocgp-ocg-layer-id nil))
+
+(add-hook 'TeX-auto-prepare-hook #'LaTeX-ocgp-auto-prepare t)
+(add-hook 'TeX-update-style-hook #'TeX-auto-parse t)
+
+(defvar LaTeX-ocgp-env-key-val-options
+  '(("printocg"      ("always" "never" "ifvisible"))
+    ("exportocg"     ("always" "never" "ifvisible"))
+    ("listintoolbar" ("always" "never" "iffirstuse")))
+  "Key=value options for ocg environment from ocg-p package.")
+
+(defun LaTeX-env-ocgp-ocg (optional)
+  "Insert arguments for ocg environment from ocg-p package."
+  ;; The optional key-val argument:
+  (let ((TeX-arg-opening-brace LaTeX-optop)
+       (TeX-arg-closing-brace LaTeX-optcl))
+    (TeX-argument-insert
+     (TeX-read-key-val t LaTeX-ocgp-env-key-val-options)
+     t))
+  ;; Layer Name:
+  (TeX-argument-insert
+   (TeX-read-string
+    (TeX-argument-prompt optional nil "Layer name"))
+   optional)
+  ;;
+  ;; Layer id: Use completing read to show which id's are available.
+  ;; Then add the new id to list of know id's and insert it
+  (TeX-argument-insert
+   (let ((id (completing-read
+             (TeX-argument-prompt optional nil "Layer id")
+             (LaTeX-ocgp-ocg-layer-id-list))))
+     (LaTeX-add-ocgp-ocg-layer-ids id)
+     id)
+   optional)
+  ;;
+  ;; Initial visibility: Insert 0 or 1
+  (TeX-argument-insert
+   (TeX-read-string
+    (TeX-argument-prompt optional nil "Initial visibility (0 or 1)"))
+   optional))
+
+(defvar LaTeX-ocgp-mac-key-val-options
+  '(("triggerocg" ("onareaenter" "onareaexit" "onmousedown"
+                  "onmouseup"   "allactions")))
+  "Key=value options for macros provided by ocg-p package.")
+
+(defun LaTeX-arg-ocgp-layer-id (optional &optional prompt)
+  "Insert (multiple) defined layer id's for various macros from ocg-p package.
+<SPC> key binding in minibuffer is removed temporarily.
+Completion is still available with <TAB> key."
+  (let* ((crm-separator "[ \t]+")
+        (crm-local-completion-map
+         (remove (assoc 32 crm-local-completion-map) crm-local-completion-map))
+        (ids (mapconcat #'identity
+                        (TeX-completing-read-multiple
+                         (TeX-argument-prompt optional prompt "Layer id ('s 
space separated)")
+                         (LaTeX-ocgp-ocg-layer-id-list))
+                        " ")))
+    (TeX-argument-insert ids optional)))
+
+(defun LaTeX-env-ocgp-ocgtabular (environment)
+  "Insert ocgtabular ENVIRONMENT with position, column spec's and 2 more 
arguments.
+Just like array and tabular."
+  (let ((pos (and LaTeX-default-position ; LaTeX-default-position can
+                                       ; be nil, i.e. do not prompt
+                 (TeX-read-string "(Optional) Position: " 
LaTeX-default-position)))
+       (fmt (TeX-read-string "Format: " LaTeX-default-format))
+       (dbase (TeX-read-string "Database name: "))
+       (opts (TeX-read-string "Additional options: ")))
+    (setq LaTeX-default-position pos)
+    (setq LaTeX-default-format fmt)
+    (LaTeX-insert-environment environment
+                             (concat
+                              (unless (zerop (length pos))
+                                (concat LaTeX-optop pos LaTeX-optcl))
+                              (concat TeX-grop fmt TeX-grcl)
+                              (concat TeX-grop dbase TeX-grcl)
+                              (concat TeX-grop opts TeX-grcl)))
+    (LaTeX-item-array t)))
+
+(TeX-add-style-hook
+ "ocg-p"
+ (lambda ()
+
+   ;; Add ocg-p to the parser
+   (TeX-auto-add-regexp LaTeX-ocgp-ocg-layer-id-regexp)
+
+   ;; 2.3 The ocg environment
+   (LaTeX-add-environments
+    '("ocg" LaTeX-env-args LaTeX-env-ocgp-ocg))
+
+   ;; 2.4 The commands of the package
+   (TeX-add-symbols
+    '("toggleocgs"
+      [ TeX-arg-key-val LaTeX-ocgp-mac-key-val-options ]
+      LaTeX-arg-ocgp-layer-id
+      "Action button")
+
+    '("showocgs"
+      [ TeX-arg-key-val LaTeX-ocgp-mac-key-val-options ]
+      LaTeX-arg-ocgp-layer-id
+      "Action button")
+
+    '("hideocgs"
+      [ TeX-arg-key-val LaTeX-ocgp-mac-key-val-options ]
+      LaTeX-arg-ocgp-layer-id
+      "Action button")
+
+    '("setocgs"
+      [ TeX-arg-key-val LaTeX-ocgp-mac-key-val-options ]
+      (LaTeX-arg-ocgp-layer-id "Toggle layer id ('s space separated)")
+      (LaTeX-arg-ocgp-layer-id "Show layer id ('s space separated)")
+      (LaTeX-arg-ocgp-layer-id "Hide layer id ('s space separated)")
+      "Action button"))
+
+   ;; 2.5 The ocgtabular environment
+   (when (LaTeX-provided-package-options-member "ocg-p" "ocgtabular")
+     (LaTeX-add-environments
+      '("ocgtabular" LaTeX-env-ocgp-ocgtabular))
+
+     (TeX-add-symbols
+      '("setocgtabularheader" "Column name" "Displayed header")))
+
+   ;; Fontification
+   (when (and (featurep 'font-latex)
+             (eq TeX-install-font-lock 'font-latex-setup))
+     (font-latex-add-keywords '(("toggleocgs"          "[{{")
+                               ("showocgs"            "[{{")
+                               ("hideocgs"            "[{{")
+                               ("setocgs"             "[{{{{"))
+                             'function)))
+ LaTeX-dialect)
+
+(defvar LaTeX-ocg-p-package-options '("ocgtabular")
+  "Package options for the ocg-p package.")
+
+;;; ocg-p.el ends here
diff --git a/style/ocgx.el b/style/ocgx.el
new file mode 100644
index 0000000..b6da24f
--- /dev/null
+++ b/style/ocgx.el
@@ -0,0 +1,68 @@
+;;; ocgx.el --- AUCTeX style for `ocgx.sty' (v0.5)
+
+;; Copyright (C) 2018 Free Software Foundation, Inc.
+
+;; Author: Arash Esbati <address@hidden>
+;; Maintainer: address@hidden
+;; Created: 2018-08-05
+;; 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 `ocgx.sty' v0.5 from 2012/11/14.
+;; `ocgx.sty' is part of TeXLive.
+
+;;; Code:
+
+(TeX-add-style-hook
+ "ocgx"
+ (lambda ()
+
+   ;; Run style hook for ocg-p package:
+   (TeX-run-style-hooks "ocg-p")
+
+   ;; 1.2 Manage the visibility of OCGs
+   (TeX-add-symbols
+    '("switchocg" LaTeX-arg-ocgp-layer-id "Action button")
+
+    '("showocg" LaTeX-arg-ocgp-layer-id "Action button")
+
+    '("hideocg" LaTeX-arg-ocgp-layer-id "Action button")
+
+    '("actionsocg"
+      (LaTeX-arg-ocgp-layer-id "Toggle layer id ('s space separated)")
+      (LaTeX-arg-ocgp-layer-id "Show layer id ('s space separated)")
+      (LaTeX-arg-ocgp-layer-id "Hide layer id ('s space separated)")
+      "Action button"))
+
+   ;; Fontification
+   (when (and (featurep 'font-latex)
+             (eq TeX-install-font-lock 'font-latex-setup))
+     (font-latex-add-keywords '(("switchocg"  "{{")
+                               ("showocg"    "{{")
+                               ("hideocg"    "{{")
+                               ("actionsocg" "{{{{"))
+                             'function)))
+ LaTeX-dialect)
+
+(defvar LaTeX-ocgx-package-options nil
+  "Package options for the ocgx package.")
+
+;;; ocgx.el ends here
diff --git a/style/pstricks.el b/style/pstricks.el
index 5b6e828..9762b68 100644
--- a/style/pstricks.el
+++ b/style/pstricks.el
@@ -1,6 +1,7 @@
 ;;; pstricks.el --- AUCTeX style for the `pstricks' package.
 
-;; Copyright (C) 2007, 2009, 2013-2015 Free Software Foundation, Inc.
+;; Copyright (C) 2007, 2009, 2013-2015,
+;;               2018  Free Software Foundation, Inc.
 
 ;; Author: Holger Sparr <address@hidden>
 ;; Maintainer: address@hidden
@@ -48,7 +49,7 @@
 ;;
 ;; 14/06/2007 rewrite of pstricks.el based on Jean-Philippe Georget's
 ;;            pstricks.el version found on <URI:
-;;            http://www.emacswiki.org/cgi-bin/wiki/pstricks.el>
+;;            https://www.emacswiki.org/emacs/pstricks.el>
 
 ;;; TODO:
 ;;
@@ -60,6 +61,9 @@
 
 ;;; Code:
 
+(eval-when-compile
+  (require 'cl-lib))
+
 ;;; General Functions
 
 (defun TeX-arg-compl-list (list &optional prompt hist)
@@ -681,7 +685,7 @@ package PNAME"
        (cond ((string= type "object")
               (setq TeX-auto-symbol
                     (cons (list (nth 1 list)
-                                (caddr (assoc (nth 2 list)
+                                (cl-caddr (assoc (nth 2 list)
                                               (TeX-symbol-list))))
                           TeX-auto-symbol)))
              ((string= type "fontdot")
diff --git a/style/thm-restate.el b/style/thm-restate.el
new file mode 100644
index 0000000..595a582
--- /dev/null
+++ b/style/thm-restate.el
@@ -0,0 +1,115 @@
+;;; thm-restate.el --- AUCTeX style for `thm-restate.sty' (v66)
+
+;; Copyright (C) 2018 Free Software Foundation, Inc.
+
+;; Author: Arash Esbati <address@hidden>
+;; Maintainer: address@hidden
+;; Created: 2018-07-07
+;; 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 `thm-restate.sty'.  `thm-restate.sty' is
+;; part of `thmtools' package (v66) from 2014/04/21.  `thmtools.sty'
+;; is part of TeXLive.
+
+;;; Code:
+
+;; Needed for auto-parsing.
+(require 'tex)
+
+;; Setup for macro names defined with
+;; \begin{restatable}[<Heading>]{<env-name>}{<macro name>}:
+
+(TeX-auto-add-type "thmrestate-restatable-macro" "LaTeX")
+
+(defvar LaTeX-thmrestate-restatable-marco-regexp
+  `(,(concat "\\\\begin{restatable}"
+            "[ \t\n\r%]*"
+            "\\(?:\\[[^]]*\\]\\)?"
+            "[ \t\n\r%]*"
+            "\\(?:{[^}]+}\\)"
+            "[ \t\n\r%]*"
+            "{\\([^}]+\\)}")
+    1 LaTeX-auto-thmrestate-restatable-macro))
+
+(defun LaTeX-thmrestate-auto-prepare ()
+  "Clear `LaTeX-auto-thmrestate-restatable-macro' before parsing."
+  (setq LaTeX-auto-thmrestate-restatable-macro nil))
+
+(defun LaTeX-thmrestate-auto-cleanup ()
+  "Process parsed elements from thm-restate package."
+  (dolist (newmac (mapcar #'car (LaTeX-thmrestate-restatable-macro-list)))
+    (TeX-add-symbols `(,newmac 0)
+                    `(,(concat newmac "*") 0))))
+
+(add-hook 'TeX-auto-prepare-hook #'LaTeX-thmrestate-auto-prepare t)
+(add-hook 'TeX-auto-cleanup-hook #'LaTeX-thmrestate-auto-cleanup t)
+(add-hook 'TeX-update-style-hook #'TeX-auto-parse t)
+
+(defun LaTeX-env-thmrestate-restatable (optional)
+  "Insert arguments for restatable environment from thm-restate package."
+  ;; The optional heading argument:
+  (let ((TeX-arg-opening-brace LaTeX-optop)
+       (TeX-arg-closing-brace LaTeX-optcl))
+    (TeX-argument-insert
+     (TeX-read-string
+      (TeX-argument-prompt t nil "Heading"))
+     t))
+  ;; Name of the environment we are referring to; this can be defined
+  ;; via amsthm.sty, ntheorem.sty or thmtools.sty:
+  (TeX-argument-insert
+   (completing-read
+    (TeX-argument-prompt optional nil "Environment")
+    (append
+     ;; Cater for environments defined with amsthm's \newtheorem
+     (when (and (fboundp 'LaTeX-amsthm-newtheorem-list)
+               (LaTeX-amsthm-newtheorem-list))
+       (LaTeX-amsthm-newtheorem-list))
+     ;; Cater for environments defined with ntheorem's \newtheorem
+     (when (and (fboundp 'LaTeX-ntheorem-newtheorem-list)
+               (LaTeX-ntheorem-newtheorem-list))
+       (LaTeX-ntheorem-newtheorem-list))
+     ;; Environments defined with \declaretheorem
+     (LaTeX-thmtools-declaretheorem-list)))
+   optional)
+  (let ((mac (TeX-read-string
+             (TeX-argument-prompt optional nil "Macro"))))
+    (TeX-add-symbols `(,mac 0)
+                    `(,(concat mac "*") 0))
+    (TeX-argument-insert mac optional)))
+
+(TeX-add-style-hook
+ "thm-restate"
+ (lambda ()
+
+   ;; Run the style hook `thmtools.el':
+   (TeX-run-style-hooks "thmtools")
+
+   ;; Add thm-restate to the parser
+   (TeX-auto-add-regexp LaTeX-thmrestate-restatable-marco-regexp)
+
+   ;; Provide restatable\\*? environment
+   (LaTeX-add-environments
+    '("restatable"  LaTeX-env-args LaTeX-env-thmrestate-restatable)
+    '("restatable*" LaTeX-env-args LaTeX-env-thmrestate-restatable)))
+ LaTeX-dialect)
+
+;;; thm-restate.el ends here
diff --git a/style/thmtools.el b/style/thmtools.el
new file mode 100644
index 0000000..9c3b51c
--- /dev/null
+++ b/style/thmtools.el
@@ -0,0 +1,299 @@
+;;; thmtools.el --- AUCTeX style for `thmtools.sty' (v66)
+
+;; Copyright (C) 2018 Free Software Foundation, Inc.
+
+;; Author: Arash Esbati <address@hidden>
+;; Maintainer: address@hidden
+;; Created: 2018-07-07
+;; 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 `thmtools.sty' (v66) from 2014/04/21.
+;; `thmtools.sty' is part of TeXLive.
+
+;;; Code:
+
+;; Needed for auto-parsing.
+(require 'tex)
+
+;; Setup for \declaretheoremstyle:
+(TeX-auto-add-type "thmtools-declaretheoremstyle" "LaTeX")
+
+(defvar LaTeX-thmtools-declaretheoremstyle-regexp
+  `(,(concat "\\\\declaretheoremstyle"
+            "[ \t\n\r%]*"
+            "\\(?:\\[[^][]*"
+              "\\(?:{[^}{]*"
+                "\\(?:{[^}{]*"
+                  "\\(?:{[^}{]*}[^}{]*\\)*"
+                "}[^}{]*\\)*"
+              "}[^][]*\\)*"
+            "\\]\\)?"
+            "[ \t\n\r%]*"
+            "{\\([^}]+\\)}")
+    1 LaTeX-auto-thmtools-declaretheoremstyle)
+  "Matches the argument of \\declaretheoremstyle from thmtools package.")
+
+;; Setup for \declaretheorem:
+(TeX-auto-add-type "thmtools-declaretheorem" "LaTeX")
+
+(defvar LaTeX-thmtools-declaretheorem-regexp
+  `(,(concat "\\\\declaretheorem"
+            "[ \t\n\r%]*"
+            "\\(?:\\[[^][]*"
+              "\\(?:{[^}{]*"
+                "\\(?:{[^}{]*"
+                  "\\(?:{[^}{]*}[^}{]*\\)*"
+                "}[^}{]*\\)*"
+              "}[^][]*\\)*"
+            "\\]\\)?"
+            "[ \t\n\r%]*"
+            "{\\([^}]+\\)}")
+    1 LaTeX-auto-thmtools-declaretheorem)
+  "Matches the argument of \\declaretheorem from thmtools package.")
+
+(defun LaTeX-thmtools-auto-prepare ()
+  "Clear `LaTeX-auto-thmtools-*' before parsing."
+  (setq LaTeX-auto-thmtools-declaretheoremstyle nil
+       LaTeX-auto-thmtools-declaretheorem      nil))
+
+(defun LaTeX-thmtools-auto-cleanup ()
+  "Process parsed elements from thmtools package."
+  (dolist (newthm (mapcar #'car (LaTeX-thmtools-declaretheorem-list)))
+    (LaTeX-add-environments `(,newthm LaTeX-thmtools-env-label))))
+
+(add-hook 'TeX-auto-prepare-hook #'LaTeX-thmtools-auto-prepare t)
+(add-hook 'TeX-auto-cleanup-hook #'LaTeX-thmtools-auto-cleanup t)
+(add-hook 'TeX-update-style-hook #'TeX-auto-parse t)
+
+(defun LaTeX-thmtools-declaretheoremstyle-key-val (optional &optional prompt)
+  "Query and return a key=val string for \\declaretheoremstyle macro.
+If OPTIONAL is non-nil, indicate an optional argument in
+minibuffer.  PROMPT replaces the standard one."
+  (let ((lengths (mapcar (lambda (x)
+                          (concat TeX-esc x))
+                        (mapcar #'car (LaTeX-length-list))))
+       (fonts (mapcar (lambda (x)
+                        (concat TeX-esc x))
+                      '("rmfamily" "sffamily" "ttfamily" "mdseries" "bfseries"
+                        "upshape" "itshape" "slshape" "scshape"
+                        "tiny"  "scriptsize" "footnotesize"
+                        "small" "normalsize" "large"
+                        "Large" "LARGE" "huge" "Huge" "normalfont"))))
+    (TeX-read-key-val
+     optional
+     `(("spaceabove" ,lengths)
+       ("spacebelow" ,lengths)
+       ("headfont" ,fonts)
+       ("notefont" ,fonts)
+       ("bodyfont" ,fonts)
+       ("headpunct")
+       ("notebraces")
+       ("postheadspace" ,lengths)
+       ("headformat" ("margin" "swapnumber" "\\NUMBER" "\\NAME" "\\NOTE"))
+       ("headindent" ,lengths))
+     prompt)))
+
+(defun LaTeX-arg-thmtools-declaretheoremstyle (optional &optional prompt)
+  "Insert the key=val and style name defined by \\declaretheoremstyle.
+If OPTIONAL is non-nil, also insert the second argument in square
+brackets.  PROMPT replaces the standard one for the second
+argument."
+  (let ((TeX-arg-opening-brace "[")
+       (TeX-arg-closing-brace "]"))
+    (TeX-argument-insert
+     (LaTeX-thmtools-declaretheoremstyle-key-val t)
+     t))
+  (let ((style (TeX-read-string
+               (TeX-argument-prompt optional prompt "Style"))))
+    (LaTeX-add-thmtools-declaretheoremstyles style)
+    (TeX-argument-insert style optional)))
+
+(defun LaTeX-thmtools-declaretheorem-key-val (optional &optional prompt)
+  "Query and return a key=val string for \\declaretheorem macro.
+If OPTIONAL is non-nil, indicate an optional argument in
+minibuffer.  PROMPT replaces the standard one."
+  (let ((counters (mapcar #'car (LaTeX-counter-list))))
+    (TeX-read-key-val
+     optional
+     `(("parent" ,counters)
+       ("numberwithin" ,counters)
+       ("within" ,counters)
+       ("sibling" ,counters)
+       ("numberlike" ,counters)
+       ("sharenumber" ,counters)
+       ("title")
+       ("name")
+       ("heading")
+       ("numbered" ("yes" "no" "unless unique"))
+       ("style"
+       ,(append
+         ;; check for \newtheoremstyle from amsthm.sty:
+         (when (and (fboundp 'LaTeX-amsthm-newtheoremstyle-list)
+                    (LaTeX-amsthm-newtheoremstyle-list))
+           (mapcar #'car (LaTeX-amsthm-newtheoremstyle-list)))
+         ;; check for \newtheoremstyle from ntheorem.sty:
+         (when (and (fboundp 'LaTeX-ntheorem-newtheoremstyle-list)
+                    (LaTeX-ntheorem-newtheoremstyle-list))
+           (mapcar #'car (LaTeX-ntheorem-newtheoremstyle-list)))
+         ;; thmtools version is called \declaretheoremstyle:
+         (mapcar #'car (LaTeX-thmtools-declaretheoremstyle-list))))
+       ("preheadhook")
+       ("postheadhook")
+       ("prefoothook")
+       ("postfoothook")
+       ("refname")
+       ("Refname")
+       ("shaded" ("textwidth" "bgcolor" "rulecolor" "rulewidth" "margin"))
+       ("thmbox" ("L" "M" "S"))))))
+
+(defun LaTeX-arg-thmtools-declaretheorem (optional &optional prompt)
+  "Insert the key=val and environment name defined by \\declaretheorem.
+If OPTIONAL is non-nil, also insert the second argument in square
+brackets.  PROMPT replaces the standard one for the second
+argument."
+  (let ((TeX-arg-opening-brace "[")
+       (TeX-arg-closing-brace "]"))
+    (TeX-argument-insert
+     (LaTeX-thmtools-declaretheorem-key-val t)
+     t))
+  (let ((env (TeX-read-string
+             (TeX-argument-prompt optional prompt "Environment"))))
+    (LaTeX-add-environments `(,env LaTeX-thmtools-env-label))
+    (TeX-argument-insert env optional)))
+
+(defun LaTeX-thmtools-listoftheorems-key-val (optional &optional prompt)
+  "Query and return a key=val string for \\listoftheorems macro.
+If OPTIONAL is non-nil, indicate an optional argument in
+minibuffer.  PROMPT replaces the standard one."
+  (let ((lengths (mapcar (lambda (x)
+                          (concat TeX-esc x))
+                        (mapcar #'car (LaTeX-length-list))))
+       (thms (append
+              ;; check for \newtheorem from amsthm.sty:
+              (when (and (fboundp 'LaTeX-amsthm-newtheorem-list)
+                         (LaTeX-amsthm-newtheorem-list))
+                (mapcar #'car (LaTeX-amsthm-newtheorem-list)))
+              ;; check for \newtheorem from ntheorem.sty:
+              (when (and (fboundp 'LaTeX-ntheorem-newtheorem-list)
+                         (LaTeX-ntheorem-newtheorem-list))
+                (mapcar #'car (LaTeX-ntheorem-newtheorem-list)))
+              ;; thmtools version is called \declaretheorem:
+              (mapcar #'car (LaTeX-thmtools-declaretheorem-list)))))
+    (TeX-read-key-val
+     optional
+     `(("numwidth" ,lengths)
+       ("ignore" ,thms)
+       ("onlynamed" ,thms)
+       ("show" ,thms)
+       ("ignoreall" ("true" "false"))
+       ("showall" ("true" "false"))))))
+
+(defun LaTeX-arg-thmtools-listoftheorems (optional &optional prompt)
+  "Insert the key=val to \\listoftheorems macro.
+If OPTIONAL is non-nil, insert the result square brackets.
+OPTIONAL and PROMPT are passed to `LaTeX-thmtools-listoftheorems-key-val'."
+  (TeX-argument-insert
+   (LaTeX-thmtools-listoftheorems-key-val optional prompt)
+   optional))
+
+(defun LaTeX-thmtools-env-label (environment)
+  "Insert thmtools ENVIRONMENT, query for an optional argument and label.
+AUCTeX users should add ENVIRONMENT to `LaTeX-label-alist' via
+customize or in init-file with:
+
+  (add-to-list \\='LaTeX-label-alist \\='(\"theorem\" . \"thm:\"))
+
+RefTeX users should customize or add ENVIRONMENT to
+`LaTeX-label-alist' and `reftex-label-alist', e.g.
+
+  (add-to-list \\='LaTeX-label-alist \\='(\"theorem\" . \"thm:\"))
+  (add-to-list \\='reftex-label-alist
+              \\='(\"theorem\" ?m \"thm:\" \"~\\ref{%s}\"
+                nil (\"Theorem\" \"theorem\") nil))"
+  (let* ((choice (read-char
+                 (TeX-argument-prompt nil nil "Heading (h), Key=val (k), Empty 
(RET)")))
+        (opthead (cond ((= choice ?h)
+                        (TeX-read-string
+                         (TeX-argument-prompt t nil "Heading")))
+                       ((= choice ?k)
+                        (TeX-read-key-val
+                         t
+                         `(("name")
+                           ("continues" ,(mapcar #'car (LaTeX-label-list)))
+                           ("restate" ,(mapcar #'car (LaTeX-label-list)))
+                           ;; We don't offer a label key here: It is
+                           ;; marked "experimental" in the manual and
+                           ;; inserting and parsing \label{foo} is
+                           ;; much easier for AUCTeX and RefTeX
+                           ;; ("label")
+                           ("listhack" ("true" "false")))))
+                       (t ""))))
+    (LaTeX-insert-environment environment
+                             (when (and opthead
+                                        (not (string= opthead "")))
+                               (format "[%s]" opthead))))
+  (when (LaTeX-label environment 'environment)
+    (LaTeX-newline)
+    (indent-according-to-mode)))
+
+(TeX-add-style-hook
+ "thmtools"
+ (lambda ()
+
+   ;; Add thmtools to the parser.
+   (TeX-auto-add-regexp LaTeX-thmtools-declaretheoremstyle-regexp)
+   (TeX-auto-add-regexp LaTeX-thmtools-declaretheorem-regexp)
+
+   (TeX-add-symbols
+    '("declaretheoremstyle" LaTeX-arg-thmtools-declaretheoremstyle)
+    '("declaretheorem" LaTeX-arg-thmtools-declaretheorem)
+
+    '("listoftheorems"  [ LaTeX-arg-thmtools-listoftheorems ])
+    '("ignoretheorems"
+      (TeX-arg-eval mapconcat #'identity
+                   (TeX-completing-read-multiple
+                    (TeX-argument-prompt optional nil "Environment(s)")
+                    (append
+                     ;; check for \newtheorem from amsthm.sty:
+                     (when (and (fboundp 'LaTeX-amsthm-newtheorem-list)
+                                (LaTeX-amsthm-newtheorem-list))
+                       (mapcar #'car (LaTeX-amsthm-newtheorem-list)))
+                     ;; check for \newtheorem from ntheorem.sty:
+                     (when (and (fboundp 'LaTeX-ntheorem-newtheorem-list)
+                                (LaTeX-ntheorem-newtheorem-list))
+                       (mapcar #'car (LaTeX-ntheorem-newtheorem-list)))
+                     ;; thmtools version is called \declaretheorem:
+                     (mapcar #'car (LaTeX-thmtools-declaretheorem-list))))
+                   ","))
+    '("listtheoremname" 0))
+
+   ;; Fontification
+   (when (and (featurep 'font-latex)
+             (eq TeX-install-font-lock 'font-latex-setup))
+     (font-latex-add-keywords '(("declaretheoremstyle"  "[{")
+                               ("declaretheorem"       "[{")
+                               ("listoftheorems"       "[")
+                               ("ignoretheorems"       "{"))
+                             'function)))
+ LaTeX-dialect)
+
+;;; thmtools.el ends here
diff --git a/tests/Makefile b/tests/Makefile
index db62b30..2a490bb 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -13,7 +13,7 @@
 # GNU General Public License for more details.
 
 # You should have received a copy of the GNU General Public License
-# along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.
+# along with GNU Emacs.  If not, see <https://www.gnu.org/licenses/>.
 
 ### Commentary:
 
diff --git a/tests/japanese/preview-latex.el b/tests/japanese/preview-latex.el
index 44697d6..41907df 100644
--- a/tests/japanese/preview-latex.el
+++ b/tests/japanese/preview-latex.el
@@ -1,6 +1,6 @@
 ;;; preview-latex.el --- tests for preview-latex compatibility
 
-;; Copyright (C) 2017 Free Software Foundation, Inc.
+;; Copyright (C) 2017, 2018 Free Software Foundation, Inc.
 
 ;; This file is part of AUCTeX.
 
@@ -37,7 +37,7 @@
 
 ;; Make sure coding system output from tex process to be expected
 ;; value.
-(setq japanese-TeX-use-kanji-opt-flag t) ; assume unix or darwin.
+(setq japanese-TeX-use-kanji-opt-flag t)
 
 (setq TeX-process-asynchronous t)
 (setq TeX-after-start-process-function #'TeX-adjust-process-coding-system)
@@ -51,7 +51,7 @@ character used to cause trouble.  Such patterns are tested."
   (skip-unless (not noninteractive))
   (let ((TeX-clean-confirm nil)
        (preview-auto-cache-preamble nil)
-       (process-environment process-environment)
+       (process-environment (copy-sequence process-environment))
        (locale-coding-system 'shift_jis)
        (TeX-japanese-process-output-coding-system nil)
        (TeX-japanese-process-input-coding-system nil))
@@ -101,7 +101,7 @@ the process differ."
   (skip-unless (not noninteractive))
   (let ((TeX-clean-confirm nil)
        (preview-auto-cache-preamble nil)
-       (process-environment process-environment)
+       (process-environment (copy-sequence process-environment))
        (locale-coding-system 'shift_jis)
        (TeX-japanese-process-output-coding-system nil)
        (TeX-japanese-process-input-coding-system nil))
@@ -190,10 +190,9 @@ Did the image come out at the correct position? ")))
   "`preview-error-quote' is robust against `shift_jis' or not.
 String encoded in `shift_jis' can have regexp meta characters in it."
   (let (case-fold-search
-       (buffer-file-coding-system 'shift_jis)
-       (TeX-japanese-process-output-coding-system nil))
-    (dolist (str '("$BI=(B(1)" "$BM=(B{a}" "$BG=(B\|" "{$B$"(B} 
%$BG=(B" "$B%"!<%9(B" "$B7?(B"))
-      (should (string-match (preview-error-quote str 'shift_jis) str)))))
+       (buffer-file-coding-system 'shift_jis))
+    (dolist (str '("$BI=(B(1)" "$BM=(B{a}" "$BG=(B|" "{$B$"(B} 
%$BG=(B" "$B%"!<%9(B" "$B7?(B"))
+      (should (string-match (preview-error-quote str) str)))))
 
 (ert-deftest japanese-preview-decode-^^ab ()
   "`preview--decode-^^ab' doesn't leave regexp meta characters in results."
@@ -215,59 +214,60 @@ String encoded in `shift_jis' can have regexp meta 
characters in it."
     (should (string= (preview--convert-^^ab "^^^a0") "^\xa0"))
     (should (string= (preview--convert-^^ab "^^c0^^Ab") "\xc0^^Ab"))))
 
-(ert-deftest japanese-preview-process-coding-system ()
-  "`TeX-inline-preview-internal' records process coding system or not.
-It used to discard the coding system for decode without recording
-previously set by `japanese-TeX-set-process-coding-system'."
-  (let ((dummyfile (make-temp-file "japanese-TeX-ert"))
-       (file-cs 'japanese-shift-jis-unix)
-       (locale-cs 'japanese-iso-8bit-unix)
+(ert-deftest japanese-preview-preserve-kanji-option2 ()
+  "Test command to use dumped format preserves kanji option or not."
+  (let ((TeX-clean-confirm nil)
        ;; Make `preview-call-hook' inactive.
        (preview-image-creators nil)
-       process)
-    (find-file dummyfile)
-    ;; Make `japanese-TeX-set-process-coding-system' to be called in
-    ;; `TeX-adjust-process-coding-system'.
-    (setq japanese-TeX-mode t)
-    (setq buffer-file-coding-system file-cs)
+       dummyfile process)
     (unwind-protect
-       (progn
+       (save-window-excursion
+         (find-file preserve-kanji-option)
+         (setq dummyfile (TeX-master-file))
+         (delete-other-windows)
          (setq process (TeX-inline-preview-internal
-                        "echo foo" dummyfile '(nil . nil) (current-buffer)
-                        '(nil . nil) dummyfile '(nil nil nil)))
-         ;; coding system assigned by `TeX-run-command' should be saved in
-         ;; `preview-coding-system'.
-         (should (coding-system-equal locale-cs preview-coding-system))
-         ;; actual process coding system should be the one derived from the
-         ;; original coding system via `preview-buffer-recode-system'.
-         (should (coding-system-equal
-                  (car (process-coding-system process))
-                  (preview-buffer-recode-system locale-cs)))))
-    ;; Cleanup.
-    ;; Let process to exit before finishing test.
-    (accept-process-output process)
-    (set-buffer (get-file-buffer dummyfile))
-    (let* ((buffer (TeX-process-buffer-name (TeX-master-file nil t)))
-          (process (get-buffer-process buffer)))
-      (if process (delete-process process))
-      (kill-buffer buffer))
-    (kill-buffer)
-    (delete-file dummyfile)))
+                        (preview-do-replacements
+                         (TeX-command-expand
+                          (preview-string-expand preview-LaTeX-command)
+                          'TeX-master-file)
+                         preview-LaTeX-command-replacements)
+                        dummyfile '(nil . nil) (current-buffer)
+                        '(nil . (t . t)) dummyfile '(nil nil nil)))
+         (let ((cmd (process-command process)))
+           (should (string-match "-kanji" (nth (1- (length cmd)) cmd)))))
+      ;; Cleanup.
+      (accept-process-output process)
+      (set-buffer (get-file-buffer preserve-kanji-option))
+      (let* ((buffer (TeX-process-buffer-name (TeX-master-file nil t)))
+            (process (get-buffer-process buffer)))
+       (if process (delete-process process))
+       (kill-buffer buffer))
+      (TeX-clean t)
+      (dolist (dir preview-temp-dirs)
+       (if (file-exists-p (directory-file-name dir))
+           (delete-directory dir t)))
+      (kill-buffer))))
 
-(ert-deftest japanese-preview-preserve-kanji-option2 ()
-  "`TeX-inline-preview-internal' preserve kanji option or not."
+(ert-deftest japanese-preview-preserve-kanji-option3 ()
+  "Test command to dump format file preserves kanji option or not."
   (let ((TeX-clean-confirm nil)
        ;; Make `preview-call-hook' inactive.
        (preview-image-creators nil)
-       dummy process)
+       (preview-format-name "dummy")
+       dummyfile process)
     (unwind-protect
        (save-window-excursion
          (find-file preserve-kanji-option)
          (setq dummyfile (TeX-master-file))
          (delete-other-windows)
          (setq process (TeX-inline-preview-internal
-                        "platex" dummyfile '(nil . nil) (current-buffer)
-                        '(nil . (t . t)) dummyfile '(nil nil nil)))
+                        (preview-do-replacements
+                         (TeX-command-expand
+                          (preview-string-expand preview-LaTeX-command)
+                          'TeX-master-file)
+                         preview-dump-replacements)
+                        dummyfile '(nil . nil) (current-buffer)
+                        nil dummyfile '(nil nil nil)))
          (let ((cmd (process-command process)))
            (should (string-match "-kanji" (nth (1- (length cmd)) cmd)))))
       ;; Cleanup.
diff --git a/tests/latex/latex-test.el b/tests/latex/latex-test.el
index a2dc565..b3a22c5 100644
--- a/tests/latex/latex-test.el
+++ b/tests/latex/latex-test.el
@@ -162,4 +162,99 @@ backend=biber % here is a comment
     (should (LaTeX-provided-package-options-member
             "biblatex" "backend=biber"))))
 
+(ert-deftest LaTeX-includegraphics-extensions ()
+  "Check correct extensions are generated accoding to `TeX-engine'."
+  ;; Emacs 26.1 has a bug in byte compile optimization, which makes
+  ;; compiled `LaTeX-includegraphics-extensions-list' to return wrong
+  ;; value when `TeX-engine' is neither `default', `xetex' nor
+  ;; `luatex'.
+  ;; c.f. https://debbugs.gnu.org/cgi/bugreport.cgi?bug=31718
+  :expected-result (if (and (= emacs-major-version 26)
+                           (= emacs-minor-version 1))
+                      :failed
+                    :passed)
+  (with-temp-buffer
+    (LaTeX-mode)
+    (TeX-load-style "graphicx")
+    (let (TeX-engine TeX-PDF-mode TeX-PDF-from-DVI
+                    TeX-PDF-via-dvips-ps2pdf TeX-DVI-via-PDFTeX)
+      ;; tests for default engine
+      (setq TeX-engine 'default)
+      ;; default 1
+      (setq TeX-PDF-mode t
+           TeX-PDF-from-DVI nil
+           TeX-DVI-via-PDFTeX nil)
+      (should
+       (equal (sort (LaTeX-includegraphics-extensions-list) #'string<)
+             (sort '("png" "pdf" "jpe?g" "jbig2" "jb2" "mps"
+                     "PNG" "PDF" "JPE?G" "JBIG2" "JB2" "eps") #'string<)))
+      ;; default 2
+      (setq TeX-PDF-mode t
+           TeX-PDF-from-DVI "Dvips"
+           TeX-DVI-via-PDFTeX nil)
+      (should
+       (equal (sort (LaTeX-includegraphics-extensions-list) #'string<)
+             (sort '("eps" "mps" "EPS") #'string<)))
+      ;; default 3
+      (setq TeX-PDF-mode nil
+           TeX-PDF-from-DVI nil
+           TeX-DVI-via-PDFTeX nil)
+      (should
+       (equal (sort (LaTeX-includegraphics-extensions-list) #'string<)
+             (sort '("eps" "mps" "EPS") #'string<)))
+      ;; default 4
+      (setq TeX-PDF-mode nil
+           TeX-PDF-from-DVI nil
+           TeX-DVI-via-PDFTeX t)
+      (should
+       (equal (sort (LaTeX-includegraphics-extensions-list) #'string<)
+             (sort '("png" "pdf" "jpe?g" "jbig2" "jb2" "mps"
+                     "PNG" "PDF" "JPE?G" "JBIG2" "JB2" "eps") #'string<)))
+      ;; default 5
+      (setq TeX-PDF-mode t
+           TeX-PDF-from-DVI "Dvipdfmx"
+           TeX-DVI-via-PDFTeX nil)
+      (should
+       (equal (sort (LaTeX-includegraphics-extensions-list) #'string<)
+             (sort '("eps" "mps" "EPS" "jpe?g" "pdf" "png") #'string<)))
+
+      ;; tests for luatex engine
+      (setq TeX-engine 'luatex)
+      ;; luatex 1
+      (setq TeX-PDF-mode t)
+      (should
+       (equal (sort (LaTeX-includegraphics-extensions-list) #'string<)
+             (sort '("png" "pdf" "jpe?g" "jbig2" "jb2" "mps"
+                     "PNG" "PDF" "JPE?G" "JBIG2" "JB2" "eps") #'string<)))
+      ;; luatex 2
+      (setq TeX-PDF-mode nil)
+      (should
+       (equal (sort (LaTeX-includegraphics-extensions-list) #'string<)
+             (sort '("eps" "mps" "EPS") #'string<)))
+
+      ;; test for xetex engine
+      (setq TeX-engine 'xetex)
+      (should
+       (equal (sort (LaTeX-includegraphics-extensions-list) #'string<)
+             (sort '("pdf" "eps" "mps" "ps" "png" "jpe?g" "jp2" "jpf"
+                     "PDF" "EPS" "MPS" "PS" "PNG" "JPE?G" "JP2" "JPF"
+                     "bmp" "pict" "psd" "mac" "tga" "gif" "tif" "tiff"
+                     "BMP" "PICT" "PSD" "MAC" "TGA" "GIF" "TIF" "TIFF")
+                   #'string<)))
+
+      ;; test for other engine
+      (setq TeX-engine 'omega)
+      ;; other 1
+      (setq TeX-PDF-mode t
+           TeX-PDF-from-DVI "Dvipdfmx")
+      (should
+       (equal (sort (LaTeX-includegraphics-extensions-list) #'string<)
+             (sort '("eps" "mps" "EPS" "jpe?g" "pdf" "png") #'string<)))
+      ;; other 2
+      (setq TeX-PDF-mode nil
+           TeX-PDF-from-DVI nil)
+      (should
+       (equal (sort (LaTeX-includegraphics-extensions-list) #'string<)
+             (sort '("eps" "jpe?g" "pdf" "png") #'string<))))))
+
 ;;; latex-test.el ends here
diff --git a/tests/tex/command-expansion.el b/tests/tex/command-expansion.el
index 91b3235..dd1f09b 100644
--- a/tests/tex/command-expansion.el
+++ b/tests/tex/command-expansion.el
@@ -1,6 +1,6 @@
 ;;; command-expansion.el --- tests for TeX command expansion
 
-;; Copyright (C) 2014 Free Software Foundation, Inc.
+;; Copyright (C) 2014, 2018 Free Software Foundation, Inc.
 
 ;; This file is part of AUCTeX.
 
@@ -31,7 +31,7 @@
                  (list (cons "Test" '("%%%% %`%'" TeX-run-command t t)))))
             (TeX-command-expand (nth 1 (assoc "Test" TeX-command-list))
                                 'TeX-master-file))
-           "%%  \"\\input\"")))
+           "%% ")))
 
 (ert-deftest TeX-command-expansion-errors ()
   "Test error handling in `TeX-command-expand'."
@@ -84,4 +84,59 @@
        (TeX-view-command-raw)))
    :type 'error))
 
+(ert-deftest TeX-command-detokenize ()
+  "Check whether \"\\input\" and \"\\detokenize\" are supplied when necessary."
+  ;; Skip on w32 because the quoting style of `shell-quote-argument'
+  ;; is different.
+  (skip-unless (not (eq system-type 'w32)))
+  (should (string=
+           (let ((major-mode 'latex-mode)
+                (TeX-engine 'default)
+                (TeX-master "/tmp/abc")
+                (TeX-command-extra-options " \"\\foo\""))
+            (TeX-command-expand "%`%(extraopts)%' %T" #'TeX-master-file))
+          " \"\\foo\" \"\\input\" \\\\detokenize\\{\\ abc.tex\\ \\}")))
+
+(ert-deftest TeX-command-expand-skip-file-name ()
+  "Check whether file name is not subject to further expansion.
+File names obtained as expansion of \"%t\", \"%s\" and so on should be
+skipped for the following expansion to avoid possible endless loop.
+See <https://lists.gnu.org/r/bug-auctex/2014-08/msg00012.html>."
+  (let ((TeX-master "abc-def")
+       (TeX-expand-list '(("-" (lambda () ":")))))
+    (should (string=
+            (TeX-command-expand "%s" #'TeX-master-file)
+            TeX-master))
+    (should (string=
+            (TeX-command-expand "%t" #'TeX-master-file)
+            (TeX-master-file "tex" t)))
+    (should (string=
+            (TeX-command-expand "%T" #'TeX-master-file)
+            (TeX-master-file "tex" t)))
+    (should (string=
+            (TeX-command-expand "%d" #'TeX-master-file)
+            (TeX-master-file "dvi" t)))
+    (should (string=
+            (TeX-command-expand "%f" #'TeX-master-file)
+            (TeX-master-file "ps" t)))
+    ;; The expander of "%o" does not yet cater for this possible endless
+    ;; loop.
+    ;; (should (string=
+    ;;              (TeX-command-expand "%o" #'TeX-master-file)
+    ;;              (TeX-master-file "pdf" t)))
+    ))
+
+(ert-deftest TeX-command-expand-active-master ()
+  "Test whether `TeX-active-master' is valid argument for 
`TeX-command-expand'."
+  (let ((TeX-master "abc")
+       TeX-current-process-region-p)
+    (setq TeX-current-process-region-p nil)
+    (should (string=
+            (TeX-command-expand "%s" #'TeX-active-master)
+            TeX-master))
+    (setq TeX-current-process-region-p t)
+    (should (string=
+            (TeX-command-expand "%s" #'TeX-active-master)
+            TeX-region))))
+
 ;;; command-expansion.el ends here
diff --git a/tex-buf.el b/tex-buf.el
index b8f901a..cc35938 100644
--- a/tex-buf.el
+++ b/tex-buf.el
@@ -227,7 +227,7 @@ of `display-buffer' for additional customization 
information.
 
 Optional third arg NORECORD non-nil means do not put this buffer
 at the front of the list of recently selected ones."
-  (pop-to-buffer buffer other-window (and norecord TeX-record-buffer)))
+  (pop-to-buffer buffer other-window (and norecord (not TeX-record-buffer))))
 
 (defun TeX-recenter-output-buffer (line)
   "Redisplay buffer of TeX job output so that most recent output can be seen.
@@ -542,12 +542,8 @@ without further expansion."
   (let (pat
        pos ;;FIXME: Should this be dynamically scoped?
        entry TeX-command-text TeX-command-pos
-        ;; FIXME: This variable appears to be unused!
-       (file `(lambda (&rest args)
-                (shell-quote-argument
-                 (concat (and (stringp TeX-command-pos) TeX-command-pos)
-                         (apply #',file args)
-                         (and (stringp TeX-command-pos) TeX-command-pos)))))
+       (orig-file file)
+       (file #'TeX--master-or-region-file-with-extra-quotes)
         expansion-res case-fold-search string expansion arguments)
     (setq list (cons
                (list "%%" (lambda nil
@@ -585,6 +581,47 @@ without further expansion."
                (replace-match string t t command)))))
   command)
 
+(defun TeX--master-or-region-file-with-extra-quotes
+    (&optional extension nondirectory ask extra)
+  "Return file name with quote for shell.
+Wrapper for `TeX-master-file', `TeX-region-file' or
+`TeX-active-master' to be used in `TeX-command-expand'.
+It is assumed that `orig-file' has dynamic binding of the value
+of `TeX-master-file', `TeX-region-file' or `TeX-active-master'.
+Pass EXTENSION, NONDIRECTORY and ASK to that function as-is, and
+arrange the returned file name for use with command shell.
+Enclose the file name with space within quotes `\"' first when
+\" \\input\" is supplemented (indicated by dynamically binded
+variable `TeX-command-text' having string value.)
+Enclose the file name within \\detokenize{} when the following three
+conditions are met:
+1. compiling with standard (pdf)LaTeX or upLaTeX
+2. \" \\input\" is supplemented
+3. EXTRA is non-nil. (default when expanding \"%T\")"
+  (shell-quote-argument
+   (let* ((raw (funcall orig-file extension nondirectory ask))
+         ;; String `TeX-command-text' means that the file name is
+         ;; given through \input command.
+         (quote-for-space (if (and (stringp TeX-command-text)
+                                   (string-match " " raw))
+                              "\"" "")))
+     (format
+      (if (and extra
+              (stringp TeX-command-text)
+              (memq major-mode '(latex-mode doctex-mode))
+              (memq TeX-engine '(default uptex)))
+         ;; Since TeXLive 2018, the default encoding for LaTeX
+         ;; files has been changed to UTF-8 if used with
+         ;; classic TeX or pdfTeX.  I.e.,
+         ;; \usepackage[utf8]{inputenc} is enabled by default
+         ;; in (pdf)latex.
+         ;; c.f. LaTeX News issue 28
+         ;; Due to this change, \detokenize is required to
+         ;; recognize non-ascii characters in the file name
+         ;; when \input precedes.
+         "\\detokenize{ %s }" "%s")
+      (concat quote-for-space raw quote-for-space)))))
+
 (defun TeX-check-files (derived originals extensions)
   "Check if DERIVED is newer than any of the ORIGINALS.
 Try each original with each member of EXTENSIONS, in all directories
@@ -791,7 +828,7 @@ omitted) and `TeX-region-file'."
          ((and
            ;; Rationale: makeindex should be run when final document is almost
            ;; complete (see
-           ;; 
http://tex.blogoverflow.com/2012/09/dont-forget-to-run-makeindex/),
+           ;; https://tex-talk.net/2012/09/dont-forget-to-run-makeindex/),
            ;; otherwise, after following latex runs, index pages may change due
            ;; to changes in final document, resulting in extra makeindex and
            ;; latex runs.
@@ -984,48 +1021,53 @@ Called with one argument PROCESS.")
 Usually coding system is the same as the TeX file with eol format
 adjusted to OS default value.  Take care of Japanese TeX, which
 requires special treatment."
-  (when (featurep 'mule)
-    (if (and (boundp 'japanese-TeX-mode)
-            (fboundp 'japanese-TeX-set-process-coding-system)
-            (with-current-buffer TeX-command-buffer
-              japanese-TeX-mode))
-       (japanese-TeX-set-process-coding-system process)
-      (let ((cs (with-current-buffer TeX-command-buffer
-                 buffer-file-coding-system)))
-       ;; The value of `buffer-file-coding-system' is sometimes
-       ;; undecided-{unix,dos,mac}.  That happens when the file
-       ;; contains no multibyte chars and only end of line format is
-       ;; determined.  Emacs lisp reference recommends not to use
-       ;; undecided-* for process coding system, so it might seem
-       ;; reasonable to change undecided-* to some fixed coding
-       ;; system like this:
-       ;; (if (eq 'undecided (coding-sytem-type cs))
-       ;;     (setq cs 'utf-8))
-       ;; However, that can lose when the following conditions are
-       ;; met:
-       ;; (1) The document is divided into multiple files.
-       ;; (2) The command buffer contains no multibyte chars.
-       ;; (3) The other files contain mutlibyte chars and saved in
-       ;;     a coding system other than the coding system chosen
-       ;;     above.
-       ;; So we leave undecided-* unchanged here.  Although
-       ;; undecided-* is not quite safe for the coding system for
-       ;; encoding, i.e., keyboard input to the TeX process, we
-       ;; expect that this does not raise serious problems because it
-       ;; is pretty rare that TeX process needs keyboard input of
-       ;; multibyte chars.
-
-       ;; Eol format of TeX files can differ from OS default. TeX
-       ;; binaries accept all type of eol format in the given files
-       ;; and output messages according to OS default.  So we set eol
-       ;; format to OS default value.
-       (setq cs (coding-system-change-eol-conversion
-                 cs
-                 ;; The eol of macosX is LF, not CR.  So we choose
-                 ;; other than `unix' only for w32 system.
-                 ;; FIXME: what should we do for cygwin?
-                 (if (eq system-type 'windows-nt) 'dos 'unix)))
-       (set-process-coding-system process cs cs)))))
+  (if (and (boundp 'japanese-TeX-mode)
+          (fboundp 'japanese-TeX-set-process-coding-system)
+          (with-current-buffer TeX-command-buffer
+            japanese-TeX-mode))
+      (japanese-TeX-set-process-coding-system process)
+    (let ((cs (coding-system-base (with-current-buffer TeX-command-buffer
+                                   buffer-file-coding-system))))
+      ;; The value of `buffer-file-coding-system' is sometimes
+      ;; undecided-{unix,dos,mac}.  That happens when the file
+      ;; contains no multibyte chars and only end of line format is
+      ;; determined.  Emacs lisp reference recommends not to use
+      ;; undecided-* for process coding system, so it might seem
+      ;; reasonable to change `undecided' into some fixed coding
+      ;; system like this:
+      ;; (if (eq 'undecided cs)
+      ;;     (setq cs 'utf-8))
+      ;; However, that can lose when the following conditions are met:
+      ;; (1) The document is divided into multiple files.
+      ;; (2) The command buffer contains no multibyte chars.
+      ;; (3) The other files contain mutlibyte chars and saved in a
+      ;;     coding system other than the one chosen above.
+      ;; So we leave `undecided' unchanged here.  Although `undecided'
+      ;; is not quite safe for the coding system for encoding, i.e.,
+      ;; keyboard input to the TeX process, we expect that this does
+      ;; not raise serious problems because it is pretty rare that TeX
+      ;; process needs keyboard input of multibyte chars.
+
+      ;; `utf-8-with-signature' (UTF-8 with BOM) doesn't suit at all
+      ;; for the coding system for encoding because it always injects
+      ;; 3-byte BOM in front of its return value (even when the string
+      ;; to be sent has only ascii characters!)  Thus we change it
+      ;; into `utf-8'.  On decoding, `utf-8' can decode UTF-8 with
+      ;; BOM.  So it is safe for both decoding and encoding.
+      (if (eq cs 'utf-8-with-signature)
+         (setq cs 'utf-8))
+
+      ;; Eol format of TeX files can differ from OS default. TeX
+      ;; binaries accept all type of eol format in the given files
+      ;; and output messages according to OS default.  So we set eol
+      ;; format to OS default value.
+      (setq cs (coding-system-change-eol-conversion
+               cs
+               ;; The eol of macosX is LF, not CR.  So we choose
+               ;; other than `unix' only for w32 system.
+               ;; FIXME: what should we do for cygwin?
+               (if (eq system-type 'windows-nt) 'dos 'unix)))
+      (set-process-coding-system process cs cs))))
 
 (defcustom TeX-show-compilation nil
   "*If non-nil, show output of TeX compilation in other window."
@@ -1982,14 +2024,22 @@ command."
        (with-current-buffer TeX-command-buffer
         (TeX-process-buffer (TeX-active-master)))))
 
-(defun TeX-active-master (&optional extension nondirectory)
+(defun TeX-active-master (&optional extension nondirectory _ignore)
   "The master file currently being compiled.
 
 If optional argument EXTENSION is non-nil, add that file extension to
 the name.  Special value t means use `TeX-default-extension'.
 
 If optional second argument NONDIRECTORY is non-nil, do not include
-the directory."
+the directory.
+
+The compatibility argument IGNORE is ignored."
+  ;; The third argument `_ignore' is kept for symmetry with
+  ;; `TeX-master-file's third argument `ask'.  For example, it's used
+  ;; in `TeX--master-or-region-file-with-extra-quotes', where we don't
+  ;; know which function has to be called.  Keep this in mind should
+  ;; you want to use another argument here.
+  ;; See also the similar comment in `TeX-region-file'.
   (if TeX-current-process-region-p
       (TeX-region-file extension nondirectory)
     (TeX-master-file extension nondirectory)))
@@ -2027,7 +2077,33 @@ The hooks are run in the region buffer, you may use the 
variable
     (while (setq pos (string-match "[~#]" file pos))
       (setq file (replace-match "\\\\string\\&" t nil file 0)
            pos (+ pos 8))))
-  file)
+  ;; Use \unexpanded so that \message outputs the raw file name.
+  ;; When \usepackage[utf8]{inputenc} is used in standard (pdf)latex,
+  ;; \message does not output non-ascii file name in raw form without
+  ;; \unexpanded, which makes AUCTeX to fail to recognize the file
+  ;; names right when analysing the process output buffer.
+  ;; Note that \usepackage[utf8]{inputenc} is enabled by default in
+  ;; standard (pdf)latex since TeXLive 2018.
+  (if (and (memq major-mode '(latex-mode doctex-mode))
+          ;; Japanese upLaTeX requires the same treatment with
+          ;; respect to non-ascii characters other than Japanese, in
+          ;; file names within \message{}.
+          ;; However, pLaTeX (non u- version) does not support
+          ;; non-ascii file name encoded in UTF-8.  So considering
+          ;; `ptex' doesn't make sense here.  We cater for only
+          ;; `default' and `uptex' engines.
+          (memq TeX-engine '(default uptex)))
+      ;; It would fail to put entire `file' inside \unexpanded{} when
+      ;; the above loop injects \string before "#" and "~".  So put
+      ;; only multibyte characters inside \unexpanded{}.
+      ;; It is safe in upLaTeX to use \unexpanded{} on Japanese
+      ;; characters though they are handled by upLaTeX in a totally
+      ;; different way from inputenc.
+      ;; Thus put all multibyte characters, without considering
+      ;; whether they are Japanese or not, inside \unexpanded{}.
+      (replace-regexp-in-string "[[:multibyte:]]+"
+                               "\\\\unexpanded{\\&}" file t)
+    file))
 
 (defvar font-lock-mode-enable-list)
 (defvar font-lock-auto-fontify)
@@ -2092,8 +2168,10 @@ original file."
                           (if (not (re-search-forward TeX-header-end nil t))
                               ""
                             (re-search-forward "[\r\n]" nil t)
-                            (buffer-substring (point-min) (point)))))))))
+                            (buffer-substring-no-properties
+                             (point-min) (point)))))))))
         (header-offset 0)
+        first-line
         ;; We search for the trailer from the master file, if it is
         ;; not present in the region.
         (trailer-offset 0)
@@ -2113,21 +2191,36 @@ original file."
                              ;;(beginning-of-line 1)
                              (re-search-backward "[\r\n]" nil t)
                              (setq trailer-offset (TeX-current-offset))
-                             (buffer-substring (point) (point-max))))))))))
+                             (buffer-substring-no-properties
+                              (point) (point-max))))))))))
     ;; file name should be relative to master
     (setq original (TeX-quote-filename (file-relative-name
                                        original (TeX-master-directory)))
          master-name (TeX-quote-filename master-name))
+
+    ;; If the first line begins with "%&", put that line separately on
+    ;; the very first line of the region file so that the first line
+    ;; parsing will work.
+    (setq first-line (if (and (> (length header) 1)
+                             (string= (substring header 0 2) "%&"))
+                        ;; This would work even if header has no newline.
+                        (substring header 0 (string-match "\n" header))
+                      ""))
+    (unless (string= first-line "")
+      ;; Remove first-line from header.
+      (setq header (substring header (length first-line)))
+      (setq first-line (concat first-line "\n")))
+
     (with-current-buffer file-buffer
       (setq buffer-read-only t
            buffer-undo-list t)
       (setq original-content (buffer-string))
       (let ((inhibit-read-only t))
        (erase-buffer)
-       (when (boundp 'buffer-file-coding-system)
-         (setq buffer-file-coding-system
-               (with-current-buffer master-buffer buffer-file-coding-system)))
-       (insert "\\message{ !name(" master-name ")}"
+       (setq buffer-file-coding-system
+             (with-current-buffer master-buffer buffer-file-coding-system))
+       (insert first-line
+               "\\message{ !name(" master-name ")}"
                header
                TeX-region-extra
                "\n\\message{ !name(" original ") !offset(")
diff --git a/tex-fold.el b/tex-fold.el
index 16dacae..82b6ca8 100644
--- a/tex-fold.el
+++ b/tex-fold.el
@@ -569,20 +569,21 @@ TYPE can be either 'env for environments, 'macro for 
macros or
   "Return t if an overfull line will result after adding an overlay.
 The overlay extends from OV-START to OV-END and will display the
 string DISPLAY-STRING."
-  (save-excursion
-    (goto-char ov-end)
-    (search-backward "\n" ov-start t))
-  (not (string-match "\n" display-string))
-  (> (+ (- ov-start
-          (save-excursion
-            (goto-char ov-start)
-            (line-beginning-position)))
-       (length display-string)
-       (- (save-excursion
-            (goto-char ov-end)
-            (line-end-position))
-          ov-end))
-     (current-fill-column)))
+  (and
+   (save-excursion
+     (goto-char ov-end)
+     (search-backward "\n" ov-start t))
+   (not (string-match "\n" display-string))
+   (> (+ (- ov-start
+           (save-excursion
+             (goto-char ov-start)
+             (line-beginning-position)))
+        (length display-string)
+        (- (save-excursion
+             (goto-char ov-end)
+             (line-end-position))
+           ov-end))
+      (current-fill-column))))
 
 (defun TeX-fold-macro-nth-arg (n macro-start &optional macro-end delims)
   "Return a property list of the argument number N of a macro.
diff --git a/tex-jp.el b/tex-jp.el
index 83e66af..c20e62d 100644
--- a/tex-jp.el
+++ b/tex-jp.el
@@ -1,6 +1,6 @@
 ;;; tex-jp.el --- Support for Japanese TeX.  -*- coding: iso-2022-jp-unix; -*-
 
-;; Copyright (C) 1999, 2001-2008, 2012-2013, 2016-2017
+;; Copyright (C) 1999, 2001-2008, 2012-2013, 2016-2018
 ;;   Free Software Foundation, Inc.
 
 ;; Author:     KOBAYASHI Shinji <address@hidden>,
@@ -50,7 +50,7 @@
                 (const :tag "jTeX" jtex)
                 (const :tag "upTeX" uptex)))
 
-(defcustom japanese-TeX-use-kanji-opt-flag (not (eq system-type 'windows-nt))
+(defcustom japanese-TeX-use-kanji-opt-flag t
   "Add kanji option to Japanese pTeX family if non-nil.
 If `TeX-japanese-process-input-coding-system' or
 `TeX-japanese-process-output-coding-system' are non-nil, the process coding
@@ -64,55 +64,6 @@ systems are determined by their values regardless of the 
kanji option."
                (jtex "jTeX" "jtex" "jlatex" nil)
                (uptex "upTeX" "euptex" "uplatex" "euptex"))))
 
-;; $B=gD4$K9T$1$PITMW$K$J$k!#(B
-(defcustom japanese-TeX-command-list
-  ;; Changed to double quotes for Windows afflicted people.  I don't
-  ;; use the %(latex) and %(tex) shorthands here because I have not
-  ;; clue whether Omega-related versions exist.  --dak
-  '(("jTeX" "%(PDF)jtex %`%S%(PDFout)%(mode)%' %t"
-     TeX-run-TeX nil (plain-tex-mode) :help "Run NTT jTeX")
-    ("jLaTeX" "%(PDF)jlatex %`%S%(PDFout)%(mode)%' %t"
-     TeX-run-TeX nil (latex-mode) :help "Run NTT jLaTeX")
-    ("pTeX" "%(PDF)ptex %(kanjiopt)%`%S%(PDFout)%(mode)%' %t"
-     TeX-run-TeX nil (plain-tex-mode) :help "Run ASCII pTeX")
-    ("pLaTeX" "%(PDF)platex %(kanjiopt)%`%S%(PDFout)%(mode)%' %t"
-     TeX-run-TeX nil (latex-mode) :help "Run ASCII pLaTeX")
-    ("Mendex" "mendex %(mendexkopt)%s" TeX-run-command nil t :help "Create 
index file with mendex")
-    ("jBibTeX" "jbibtex %s" TeX-run-BibTeX nil t :help "Run jBibTeX")
-    ("pBibTeX" "pbibtex %(kanjiopt)%s" TeX-run-BibTeX nil t :help "Run 
pBibTeX"))
-  "Additional list of commands, especially for Japanese.
-For detail, see `TeX-command-list', to which this list is appended."
-  :group 'AUCTeX-jp
-  :type '(repeat (group :value ("" "" TeX-run-command nil t)
-                       (string :tag "Name")
-                       (string :tag "Command")
-                       (choice :tag "How"
-                               :value TeX-run-command
-                               (function-item TeX-run-command)
-                               (function-item TeX-run-format)
-                               (function-item TeX-run-TeX)
-                               (function-item TeX-run-interactive)
-                               (function-item TeX-run-BibTeX)
-                               (function-item TeX-run-compile)
-                               (function-item TeX-run-shell)
-                               (function-item TeX-run-discard)
-                               (function-item TeX-run-background)
-                               (function-item TeX-run-silent)
-                               (function-item TeX-run-discard-foreground)
-                               (function-item TeX-run-function)
-                               (function-item TeX-run-discard-or-function)
-                               (function :tag "Other"))
-                       (boolean :tag "Prompt")
-                       (choice :tag "Modes"
-                               (const :tag "All" t)
-                               (set (const :tag "Plain TeX" plain-tex-mode)
-                                    (const :tag "LaTeX" latex-mode)
-                                    (const :tag "DocTeX" doctex-mode)
-                                    (const :tag "ConTeXt" context-mode)
-                                    (const :tag "Texinfo" texinfo-mode)
-                                    (const :tag "AmSTeX" ams-tex-mode)))
-                       (repeat :tag "Menu elements" :inline t sexp))))
-
 ;; customize option $B$N=i4|CM$d(B saved value 
$B$=$N$b$N$r2~JQ$7$J$$$h$&$K(B
 ;; $B$9$k$?$a!"(Bsetcar $B$N;HMQ$OHr$1$k!#(B
 (setq TeX-command-list
@@ -133,12 +84,6 @@ For detail, see `TeX-command-list', to which this list is 
appended."
           l)))
        TeX-command-list))
 
-;; $B=gD4$K9T$1$PITMW$K$J$k!#(B
-(setq TeX-command-list
-      (append japanese-TeX-command-list
-             '(("-" "" ignore nil t)) ;; separator for command menu
-             TeX-command-list))
-
 ;; Define before first use.
 (defvar japanese-TeX-mode nil
   "Non-nil means the current buffer handles Japanese TeX/LaTeX.")
@@ -151,12 +96,7 @@ For detail, see `TeX-command-list', to which this list is 
appended."
        '(
         ;; -kanji $B%*%W%7%g%s$NJ8;zNs$r:n$k!#(B
         ("%(kanjiopt)" (lambda ()
-                         (if (and
-                              ;; non-mule $B$J(B emacsen 
$B$O$=$b$=$bF|K\8l(B
-                              ;; $BJ8=q$r(B typeset 
$B$9$k$3$H$O9M$($J$/$F$b(B
-                              ;; address@hidden&!"$H$O;W$&$1$I0l1~!D!#(B
-                              (featurep 'mule)
-                              japanese-TeX-use-kanji-opt-flag)
+                         (if japanese-TeX-use-kanji-opt-flag
                              (let ((str (japanese-TeX-get-encoding-string)))
                                (if str (format " -kanji=%s " str) ""))
                            "")))
@@ -189,8 +129,7 @@ For detail, see `TeX-command-list', to which this list is 
appended."
                            (t "makeindex"))))
         ;; mendex $BMQF|K\8l%3!<%I%*%W%7%g%s!#(B
         ("%(mendexkopt)" (lambda ()
-                           (if (and (featurep 'mule)
-                                    japanese-TeX-use-kanji-opt-flag)
+                           (if japanese-TeX-use-kanji-opt-flag
                                (let ((str (japanese-TeX-get-encoding-string)))
                                  ;; $B#1J8;zL\$rBgJ8;z$K!#(B
                                  (if str (format " -%c " (upcase (aref str 0)))
@@ -368,12 +307,14 @@ See also a user custom option 
`TeX-japanese-process-input-coding-system'."
                   ;; ptex $B$J$i(B mac $B$O(B utf-8$B!#(B
                   ;; windows $B$G(B -kanji 
$B%*%W%7%g%s$"$j$N;~$O$=$NJ8;z%3!<%I!"(B
                   ;; $B$J$7$N;~$O(B sjis$B!#(B
+                  ;; texlive 2018 $B$+$i$O(B sjis $B$G$O$J$/(B utf-8 
$B$K$J$C$?$N$G(B
+                  ;; $B$=$A$i$K9g$o$;$k!#(B
                   ((eq TeX-engine 'ptex)
                    (cond ((eq system-type 'darwin)
                           'utf-8)
                          ((and japanese-TeX-use-kanji-opt-flag kanji)
                           kanji)
-                         (t 'shift_jis)))
+                         (t 'utf-8)))
                   ;; jtex $B$J$i(B sjis $B$K8GDj$9$k!#(B
                   ((eq TeX-engine 'jtex)
                    'shift_jis)
@@ -398,11 +339,12 @@ See also a user custom option 
`TeX-japanese-process-input-coding-system'."
           (enc (cond
                 ;; ptex $B$G(B -kanji 
$B%*%W%7%g%s$"$j$J$i!"$=$NJ8;z%3!<%I!#(B
                 ;; $B$J$7$J$i(B utf-8 $B$+(B sjis$B!#(B
+                ;; texlive 2018 $B$G(B w32 $B$G$b(B utf-8 
$B$,%G%U%)%k%H$K$J$C(B
+                ;; $B$?$h$&$J$N$G!"$=$l$K9g$o$;$k!#(B
                 ((eq TeX-engine 'ptex)
                  (if (and japanese-TeX-use-kanji-opt-flag kanji)
                      kanji
-                   (if (eq system-type 'windows-nt)
-                       'shift_jis 'utf-8)))
+                   'utf-8))
                 ;; jtex $B$J$i(B euc $B$+(B sjis $B$K8GDj$9$k!#(B
                 ((eq TeX-engine 'jtex)
                  (if (memq system-type '(windows-nt darwin))
@@ -438,6 +380,8 @@ Return nil otherwise."
                 (iso-2022-jp . "jis")
                 (japanese-shift-jis . "sjis")
                 (utf-8 . "utf8")
+               ;; TeXLive 2018 $B$+$i(B BOM $B$D$-(B UTF-8 
$B$b%5%]!<%H$5$l$?!#(B
+                (utf-8-with-signature . "utf8")
 
                 (euc-jis-2004 . "euc")
                 (iso-2022-jp-2004 . "jis")
@@ -578,15 +522,15 @@ overwrite the value already set locally."
 
 ;;; Support for various self-insert-command
 
-(fset 'japanese-TeX-self-insert-command
-      (cond ((fboundp 'can-n-egg-self-insert-command)
-            #'can-n-egg-self-insert-command)
-           ((fboundp 'egg-self-insert-command)
-            #'egg-self-insert-command)
-           ((fboundp 'canna-self-insert-command)
-            #'canna-self-insert-command)
-           (t
-            #'self-insert-command)))
+(defalias 'japanese-TeX-self-insert-command
+  (cond ((fboundp 'can-n-egg-self-insert-command)
+        #'can-n-egg-self-insert-command)
+       ((fboundp 'egg-self-insert-command)
+        #'egg-self-insert-command)
+       ((fboundp 'canna-self-insert-command)
+        #'canna-self-insert-command)
+       (t
+        #'self-insert-command)))
 
 (defun TeX-insert-punctuation ()
   "Insert point or comma, cleaning up preceding space."
diff --git a/tex-site.el.in b/tex-site.el.in
index 2e2e445..3f29021 100644
--- a/tex-site.el.in
+++ b/tex-site.el.in
@@ -1,6 +1,6 @@
 ;;; tex-site.el - Site specific variables.  Don't edit.
 
-;; Copyright (C) 2005, 2013, 2016-2017 Free Software Foundation, Inc.
+;; Copyright (C) 2005, 2013, 2016-2018 Free Software Foundation, Inc.
 ;;
 ;; completely rewritten.
 
@@ -54,7 +54,7 @@
   "A (La)TeX environment."
   :tag "AUCTeX"
   :link '(custom-manual "(auctex)Top")
-  :link '(url-link :tag "Home Page" "http://www.gnu.org/software/auctex/";)
+  :link '(url-link :tag "Home Page" "https://www.gnu.org/software/auctex/";)
   :prefix "TeX-"
   :group 'tex
   :load "tex" :load "latex" :load "tex-style")
diff --git a/tex.el b/tex.el
index d9a0b93..9995af3 100644
--- a/tex.el
+++ b/tex.el
@@ -109,11 +109,6 @@ If nil, none is specified."
   :type 'hook
   :group 'TeX-misc)
 
-(defcustom AmS-TeX-mode-hook nil
-  "A hook run in AmS-TeX mode buffers."
-  :type 'hook
-  :group 'TeX-misc)
-
 ;; This is the major configuration variable.  Most sites will only need to
 ;; change the second string in each entry, which is the name of a command to
 ;; send to the shell.  If you use other formatters like AMSLaTeX or AMSTeX, you
@@ -121,10 +116,10 @@ If nil, none is specified."
 ;; `TeX-expand-list-builtin' for a description of the % escapes
 
 (defcustom TeX-command-list
-  '(("TeX" "%(PDF)%(tex) %(file-line-error) %(extraopts) 
%`%S%(PDFout)%(mode)%' %t"
+  '(("TeX" "%(PDF)%(tex) %(file-line-error) %`%(extraopts) 
%S%(PDFout)%(mode)%' %t"
      TeX-run-TeX nil
      (plain-tex-mode ams-tex-mode texinfo-mode) :help "Run plain TeX")
-    ("LaTeX" "%`%l%(mode)%' %t"
+    ("LaTeX" "%`%l%(mode)%' %T"
      TeX-run-TeX nil
      (latex-mode doctex-mode) :help "Run LaTeX")
     ;; Not part of standard TeX.
@@ -132,7 +127,7 @@ If nil, none is specified."
      (texinfo-mode) :help "Run Makeinfo with Info output")
     ("Makeinfo HTML" "makeinfo %(extraopts) --html %t" TeX-run-compile nil
      (texinfo-mode) :help "Run Makeinfo with HTML output")
-    ("AmSTeX" "amstex %(PDFout) %(extraopts) %`%S%(mode)%' %t"
+    ("AmSTeX" "amstex %(PDFout) %`%(extraopts) %S%(mode)%' %t"
      TeX-run-TeX nil (ams-tex-mode) :help "Run AMSTeX")
     ;; support for ConTeXt  --pg
     ;; first version of ConTeXt to support nonstopmode: 2003.2.10
@@ -500,11 +495,22 @@ string."
                    (or (if TeX-source-correlate-output-page-function
                            (funcall TeX-source-correlate-output-page-function))
                        "1")))
-    ;; `file' means to call `TeX-master-file' or `TeX-region-file'
+    ;; `file' means to call `TeX-master-file', `TeX-region-file' or 
`TeX-active-master'
     ("%s" file nil t)
     ("%t" file t t)
+    ;; If any TeX codes appear in the interval between %` and %', move
+    ;; all of them after the interval and supplement " \input".  The
+    ;; appearance is marked by leaving the bind to `TeX-command-text'
+    ;; with the TeX codes.
+    ;; Rule:
+    ;; 1. %` and %' must appear in pair.
+    ;; 2. %` and %' must not appear more than once in one command
+    ;;    line string (including the results of %-expansion).
+    ;; 3. Each TeX codes between %` and %' must be enclosed in
+    ;;    double quotes and preceded by a space.
     ("%`" (lambda nil
-           (setq TeX-command-pos t TeX-command-text "")))
+           (setq TeX-command-pos t TeX-command-text nil)
+           ""))
     (" \"\\" (lambda nil
               (if (eq TeX-command-pos t)
                   (setq TeX-command-pos pos
@@ -528,18 +534,16 @@ string."
                                TeX-command-pos t)
                        (setq pos (1+ pos)))))
     ("%'" (lambda nil
-           (prog1
-               (if (stringp TeX-command-text)
-                   (progn
-                     (setq pos (+ pos (length TeX-command-text) 9)
-                           TeX-command-pos
-                           (and (string-match " "
-                                              (funcall file t t))
-                                "\""))
-                     (concat TeX-command-text " \"\\input\""))
-                 (setq TeX-command-pos nil)
-                 "")
-             (setq TeX-command-text nil))))
+           (setq TeX-command-pos nil)
+           (if (stringp TeX-command-text)
+               (progn
+                 (setq pos (+ pos (length TeX-command-text) 9))
+                 (concat TeX-command-text " \"\\input\""))
+             "")))
+    ;; The fourth argument of t is actually for wrapper function
+    ;; `TeX--master-or-region-file-with-extra-quotes', temporally set
+    ;; as value of `file' in `TeX-command-expand'.
+    ("%T" file t t nil t)
     ("%n" TeX-current-line)
     ("%d" file "dvi" t)
     ("%f" file "ps" t)
@@ -587,7 +591,7 @@ Programs should not use these variables directly but the 
function
 (defun TeX-expand-list ()
   "Complete list of expansion strings for TeX command names.
 
-Concatenate `TeX-expand-list' and `TeX-expand-list-bultin' making
+Concatenate `TeX-expand-list' and `TeX-expand-list-builtin' making
 sure \"%p\" is the first entry."
   (append
    ;; %p must be the first entry, see `TeX-print-command'.
@@ -1038,6 +1042,7 @@ If RESET is non-nil, `TeX-command-next' is reset to
 If no mode is given the current major mode is used."
   (cdr (assoc (or mode major-mode) '((plain-tex-mode . "plain-TeX")
                                     (latex-mode . "LaTeX")
+                                    (ams-tex-mode . "AmSTeX")
                                     (doctex-mode . "docTeX")
                                     (texinfo-mode . "Texinfo")
                                     (context-mode . "ConTeXt")))))
@@ -1369,7 +1374,7 @@ viewer."
                 "%d" (mode-io-correlate " \"# %n '%b'\"")) "dviout")
       ("SumatraPDF"
        ("SumatraPDF -reuse-instance"
-       (mode-io-correlate " -forward-search %b %n") " %o")
+       (mode-io-correlate " -forward-search \"%b\" %n") " %o")
        "SumatraPDF")
       ("dvips and start" "dvips %d -o && start \"\" %f" "dvips")
       ("start" "start \"\" %o")))
@@ -1403,7 +1408,7 @@ viewer."
       ("Zathura"
        ("zathura %o"
        (mode-io-correlate
-        " --synctex-forward %n:0:%b -x \"emacsclient +%{line} %{input}\""))
+        " --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
@@ -2395,11 +2400,12 @@ this variable to \"<none>\"."
 (defun TeX-dwim-master ()
   "Find a likely `TeX-master'."
   (let ((dir default-directory))
-    (dolist (buf (buffer-list))
-      (when (with-current-buffer buf
-             (and (equal dir default-directory)
-                  (stringp TeX-master)))
-       (cl-return (with-current-buffer buf TeX-master))))))
+    (cl-loop for buf in (buffer-list)
+             until
+             (when (with-current-buffer buf
+                    (and (equal dir default-directory)
+                         (stringp TeX-master)))
+               (cl-return (with-current-buffer buf TeX-master))))))
 
 (defun TeX-master-file-ask ()
   "Ask for master file, set `TeX-master' and add local variables."
@@ -4418,7 +4424,7 @@ Check for potential LaTeX environments."
 (defcustom TeX-file-extensions '("tex" "sty" "cls" "ltx" "texi" "txi" 
"texinfo" "dtx")
   "*File extensions used by manually generated TeX files."
   :group 'TeX-file-extension
-  :type '(repeat (string :format "%v")))
+  :type '(repeat (regexp :format "%v")))
 
 (defcustom TeX-all-extensions '("[^.\n]+")
   "All possible file extensions."
@@ -4433,8 +4439,8 @@ Check for potential LaTeX environments."
   (make-variable-buffer-local 'TeX-default-extension)
 
 (defvar TeX-doc-extensions
-  '("dvi" "pdf" "ps" "txt" "html" "dvi.gz" "pdf.gz" "ps.gz" "txt.gz" "html.gz"
-    "dvi.bz2" "pdf.bz2" "ps.bz2" "txt.bz2" "html.bz2")
+  '("dvi" "pdf" "ps" "txt" "html" "dvi\\.gz" "pdf\\.gz" "ps\\.gz" "txt\\.gz"
+    "html\\.gz" "dvi\\.bz2" "pdf\\.bz2" "ps\\.bz2" "txt\\.bz2" "html\\.bz2")
   "File extensions of documentation files.")
 
 (defcustom docTeX-default-extension "dtx"
@@ -4453,22 +4459,22 @@ Access to the value should be through the function 
`TeX-output-extension'.")
 (defcustom TeX-Biber-file-extensions '("bib" "ris" "xml")
   "Valid file extensions for Biber files."
   :group 'TeX-file-extension
-  :type '(repeat (string :format "%v")))
+  :type '(repeat (regexp :format "%v")))
 
 (defcustom BibTeX-file-extensions '("bib")
   "Valid file extensions for BibTeX files."
   :group 'TeX-file-extension
-  :type '(repeat (string :format "%v")))
+  :type '(repeat (regexp :format "%v")))
 
 (defcustom BibLaTeX-style-extensions '("bbx")
   "Valid file extensions for BibLaTeX styles."
   :group 'TeX-file-extension
-  :type '(repeat (string :format "%v")))
+  :type '(repeat (regexp :format "%v")))
 
 (defcustom BibTeX-style-extensions '("bst")
   "Valid file extensions for BibTeX styles."
   :group 'TeX-file-extension
-  :type '(repeat (string :format "%v")))
+  :type '(repeat (regexp :format "%v")))
 
 (defun TeX-match-extension (file &optional extensions)
   "Return non-nil if FILE has one of EXTENSIONS.
@@ -4546,7 +4552,9 @@ non-nil, remove file extension."
          result)
       (if (eq scope 'global)
          (setq dirs (delete "./" dirs)))
-      (setq extensions (concat "\\." (regexp-opt extensions t) "\\'")
+      (setq extensions (concat "\\.\\(?:"
+                              (mapconcat #'identity extensions "\\|")
+                              "\\)\\'")
            result (apply #'append (mapcar (lambda (x)
                                             (when (file-readable-p x)
                                               (directory-files
@@ -4609,7 +4617,6 @@ If optional argument EXTENSIONS is not set, use 
`TeX-file-extensions'"
 (defvar TeX-search-files-type-alist
   '((texinputs "${TEXINPUTS}" ("tex/") TeX-file-extensions)
     (docs "${TEXDOCS}" ("doc/") TeX-doc-extensions)
-    (graphics "${TEXINPUTS}" ("tex/") LaTeX-includegraphics-extensions)
     (bibinputs "${BIBINPUTS}" ("bibtex/bib/") BibTeX-file-extensions)
     (bstinputs "${BSTINPUTS}" ("bibtex/bst/") BibTeX-style-extensions))
   "Alist of filetypes with locations and file extensions.
@@ -6021,7 +6028,8 @@ With optional argument ARG, also reload the style hooks."
            BibLaTeX-global-style-files nil
            TeX-Biber-global-files nil
            TeX-global-input-files nil
-           LaTeX-global-class-files nil))
+           LaTeX-global-class-files nil
+           LaTeX-includegraphics-global-files nil))
   (let ((TeX-auto-save t))
     (if (buffer-modified-p)
        (save-buffer)
@@ -6250,11 +6258,11 @@ a bug report.  In addition check if the bug is 
reproducable with an
 up-to-date version of AUCTeX.  So please upgrade to the version
 available from ")
        (insert-text-button
-        "http://www.gnu.org/software/auctex/";
+        "https://www.gnu.org/software/auctex/";
         'face 'link
         'help-echo (concat "mouse-2, RET: Follow this link")
         'action (lambda (button)
-                  (browse-url "http://www.gnu.org/software/auctex/";))
+                  (browse-url "https://www.gnu.org/software/auctex/";))
         'follow-link t)
        (insert " if your
 installation is older than the one available from the web site.
@@ -6266,11 +6274,11 @@ in your report.
 Your report will be posted for the auctex package at the GNU bug
 tracker.  Visit ")
        (insert-text-button
-        "http://debbugs.gnu.org/cgi/pkgreport.cgi?pkg=auctex";
+        "https://debbugs.gnu.org/cgi/pkgreport.cgi?pkg=auctex";
         'face 'link
         'help-echo (concat "mouse-2, RET: Follow this link")
         'action (lambda (button)
-                  (browse-url 
"http://debbugs.gnu.org/cgi/pkgreport.cgi?pkg=auctex";))
+                  (browse-url 
"https://debbugs.gnu.org/cgi/pkgreport.cgi?pkg=auctex";))
         'follow-link t)
        (insert "\nto browse existing AUCTeX bugs.
 ------------------------------------------------------------------------\n\n")
@@ -6494,7 +6502,7 @@ NAME may be a package, a command, or a document."
                                   (cons (file-name-nondirectory name)
                                         (TeX-style-list)) "\\|")
                        "\\)\\.\\("
-                       (mapconcat 'regexp-quote TeX-file-extensions "\\|")
+                       (mapconcat #'identity TeX-file-extensions "\\|")
                        "\\)\\'"))
        (buffers (buffer-list)))
     (while buffers
diff --git a/toolbar-x.el b/toolbar-x.el
index 79dacdc..2eab8d3 100644
--- a/toolbar-x.el
+++ b/toolbar-x.el
@@ -1492,9 +1492,9 @@ this button is ignored."
 
 
 (defconst toolbarx-default-toolbar-meaning-alist
-  `((separator :image "sep" :command t :enable nil :help "")
+  '((separator :image "sep" :command t :enable nil :help "")
 
-    ('new-file
+    (new-file
      :image ["new" toolbar-file-icon]
      :command [find-file toolbar-open]
      :enable [(not (window-minibuffer-p
@@ -1502,7 +1502,7 @@ this button is ignored."
              t]
      :help ["Specify a new file's name, to edit the file" "Visit new file"])
 
-    '(open-file :image ["open" toolbar-file-icon]
+    (open-file :image ["open" toolbar-file-icon]
                :command [menu-find-file-existing toolbar-open]
                :enable [(not (window-minibuffer-p
                               (frame-selected-window menu-updating-frame)))



reply via email to

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