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

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

[elpa] externals/auctex d563566 42/43: Merge branch 'master' into extern


From: Tassilo Horn
Subject: [elpa] externals/auctex d563566 42/43: Merge branch 'master' into externals/auctex
Date: Tue, 20 Mar 2018 11:34:16 -0400 (EDT)

branch: externals/auctex
commit d5635660eb900d41a91018ed4d3245e91eb7d31c
Merge: aeeedbd c1f04df
Author: Tassilo Horn <address@hidden>
Commit: Tassilo Horn <address@hidden>

    Merge branch 'master' into externals/auctex
---
 Makefile.in                  |   2 +-
 bib-cite.el                  | 269 +++------------
 context.el                   |   2 +-
 doc/auctex.texi              |  29 +-
 doc/changes.texi             |   9 +
 font-latex.el                | 120 ++-----
 latex-flymake.el             | 104 ++++++
 latex.el                     | 321 +++++++-----------
 plain-tex.el                 |   2 +-
 preview.el                   |  14 +-
 prv-xemacs.el                | 759 -------------------------------------------
 style/alphanum.el            |   6 +-
 style/amsmath.el             |   5 +-
 style/babel.el               |   7 +-
 style/bidi.el                | 154 ++++++++-
 style/caption.el             |  22 +-
 style/currvita.el            |   2 +-
 style/dinbrief.el            |   4 +-
 style/dk-bib.el              |   4 +-
 style/doc.el                 |   4 +-
 style/empheq.el              |  12 +-
 style/enumitem.el            |  20 +-
 style/floatrow.el            |  17 +-
 style/fvextra.el             |   9 +-
 style/inputenc.el            |   4 +-
 style/jura.el                |   4 +-
 style/listings.el            |  16 +-
 style/ltx-base.el            |   4 +-
 style/ltxdoc.el              |   4 +-
 style/mdframed.el            |  13 +-
 style/minted.el              |   6 +-
 style/moodle.el              |   2 +-
 style/pdfsync.el             |   2 +-
 style/tcolorbox.el           |   7 +-
 style/tcolorboxlib-raster.el |   2 +-
 style/url.el                 |   8 +-
 tex-buf.el                   | 163 ++++------
 tex-fold.el                  |  85 ++---
 tex-font.el                  |  10 +-
 tex-info.el                  |  29 +-
 tex-jp.el                    |  50 +--
 tex.el                       | 386 +++++++---------------
 texmathp.el                  |  14 +-
 toolbar-x.el                 | 613 ++++------------------------------
 44 files changed, 895 insertions(+), 2424 deletions(-)

diff --git a/Makefile.in b/Makefile.in
index abe2b2e..5a61a37 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -86,7 +86,7 @@ MULEELC = @MULEELC@
 AUCSRC = tex.el tex-buf.el tex-style.el plain-tex.el latex.el tex-info.el \
        texmathp.el multi-prompt.el tex-mik.el font-latex.el tex-font.el \
        context.el context-en.el context-nl.el tex-fold.el \
-       toolbar-x.el tex-bar.el bib-cite.el tex-ispell.el
+       toolbar-x.el tex-bar.el bib-cite.el tex-ispell.el latex-flymake.el
 AUCELC = $(AUCSRC:.el=.elc)
 
 STYLESRC = style/prosper.el \
diff --git a/bib-cite.el b/bib-cite.el
index 0ff47fb..5cb8a1d 100644
--- a/bib-cite.el
+++ b/bib-cite.el
@@ -589,7 +589,8 @@
 ;; ----------------------------------------------------------------------------
 ;;; Code:
 
-(eval-when-compile (require 'cl))
+(eval-when-compile
+  (require 'cl-lib))
 
 (defgroup bib-cite nil
   "bib-cite, LaTeX minor-mode to display \\cite, \\ref and \\label commands."
@@ -759,32 +760,17 @@ runs bib-find, and [mouse-3] runs bib-display."
        (progn
          (bib-cite-setup-highlight-mouse-keymap)
          (bib-highlight-mouse)
-         (when (featurep 'xemacs)
-           (make-local-hook 'after-change-functions))
          (add-hook 'after-change-functions
-                   'bib-cite-setup-mouse-function nil t)))
-    (if (featurep 'xemacs)
-       (progn
-         (or (local-variable-p 'current-menubar (current-buffer))
-             (set-buffer-menubar current-menubar))
-         (add-submenu nil bib-cite-minor-mode-menu))))
+                   'bib-cite-setup-mouse-function nil t))))
    (t
    ;;;Undo the minor-mode
     ;; mouse overlay
-    (cond
-     ((featurep 'xemacs)
-      (while bib-ext-list
-       (delete-extent (car bib-ext-list))
-       (setq bib-ext-list (cdr bib-ext-list))))
-     (t
-      (remove-hook 'after-change-functions 'bib-cite-setup-mouse-function t)
-      (let ((before-change-functions) (after-change-functions))
-       ;; FIXME This detroys all mouse-faces and local-maps!
-       ;; FIXME Hope no other package is using them in this buffer!
-       (remove-text-properties (point-min) (point-max)
-                               '(mouse-face t local-map t)))))
-    (if (featurep 'xemacs)
-       (delete-menu-item '("BCite"))))))
+    (remove-hook 'after-change-functions 'bib-cite-setup-mouse-function t)
+    (let ((before-change-functions) (after-change-functions))
+      ;; FIXME This detroys all mouse-faces and local-maps!
+      ;; FIXME Hope no other package is using them in this buffer!
+      (remove-text-properties (point-min) (point-max)
+                             '(mouse-face t local-map t))))))
 
 ;;This must be eval'ed when the LaTeX mode is in use.
 ;; bib-highlight-mouse-keymap is a local variable so each buffer can have it's
@@ -799,46 +785,22 @@ runs bib-find, and [mouse-3] runs bib-display."
    ;;;        menus to display.  Maybe on `highlighted' commands we could only
    ;;;        display the bib-cite stuff (or a subset of it).
        (let ((m (copy-keymap (current-local-map))))
+         ;; emacs 19
          (cond
-          ((featurep 'xemacs)
-           (set-keymap-name m 'bib-highlight-mouse-keymap)
-           (cond
-            ;;action-key stuff from Vladimir Alexiev <address@hidden>
-            ((commandp 'action-key)
-             ;; for hyperbole. The Right Way is to define implicit buttons
-             ;; (defib) bib-cite and label-ref instead of overriding
-             ;; action-key and assist key, so that eg smart key help can
-             ;; be obtained, but I'm lazy.
-             (substitute-key-definition 'action-key 'bib-find m global-map)
-             (substitute-key-definition 'assist-key 'bib-display m global-map)
-             (substitute-key-definition 'action-key-depress
-                                        'bib-find-mouse m global-map)
-             (substitute-key-definition 'assist-key-depress
-                                        'bib-display-mouse m global-map)
-             (substitute-key-definition 'action-mouse-key nil m global-map)
-             (substitute-key-definition 'assist-mouse-key nil m global-map))
-            (t                               ; xemacs, not hyperbole
-             (define-key m "\e\r" 'bib-find-mouse) ;   bug Fixed in V2.17
-             (define-key m "\e\n" 'bib-display-mouse) ;bug Fixed in V2.17
-             ;;(define-key m [(shift button1)] 'bib-display-mouse)
-             (define-key m [button3] 'bib-display-mouse)
-             (define-key m [button2] 'bib-find-mouse))))
-           (t                                 ; emacs 19
-            (cond
-             ((commandp 'action-key)
-              (substitute-key-definition 'action-key 'bib-find m global-map)
-              (substitute-key-definition 'assist-key 'bib-display m global-map)
-              (substitute-key-definition 'action-mouse-key-emacs19
-                                         'bib-find-mouse m global-map)
-              (substitute-key-definition 'assist-mouse-key-emacs19
-                                         'bib-display-mouse m global-map)
-              (substitute-key-definition 'action-key-depress-emacs19
-                                         nil m global-map)
-              (substitute-key-definition 'assist-key-depress-emacs19
-                                         nil m global-map))
-             (t                               ; emacs 19, not hyperbole
-              (define-key m [down-mouse-3] 'bib-display-mouse)
-              (define-key m [mouse-2] 'bib-find-mouse)))))
+          ((commandp 'action-key)
+           (substitute-key-definition 'action-key 'bib-find m global-map)
+           (substitute-key-definition 'assist-key 'bib-display m global-map)
+           (substitute-key-definition 'action-mouse-key-emacs19
+                                      'bib-find-mouse m global-map)
+           (substitute-key-definition 'assist-mouse-key-emacs19
+                                      'bib-display-mouse m global-map)
+           (substitute-key-definition 'action-key-depress-emacs19
+                                      nil m global-map)
+           (substitute-key-definition 'assist-key-depress-emacs19
+                                      nil m global-map))
+          (t                               ; emacs 19, not hyperbole
+           (define-key m [down-mouse-3] 'bib-display-mouse)
+           (define-key m [mouse-2] 'bib-find-mouse)))
          m)))
 
 ;;;###autoload
@@ -888,83 +850,6 @@ runs bib-find, and [mouse-3] runs bib-display."
                minor-mode-map-alist)))
 
 
-;;; Add a menu entry to bibtex.el (Perhaps I should not do this).
-(cond
- ((and (featurep 'xemacs)
-       (or window-system
-          (fboundp 'smart-menu)))      ;text menus by Bob Weiner
-  ;;
-  ;; xemacs under X with AUCTeX
-  ;;
-
-  ;; Add to bibtex.el's popup menu
-  (defvar bib-cite-xemacs-bibtex-mode-menu
-    '("---"
-      "Bib-Cite"
-      "---"
-      ["Search apropos BibTeX files" bib-apropos t]
-      ["Create AUCTeX auto parsing file" bib-create-auto-file t])
-    "Submenu of bibtex-mode menu, used by bib-cite.")
-
-  (if (boundp 'bibtex-menu)
-      ;; Add menu now
-      (setq bibtex-menu
-           (append
-            bibtex-menu
-            bib-cite-xemacs-bibtex-mode-menu))
-    ;; Setup to add menu later
-    (defun bib-cite-bibtex-mode-hook ()
-      (if (boundp 'bibtex-menu)
-         (progn
-           (setq bibtex-menu
-                 (append
-                  bibtex-menu
-                  bib-cite-xemacs-bibtex-mode-menu))
-           (remove-hook 'bibtex-mode-hook 'bib-cite-bibtex-mode-hook))))
-    (add-hook 'bibtex-mode-hook 'bib-cite-bibtex-mode-hook))
-  )
-
- ((and (not (featurep 'xemacs))
-       (string-equal "19" (substring emacs-version 0 2))
-       (or window-system
-          (fboundp 'tmm-menubar)))     ; 19.30 - Will autoload if necessary
-  ;;
-  ;; emacs-19 under X-windows (or non-X with tmm)
-  ;;
-
-  ;; This *almost* makes me want to switch over to XEmacs...
-
-  ;; to AUCTeX auto file for a bibtex buffer
-  (eval-after-load
-   "bibtex"
-   '(progn
-      (add-hook 'bibtex-mode-hook 'TeX-bibtex-set-BibTeX-dialect)
-      (cond
-       ((lookup-key bibtex-mode-map [menu-bar move/edit])
-       (define-key-after
-         (lookup-key bibtex-mode-map [menu-bar move/edit])
-         [bib-nil] '("---" . nil) '"--")
-       (define-key-after
-         (lookup-key bibtex-mode-map [menu-bar move/edit])
-         [bib-apropos] '("Search Apropos" . bib-apropos) 'bib-nil)
-       (define-key-after
-         (lookup-key bibtex-mode-map [menu-bar move/edit])
-         [auc-tex-parse]
-         '("Create AUCTeX auto parsing file" . bib-create-auto-file)
-         'bib-apropos))
-       ((lookup-key bibtex-mode-map [menu-bar bibtex-edit])
-       (define-key-after
-         (lookup-key bibtex-mode-map [menu-bar bibtex-edit])
-         [bib-nil] '("---" . nil) '"--")
-       (define-key-after
-         (lookup-key bibtex-mode-map [menu-bar bibtex-edit])
-         [bib-apropos] '("Search Apropos" . bib-apropos) 'bib-nil)
-       (define-key-after
-         (lookup-key bibtex-mode-map [menu-bar bibtex-edit])
-         [auc-tex-parse]
-         '("Create AUCTeX auto parsing file" . bib-create-auto-file)
-         'bib-apropos)))))))
-
 ;; Following from bibtex.el
 (defvar
   bib-cite-bibtex-font-lock-keywords
@@ -1227,19 +1112,6 @@ to create a bibtex file containing only the references 
used in the document."
       (put-text-property (point-min)(or limit (point-max))
                         'face 'red-bold))))
 
-(when (featurep 'xemacs)
-  (defun bib-cite-fontify-help-xemacs (defaults)
-    (if (fboundp 'font-lock-set-defaults-1) ; >= XEmacs 19.14
-        (with-current-buffer "*Help*"
-          (setq font-lock-defaults-computed nil
-                font-lock-keywords nil)
-          (font-lock-set-defaults-1
-           (and defaults (font-lock-find-font-lock-defaults defaults)))
-          (font-lock-fontify-buffer)
-          (setq font-lock-defaults-computed nil
-                font-lock-keywords nil)
-          (font-lock-set-defaults-1)))))
-
 (defun bib-cite--fontify-help ()
   ;; FIXME: This looks ugly and incorrect.
   (if font-lock-mode
@@ -1254,10 +1126,6 @@ to create a bibtex file containing only the references 
used in the document."
   (cond
    ((not (featurep 'font-lock))
     nil)                                ;No font-lock! Stop here.
-   ;; font-lock under Emacs and XEmacs
-   ((featurep 'xemacs)
-    ;; XEmacs
-    (bib-cite-fontify-help-xemacs 'bibtex-mode))
    (t
     ;; Emacs
     (with-current-buffer "*Help*"
@@ -1270,11 +1138,6 @@ to create a bibtex file containing only the references 
used in the document."
   (cond
    ((not (featurep 'font-lock))
     nil)                                ;No font-lock! Stop here.
-   ;; font-lock under Emacs and XEmacs
-   ((featurep 'xemacs)
-    ;; XEmacs, not necessary to do s.th. special for font-latex, we do *not*
-    ;; want the buffer-local faces!
-    (bib-cite-fontify-help-xemacs 'latex-mode))
    (t
     ;; Emacs
     (with-current-buffer "*Help*"
@@ -1337,9 +1200,8 @@ See variables bib-etags-command and bib-etags-filename"
     ;;  buffer and returns an error because TAGS buffer does have
     ;;  tags-file-name set.
     ;;  To get around this.  I'm setting this variable in the TAGS buffer.
-    ;; Skip this in XEmacs (Changed by Anders Stenman)
-    (if (and (not (featurep 'xemacs))
-            (get-file-buffer the-tags-file))
+    ;; (Changed by Anders Stenman)
+    (if (get-file-buffer the-tags-file)
        (with-current-buffer (get-file-buffer the-tags-file)
          (set (make-local-variable 'tags-file-name) the-tags-file))))
 
@@ -1381,21 +1243,12 @@ See variables bib-etags-command and bib-etags-filename"
       ;; * peta Wed Nov  8 16:27:29 1995 -- better remove the mouse face
       ;;   properties first.
       (setq bib-ext-list nil)          ;Reconstructed below...
-      (if (featurep 'xemacs)
-         (while local-extent-list
-           (setq extent (car local-extent-list))
-           (if (or (extent-detached-p extent)
-                   (and (<= (point-min)(extent-start-position extent))
-                        (>= (point-max)(extent-end-position extent))))
-               (delete-extent extent)
-             (setq bib-ext-list (cons extent bib-ext-list)))
-           (setq local-extent-list (cdr local-extent-list)))
-       ;; Remove properties for regular emacs
-       ;; FIXME This detroys all mouse-faces and local-maps!
-       ;; FIXME Hope no other package is using them in this buffer!
-       (let ((before-change-functions) (after-change-functions))
-         (remove-text-properties (point-min) (point-max)
-                                 '(mouse-face t local-map t))))
+      ;; Remove properties for regular emacs
+      ;; FIXME This detroys all mouse-faces and local-maps!
+      ;; FIXME Hope no other package is using them in this buffer!
+      (let ((before-change-functions) (after-change-functions))
+       (remove-text-properties (point-min) (point-max)
+                               '(mouse-face t local-map t)))
       (goto-char (point-min))
       (while
          (re-search-forward
@@ -1405,29 +1258,19 @@ See variables bib-etags-command and bib-etags-filename"
           nil t)
        (setq s (match-beginning 0))
        (setq e (match-end 0))
-       (cond
-        ((featurep 'xemacs)
-         (setq extent (make-extent s e))
-         (setq bib-ext-list (cons extent bib-ext-list))
-         (set-extent-property extent 'highlight t)
-         (set-extent-property extent 'start-open t)
-         (set-extent-property extent 'balloon-help 'bib-label-help)
-         (set-extent-property extent 'help-echo 'bib-label-help-echo)
-         (set-extent-property extent 'keymap bib-highlight-mouse-keymap))
-        (t
-         (let ((before-change-functions) (after-change-functions)
-               ;;(this-overlay (make-overlay s e))
-               )
+       (let ((before-change-functions) (after-change-functions)
+             ;;(this-overlay (make-overlay s e))
+             )
 ;;;  Even using overlays doesn't help here.  If bib-highlight-mouse-keymap
 ;;;  does not include the AucTeX menus, then these disappear when we click
 ;;;  onto a \cite command.  Perhaps using bib-cite as a minor mode will fix
 ;;;  this?  For now, bib-cite must be loaded after these menus are built.
 ;;;  It must therefore be loaded in a mode-hook.
-           (put-text-property s e 'local-map bib-highlight-mouse-keymap)
-           (put-text-property s e 'mouse-face 'highlight)
+         (put-text-property s e 'local-map bib-highlight-mouse-keymap)
+         (put-text-property s e 'mouse-face 'highlight)
          ;;(overlay-put this-overlay 'local-map bib-highlight-mouse-keymap)
          ;;(overlay-put this-overlay 'mouse-face 'highlight)
-           ))))
+         ))
       (set-buffer-modified-p modified))))
 
 (defun bib-toggle-highlight ()
@@ -1438,15 +1281,9 @@ See variables bib-etags-command and bib-etags-filename"
       (bib-highlight-mouse)
     (let ((modified (buffer-modified-p))
          (inhibit-read-only t))
-      (cond
-       ((featurep 'xemacs)
-       (while bib-ext-list
-         (delete-extent (car bib-ext-list))
-         (setq bib-ext-list (cdr bib-ext-list))))
-       (t
-       (let ((before-change-functions) (after-change-functions))
-         (remove-text-properties (point-min) (point-max)
-                                 '(mouse-face local-map)))))
+      (let ((before-change-functions) (after-change-functions))
+       (remove-text-properties (point-min) (point-max)
+                               '(mouse-face local-map)))
       (set-buffer-modified-p modified))))
 
 (defun bib-label-help-echo (object)
@@ -1676,17 +1513,13 @@ If within a multi-file document (in auctex only)
        ;;;  '(("label3" "label4")("label1" "label2") nil)
        ;; so let's get rid of that nil part in embedded list.
             (the-name
-             (if (string-equal "18" (substring emacs-version 0 2))
-                 (completing-read "Label: " the-alist nil nil nil)
-               (completing-read "Label: " the-alist nil nil nil
-                                'LaTeX-find-label-hist-alist))))
+             (completing-read "Label: " the-alist nil nil nil
+                              'LaTeX-find-label-hist-alist)))
        (if (not (equal the-name ""))
            (concat "\\\\label{" (regexp-quote the-name) "}")
          ;; else try to get a \ref
-         (if (string-equal "18" (substring emacs-version 0 2))
-             (setq the-name (completing-read "Ref: " the-alist nil nil nil))
-           (setq the-name (completing-read "Ref: " the-alist nil nil nil
-                                           'LaTeX-find-label-hist-alist)))
+         (setq the-name (completing-read "Ref: " the-alist nil nil nil
+                                         'LaTeX-find-label-hist-alist))
          (if (not (equal the-name ""))
              (concat bib-ref-regexpc (regexp-quote the-name) "}")
            nil)))))))
@@ -2296,15 +2129,9 @@ Makes sure TAGS file exists, etc."
        (visit-tags-table the-tags-file-name))
     ;; find-tag-noselect should set the TAGS file for the new buffer
     ;; that's what C-h f visit-tags-table says...
-    (cond
-     ((featurep 'xemacs)
-      (find-tag tag)
-      (setq new-buffer (current-buffer))
-      (set-buffer the-buffer))
-     (t
-      (setq new-buffer (find-tag-noselect tag nil t))
+    (setq new-buffer (find-tag-noselect tag nil t))
                                        ; -> Seems to set buffer to TAGS
-      (set-buffer the-buffer)))
+    (set-buffer the-buffer)
     new-buffer))
 
 ;; --------------------------------------------------------------------------
@@ -2601,7 +2428,7 @@ bib-dos-or-os2-variable affects:
                         (or (and (fboundp 'TeX-split-string)
                                  (TeX-split-string sep-char value))
                             (dired-split sep-char value)))))
-      (loop for x in entries if (bib-cite-file-directory-p x) collect x))))
+      (cl-loop for x in entries if (bib-cite-file-directory-p x) collect x))))
 
 (provide 'bib-cite)
 ;;; bib-cite.el ends here
diff --git a/context.el b/context.el
index e42423b..ee35eb6 100644
--- a/context.el
+++ b/context.el
@@ -1527,7 +1527,7 @@ else.  There might be text before point."
      ["Delete Font" (TeX-font t ?\C-d) :keys "C-c C-f C-d"]
      "-"
      ["Comment or Uncomment Region"
-      TeX-comment-or-uncomment-region
+      comment-or-uncomment-region
       :help "Make the selected region outcommented or active again"]
      ["Comment or Uncomment Paragraph"
       TeX-comment-or-uncomment-paragraph
diff --git a/doc/auctex.texi b/doc/auctex.texi
index f2e4dae..e861a75 100644
--- a/doc/auctex.texi
+++ b/doc/auctex.texi
@@ -3831,6 +3831,8 @@ will be used regardless of the value of this variable.
 @cindex Running @code{chktex}
 @cindex Style
 @cindex Problems
address@hidden Flymake
address@hidden Running Flymake
 
 Running @TeX{} or @LaTeX{} will only find regular errors in the
 document, not examples of bad style.  Furthermore, description of the
@@ -3844,10 +3846,21 @@ escape the space after an abbreviation or using 
@samp{...} instead of
 @kbd{C-x `} (@code{next-error}, @pxref{Compilation,,,emacs,The Emacs
 Editor}), which will move point to the location of the next error.
 
-Each of the two utilities will find some errors the other doesn't, but
address@hidden 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
+Alternatively, you may want in-buffer notation.  @AUCTeX{} provides
+support for this using the Flymake package in Emacs 26 or newer
+(@xref{Using Flymake,,,Flymake,GNU Flymake} for details).  To enable,
+call @kbd{M-x flymake-mode RET} in the buffer or enable it in all
+buffers by adding this to your init file:
address@hidden
+(add-hook 'LaTeX-mode-hook #'flymake-mode)
address@hidden lisp
+Note that @AUCTeX{} currently only provides support for using
address@hidden as the flymake backend.
+
+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
 @file{<URL:ftp://ftp.ctan.org/tex-archive/support/lacheck/>} and
 @code{chktex} from
 @file{<URL:ftp://ftp.ctan.org/tex-archive/support/chktex/>}.
@@ -4702,7 +4715,7 @@ 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 obsolete.  Use
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}.
@@ -5202,7 +5215,6 @@ defined labels.
 Prompt for a @LaTeX{} length completing with known lengths.  Add length
 to list of defined lengths.
 
-
 @item TeX-arg-define-macro
 Prompt for a @TeX{} macro with completion.  Add macro to list of defined
 macros.
@@ -5263,6 +5275,11 @@ Prompt for a @LaTeX{} pagestyle with completion.
 @item TeX-arg-verb
 Prompt for delimiter and text.
 
address@hidden TeX-arg-verb-delim-or-brace
+Prompt for delimiter and text.  This function is similar to
address@hidden, but is intended for macros which take their
+argument enclosed in delimiters or in braces.
+
 @item TeX-arg-pair
 Insert a pair of numbers, use arguments for prompt. The numbers are
 surrounded by parentheses and separated with a comma.
diff --git a/doc/changes.texi b/doc/changes.texi
index ea3e4e8..bddec6a 100644
--- a/doc/changes.texi
+++ b/doc/changes.texi
@@ -18,6 +18,15 @@ been dropped.
 @item
 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
address@hidden 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
address@hidden file:
address@hidden
+(add-hook 'LaTeX-mode-hook #'flymake-mode)
address@hidden lisp
+
 @end itemize
 
 @heading News in 11.92
diff --git a/font-latex.el b/font-latex.el
index c3dda00..b3ab6f7 100644
--- a/font-latex.el
+++ b/font-latex.el
@@ -43,7 +43,7 @@
 (require 'tex)
 
 (eval-when-compile
-  (require 'cl))
+  (require 'cl-lib))
 
 (defgroup font-latex nil
   "Font-latex text highlighting package."
@@ -155,25 +155,15 @@ correct value from document properties."
 (defconst font-latex-sectioning-max 5
   "Highest number for font-latex-sectioning-N-face")
 (defface font-latex-sectioning-5-face
-  (if (featurep 'xemacs)
-      '((((type tty pc) (class color) (background light))
-        (:foreground "blue4" :bold t))
-       (((type tty pc) (class color) (background dark))
-        (:foreground "yellow" :bold t))
-       (((class color) (background light))
-        (:bold t :foreground "blue4" :family "helvetica"))
-       (((class color) (background dark))
-        (:bold t :foreground "yellow" :family "helvetica"))
-       (t (:bold t :family "helvetica")))
-    '((((type tty pc) (class color) (background light))
-       (:foreground "blue4" :weight bold))
-      (((type tty pc) (class color) (background dark))
-       (:foreground "yellow" :weight bold))
-      (((class color) (background light))
-       (:weight bold :inherit variable-pitch :foreground "blue4"))
-      (((class color) (background dark))
-       (:weight bold :inherit variable-pitch :foreground "yellow"))
-      (t (:weight bold :inherit variable-pitch))))
+  '((((type tty pc) (class color) (background light))
+     (:foreground "blue4" :weight bold))
+    (((type tty pc) (class color) (background dark))
+     (:foreground "yellow" :weight bold))
+    (((class color) (background light))
+     (:weight bold :inherit variable-pitch :foreground "blue4"))
+    (((class color) (background dark))
+     (:weight bold :inherit variable-pitch :foreground "yellow"))
+    (t (:weight bold :inherit variable-pitch)))
   "Face for sectioning commands at level 5."
   :group 'font-latex-highlighting-faces)
 
@@ -193,19 +183,7 @@ correct value from document properties."
           (num (- max (1+ num)))
           (face-name (intern (format "font-latex-sectioning-%s-face" num))))
       (unless (get face-name 'saved-face) ; Do not touch customized faces.
-       (if (featurep 'xemacs)
-           (let ((size
-                  ;; Multiply with .9 because `face-height' returns a value
-                  ;; slightly larger than the actual font size.
-                  ;; `make-face-size' takes numeric points according to Aidan
-                  ;; Kehoe in <address@hidden> (not
-                  ;; documented).
-                  (round (* 0.9
-                            (face-height 'default)
-                            (expt height-scale (- max 1 num))))))
-             ;; (message "%s - %s" face-name size)
-             (make-face-size face-name size))
-         (set-face-attribute face-name nil :height  height-scale))))))
+       (set-face-attribute face-name nil :height  height-scale)))))
 
 (defcustom font-latex-fontify-sectioning 1.1
   "Whether to fontify sectioning macros with varying height or a color face.
@@ -244,31 +222,18 @@ Emacs."
                           (float font-latex-fontify-sectioning)
                         1.1)))
   (dotimes (num max)
-    (let* (;; reverse for XEmacs:
-          (num (- max (1+ num)))
+    (let* ((num (- max (1+ num)))
           (face-name (intern (format "font-latex-sectioning-%s-face" num)))
-          (f-inherit (intern (format "font-latex-sectioning-%s-face" (1+ 
num))))
-          (size (when (featurep 'xemacs)
-                  (round (* 0.9 (face-height 'default)
-                            (expt height-scale (- max 1 num)))))))
+          (f-inherit (intern (format "font-latex-sectioning-%s-face" (1+ 
num)))))
       (eval
        `(defface ,face-name
-         (if (featurep 'xemacs)
-             '((t (:size ,(format "%spt" size))))
-           '((t (:height ,height-scale :inherit ,f-inherit))))
+         '((t (:height ,height-scale :inherit ,f-inherit)))
          (format "Face for sectioning commands at level %s.
 
 Probably you don't want to customize this face directly.  Better
 change the base face `font-latex-sectioning-5-face' or customize the
 variable `font-latex-fontify-sectioning'." ',num)
-         :group 'font-latex-highlighting-faces))
-      (when (and (featurep 'xemacs)
-                ;; Do not touch customized  faces.
-                (not (get face-name 'saved-face)))
-       (set-face-parent face-name f-inherit)
-       ;; Explicitely set the size again to code around the bug that
-       ;; `set-face-parent' overwrites the original face size.
-       (make-face-size face-name size)))))
+         :group 'font-latex-highlighting-faces)))))
 
 (font-latex-make-sectioning-faces font-latex-sectioning-max)
 
@@ -327,7 +292,8 @@ variable `font-latex-fontify-sectioning'." ',num)
      (("nocite" "*{") ("cite" "*[[{") ("label" "{") ("pageref" "{")
       ("vref" "*{") ("eqref" "{") ("ref" "{") ("include" "{")
       ("input" "{") ("bibliography" "{") ("index" "{") ("glossary" "{")
-      ("footnote" "[{") ("footnotemark" "[") ("footnotetext" "[{"))
+      ("footnote" "[{") ("footnotemark" "[") ("footnotetext" "[{")
+      ("marginpar" "[{"))
      font-lock-constant-face 2 command)
     ("function"
      (("begin" "{") ("end" "{") ("pagenumbering" "{")
@@ -340,11 +306,12 @@ variable `font-latex-fontify-sectioning'." ',num)
       ("newcounter" "{[") ("renewenvironment" "*{[[{{")
       ("renewcommand" "*|{\\[[{") ("renewtheorem" "{[{[")
       ("usepackage" "[{[") ("fbox" "{") ("mbox" "{") ("rule" "[{{")
-      ("vspace" "*{") ("hspace" "*{") ("thinspace" "") ("negthinspace" "")
+      ("addvspace" "{") ("vspace" "*{") ("hspace" "*{") ("thinspace" "") 
("negthinspace" "")
       ;; XXX: Should macros without arguments rather be listed in a
       ;; separate category with 'noarg instead of 'command handling?
       ("enspace" "") ("enskip" "") ("quad" "") ("qquad" "") ("nonumber" "")
-      ("centering" "") ("TeX" "") ("LaTeX" ""))
+      ("centering" "") ("raggedright" "") ("raggedleft" "")
+      ("TeX" "") ("LaTeX" "") ("LaTeXe" ""))
      font-lock-function-name-face 2 command)
     ("sectioning-0"
      (("part" "*[{"))
@@ -385,7 +352,7 @@ variable `font-latex-fontify-sectioning'." ',num)
      2 command)
     ("slide-title" () font-latex-slide-title-face 2 command)
     ("textual"
-     (("item" "[") ("title" "{") ("author" "{") ("date" "{")
+     (("item" "[") ("bibitem" "[{") ("title" "{") ("author" "{") ("date" "{")
       ("thanks" "{") ("address" "{") ("caption" "[{")
       ("textsuperscript" "{") ("textsubscript" "{") ("verb" "*"))
      font-lock-type-face 2 command)
@@ -735,10 +702,8 @@ restart Emacs."
                                :tag "Keywords with specs"
                                (group (string :tag "Keyword")
                                       (string :tag "Format specifier"))))
-                      ,(if (featurep 'xemacs)
-                           '(face :tag "Face name")
-                         '(choice (face :tag "Face name")
-                                  (custom-face-edit :tag "Face attributes")))
+                      ,'(choice (face :tag "Face name")
+                                (custom-face-edit :tag "Face attributes"))
                       (choice :tag "Type"
                               ;; Maps to
                               ;;`font-latex-match-command-with-arguments'
@@ -868,7 +833,7 @@ locking machinery will be triggered."
 
 ;;; Subscript and superscript
 
-(defcustom font-latex-fontify-script (not (featurep 'xemacs))
+(defcustom font-latex-fontify-script t
   "If non-nil, fontify subscript and superscript strings.
 This feature does not work in XEmacs.
 
@@ -1048,7 +1013,7 @@ have changed."
      ((not char) 'font-lock-comment-face)
      ((eq char ?$) 'font-latex-math-face)
      (t
-      (when (char-valid-p char)
+      (when (characterp char)
        ;; This is a \verb?...? construct.  Let's find the end and mark it.
        (save-excursion
          (skip-chars-forward (string ?^ char)) ;; Use `end' ?
@@ -1155,9 +1120,7 @@ have changed."
 
 (defface font-latex-verbatim-face
   (let ((font (if (and (assq :inherit custom-face-attributes)
-                      (if (featurep 'xemacs)
-                          (find-face 'fixed-pitch)
-                        (facep 'fixed-pitch)))
+                      (facep 'fixed-pitch))
                  '(:inherit fixed-pitch)
                '(:family "courier"))))
     `((((class grayscale) (background light))
@@ -1199,19 +1162,11 @@ have changed."
   :group 'font-latex-highlighting-faces)
 
 (defface font-latex-slide-title-face
-  (let* ((scale 1.2)
-        (size (when (featurep 'xemacs)
-                (round (* 0.9 (face-height 'default) scale)))))
-    (if (featurep 'xemacs)
-       `((t (:bold t :family "helvetica" :size ,size)))
-      `((t (:inherit (variable-pitch font-lock-type-face)
-                    :weight bold :height ,scale)))))
+  (let* ((scale 1.2))
+    `((t (:inherit (variable-pitch font-lock-type-face)
+                  :weight bold :height ,scale))))
   "Face for slide titles."
   :group 'font-latex-highlighting-faces)
-(when (featurep 'xemacs)
-  (set-face-parent 'font-latex-slide-title-face 'font-lock-type-face
-                  nil nil 'append))
-
 
 ;;; Setup
 
@@ -1315,19 +1270,8 @@ triggers Font Lock to recognize the change."
                       . font-latex-syntactic-face-function)
                      (font-lock-syntactic-keywords
                       . font-latex-syntactic-keywords)))))
-    ;; Cater for the idiosyncrasies of Emacs and XEmacs.
-    (if (featurep 'xemacs)
-       (progn
-         ;; XEmacs does not set these variables via `font-lock-defaults'
-         ;; but requires them to be set explicitely.
-         (mapc (lambda (alist)
-                 (set (car alist) (cdr alist))) variables)
-         ;; Has to be set to t as otherwise syntax properties will not be
-         ;; be picked up during fontification.
-         (set (make-local-variable 'lookup-syntax-properties) t))
-      (setq defaults (append defaults variables)))
     ;; Set the defaults.
-    (setq font-lock-defaults defaults))
+    (setq font-lock-defaults (append defaults variables)))
 
   ;; Make sure fontification will be refreshed if a user sets variables
   ;; influencing fontification in her file-local variables section.
@@ -2079,7 +2023,7 @@ END marks boundaries for searching for quotation ends."
 (defun font-latex--get-script-props (pos script-type)
   (let* ((old-raise (or (plist-get (get-text-property pos 'display) 'raise) 
0.0))
         (new-level (1+ (or (get-text-property pos 'script-level) 0)))
-        (disp-props (copy-sequence (case script-type
+        (disp-props (copy-sequence (cl-case script-type
                                      (:super (cdr font-latex-script-display))
                                      (:sub   (car 
font-latex-script-display)))))
         (new-disp-props (let ((raise (plist-get disp-props 'raise))
@@ -2097,7 +2041,7 @@ END marks boundaries for searching for quotation ends."
                                                   (* nl nl 
0.012018514285714385)))))
                             disp-props))))
     `(face ,(if (<= new-level font-latex-fontify-script-max-level)
-               (case script-type
+               (cl-case script-type
                  (:super 'font-latex-superscript-face)
                  (:sub   'font-latex-subscript-face))
              nil)
diff --git a/latex-flymake.el b/latex-flymake.el
new file mode 100644
index 0000000..2a86ebe
--- /dev/null
+++ b/latex-flymake.el
@@ -0,0 +1,104 @@
+;;; latex-flymake.el --- Flymake integration  -*- lexical-binding: t; -*-
+
+;; Copyright (C), 2018 Free Software Foundation, Inc.
+
+;; Author: Alex Branham <address@hidden>
+;; Maintainer: address@hidden
+;; Created: 2018-02-11
+;; Keywords: tex
+
+;; This file is part of AUCTeX.
+
+;; AUCTeX is free software; you can redistribute it and/or modify it
+;; under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 3, or (at your option)
+;; any later version.
+
+;; AUCTeX is distributed in the hope that it will be useful, but
+;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+;; General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with AUCTeX; see the file COPYING.  If not, write to the Free
+;; Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+;; 02110-1301, USA.
+
+;;; Commentary:
+
+;; This file provides flymake integration for latex documents using
+;; "chktex" as a backend.  You must be running Emacs 26 or newer.
+;; Enable it by adding the following to your init file:
+
+;;   (add-hook 'LaTeX-mode-hook #'flymake-mode)
+
+;;; Code:
+
+(eval-when-compile
+  (require 'cl-lib))
+(require 'flymake)
+
+(defvar-local LaTeX--flymake-proc nil)
+
+(defun LaTeX-flymake (report-fn &rest _args)
+  "Setup flymake integration.
+
+REPORT-FN is flymake's callback function."
+  (unless (executable-find "chktex")
+    (error "Cannot find chktex"))
+  (when (process-live-p LaTeX--flymake-proc)
+    (kill-process LaTeX--flymake-proc))
+  (let ((source (current-buffer)))
+    (save-restriction
+      (widen)
+      (setq
+       LaTeX--flymake-proc
+       (make-process
+        :name "LaTeX-flymake" :noquery t :connection-type 'pipe
+        :buffer (generate-new-buffer " *LaTeX-flymake*")
+        :command '("chktex" "--verbosity=0" "--quiet" "--inputfiles")
+        :sentinel
+        (lambda (proc _event)
+          (when (eq 'exit (process-status proc))
+            (unwind-protect
+                (if (with-current-buffer source (eq proc LaTeX--flymake-proc))
+                    (with-current-buffer (process-buffer proc)
+                      (goto-char (point-min))
+                      (cl-loop
+                       while (search-forward-regexp
+                              (rx line-start "stdin:"
+                                  ;; line
+                                  (group-n 1 (one-or-more num))
+                                  ":"
+                                  ;; column
+                                  (group-n 2 (one-or-more num))
+                                  ":"
+                                  ;; This is information about the
+                                  ;; number of the warning, which we
+                                  ;; probably don't care about:
+                                  (one-or-more num)
+                                  ":"
+                                  ;; Warning message:
+                                  (group-n 3 (one-or-more not-newline)) 
line-end)
+                              nil t)
+                       for msg = (match-string 3)
+                       for (beg . end) = (flymake-diag-region
+                                          source
+                                          (string-to-number (match-string 1))
+                                          (string-to-number (match-string 2)))
+                       for type = :warning
+                       collect (flymake-make-diagnostic source
+                                                        beg
+                                                        end
+                                                        type
+                                                        msg)
+                       into diags
+                       finally (funcall report-fn diags)))
+                  (flymake-log :warning "Canceling obsolete check %s"
+                               proc))
+              (kill-buffer (process-buffer proc)))))))
+      (process-send-region LaTeX--flymake-proc (point-min) (point-max))
+      (process-send-eof LaTeX--flymake-proc))))
+
+(provide 'latex-flymake)
+;;; latex-flymake.el ends here
diff --git a/latex.el b/latex.el
index fa2ae34..9df3d52 100644
--- a/latex.el
+++ b/latex.el
@@ -1,6 +1,6 @@
 ;;; latex.el --- Support for LaTeX documents.
 
-;; Copyright (C) 1991, 1993-2017 Free Software Foundation, Inc.
+;; Copyright (C) 1991, 1993-2018 Free Software Foundation, Inc.
 
 ;; Maintainer: address@hidden
 ;; Keywords: tex
@@ -31,7 +31,11 @@
 (require 'tex)
 (require 'tex-style)
 (require 'tex-ispell)
-(eval-when-compile (require 'cl))       ;FIXME: Use cl-lib.
+(when (<= 26 emacs-major-version)
+  ;; latex-flymake requires Emacs 26.
+  (require 'latex-flymake))
+(eval-when-compile
+  (require 'cl-lib))
 
 ;;; Syntax
 
@@ -296,9 +300,7 @@ Additionally the function will invalidate the section 
submenu in
 order to let the menu filter regenerate it."
   (setq LaTeX-largest-level (LaTeX-section-level section))
   (let ((offset (LaTeX-outline-offset)))
-    (when (and (> offset 0)
-              ;; XEmacs does not know `outline-heading-alist'.
-              (boundp 'outline-heading-alist))
+    (when (> offset 0)
       (let (lst)
        (dolist (tup outline-heading-alist)
          (setq lst (cons (cons (car tup)
@@ -645,9 +647,7 @@ With prefix-argument, reopen environment afterwards."
                         marker))
        (move-marker marker nil)))))
 
-(if (featurep 'xemacs)
-    (define-obsolete-variable-alias 'LaTeX-after-insert-env-hooks 
'LaTeX-after-insert-env-hook)
-  (define-obsolete-variable-alias 'LaTeX-after-insert-env-hooks 
'LaTeX-after-insert-env-hook "11.89"))
+(define-obsolete-variable-alias 'LaTeX-after-insert-env-hooks 
'LaTeX-after-insert-env-hook "11.89")
 
 (defvar LaTeX-after-insert-env-hook nil
   "List of functions to be run at the end of `LaTeX-insert-environment'.
@@ -963,7 +963,7 @@ If nil, act like the empty string is given, but do not 
prompt."
   ;; Deactivate the mark here in order to prevent `TeX-parse-macro'
   ;; from swapping point and mark and the \item ending up right after
   ;; \begin{...}.
-  (TeX-deactivate-mark)
+  (deactivate-mark)
   (LaTeX-insert-item)
   ;; The inserted \item may have outdented the first line to the
   ;; right.  Fill it, if appropriate.
@@ -2236,7 +2236,7 @@ To insert a hook here, you must insert it in the 
appropiate style file.")
 OPTIONAL and IGNORE are ignored."
   (let* ((TeX-file-extensions '("cls"))
         (crm-separator ",")
-        style var options)
+        style var options defopt optprmpt)
     (unless LaTeX-global-class-files
       (setq LaTeX-global-class-files
            (if (if (eq TeX-arg-input-file-search 'ask)
@@ -2254,6 +2254,12 @@ OPTIONAL and IGNORE are ignored."
     (setq TeX-after-document-hook nil)
     (TeX-run-style-hooks style)
     (setq var (intern (format "LaTeX-%s-class-options" style)))
+    (setq defopt (if (stringp LaTeX-default-options)
+                    LaTeX-default-options
+                  (mapconcat #'identity LaTeX-default-options ",")))
+    (setq optprmpt
+         (if (and defopt (not (string-equal defopt "")))
+             (format "Options (default %s): " defopt) "Options: "))
     (if (or (and (boundp var)
                 (listp (symbol-value var)))
            (fboundp var))
@@ -2263,12 +2269,10 @@ OPTIONAL and IGNORE are ignored."
            (setq options
                  (mapconcat 'identity
                             (TeX-completing-read-multiple
-                             "Options: " (mapcar 'list (symbol-value var)) nil 
nil
-                             (if (stringp LaTeX-default-options)
-                                 LaTeX-default-options
-                               (mapconcat 'identity LaTeX-default-options 
",")))
+                             optprmpt (mapcar 'list (symbol-value var)) nil nil
+                             nil nil defopt)
                             ","))))
-      (setq options (TeX-read-string "Options: ")))
+      (setq options (TeX-read-string optprmpt nil nil defopt)))
     (unless (zerop (length options))
       (insert LaTeX-optop options LaTeX-optcl)
       (let ((opts (LaTeX-listify-package-options options)))
@@ -2614,6 +2618,38 @@ argument, otherwise as a mandatory one.  IGNORE is 
ignored."
       (insert del (read-from-minibuffer "Text: ") del))
     (setq LaTeX-default-verb-delimiter del)))
 
+(defun TeX-arg-verb-delim-or-brace (optional &optional prompt)
+  "Prompt for delimiter and text.
+If OPTIONAL, indicate optional argument in minibuffer.  PROMPT is
+a string replacing the default one when asking the user for text.
+This function is intended for \\verb like macros which take their
+argument in delimiters like \"\| \|\" or braces \"\{ \}\"."
+  (let ((del (read-quoted-char
+             (concat "Delimiter (default "
+                     (char-to-string LaTeX-default-verb-delimiter) "): "))))
+    (when (<= del ?\ )
+      (setq del LaTeX-default-verb-delimiter))
+    (if (TeX-active-mark)
+       (progn
+         (insert del)
+         (goto-char (mark))
+         ;; If the delimiter was an opening brace, close it with a
+         ;; brace, otherwise use the delimiter again
+         (insert (if (= del ?\{)
+                     ?\}
+                   del)))
+      ;; Same thing again
+      (insert del (read-from-minibuffer
+                  (TeX-argument-prompt optional prompt "Text"))
+             (if (= del ?\{)
+                 ?\}
+               del)))
+    ;; Do not set `LaTeX-default-verb-delimiter' if the user input was
+    ;; an opening brace.  This would give funny results for the next
+    ;; "C-c C-m \verb RET"
+    (unless (= del ?\{)
+      (setq LaTeX-default-verb-delimiter del))))
+
 (defun TeX-arg-pair (optional first second)
   "Insert a pair of number, prompted by FIRST and SECOND.
 
@@ -3223,23 +3259,7 @@ Lines starting with an item is given an extra 
indentation of
                 (looking-at
                  (concat "\\([ \t]*" TeX-comment-start-regexp "+\\)+"))
                 (concat (match-string 0) (TeX-comment-padding-string)))))
-        (overlays (when (featurep 'xemacs)
-                    ;; Isn't that fun?  In Emacs an `(overlays-at
-                    ;; (line-beginning-position))' would do the
-                    ;; trick.  How boring.
-                    (extent-list
-                     nil (line-beginning-position) (line-beginning-position)
-                     'all-extents-closed-open 'overlay)))
         ol-specs)
-    ;; XEmacs' `indent-to' function (at least in version 21.4.15) has
-    ;; a bug which leads to the insertion of whitespace in front of an
-    ;; invisible overlay.  So during indentation we temporarily remove
-    ;; the 'invisible property.
-    (dolist (ol overlays)
-      (when (extent-property ol 'invisible)
-        (pushnew (list ol (extent-property ol 'invisible))
-                 ol-specs :test #'equal)
-       (set-extent-property ol 'invisible nil)))
     (save-excursion
       (cond ((and fill-prefix
                  (TeX-in-line-comment)
@@ -3584,16 +3604,7 @@ not be subject to filling."
   :group 'LaTeX
   :type '(repeat string))
 
-(defvar LaTeX-nospace-between-char-regexp
-  (if (featurep 'xemacs)
-    (if (and (boundp 'word-across-newline) word-across-newline)
-       word-across-newline
-      ;; NOTE: Ensure not to have a value of nil for such a rare case that
-      ;; somebody removes the mule test in `LaTeX-fill-delete-newlines' so that
-      ;; it could match only "\n" and this could lead to problem.  XEmacs does
-      ;; not have a category `\c|' and `\ct' means `Chinese Taiwan' in XEmacs.
-      "\\(\\cj\\|\\cc\\|\\ct\\)")
-    "\\c|")
+(defvar LaTeX-nospace-between-char-regexp "\\c|"
   "Regexp matching a character where no interword space is necessary.
 Words formed by such characters can be broken across newlines.")
 
@@ -3783,7 +3794,7 @@ space does not end a sentence, so don't break a line 
there."
        ;; FROM, and point, are now before the text to fill,
        ;; but after any fill prefix on the first line.
 
-       (LaTeX-fill-delete-newlines from to justify nosqueeze squeeze-after)
+       (fill-delete-newlines from to justify nosqueeze squeeze-after)
 
        ;; This is the actual FILLING LOOP.
        (goto-char from)
@@ -3875,100 +3886,9 @@ space does not end a sentence, so don't break a line 
there."
       ;; Return the fill-prefix we used
       fill-prefix)))
 
-;; Following lines are copied from `fill.el' (CVS Emacs, March 2005).
-;;   The `fill-space' property carries the string with which a newline should 
be
-;;   replaced when unbreaking a line (in fill-delete-newlines).  It is added to
-;;   newline characters by fill-newline when the default behavior of
-;;   fill-delete-newlines is not what we want.
-(unless (featurep 'xemacs)
-  ;; COMPATIBILITY for Emacs < 22.1
-  (add-to-list 'text-property-default-nonsticky '(fill-space . t)))
-
-(defun LaTeX-fill-delete-newlines (from to justify nosqueeze squeeze-after)
-  ;; COMPATIBILITY for Emacs < 22.1 and XEmacs
-  (if (fboundp 'fill-delete-newlines)
-      (fill-delete-newlines from to justify nosqueeze squeeze-after)
-    (if (featurep 'xemacs)
-       (when (featurep 'mule)
-         (goto-char from)
-         (let ((unwished-newline (concat LaTeX-nospace-between-char-regexp "\n"
-                                         LaTeX-nospace-between-char-regexp)))
-           (while (re-search-forward unwished-newline to t)
-             (skip-chars-backward "^\n")
-             (delete-char -1))))
-      ;; This else-sentence was copied from the function `fill-delete-newlines'
-      ;; in `fill.el' (CVS Emacs, 2005-02-17) and adapted accordingly.
-      (while (search-forward "\n" to t)
-       (if (get-text-property (match-beginning 0) 'fill-space)
-           (replace-match (get-text-property (match-beginning 0) 'fill-space))
-         (let ((prev (char-before (match-beginning 0)))
-               (next (following-char)))
-           (when (or (aref (char-category-set next) ?|)
-                     (aref (char-category-set prev) ?|))
-             (delete-char -1))))))
-
-    ;; Make sure sentences ending at end of line get an extra space.
-    (if (or (not (boundp 'sentence-end-double-space))
-           sentence-end-double-space)
-       (progn
-         (goto-char from)
-         (while (re-search-forward "[.?!][]})\"']*$" to t)
-           (insert ? ))))
-    ;; Then change all newlines to spaces.
-    (let ((point-max (progn
-                      (goto-char to)
-                      (skip-chars-backward "\n")
-                      (point))))
-      (subst-char-in-region from point-max ?\n ?\ ))
-    (goto-char from)
-    (skip-chars-forward " \t")
-    ;; Remove extra spaces between words.
-    (unless (and nosqueeze (not (eq justify 'full)))
-      (canonically-space-region (or squeeze-after (point)) to)
-      ;; Remove trailing whitespace.
-      (goto-char (line-end-position))
-      (delete-char (- (skip-chars-backward " \t"))))))
-
 (defun LaTeX-fill-move-to-break-point (linebeg)
   "Move to the position where the line should be broken."
-  ;; COMPATIBILITY for Emacs < 22.1 and XEmacs
-  (if (fboundp 'fill-move-to-break-point)
-      (fill-move-to-break-point linebeg)
-    (if (featurep 'mule)
-       (if (TeX-looking-at-backward
-            (concat LaTeX-nospace-between-char-regexp ".?") 2)
-           ;; Cancel `forward-char' which is called just before
-           ;; `LaTeX-fill-move-to-break-point' if the char before point matches
-           ;; `LaTeX-nospace-between-char-regexp'.
-           (backward-char 1)
-         (when (re-search-backward
-                (concat " \\|\n\\|" LaTeX-nospace-between-char-regexp)
-                linebeg 'move)
-           (forward-char 1)))
-      (skip-chars-backward "^ \n"))
-    ;; Prevent infinite loops: If we cannot find a place to break
-    ;; while searching backward, search forward again.
-    (when (save-excursion
-           (skip-chars-backward " \t%")
-           (bolp))
-      (skip-chars-forward "^ \n" (point-max)))
-    ;; This code was copied from the function `fill-move-to-break-point'
-    ;; in `fill.el' (CVS Emacs, 2005-02-22) and adapted accordingly.
-    (when (and (< linebeg (point))
-              ;; If we are going to break the line after or
-              ;; before a non-ascii character, we may have to
-              ;; run a special function for the charset of the
-              ;; character to find the correct break point.
-              (boundp 'enable-multibyte-characters)
-              enable-multibyte-characters
-              (fboundp 'charset-after) ; Non-MULE XEmacsen don't have this.
-              (not (and (eq (charset-after (1- (point))) 'ascii)
-                        (eq (charset-after (point)) 'ascii))))
-      ;; Make sure we take SOMETHING after the fill prefix if any.
-      (if (fboundp 'fill-find-break-point)
-         (fill-find-break-point linebeg)
-       (when (fboundp 'kinsoku-process) ;XEmacs
-         (kinsoku-process)))))
+  (fill-move-to-break-point linebeg)
   ;; Prevent line break between 2-byte char and 1-byte char.
   (when (and (featurep 'mule)
             enable-multibyte-characters
@@ -4156,25 +4076,21 @@ space does not end a sentence, so don't break a line 
there."
   "Replace whitespace here with one newline and indent the line."
   (skip-chars-backward " \t")
   (newline 1)
-  ;; COMPATIBILITY for XEmacs
-  (unless (featurep 'xemacs)
-    ;; Give newline the properties of the space(s) it replaces
-    (set-text-properties (1- (point)) (point)
-                        (text-properties-at (point)))
-    (and (looking-at "\\( [ \t]*\\)\\(\\c|\\)?")
-        (or (aref (char-category-set (or (char-before (1- (point))) ?\000)) ?|)
-            (match-end 2))
-        ;; When refilling later on, this newline would normally not
-        ;; be replaced by a space, so we need to mark it specially to
-        ;; re-install the space when we unfill.
-        (put-text-property (1- (point)) (point) 'fill-space (match-string 1)))
-    ;; COMPATIBILITY for Emacs <= 21.3
-    (when (boundp 'fill-nobreak-invisible)
-      ;; If we don't want breaks in invisible text, don't insert
-      ;; an invisible newline.
-      (if fill-nobreak-invisible
-         (remove-text-properties (1- (point)) (point)
-                                 '(invisible t)))))
+  ;; Give newline the properties of the space(s) it replaces
+  (set-text-properties (1- (point)) (point)
+                      (text-properties-at (point)))
+  (and (looking-at "\\( [ \t]*\\)\\(\\c|\\)?")
+       (or (aref (char-category-set (or (char-before (1- (point))) ?\000)) ?|)
+          (match-end 2))
+       ;; When refilling later on, this newline would normally not
+       ;; be replaced by a space, so we need to mark it specially to
+       ;; re-install the space when we unfill.
+       (put-text-property (1- (point)) (point) 'fill-space (match-string 1)))
+  ;; If we don't want breaks in invisible text, don't insert
+  ;; an invisible newline.
+  (if fill-nobreak-invisible
+      (remove-text-properties (1- (point)) (point)
+                             '(invisible t)))
   ;; Insert the fill prefix.
   (and fill-prefix (not (equal fill-prefix ""))
        ;; Markers that were after the whitespace are now at point: insert
@@ -5763,7 +5679,7 @@ regenerated by the respective menu filter."
      ["Delete Font" (TeX-font t ?\C-d) :keys "C-c C-f C-d"]
      "-"
      ["Comment or Uncomment Region"
-      TeX-comment-or-uncomment-region
+      comment-or-uncomment-region
       :help "Make the selected region outcommented or active again"]
      ["Comment or Uncomment Paragraph"
       TeX-comment-or-uncomment-paragraph
@@ -6000,9 +5916,7 @@ of `LaTeX-mode-hook'."
   (setq TeX-command-default "LaTeX")
   (setq TeX-sentinel-default-function 'TeX-LaTeX-sentinel)
   (add-hook 'tool-bar-mode-on-hook 'LaTeX-maybe-install-toolbar nil t)
-  (when (if (featurep 'xemacs)
-           (featurep 'toolbar)
-         (and (boundp 'tool-bar-mode) tool-bar-mode))
+  (when (and (boundp 'tool-bar-mode) tool-bar-mode)
     (LaTeX-maybe-install-toolbar))
   ;; Set the value of `LaTeX-using-Biber' based on the local value of
   ;; `LaTeX-biblatex-use-Biber'.  This should be run within
@@ -6019,7 +5933,10 @@ of `LaTeX-mode-hook'."
   ;; Defeat filladapt
   (if (and (boundp 'filladapt-mode)
           filladapt-mode)
-      (turn-off-filladapt-mode)))
+      (turn-off-filladapt-mode))
+  (when (< 25 emacs-major-version)
+    ;; Set up flymake backend, see latex-flymake.el
+    (add-hook 'flymake-diagnostic-functions 'LaTeX-flymake nil t)))
 
 (TeX-abbrev-mode-setup doctex-mode)
 
@@ -6642,53 +6559,53 @@ function would return non-nil and `(match-string 1)' 
would return
 
 (defun LaTeX-hanging-ampersand-position ()
   "Return indent column for a hanging ampersand (i.e. ^\\s-*&)."
-  (destructuring-bind
-   (beg-pos . beg-col)
-   (LaTeX-env-beginning-pos-col)
-   (let* ((cur-pos (point)))
-     (save-excursion
-       (if (re-search-backward "\\\\\\\\" beg-pos t)
-          (let ((cur-idx (TeX-how-many "[^\\]&" (point) cur-pos)))
-            (goto-char beg-pos)
-            (re-search-forward "[^\\]&" cur-pos t (+ 1 cur-idx))
-            ;; If the above searchs fails, i.e. no "&" found,
-            ;; (- (current-column) 1) returns -1, which is wrong.  So
-            ;; we use a fallback (+ 2 beg-col) whenever this happens:
-            (max (- (current-column) 1)
-                 (+ 2 beg-col)))
-        (+ 2 beg-col))))))
+  (cl-destructuring-bind
+      (beg-pos . beg-col)
+      (LaTeX-env-beginning-pos-col)
+    (let* ((cur-pos (point)))
+      (save-excursion
+       (if (re-search-backward "\\\\\\\\" beg-pos t)
+           (let ((cur-idx (how-many "[^\\]&" (point) cur-pos)))
+             (goto-char beg-pos)
+             (re-search-forward "[^\\]&" cur-pos t (+ 1 cur-idx))
+             ;; If the above searchs fails, i.e. no "&" found,
+             ;; (- (current-column) 1) returns -1, which is wrong.  So
+             ;; we use a fallback (+ 2 beg-col) whenever this happens:
+             (max (- (current-column) 1)
+                  (+ 2 beg-col)))
+         (+ 2 beg-col))))))
 
 (defun LaTeX-indent-tabular ()
   "Return indent column for the current tabular-like line."
-  (destructuring-bind
-   (beg-pos . beg-col)
-   (LaTeX-env-beginning-pos-col)
-   (let ((tabular-like-end-regex
-         (format "\\\\end{%s}"
-                 (regexp-opt
-                  (let (out)
-                    (mapc (lambda (x)
-                             (when (eq (cadr x) 'LaTeX-indent-tabular)
-                               (push (car x) out)))
-                           LaTeX-indent-environment-list)
-                    out)))))
-     (cond ((looking-at tabular-like-end-regex)
-           beg-col)
-
-          ((looking-at "\\\\\\\\")
-           (+ 2 beg-col))
-
-          ((looking-at "&")
-           (LaTeX-hanging-ampersand-position))
-
-          (t
-           (+ 2
-              (let ((any-col (save-excursion
-                               (when (re-search-backward "\\\\\\\\\\|[^\\]&" 
beg-pos t)
-                                 (current-column)))))
-                (if (and any-col (= ?& (char-before (match-end 0))))
-                    (1+ any-col)
-                  beg-col))))))))
+  (cl-destructuring-bind
+      (beg-pos . beg-col)
+      (LaTeX-env-beginning-pos-col)
+    (let ((tabular-like-end-regex
+          (format "\\\\end{%s}"
+                  (regexp-opt
+                   (let (out)
+                     (mapc (lambda (x)
+                              (when (eq (cadr x) 'LaTeX-indent-tabular)
+                                (push (car x) out)))
+                            LaTeX-indent-environment-list)
+                     out)))))
+      (cond ((looking-at tabular-like-end-regex)
+            beg-col)
+
+           ((looking-at "\\\\\\\\")
+            (+ 2 beg-col))
+
+           ((looking-at "&")
+            (LaTeX-hanging-ampersand-position))
+
+           (t
+            (+ 2
+               (let ((any-col (save-excursion
+                                (when (re-search-backward "\\\\\\\\\\|[^\\]&" 
beg-pos t)
+                                  (current-column)))))
+                 (if (and any-col (= ?& (char-before (match-end 0))))
+                     (1+ any-col)
+                   beg-col))))))))
 
 (provide 'latex)
 
diff --git a/plain-tex.el b/plain-tex.el
index 9b561ac..99df58a 100644
--- a/plain-tex.el
+++ b/plain-tex.el
@@ -83,7 +83,7 @@ Install tool bar if `plain-TeX-enable-toolbar' is non-nil."
       ["Calligraphic" (TeX-font t ?\C-a) :keys "C-u C-c C-f C-a"])
      ["Delete Font" (TeX-font t ?\C-d) :keys "C-c C-f C-d"]
      "-"
-     ["Comment or Uncomment Region" TeX-comment-or-uncomment-region
+     ["Comment or Uncomment Region" comment-or-uncomment-region
       :help "Comment or uncomment the currently selected region"]
      ["Comment or Uncomment Paragraph" TeX-comment-or-uncomment-paragraph
       :help "Comment or uncomment the paragraph containing point"]
diff --git a/preview.el b/preview.el
index f938221..06736a0 100644
--- a/preview.el
+++ b/preview.el
@@ -54,15 +54,7 @@ preview-latex buffers will not survive across sessions.")))
 preview-latex's bug reporting commands will probably not work.")))
   (require 'info))
 
-;; we need the compatibility macros which do _not_ get byte-compiled.
-(eval-when-compile
-  (if (featurep 'xemacs)
-      (load-library "prv-xemacs.el")))
-
-;; if the above load-library kicked in, this will not cause anything
-;; to get loaded.
-(require (if (featurep 'xemacs)
-            'prv-xemacs 'prv-emacs))
+(require 'prv-emacs)
 
 (defgroup preview nil "Embed Preview images into LaTeX buffers."
   :group 'AUCTeX
@@ -713,7 +705,7 @@ Gets the usual PROCESS and STRING parameters, see
                                         preview-gs-command-line)
                                        " ") "''\n")
       (setq preview-gs-answer "")
-      (process-kill-without-query process)
+      (set-process-query-on-exit-flag process nil)
       (set-process-sentinel process #'preview-gs-sentinel)
       (set-process-filter process #'preview-gs-filter)
       (process-send-string process preview-gs-init-string)
@@ -3537,7 +3529,7 @@ internal parameters, STR may be a log to insert into the 
current log."
       ((preview-format-name (shell-quote-argument
                             (preview-dump-file-name
                              (file-name-nondirectory master))))
-       (process-environment process-environment)
+       (process-environment (copy-sequence process-environment))
        (process
        (progn
          ;; Fix Bug#20773, Bug#27088.
diff --git a/prv-xemacs.el b/prv-xemacs.el
deleted file mode 100644
index ae20402..0000000
--- a/prv-xemacs.el
+++ /dev/null
@@ -1,759 +0,0 @@
-;;; prv-xemacs.el --- XEmacs support for preview-latex
-
-;; Copyright (C) 2001-2006, 2017 Free Software Foundation, Inc.
-
-;; Author: David Kastrup
-;; Keywords: convenience, tex, wp
-
-;; This file is free software; you can redistribute it and/or modify
-;; it under the terms of the GNU General Public License as published by
-;; the Free Software Foundation; either version 3, or (at your option)
-;; any later version.
-
-;; This file is distributed in the hope that it will be useful,
-;; but WITHOUT ANY WARRANTY; without even the implied warranty of
-;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-;; GNU General Public License for more details.
-
-;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs; see the file COPYING.  If not, write to
-;; the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
-;; Boston, MA 02110-1301, USA.
-
-;;; Commentary:
-
-;; 
-
-;;; Code:
-
-(require 'overlay)
-(require 'tex-site)
-(require 'tex)
-(require 'latex)
-
-;; Compatibility macros and functions.
-
-(eval-when-compile
-  (defvar preview-compatibility-macros nil
-    "List of macros only present when compiling/loading uncompiled.")
-
-  (defmacro preview-defmacro (name &rest rest)
-    (when (featurep 'xemacs)
-      (push
-       (if (fboundp name)
-          (cons name (symbol-function name))
-        name)
-       preview-compatibility-macros)
-      `(eval-when-compile (defmacro ,name ,@rest))))
-  (push 'preview-defmacro preview-compatibility-macros))
-
-(preview-defmacro assoc-default (key alist test)
-  `(cdr (assoc* ,key ,alist
-                :test #'(lambda(a b) (funcall ,test b a)))))
-
-(preview-defmacro display-mm-height () '(device-mm-height))
-(preview-defmacro display-mm-width () '(device-mm-width))
-(preview-defmacro display-pixel-height () '(device-pixel-height))
-(preview-defmacro display-pixel-width () '(device-pixel-width))
-(preview-defmacro line-beginning-position () '(point-at-bol))
-(preview-defmacro line-end-position () '(point-at-eol))
-
-;; This is not quite the case, but unless we're playing with duplicable 
extents,
-;; the two are equivalent in XEmacs.
-(preview-defmacro match-string-no-properties (&rest args)
-  `(match-string ,@args))
-
-(preview-defmacro face-attribute (face attr)
-  (cond
-    ((eq attr :height)
-     `(round (/ (* ,(/ 720.0 25.4)
-                  (face-height ,face)
-                  (device-mm-height))
-               (device-pixel-height))))
-    ((eq attr :foreground)
-     `(face-foreground-instance ,face))
-    ((eq attr :background)
-     `(face-background-instance ,face))
-    (t
-     (error 'unimplemented (format "Don't know how to fake %s" attr)))))
-
-(preview-defmacro make-temp-file (prefix dir-flag)
-  (if (not dir-flag)
-      (error 'unimplemented "Can only fake make-temp-file for directories"))
-  `(let (file)
-     (while (condition-case ()
-                (progn
-                  (setq file
-                        (make-temp-name ,prefix))
-                  (make-directory file)
-                  nil)
-              (file-already-exists t))
-       nil)
-     file))
-
-(preview-defmacro set-buffer-multibyte (multibyte)
-  "Set the representation type of the current buffer.  If MULTIBYTE
-is non-`nil', the buffer becomes multibyte.  If MULTIBYTE is
-`nil', the buffer becomes unibyte.
-
-Because XEmacs does not implement multibyte versus unibyte buffers
-per se (they just have encodings which may be unibyte or multibyte),
-this is only implemented for the `nil' case."
-  (if (not multibyte)
-      `(if (fboundp 'set-buffer-file-coding-system)
-           (set-buffer-file-coding-system 'binary))
-    (error 'unimplemented "`set-buffer-multibyte is only implemented for the 
binary case.")))
-
-(preview-defmacro next-single-char-property-change (pos prop)
-  "Return the position of next property change for a specific property.
-This is like `next-single-property-change', except that if no
-change is found before the end of the buffer, it returns
-\(point-max) rather than `nil'."
-  `(or (next-single-property-change ,pos ,prop)
-       (point-max)))
-
-(preview-defmacro previous-single-char-property-change (pos prop)
-  "Return the position of previous property change for a specific property.
-This is like `next-single-property-change', except that if no
-change is found before the end of the buffer, it returns
-\(point-min) rather than `nil'."
-  `(or (previous-single-property-change ,pos ,prop)
-       (point-min)))
-
-(preview-defmacro with-temp-message (message &rest body)
-  "Display MESSAGE temporarily if non-nil while BODY is evaluated.
-The original message is restored to the echo area after BODY has finished.
-The value returned is the value of the last form in BODY.
-MESSAGE is written to the message log buffer if `message-log-max' is non-nil.
-If MESSAGE is nil, the echo area and message log buffer are unchanged.
-Use a MESSAGE of \"\" to temporarily clear the echo area.
-
-The message is displayed with label `progress'; see `display-message'."
-  (let ((current-message (make-symbol "current-message"))
-        (temp-message (make-symbol "with-temp-message")))
-    `(let ((,temp-message ,message)
-           (,current-message))
-       (unwind-protect
-           (progn
-             (when ,temp-message
-               (setq ,current-message (current-message))
-               (display-message 'progress ,temp-message))
-             ,@body)
-         (and ,temp-message
-              (if ,current-message
-                  (display-message 'progress ,current-message)
-                (message nil)))))))
-
-(defun preview-mark-active ()
-  "Return t if the mark is active."
-  (and (mark)
-       t))
-
-(defvar preview-transparent-border)
-
-;; Images.
-
-(defsubst preview-supports-image-type (imagetype)
-  "Return whether IMAGETYPE is supported by XEmacs."
-  (memq imagetype (image-instantiator-format-list)))
-
-;; TODO: Generalize this so we can create the fixed icons using it.
-
-;; Argh, dired breaks :file :(
-;; This is a temporary kludge to get around that until a fixed dired
-;; or a fixed XEmacs is released.
-
-(defun preview-create-icon-1 (file type ascent)
-  "Create an icon from FILE, image TYPE and ASCENT."
-  (let ((glyph
-        (make-glyph
-         (vector type
-                 :file file
-                 :data (with-temp-buffer
-                         (insert-file-contents-literally file)
-                         (buffer-string))))))
-    (set-glyph-baseline glyph ascent)
-    glyph))
-
-(defun preview-create-icon (file type ascent border)
-  "Create an icon from FILE, image TYPE, ASCENT and BORDER."
-  (list
-   (preview-create-icon-1 file type ascent)
-   file type ascent border))
-
-(defvar preview-ascent-spec)
-
-(put 'preview-filter-specs :type
-     #'(lambda (keyword value &rest args)
-        (if (preview-supports-image-type value)
-            (let* (preview-ascent-spec
-                   (glyph (make-glyph `[,value
-                                        ,@(preview-filter-specs-1 args)])))
-              (when preview-ascent-spec
-                (set-glyph-baseline glyph preview-ascent-spec))
-              glyph)
-          (throw 'preview-filter-specs nil))))
-
-(put 'preview-filter-specs :ascent
-     #'(lambda (keyword value &rest args)
-        (setq preview-ascent-spec value)
-        (preview-filter-specs-1 args)))
-
-;; No defcustom here: does not seem to make sense.
-
-(defvar preview-tb-icon-specs
-  '((:type xpm :file "prvtex-cap-up.xpm" :ascent 75)
-    (:type xbm :file "prvtex24.xbm" :ascent 75)))
-
-(defvar preview-tb-icon nil)
-
-;; Image frobbing.
-
-(defun preview-add-urgentization (fun ov &rest rest)
-  "Cause FUN (function call form) to be called when redisplayed.
-FUN must be a form with OV as first argument,
-REST as the remainder, returning T.  An alternative is to give
-what `preview-remove-urgentization' returns, this will reinstate
-the previous state."
-  (set-extent-initial-redisplay-function
-   ov
-   (if (null rest)
-       fun
-     `(lambda (ov) (,fun ,ov ,@rest)))))
-
-(defun preview-remove-urgentization (ov)
-  "Undo urgentization of OV by `preview-add-urgentization'.
-Returns the old arguments to `preview-add-urgentization'
-if there was any urgentization."
-  (prog1 (list (extent-property ov 'initial-redisplay-function) ov)
-    (set-extent-initial-redisplay-function ov nil)))
-
-(defsubst preview-icon-copy (icon)
-  "Prepare for a later call of `preview-replace-active-icon'."
-  icon)
-
-(defsubst preview-replace-active-icon (ov replacement)
-  "Replace the active Icon in OV by REPLACEMENT, another icon."
-  (set-extent-property ov 'preview-image replacement)
-  (add-text-properties 0 1 (list 'end-glyph (car replacement))
-                      (car (extent-property ov 'strings)))
-  (if (eq (extent-property ov 'preview-state) 'active)
-      (set-extent-end-glyph ov (car replacement))))
-
-(defvar preview-button-1 'button2)
-(defvar preview-button-2 'button3)
-
-;; The `x' and invisible junk is because XEmacs doesn't bother to insert
-;; the extents of a zero-length string. Bah.
-;; When this is fixed, we'll autodetect this case and use zero-length
-;; strings where possible.
-(defmacro preview-make-clickable (&optional map glyph helpstring click1 click2)
-  "Generate a clickable string or keymap.
-If MAP is non-nil, it specifies a keymap to add to, otherwise
-a new one is created.  If GLYPH is given, the result is made
-to display it wrapped in a string.  In that case,
-HELPSTRING is a format string with one or two %s specifiers
-for preview's clicks, displayed as a help-echo.  CLICK1 and CLICK2
-are functions to call on preview's clicks."
-  `(let (,@(and glyph '((res (copy-sequence "x"))))
-           (resmap ,(or map '(make-sparse-keymap))))
-     ,@(if click1
-           `((define-key resmap preview-button-1 ,click1)))
-     ,@(if click2
-           `((define-key resmap preview-button-2 ,click2)))
-     ,@(if glyph
-          `((add-text-properties
-              0 1
-              (list 'end-glyph ,glyph
-                   'mouse-face 'highlight
-              'preview-balloon-help
-             ,(if (stringp helpstring)
-                  (format helpstring preview-button-1 preview-button-2)
-                `(format ,helpstring preview-button-1 preview-button-2))
-              'preview-keymap resmap)
-              res)
-             res)
-        '(resmap))))
-
-(defun preview-click-reroute (ov event)
-  "If OV received a click EVENT on a glyph, reroute to special map."
-  (let ((oldmap (extent-keymap ov)))
-    (unwind-protect
-       (progn
-         (set-extent-keymap ov
-                            (and (event-over-glyph-p event)
-                                 (extent-property ov 'preview-keymap)))
-         (dispatch-event event))
-      (set-extent-keymap ov oldmap))))
-
-(defun preview-reroute-map (ov)
-  "Get rerouting keymap for OV for catching glyph clicks only."
-  (let ((map (make-sparse-keymap))
-       (fun `(lambda (event)
-               (interactive "e")
-               (preview-click-reroute ,ov event))))
-    (define-key map preview-button-1 fun)
-    (define-key map preview-button-2 fun)
-    map))
-
-(defun preview-balloon-reroute (ov)
-  "Give balloon help only if over glyph of OV."
-  (and (eq ov (event-glyph-extent (mouse-position-as-motion-event)))
-       (extent-property ov 'preview-balloon-help)))
-
-;; Most of the changes to this are junking the use of overlays;
-;; a bit of it is different, and there's a little extra paranoia.
-
-;; We also have to move the image from the begin to the end-glyph
-;; whenever the extent is invisible because of a bug in XEmacs-21.4's
-;; redisplay engine.
-(defun preview-toggle (ov &optional arg event)
-  "Toggle visibility of preview overlay OV.
-ARG can be one of the following: t displays the overlay,
-nil displays the underlying text, and 'toggle toggles.
-If EVENT is given, it indicates the window where the event
-occured, either by being a mouse event or by directly being
-the window in question.  This may be used for cursor restoration
-purposes."
-  (if (not (bufferp (extent-object ov)))
-      (error 'wrong-type-argument ov))
-  (let ((old-urgent (preview-remove-urgentization ov))
-        (preview-state
-         (if (if (eq arg 'toggle)
-                 (not (eq (extent-property ov 'preview-state) 'active))
-               arg)
-             'active
-           'inactive))
-        (strings (extent-property ov 'strings)))
-    (unless (eq (extent-property ov 'preview-state) 'disabled)
-      (set-extent-property ov 'preview-state preview-state)
-      (if (eq preview-state 'active)
-          (progn
-           (unless (extent-keymap ov)
-             (set-extent-keymap ov (preview-reroute-map ov))
-             (set-extent-property ov 'balloon-help #'preview-balloon-reroute))
-           (set-extent-begin-glyph ov nil)
-           (set-extent-end-glyph-layout ov 'text)
-           (set-extent-end-glyph ov (get-text-property
-                                     0 'end-glyph (car strings)))
-            (set-extent-properties ov '(invisible t
-                                       isearch-open-invisible ignore
-                                       isearch-invisible t
-                                        face nil))
-           (dolist (prop '(preview-keymap
-                           mouse-face preview-balloon-help))
-              (set-extent-property ov prop
-                                   (get-text-property 0 prop (car strings)))))
-       (unless (cdr strings)
-         (setcdr strings (preview-inactive-string ov)))
-       (set-extent-end-glyph ov nil)
-       (set-extent-begin-glyph-layout ov 'text)
-       (set-extent-begin-glyph ov (get-text-property
-                                   0 'end-glyph (cdr strings)))
-        (set-extent-properties ov `(face preview-face
-                                   mouse-face nil
-                                   invisible nil
-                                   isearch-invisible nil
-                                   preview-keymap
-                                   ,(get-text-property
-                                    0 'preview-keymap (cdr strings))
-                                   preview-balloon-help
-                                   ,(get-text-property
-                                    0 'preview-balloon-help (cdr strings)))))
-      (if old-urgent
-          (apply 'preview-add-urgentization old-urgent))))
-  (if event
-      (preview-restore-position
-       ov
-       (if (windowp event)
-          event
-        (event-window event)))))
-
-; Does FALLBACKS need to be implemented? Likely not.
-(defmacro preview-inherited-face-attribute (face attribute &optional
-                                              fallbacks)
-  "Fetch face attribute while adhering to inheritance.
-This searches FACE and all its ancestors for an ATTRIBUTE.
-FALLBACKS is unused."
-  `(face-attribute ,face ,attribute))
-
-(defun preview-get-colors ()
-  "Return colors from the current display.
-Fetches the current screen colors and makes a vector
-of colors as numbers in the range 0..65535.
-Pure borderless black-on-white will return quadruple NIL."
-  (let
-      ((bg (color-instance-rgb-components (preview-inherited-face-attribute
-             'preview-reference-face :background 'default)))
-       (fg (color-instance-rgb-components (preview-inherited-face-attribute
-                                           'preview-reference-face :foreground 
'default))))
-    (if (equal '(65535 65535 65535) bg)
-        (setq bg nil))
-    (if (equal '(0 0 0) fg)
-        (setq fg nil))
-    (vector bg fg nil nil)))
-
-(defcustom preview-use-balloon-help nil
-  "*Is balloon help enabled in preview-latex?"
-  :group 'preview-appearance
-  :type 'boolean)
-
-(defcustom preview-buffer-recoding-alist
-  (if (and (= emacs-major-version 21)
-          (< emacs-minor-version 5))
-      '((utf-8-unix . raw-text-unix)
-       (utf-8-dos . raw-text-dos)
-       (utf-8-mac . raw-text-mac)
-       (utf-8 . raw-text)))
-  "Translate buffer encodings into process encodings.
-TeX is sometimes bad dealing with 8bit encodings and rather bad
-dealing with multibyte encodings.  So the process encoding output
-might need to get temporarily reprocessed into the original byte
-stream before the buffer characters can be identified.  XEmacs
-21.4 is rather bad at preserving incomplete multibyte characters
-in that process.  This variable makes it possible to use a
-reconstructable coding system in the run buffer instead.  Specify
-an alist of coding system names here, which you can get using
-
-  \(coding-system-name buffer-file-coding-system)
-
-in properly detected buffers."
-  :group 'preview-latex
-  :type '(repeat (cons symbol symbol)))
-
-(defun 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.  XEmacs mule-ucs is so broken that this may be
- needed."
-  (or (cdr (assq (coding-system-name base)
-                preview-buffer-recoding-alist))
-      base))
-
-(if (and (featurep 'mule)
-        (= emacs-major-version 21)
-        (< emacs-minor-version 5))
-    (defadvice coding-system-change-eol-conversion
-       (after fallback activate)
-      "Return CODING-SYSTEM as-is if the result is nil.
-XEmacs 21.4 mule-ucs fails to define utf-8 to respond properly to
-this function."
-      (unless ad-return-value
-       (setq ad-return-value (ad-get-arg 0)))))
-
-(defun preview-mode-setup ()
-  "Setup proper buffer hooks and behavior for previews."
-  (set (make-local-variable 'desktop-save-buffer)
-       #'desktop-buffer-preview-misc-data)
-  (mapc #'make-local-hook
-        '(pre-command-hook post-command-hook
-         before-change-functions after-change-functions))
-  (add-hook 'pre-command-hook #'preview-mark-point nil t)
-  (add-hook 'post-command-hook #'preview-move-point nil t)
-  (and preview-use-balloon-help
-       (not (and (boundp 'balloon-help-mode)
-                balloon-help-mode))
-       (balloon-help-minor-mode 1))
-  (add-hook 'before-change-functions #'preview-handle-before-change nil t)
-  (add-hook 'after-change-functions #'preview-handle-after-change nil t)
-  (easy-menu-add preview-menu)
-  (unless preview-tb-icon
-    (setq preview-tb-icon (preview-filter-specs
-                                      preview-tb-icon-specs))
-    (when preview-tb-icon
-      (setq preview-tb-icon
-           (vector
-            (list preview-tb-icon)
-            #'preview-at-point
-            t
-            "Preview on/off at point"))))
-;;; [Courtesy Stephen J. Turnbull, with some modifications
-;;;  Message-ID: <address@hidden>
-;;;  I could not have figured this out for the world]
-;;; Hm, there really ought to be a way to get the spec that would be
-;;; instantiated in a given domain
-  (when preview-tb-icon
-    (let ((tb (cdadar (or (specifier-spec-list default-toolbar 
(current-buffer))
-                         (specifier-spec-list default-toolbar 'global)))))
-      (unless (member preview-tb-icon tb)
-       (set-specifier default-toolbar
-                      (append tb (list preview-tb-icon))
-                      (current-buffer)))))
-  (when buffer-file-name
-    (let* ((filename (expand-file-name buffer-file-name))
-          format-cons)
-      (when (string-match (concat "\\." TeX-default-extension "\\'")
-                         filename)
-       (setq filename (substring filename 0 (match-beginning 0))))
-      (setq format-cons (assoc filename preview-dumped-alist))
-      (when (consp (cdr format-cons))
-       (preview-unwatch-preamble format-cons)
-       (preview-watch-preamble (current-buffer)
-                               (cadr format-cons)
-                               format-cons)))))
-
-(defvar preview-marker (make-marker)
-  "Marker for fake intangibility.")
-
-(defvar preview-temporary-opened nil)
-
-(defvar preview-last-location nil
-  "Restored cursor position marker for reopened previews.")
-(make-variable-buffer-local 'preview-last-location)
-
-(defun preview-mark-point ()
-  "Mark position for fake intangibility."
-  (when (eq (get-char-property (point) 'preview-state) 'active)
-    (unless preview-last-location
-      (setq preview-last-location (make-marker)))
-    (set-marker preview-last-location (point))
-    (set-marker preview-marker (point))
-    (preview-move-point))
-  (set-marker preview-marker (point)))
-
-(defun preview-restore-position (ov window)
-  "Tweak position after opening/closing preview.
-The treated overlay OV has been triggered in WINDOW.  This function
-records the original buffer position for reopening, or restores it
-after reopening.  Note that by using the mouse, you can open/close
-overlays not in the active window."
-  (when (eq (extent-object ov) (window-buffer window))
-    (with-current-buffer (extent-object ov)
-      (if (eq (extent-property ov 'preview-state) 'active)
-         (setq preview-last-location
-               (set-marker (or preview-last-location (make-marker))
-                           (window-point window)))
-       (when (and
-              (markerp preview-last-location)
-              (eq (extent-object ov) (marker-buffer preview-last-location))
-              (< (extent-start-position ov) preview-last-location)
-              (> (extent-end-position ov) preview-last-location))
-         (set-window-point window preview-last-location))))))
-
-(defun preview-move-point ()
-  "Move point out of fake-intangible areas."
-  (preview-check-changes)
-  (let (newlist (pt (point)) distance)
-    (setq preview-temporary-opened
-         (dolist (ov preview-temporary-opened newlist)
-           (and (extent-object ov)
-                (not (extent-detached-p ov))
-                (eq (extent-property ov 'preview-state) 'inactive)
-                (if (and (eq (extent-object ov) (current-buffer))
-                         (or (<= pt (extent-start-position ov))
-                             (>= pt (extent-end-position ov))))
-                    (preview-toggle ov t)
-                  (push ov newlist)))))
-    (if        (preview-auto-reveal-p
-        preview-auto-reveal
-        (setq distance
-              (and (eq (marker-buffer preview-marker)
-                       (current-buffer))
-                   (- pt (marker-position preview-marker)))))
-       (map-extents #'preview-open-overlay nil
-                    pt pt nil nil 'preview-state 'active)
-      (let (newpt)
-       (while (setq newpt
-                    (map-extents #'preview-skip-overlay nil
-                                 pt pt (and distance (< distance 0)) nil
-                                 'preview-state 'active))
-         (setq pt newpt))
-       (goto-char pt)))))
-
-(defun preview-skip-overlay (ovr backward)
-  "Skip point over OVR, BACKWARD is set if backwards.
-Returns new position or NIL."
-  (if backward
-      (and (> (extent-start-position ovr) (point-min))
-          (1- (extent-start-position ovr)))
-    (and (<= (extent-end-position ovr) (point-max))
-        (> (extent-end-position ovr) (extent-start-position ovr))
-        (extent-end-position ovr))))
-
-(defun preview-open-overlay (ovr ignored)
-  "Open the active preview OVR, IGNORED gets ignored.
-NIL is returned: this is for `map-extents'."
-  (preview-toggle ovr)
-  (push ovr preview-temporary-opened)
-  nil)
-
-(defadvice isearch-highlight (before preview protect disable)
-  "Make isearch open preview text that's a search hit.
-Also make `query-replace' open preview text about to be replaced."
-  (map-extents #'preview-open-overlay nil
-              (ad-get-arg 0) (ad-get-arg 1)
-              nil nil 'preview-state 'active))
-
-(defcustom preview-query-replace-reveal t
-  "*Make `isearch' and `query-replace' autoreveal previews."
-  :group 'preview-appearance
-  :type 'boolean
-  :require 'preview
-  :set (lambda (symbol value)
-        (set-default symbol value)
-        (if value
-            (ad-enable-advice 'isearch-highlight 'before 'preview)
-          (ad-disable-advice 'isearch-highlight 'before 'preview))
-        (ad-activate 'isearch-highlight))
-  :initialize #'custom-initialize-reset)
-
-;; Here is the beef: for best intuitiveness, we want to have
-;; insertions be carried out as expected before iconized text
-;; passages, but we want to insert *into* the overlay when not
-;; iconized.  A preview that has become empty can not get content
-;; again: we remove it.  A disabled preview needs no insert-in-front
-;; handler.
-
-(defvar preview-change-list nil
-  "List of tentatively changed overlays.")
-
-(defcustom preview-dump-threshold
-  "^ *\\\\begin *{document}[ %]*$"
-  "*Regexp denoting end of preamble.
-This is the location up to which preamble changes are considered
-to require redumping of a format."
-  :group 'preview-latex
-  :type 'string)
-
-(defvar preview-preamble-format-cons nil
-  "Where our preamble is supposed to end.")
-(make-variable-buffer-local 'preview-preamble-format-cons)
-
-(defun preview-preamble-check-change (beg end)
-  "Hook function for change hooks on preamble.
-Reacts to changes between BEG and END."
-  (when (and (consp (cdr preview-preamble-format-cons))
-            (cddr preview-preamble-format-cons)
-            (< beg (cddr preview-preamble-format-cons)))
-    (preview-unwatch-preamble preview-preamble-format-cons)
-    (preview-format-kill preview-preamble-format-cons)
-    (setcdr preview-preamble-format-cons t)))
-
-(defun preview-watch-preamble (file command format-cons)
-  "Set up a watch on master file FILE.
-FILE can be an associated buffer instead of a filename.
-COMMAND is the command that generated the format.
-FORMAT-CONS contains the format info for the main
-format dump handler."
-  (let ((buffer (if (bufferp file)
-                   file
-                 (find-buffer-visiting file))) ov)
-    (setq preview-preamble-format-cons nil)
-    (setcdr
-     format-cons
-     (cons command
-          (when buffer
-            (with-current-buffer buffer
-              (save-excursion
-                (save-restriction
-                  (widen)
-                  (goto-char (point-min))
-                  (unless (re-search-forward preview-dump-threshold nil t)
-                    (error "Can't find preamble of `%s'" file))
-                  (setq preview-preamble-format-cons format-cons)
-                  (point)))))))))
-
-(defun preview-unwatch-preamble (format-cons)
-  "Stop watching a format on FORMAT-CONS.
-The watch has been set up by `preview-watch-preamble'."
-  (when (consp (cdr format-cons))
-    (setcdr (cdr format-cons) nil)))
-
-(defun preview-register-change (ov map-arg)
-  "Register not yet changed OV for verification.
-This stores the old contents of the overlay in the
-`preview-prechange' property and puts the overlay into
-`preview-change-list' where `preview-check-changes' will
-find it at some later point of time.  MAP-ARG is ignored;
-it is usually generated by `map-extents'."
-  (unless (extent-property ov 'preview-prechange)
-    (if (eq (extent-property ov 'preview-state) 'disabled)
-       (set-extent-property ov 'preview-prechange t)
-      (set-extent-property ov
-                          'preview-prechange
-                          (save-restriction
-                            (widen)
-                            (buffer-substring-no-properties
-                             (extent-start-position ov)
-                             (extent-end-position ov)))))
-    (push ov preview-change-list))
-  nil)
-
-(defun preview-check-changes ()
-  "Check whether the contents under the overlay have changed.
-Disable it if that is the case.  Ignores text properties."
-  (dolist (ov preview-change-list)
-    (condition-case nil
-       (with-current-buffer (extent-object ov)
-         (let ((text (save-restriction
-                       (widen)
-                       (buffer-substring-no-properties
-                        (extent-start-position ov)
-                        (extent-end-position ov)))))
-           (if (or (zerop (length text))
-                   (extent-detached-p ov))
-               (preview-delete ov)
-             (unless
-                 (or (eq (extent-property ov 'preview-state) 'disabled)
-                     (preview-relaxed-string=
-                      text (extent-property ov 'preview-prechange)))
-               (preview-disable ov)))))
-      (error nil))
-    (set-extent-property ov 'preview-prechange nil))
-  (setq preview-change-list nil))
-
-(defun preview-handle-before-change (beg end)
-  "Hook function for `before-change-functions'.
-Receives BEG and END, the affected region."
-  (map-extents #'preview-register-change nil beg end
-              nil nil 'preview-state)
-  (preview-preamble-check-change beg end))
-
-(defun preview-handle-after-change (beg end length)
-  "Hook function for `after-change-functions'.
-Receives BEG and END, the affected region, and LENGTH
-of an insertion."
-  (when (and preview-change-list
-            (zerop length)
-            (not (eq this-command 'undo)))
-    (map-extents (lambda (ov maparg)
-                  (set-extent-endpoints
-                   ov maparg (extent-end-position ov))) nil
-                   beg beg end 'start-in-region 'preview-state 'active)
-    (map-extents (lambda (ov maparg)
-                  (set-extent-endpoints
-                   ov (extent-start-position ov) maparg)) nil
-                   end end beg 'end-in-region 'preview-state 'active)))
-
-(defun preview-import-image (image)
-  "Convert the printable IMAGE rendition back to an image."
-  (cond ((stringp image)
-        (setq image (copy-sequence image))
-        (add-text-properties 0 (length image)
-                             '(face preview-face)
-                             image)
-        image)
-       ((eq (car image) 'image)
-        (let ((plist (cdr image)))
-          (preview-create-icon-1
-           (plist-get plist :file)
-           (plist-get plist :type)
-           (plist-get plist :ascent))))
-       (t
-        (preview-create-icon-1 (nth 0 image)
-                               (nth 1 image)
-                               (nth 2 image)))))
-
-(if (eq system-type 'windows-nt)
-    (defadvice preview-ps-quote-filename (around path-sep-to-slash)
-      "Make path separator to slash so that the function will not be confused."
-      (let ((directory-sep-char ?/))
-       ad-do-it)))
-
-(provide 'prv-xemacs)
-
-;;; Local variables:
-;;; eval: (put 'preview-defmacro 'lisp-indent-function 'defun)
-;;; end:
-
-;;; prv-xemacs.el ends here
diff --git a/style/alphanum.el b/style/alphanum.el
index 64d694c..d680aac 100644
--- a/style/alphanum.el
+++ b/style/alphanum.el
@@ -2,7 +2,7 @@
 
 ;; Copyright (C) 2004 Free Software Foundation, Inc.
 
-;; Author: Frank K�ster <address@hidden>
+;; Author: Frank Küster <address@hidden>
 ;; Maintainer: address@hidden
 ;; Keywords: tex
 
@@ -28,7 +28,7 @@
 ;; This is file alphanum.el, which makes AUCTeX usable with jura.cls
 ;; and its style file alphanum.sty.
 ;;
-;; Contributed by Frank K�ster <address@hidden>. The code for
+;; Contributed by Frank Küster <address@hidden>. The code for
 ;; reftex has been written by Carsten Dominik, the maintainer of
 ;; reftex, but all the errors are mine.
 
@@ -96,5 +96,5 @@
  LaTeX-dialect)
 
 ;; Local Variables:
-;; coding: iso-8859-1
+;; coding: utf-8
 ;; End:
diff --git a/style/amsmath.el b/style/amsmath.el
index 76f922f..7495d67 100644
--- a/style/amsmath.el
+++ b/style/amsmath.el
@@ -1,6 +1,7 @@
 ;;; amsmath.el --- Style hook for the AMS-LaTeX amsmath package.
 
-;; Copyright (C) 2002, 2005-2007, 2012-2014  Free Software Foundation, Inc.
+;; Copyright (C) 2002, 2005-2007, 2012-2014, 2017-2018
+;;      Free Software Foundation, Inc.
 ;; FIXME: What about the copyright for <= 2001?
 
 ;; Author: Carsten Dominik <address@hidden>
@@ -71,7 +72,7 @@
      '("tbinom" 2)
      '("genfrac" "Left delimiter" "Right delimiter" "Thickness"
        "Mathstyle" 2)
-     '("cfrac" ["position (l or r)"] t)
+     '("cfrac" ["position (l or r)"] 2)
      '("smash" ["where (t or b)"] t)
      '("sideset" "Left" "Right")
      '("tag" "(Tag)")
diff --git a/style/babel.el b/style/babel.el
index c1119b9..8f4fce4 100644
--- a/style/babel.el
+++ b/style/babel.el
@@ -30,7 +30,8 @@
 
 ;;; Code:
 
-(eval-when-compile (require 'cl))
+(eval-when-compile
+  (require 'cl-lib))
 
 (defvar LaTeX-babel-language-list
   '("afrikaans"
@@ -109,9 +110,9 @@
            ;; Append element to `active-languages' to respect loading order.
            ;; `babel' package uses as default language the last loaded one,
            ;; except if it is set with the `main' option.
-           (pushnew elt active-languages :test #'equal))))
+           (cl-pushnew elt active-languages :test #'equal))))
     (if main-language
-        (pushnew main-language active-languages :test #'equal))
+        (cl-pushnew main-language active-languages :test #'equal))
     (nreverse active-languages)))
 
 (defun TeX-arg-babel-lang (_optional &optional _prompt)
diff --git a/style/bidi.el b/style/bidi.el
index 095eb14..1e4fd6e 100644
--- a/style/bidi.el
+++ b/style/bidi.el
@@ -1,6 +1,6 @@
 ;;; bidi.el --- AUCTeX style for the (XeLaTeX) bidi package
 
-;; Copyright (C) 2016 Free Software Foundation, Inc.
+;; Copyright (C) 2016, 2017 Free Software Foundation, Inc.
 
 ;; Author: Uwe Brauer <address@hidden>
 ;; Created: 2016-03-06
@@ -25,35 +25,163 @@
 
 ;;; Commentary:
 
-;; This file adds support for the bidi package.
+;; This file adds support for the bidi package version 31.7
 
 ;;; Code:
 
-(defvar LaTeX-bidi-package-options '("RTLdocument" "rldocument")
+(defvar LaTeX-bidi-package-options
+  '("RTLdocument" "rldocument" "extrafootnotefeatures")
   "Package options for the bidi package.")
 
+(defun LaTeX-env-bidi-bib (environment)
+  "Insert bidi-ENVIRONMENT and a bibitem."
+  (LaTeX-insert-environment environment)
+  (end-of-line 0)
+  (delete-char 1)
+  (delete-horizontal-space)
+  (LaTeX-insert-item))
+
 (TeX-add-style-hook
  "bidi"
  (lambda ()
+   ;; bidi.sty requires xelatex, so set the engine
    (TeX-check-engine-add-engines 'xetex)
-   (LaTeX-add-environments
-    "LTR"
-    "RTL")
-   ;; Fontification
+
+   ;; 1.4 Turning TeX--XeT features on and off
+   (TeX-add-symbols
+    '("TeXXeTOn" 0)
+    '("TeXXeTOff" 0))
+
+   ;; 1.5 Options of The Package: These macros rely on package option
+   ;; "extrafootnotefeatures".  So check for it first
+   (when (LaTeX-provided-package-options-member "bidi" "extrafootnotefeatures")
+     (TeX-add-symbols
+      '("normalfootnotes" 0)
+      '("twocolumnfootnotes" 0)
+      '("threecolumnfootnotes" 0)
+      '("fourcolumnfootnotes" 0)
+      '("fivecolumnfootnotes" 0)
+      '("sixcolumnfootnotes" 0)
+      '("sevencolumnfootnotes" 0)
+      '("eightcolumnfootnotes" 0)
+      '("ninecolumnfootnotes" 0)
+      '("tencolumnfootnotes" 0)
+      '("RTLcolumnfootnotes" 0)
+      '("LTRcolumnfootnotes" 0)
+      '("paragraphfootnotes" 0)
+      '("setLTRparagraphfootnotes" 0)
+      '("setRTLparagraphfootnotes" 0)))
+
    (TeX-add-symbols
+    ;; 1.6 Paragraph Switching Commands
+    '("setLTR" 0)
+    '("setRTL" 0)
+    '("setLR" 0)
     '("setRL" 0)
     '("unsetRL" 0)
-    '("setRTL" 0)
     '("unsetRTL" 0)
-    '("setLR" 0)
-    '("unsetLR" 0)
-    '("setLTR" 0)
     '("unsetLTR" 0)
+
+    ;; 1.8 Typesetting Short LTR and RTL Texts
     '("LR" 1)
     '("LRE" 1)
     '("RLE" 1)
-    '("RL" 1)))
- LaTeX-dialect)
+    '("RL" 1)
 
+    ;; 1.9 Footnotes
+    '("LTRfootnote"
+      (TeX-arg-conditional TeX-arg-footnote-number-p ([ "Number" ]) nil)
+      t)
+    '("RTLfootnote"
+      (TeX-arg-conditional TeX-arg-footnote-number-p ([ "Number" ]) nil)
+      t)
+    '("setfootnoteRL" 0)
+    '("setfootnoteLR" 0)
+    '("unsetfootnoteRL" 0)
+    '("LTRthanks" 1)
+    '("RTLthanks" 1)
+    '("LTRfootnotetext"
+      (TeX-arg-conditional TeX-arg-footnote-number-p ([ "Number" ]) nil)
+      t)
+    '("RTLfootnotetext"
+      (TeX-arg-conditional TeX-arg-footnote-number-p ([ "Number" ]) nil)
+      t)
+
+    ;; 1.9.1 Footnote Rule
+    '("autofootnoterule"  0)
+    '("rightfootnoterule" 0)
+    '("leftfootnoterule" 0)
+    '("LRfootnoterule" 0)
+    '("textwidthfootnoterule" 0)
+    '("SplitFootnoteRule" 0)
+    '("debugfootnotedirection" 0)
+
+    ;; 1.10 Two Column Typesetting
+    '("RTLdblcol" 0)
+    '("LTRdblcol" 0)
+
+    ;; 1.11 RTL cases
+    '("RTLcases" t)
+
+    ;; 1.12 Typesetting Logos
+    '("XeTeX" 0)
+    '("XeLaTeX" 0)
+
+    ;; 1.13 Separation Mark
+    '("SepMark" "Mark")
+
+    ;; 1.20 \setLTRbibitems, \setRTLbibitems, and \setdefaultbibitems
+    ;; commands
+    '("setLTRbibitems" 0)
+    '("setRTLbibitems" 0)
+    '("setdefaultbibitems" 0)
+
+    ;; 1.21 Typesetting margin par
+    '("setRTLmarginpar" 0)
+    '("setLTRmarginpar" 0)
+    '("setdefaultmarginpar" 0)
+    '("LTRmarginpar" [ "Left margin text" ] "Text")
+    '("RTLmarginpar" [ "Left margin text" ] "Text"))
+
+   (LaTeX-add-environments
+    ;; 1.7 Pargraph Switching Environments
+    "LTR"
+    "RTL"
+
+    ;; 1.18 LTRitems and RTLitems Environments
+    '("RTLitems" LaTeX-env-item)
+    '("LTRitems" LaTeX-env-item)
+
+    ;; 1.19 LTRbibitems and RTLbibitems Environments
+    '("LTRbibitems"  LaTeX-env-bidi-bib)
+    '("RTLbibitems"  LaTeX-env-bidi-bib))
+
+   ;; Append "LTRbibitems" & "RTLbibitems" to `LaTeX-item-list':
+   (make-local-variable 'LaTeX-item-list)
+   (dolist (env '("LTRbibitems" "RTLbibitems"))
+     (add-to-list 'LaTeX-item-list `(,env . LaTeX-item-bib) t))
+
+   ;; Fontification
+   (when (and (featurep 'font-latex)
+             (eq TeX-install-font-lock 'font-latex-setup))
+     (font-latex-add-keywords '(("LR"        "{")
+                               ("LRE"       "{")
+                               ("RLE"       "{")
+                               ("RL"        "{")
+                               ("LTRthanks" "{")
+                               ("RTLthanks" "{"))
+                             'textual)
+     (font-latex-add-keywords '(("LTRfootnote"     "[{")
+                               ("RTLfootnote"     "[{")
+                               ("LTRfootnotetext" "[{")
+                               ("RTLfootnotetext" "[{")
+                               ("LTRmarginpar"    "[{")
+                               ("RTLmarginpar"    "[{"))
+                             'reference)
+     (font-latex-add-keywords '(("XeTeX"   "")
+                               ("XeLaTeX" "")
+                               ("SepMark" "{"))
+                             'function)))
+ LaTeX-dialect)
 
 ;;; bidi.el ends here
diff --git a/style/caption.el b/style/caption.el
index df6328e..f23e59d 100644
--- a/style/caption.el
+++ b/style/caption.el
@@ -34,8 +34,8 @@
 
 ;;; Code:
 
-;; Needed for compiling `pushnew':
-(eval-when-compile (require 'cl))
+(eval-when-compile
+  (require 'cl-lib))
 
 ;; Needed for auto-parsing.
 (require 'tex)
@@ -168,19 +168,19 @@ in `caption'-completions."
       ;; For `\DeclareCaptionOption', only add the value
       ;; (remember:      key=^^^^^^, val="defined key")
       (if (string-equal key "option")
-         (pushnew (list val) opts :test #'equal)
+         (cl-pushnew (list val) opts :test #'equal)
        ;; For anything but `\DeclareCaptionOption', do the standard
        ;; procedure.  Again, take care of `subrefformat' for `subcaption.el'.
        (if val-match
            (progn
              (when (and (string-equal key "labelformat")
                         (boundp 'LaTeX-subcaption-key-val-options))
-               (pushnew (list "subrefformat"
-                              (TeX-delete-duplicate-strings (apply #'append 
(list val) val-match)))
-                        opts :test #'equal))
-             (pushnew (list key (TeX-delete-duplicate-strings (apply #'append 
(list val) val-match)))
-                      opts :test #'equal))
-         (pushnew (list key (list val)) opts :test #'equal)))
+               (cl-pushnew (list "subrefformat"
+                                 (TeX-delete-duplicate-strings (apply #'append 
(list val) val-match)))
+                           opts :test #'equal))
+             (cl-pushnew (list key (TeX-delete-duplicate-strings (apply 
#'append (list val) val-match)))
+                         opts :test #'equal))
+         (cl-pushnew (list key (list val)) opts :test #'equal)))
       (setq LaTeX-caption-key-val-options-local (copy-alist opts))))
   ;; Support for environments defined with newfloat.sty: These
   ;; environments are added to "type" and "type*" key:
@@ -192,8 +192,8 @@ in `caption'-completions."
             (val-match (cdr (assoc key LaTeX-caption-key-val-options-local)))
             (temp (copy-alist LaTeX-caption-key-val-options-local))
             (opts (assq-delete-all (car (assoc key temp)) temp)))
-       (pushnew (list key (TeX-delete-duplicate-strings (apply #'append val 
val-match)))
-                opts :test #'equal)
+       (cl-pushnew (list key (TeX-delete-duplicate-strings (apply #'append val 
val-match)))
+                   opts :test #'equal)
        (setq LaTeX-caption-key-val-options-local (copy-alist opts))))))
 
 (defun LaTeX-arg-caption-command (optional &optional prompt)
diff --git a/style/currvita.el b/style/currvita.el
index 0973190..127d68e 100644
--- a/style/currvita.el
+++ b/style/currvita.el
@@ -51,7 +51,7 @@
   ;; Deactivate the mark here in order to prevent `TeX-parse-macro'
   ;; from swapping point and mark and the \item ending up right after
   ;; \begin{...}.
-  (TeX-deactivate-mark)
+  (deactivate-mark)
   (LaTeX-insert-item)
   ;; The inserted \item may have outdented the first line to the
   ;; right.  Fill it, if appropriate.
diff --git a/style/dinbrief.el b/style/dinbrief.el
index 6455e82..2ec5611 100644
--- a/style/dinbrief.el
+++ b/style/dinbrief.el
@@ -67,7 +67,7 @@
 
 (defmacro LaTeX-dinbrief-insert (&rest args)
   "Insert text ignoring active markers."
-  `(progn (if (TeX-mark-active) (TeX-deactivate-mark))
+  `(progn (if (TeX-mark-active) (deactivate-mark))
      (insert ,@args)))
 
 (defun LaTeX-dinbrief-style ()
@@ -123,7 +123,7 @@
            (newline-and-indent)
          (if (not (zerop (length retouradr)))
              (progn
-               (if (TeX-mark-active) (TeX-deactivate-mark))
+               (if (TeX-mark-active) (deactivate-mark))
                (LaTeX-dinbrief-insert TeX-esc "backaddress" TeX-grop retouradr 
TeX-grcl)
                (newline-and-indent)))))
       (LaTeX-dinbrief-insert TeX-esc "enabledraftstandard")
diff --git a/style/dk-bib.el b/style/dk-bib.el
index 63c8d3f..9c35a16 100644
--- a/style/dk-bib.el
+++ b/style/dk-bib.el
@@ -2,7 +2,7 @@
 
 ;; Copyright (C) 2005, 2014 Free Software Foundation, Inc.
 
-;; Author: Arne J�rgensen <address@hidden>
+;; Author: Arne Jørgensen <address@hidden>
 ;; Keywords: tex
 
 ;; This file is part of AUCTeX.
@@ -56,7 +56,7 @@
     options))
 
 ;; Local Variables:
-;; coding: iso-8859-1
+;; coding: utf-8
 ;; End:
 
 ;;; dk-bib.el ends here
diff --git a/style/doc.el b/style/doc.el
index 57b3ee9..b6f3060 100644
--- a/style/doc.el
+++ b/style/doc.el
@@ -2,7 +2,7 @@
 
 ;; Copyright (C) 2004, 2008, 2016 Free Software Foundation, Inc.
 
-;; Author: Frank K�ster <address@hidden>
+;; Author: Frank Küster <address@hidden>
 ;; Maintainer: address@hidden
 ;; Keywords: tex
 
@@ -189,5 +189,5 @@
  LaTeX-dialect)
 
 ;; Local Variables:
-;; coding: iso-8859-1
+;; coding: utf-8
 ;; End:
diff --git a/style/empheq.el b/style/empheq.el
index 4365136..b0231e8 100644
--- a/style/empheq.el
+++ b/style/empheq.el
@@ -31,8 +31,8 @@
 
 ;;; Code:
 
-;; Needed for compiling `pushnew':
-(eval-when-compile (require 'cl))
+(eval-when-compile
+  (require 'cl-lib))
 
 ;; Needed for auto-parsing.
 (require 'tex)
@@ -142,11 +142,11 @@
              (where (cadr delims)))
          (if (string= where "Left")
              (progn
-               (pushnew (concat TeX-esc "empheq" delim) lval :test #'equal)
-               (pushnew (concat TeX-esc "empheqbig" delim) lval :test #'equal))
+               (cl-pushnew (concat TeX-esc "empheq" delim) lval :test #'equal)
+               (cl-pushnew (concat TeX-esc "empheqbig" delim) lval :test 
#'equal))
            (progn
-             (pushnew (concat TeX-esc "empheq" delim) rval :test #'equal)
-             (pushnew (concat TeX-esc "empheqbig" delim) rval :test 
#'equal)))))
+             (cl-pushnew (concat TeX-esc "empheq" delim) rval :test #'equal)
+             (cl-pushnew (concat TeX-esc "empheqbig" delim) rval :test 
#'equal)))))
       (when lval
        (setq tmp (assq-delete-all (car (assoc "left" tmp)) tmp))
        (setq lvals (append lval lvals))
diff --git a/style/enumitem.el b/style/enumitem.el
index 699dbe6..1518a7a 100644
--- a/style/enumitem.el
+++ b/style/enumitem.el
@@ -38,8 +38,8 @@
 
 ;;; Code:
 
-;; Needed for compiling `pushnew':
-(eval-when-compile (require 'cl))
+(eval-when-compile
+  (require 'cl-lib))
 
 ;; Needed for auto-parsing.
 (require 'tex)
@@ -206,7 +206,7 @@ key-val and the first item."
   ;; Deactivate the mark here in order to prevent `TeX-parse-macro'
   ;; from swapping point and mark and the \item ending up right after
   ;; \begin{...}.
-  (TeX-deactivate-mark)
+  (deactivate-mark)
   (LaTeX-insert-item)
   ;; The inserted \item may have outdented the first line to the
   ;; right.  Fill it, if appropriate.
@@ -266,9 +266,9 @@ in `enumitem'-completions."
           (temp (copy-alist LaTeX-enumitem-key-val-options-local))
           (opts (assq-delete-all (car (assoc key temp)) temp)))
       (if val-match
-         (pushnew (list key (TeX-delete-duplicate-strings (apply #'append 
(list val) val-match)))
-                  opts :test #'equal)
-       (pushnew (list key (list val)) opts :test #'equal))
+         (cl-pushnew (list key (TeX-delete-duplicate-strings (apply #'append 
(list val) val-match)))
+                     opts :test #'equal)
+       (cl-pushnew (list key (list val)) opts :test #'equal))
       (setq LaTeX-enumitem-key-val-options-local (copy-alist opts))))
   (dolist (newalign (LaTeX-enumitem-SetLabelAlign-list))
     (let* ((key "align")
@@ -276,8 +276,8 @@ in `enumitem'-completions."
           (val-match (cdr (assoc key LaTeX-enumitem-key-val-options-local)))
           (temp (copy-alist LaTeX-enumitem-key-val-options-local))
           (opts (assq-delete-all (car (assoc key temp)) temp)))
-      (pushnew (list key (TeX-delete-duplicate-strings (apply #'append (list 
val) val-match)))
-              opts :test #'equal)
+      (cl-pushnew (list key (TeX-delete-duplicate-strings (apply #'append 
(list val) val-match)))
+                 opts :test #'equal)
       (setq LaTeX-enumitem-key-val-options-local (copy-alist opts)))))
 
 (TeX-add-style-hook
@@ -405,13 +405,13 @@ in `enumitem'-completions."
        (lambda ()
         (let ((enums '("enumerate")))
           (when (LaTeX-provided-package-options-member "enumitem" "inline")
-            (pushnew "enumerate*" enums :test #'equal))
+            (cl-pushnew "enumerate*" enums :test #'equal))
           (dolist (env-type (LaTeX-enumitem-newlist-list))
             (let ((env   (car env-type))
                   (type  (cadr env-type)))
               (when (or (string-equal type "enumerate")
                         (string-equal type "enumerate*"))
-                (pushnew env enums :test #'equal))))
+                (cl-pushnew env enums :test #'equal))))
           (completing-read "List name: " enums)))))
 
     ;; "Align" is added as new value to "align" key in key-val list.
diff --git a/style/floatrow.el b/style/floatrow.el
index 5beb109..bc358d1 100644
--- a/style/floatrow.el
+++ b/style/floatrow.el
@@ -58,8 +58,9 @@
 
 ;;; Code:
 
-;; Needed for compiling `pushnew':
-(eval-when-compile (require 'cl))
+;; Needed for compiling `cl-pushnew':
+(eval-when-compile
+  (require 'cl-lib))
 
 ;; Needed for auto-parsing.
 (require 'tex)
@@ -317,15 +318,15 @@
                          (assq-delete-all (car (assoc key temp)) temp)))))
        (cond ((string= key "precode")
               (dolist (x vcode-keys)
-                (pushnew (list x (TeX-delete-duplicate-strings (append (list 
val) val-match)))
-                         opts :test #'equal)))
+                (cl-pushnew (list x (TeX-delete-duplicate-strings (append 
(list val) val-match)))
+                            opts :test #'equal)))
              ((string= key "floatrowsep")
               (dolist (x sep-keys)
-                (pushnew (list x (TeX-delete-duplicate-strings (append (list 
val) val-match)))
-                         opts :test #'equal)))
+                (cl-pushnew (list x (TeX-delete-duplicate-strings (append 
(list val) val-match)))
+                            opts :test #'equal)))
              (t
-              (pushnew (list key (TeX-delete-duplicate-strings (append (list 
val) val-match)))
-                       opts :test #'equal)))
+              (cl-pushnew (list key (TeX-delete-duplicate-strings (append 
(list val) val-match)))
+                          opts :test #'equal)))
        (setq LaTeX-floatrow-key-val-options-local (copy-alist opts))))))
 
 (defun LaTeX-floatrow-arg-floatbox (optional)
diff --git a/style/fvextra.el b/style/fvextra.el
index eeb7d37..7f49d6c 100644
--- a/style/fvextra.el
+++ b/style/fvextra.el
@@ -31,8 +31,9 @@
 
 ;;; Code:
 
-;; Needed for compiling `pushnew':
-(eval-when-compile (require 'cl))
+;; Needed for compiling `cl-pushnew':
+(eval-when-compile
+  (require 'cl-lib))
 
 (defvar LaTeX-fvextra-key-val-options
   '(;; 3 General options
@@ -99,8 +100,8 @@
       (dolist (x keys)
        (setq tmp (assq-delete-all (car (assoc x tmp)) tmp))
        (if (string= x "highlightcolor")
-           (pushnew (list x (mapcar #'car (funcall colorcmd))) tmp :test 
#'equal)
-         (pushnew (list x (append '("none") (mapcar #'car (funcall 
colorcmd)))) tmp :test #'equal)))
+           (cl-pushnew (list x (mapcar #'car (funcall colorcmd))) tmp :test 
#'equal)
+         (cl-pushnew (list x (append '("none") (mapcar #'car (funcall 
colorcmd)))) tmp :test #'equal)))
       (setq LaTeX-fancyvrb-key-val-options-local
            (copy-alist tmp)))))
 
diff --git a/style/inputenc.el b/style/inputenc.el
index 53ba4f9..42a99e3 100644
--- a/style/inputenc.el
+++ b/style/inputenc.el
@@ -2,7 +2,7 @@
 
 ;; Copyright (C) 2005, 2014 Free Software Foundation, Inc.
 
-;; Author: Arne J�rgensen <address@hidden>
+;; Author: Arne Jørgensen <address@hidden>
 ;; Keywords: tex
 
 ;; This file is part of AUCTeX.
@@ -81,7 +81,7 @@
  LaTeX-dialect)
 
 ;; Local Variables:
-;; coding: iso-8859-1
+;; coding: utf-8
 ;; End:
 
 ;;; inputenc.el ends here
diff --git a/style/jura.el b/style/jura.el
index 4baac97..236f2ce 100644
--- a/style/jura.el
+++ b/style/jura.el
@@ -2,7 +2,7 @@
 
 ;; Copyright (C) 2004 Free Software Foundation, Inc.
 
-;; Author: Frank K�ster <address@hidden>
+;; Author: Frank Küster <address@hidden>
 ;; Maintainer: address@hidden
 ;; Keywords: tex
 
@@ -36,5 +36,5 @@
  LaTeX-dialect)
 
 ;; Local Variables:
-;; coding: iso-8859-1
+;; coding: utf-8
 ;; End:
diff --git a/style/listings.el b/style/listings.el
index 73ddc00..44c7e6e 100644
--- a/style/listings.el
+++ b/style/listings.el
@@ -1,6 +1,6 @@
 ;;; listings.el --- AUCTeX style for `listings.sty'
 
-;; Copyright (C) 2004, 2005, 2009, 2013-2017 Free Software Foundation, Inc.
+;; Copyright (C) 2004, 2005, 2009, 2013-2018 Free Software Foundation, Inc.
 
 ;; Author: Ralf Angeli <address@hidden>
 ;; Maintainer: address@hidden
@@ -40,8 +40,9 @@
 
 ;;; Code:
 
-;; Needed for compiling `pushnew':
-(eval-when-compile (require 'cl))
+;; Needed for compiling `cl-pushnew':
+(eval-when-compile
+  (require 'cl-lib))
 
 ;; The following are options taken from chapter 4 of the listings
 ;; manual (2007/02/22 Version 1.4).
@@ -284,9 +285,9 @@ with user-defined values via the \"lstdefinestyle\" macro."
         (key (car elt))
         (temp (copy-alist LaTeX-listings-key-val-options-local))
         (opts (assq-delete-all (car (assoc key temp)) temp)))
-    (pushnew (list key (TeX-delete-duplicate-strings
-                       (mapcar #'car (LaTeX-listings-lstdefinestyle-list))))
-            opts :test #'equal)
+    (cl-pushnew (list key (TeX-delete-duplicate-strings
+                          (mapcar #'car (LaTeX-listings-lstdefinestyle-list))))
+               opts :test #'equal)
     (setq LaTeX-listings-key-val-options-local
          (copy-alist opts))))
 
@@ -368,7 +369,8 @@ with user-defined values via the \"lstdefinestyle\" macro."
           (LaTeX-listings-update-style-key)
           (format "%s" name))))
       (TeX-arg-key-val LaTeX-listings-key-val-options-local))
-    '("lstinline" TeX-arg-verb)
+    '("lstinline" [TeX-arg-key-val LaTeX-listings-key-val-options-local]
+      TeX-arg-verb-delim-or-brace)
     '("lstinputlisting" [TeX-arg-key-val LaTeX-listings-key-val-options-local]
       TeX-arg-file)
     "lstlistoflistings"
diff --git a/style/ltx-base.el b/style/ltx-base.el
index 12f9234..1237afb 100644
--- a/style/ltx-base.el
+++ b/style/ltx-base.el
@@ -2,7 +2,7 @@
 
 ;; Copyright (C) 2004, 2016 Free Software Foundation, Inc.
 
-;; Author: Frank K�ster <address@hidden>
+;; Author: Frank Küster <address@hidden>
 ;; Maintainer: address@hidden
 ;; Keywords: tex
 
@@ -83,5 +83,5 @@
  LaTeX-dialect)
 
 ;; Local Variables:
-;; coding: iso-8859-1
+;; coding: utf-8
 ;; End:
diff --git a/style/ltxdoc.el b/style/ltxdoc.el
index 7edf178..c645a8b 100644
--- a/style/ltxdoc.el
+++ b/style/ltxdoc.el
@@ -2,7 +2,7 @@
 
 ;; Copyright (C) 2004 Free Software Foundation, Inc.
 
-;; Author: Frank K�ster <address@hidden>
+;; Author: Frank Küster <address@hidden>
 ;; Maintainer: address@hidden
 ;; Keywords: tex
 
@@ -37,5 +37,5 @@
  LaTeX-dialect)
 
 ;; Local Variables:
-;; coding: iso-8859-1
+;; coding: utf-8
 ;; End:
diff --git a/style/mdframed.el b/style/mdframed.el
index cd26e3f..ed643da 100644
--- a/style/mdframed.el
+++ b/style/mdframed.el
@@ -37,8 +37,9 @@
 
 ;;; Code:
 
-;; Needed for compiling `pushnew':
-(eval-when-compile (require 'cl))
+;; Needed for compiling `cl-pushnew':
+(eval-when-compile
+  (require 'cl-lib))
 
 ;; Needed for auto-parsing.
 (require 'tex)
@@ -214,9 +215,9 @@
           (val (cadr (assoc "style" LaTeX-mdframed-key-val-options)))
           (temp (copy-alist LaTeX-mdframed-key-val-options-local))
           (opts (assq-delete-all (car (assoc key temp)) temp)))
-      (pushnew (list key (TeX-delete-duplicate-strings
-                         (append val (mapcar #'car 
(LaTeX-mdframed-mdfdefinestyle-list)))))
-              opts :test #'equal)
+      (cl-pushnew (list key (TeX-delete-duplicate-strings
+                            (append val (mapcar #'car 
(LaTeX-mdframed-mdfdefinestyle-list)))))
+                 opts :test #'equal)
       (setq LaTeX-mdframed-key-val-options-local
            (copy-alist opts))))
   ;;
@@ -242,7 +243,7 @@
           (tmp (copy-alist LaTeX-mdframed-key-val-options-local)))
       (dolist (x keys)
        (setq tmp (assq-delete-all (car (assoc x tmp)) tmp))
-       (pushnew (list x (mapcar #'car (funcall colorcmd))) tmp :test #'equal))
+       (cl-pushnew (list x (mapcar #'car (funcall colorcmd))) tmp :test 
#'equal))
       (setq LaTeX-mdframed-key-val-options-local
            (copy-alist tmp)))))
 
diff --git a/style/minted.el b/style/minted.el
index 4e4ccd2..3340efc 100644
--- a/style/minted.el
+++ b/style/minted.el
@@ -1,6 +1,6 @@
 ;;; minted.el --- AUCTeX style for `minted.sty' (v2.5)
 
-;; Copyright (C) 2014-2017 Free Software Foundation, Inc.
+;; Copyright (C) 2014-2018 Free Software Foundation, Inc.
 
 ;; Author: Tassilo Horn <address@hidden>
 ;; Maintainer: address@hidden
@@ -286,7 +286,7 @@ are loaded."
                  (concat (cadr name-lang) "inline"))))
       (add-to-list 'TeX-auto-symbol
                   `(,lang [ TeX-arg-key-val LaTeX-minted-key-val-options-local 
]
-                         TeX-arg-verb))
+                         TeX-arg-verb-delim-or-brace))
       (add-to-list 'LaTeX-verbatim-macros-with-delims-local lang)
       (add-to-list 'LaTeX-verbatim-macros-with-braces-local lang)
       (when (and (fboundp 'font-latex-add-keywords)
@@ -368,7 +368,7 @@ a list of strings."
       LaTeX-arg-minted-language TeX-arg-verb)
     '("mintinline"
       [ TeX-arg-key-val LaTeX-minted-key-val-options-local ]
-      LaTeX-arg-minted-language TeX-arg-verb)
+      LaTeX-arg-minted-language TeX-arg-verb-delim-or-brace)
     '("newminted" ["Environment Name"] LaTeX-arg-minted-language
       (TeX-arg-key-val LaTeX-minted-key-val-options-local))
     '("newmint" ["Macro Name"] LaTeX-arg-minted-language
diff --git a/style/moodle.el b/style/moodle.el
index c304481..92c623c 100644
--- a/style/moodle.el
+++ b/style/moodle.el
@@ -114,7 +114,7 @@
   ;; Deactivate the mark here in order to prevent `TeX-parse-macro'
   ;; from swapping point and mark and the \item ending up right after
   ;; \begin{...}.
-  (TeX-deactivate-mark)
+  (deactivate-mark)
   ;; Query and insert the question text.
   (let ((qtext (TeX-read-string (TeX-argument-prompt nil nil "Question 
Text"))))
     (when (and qtext (not (string= qtext "")))
diff --git a/style/pdfsync.el b/style/pdfsync.el
index d2076fd..fd64421 100644
--- a/style/pdfsync.el
+++ b/style/pdfsync.el
@@ -32,7 +32,7 @@
 
 (defun LaTeX-pdfsync-output-page ()
   "Return page number in output file corresponding to buffer position."
-  (let* ((line (TeX-line-number-at-pos))
+  (let* ((line (line-number-at-pos))
         (master (TeX-active-master))
         (file (file-name-sans-extension
                (file-relative-name (buffer-file-name)
diff --git a/style/tcolorbox.el b/style/tcolorbox.el
index 6805983..b8e6512 100644
--- a/style/tcolorbox.el
+++ b/style/tcolorbox.el
@@ -40,8 +40,9 @@
 
 ;;; Code:
 
-;; Needed for compiling `pushnew':
-(eval-when-compile (require 'cl))
+;; Needed for compiling `cl-pushnew':
+(eval-when-compile
+  (require 'cl-lib))
 
 ;; Needed for auto-parsing.
 (require 'tex)
@@ -476,7 +477,7 @@ e.g. \"tcolorboxlib-raster.el\"."
         (tmp (copy-alist LaTeX-tcolorbox-keyval-options-local)))
     (dolist (key keys)
       (setq tmp (assq-delete-all (car (assoc key tmp)) tmp))
-      (pushnew
+      (cl-pushnew
        (list key (mapcar #'car (LaTeX-xcolor-definecolor-list))) tmp :test 
#'equal))
     (setq LaTeX-tcolorbox-keyval-options-local (copy-alist tmp)))
   (setq LaTeX-tcolorbox-keyval-options-full
diff --git a/style/tcolorboxlib-raster.el b/style/tcolorboxlib-raster.el
index 2bf33ee..822e267 100644
--- a/style/tcolorboxlib-raster.el
+++ b/style/tcolorboxlib-raster.el
@@ -104,7 +104,7 @@
   ;; Deactivate the mark here in order to prevent `TeX-parse-macro'
   ;; from swapping point and mark and the \item ending up right after
   ;; \begin{...}.
-  (TeX-deactivate-mark)
+  (deactivate-mark)
   (LaTeX-insert-item)
   ;; The inserted \item may have outdented the first line to the
   ;; right.  Fill it, if appropriate.
diff --git a/style/url.el b/style/url.el
index 9c36a07..0f4bb25 100644
--- a/style/url.el
+++ b/style/url.el
@@ -1,6 +1,6 @@
 ;;; url.el --- AUCTeX style for `url.sty'
 
-;; Copyright (C) 2004, 2005 Free Software Foundation, Inc.
+;; Copyright (C) 2004, 2005, 2018 Free Software Foundation, Inc.
 
 ;; Author: Ralf Angeli <address@hidden>
 ;; Maintainer: address@hidden
@@ -46,8 +46,8 @@
     "UrlOrds"
     "UrlRight"
     "UrlSpecials"
-    "path"
-    "url"
+    '("path" (TeX-arg-verb-delim-or-brace "Path"))
+    '("url" (TeX-arg-verb-delim-or-brace "Url"))
     "urldef"
     '("urlstyle" TeX-arg-urlstyle))
 
@@ -60,7 +60,7 @@
    (when (and (fboundp 'font-latex-add-keywords)
              (fboundp 'font-latex-update-font-lock)
              (eq TeX-install-font-lock 'font-latex-setup))
-     (font-latex-add-keywords '(("path" "{") ("url" "{")) 'reference)
+     (font-latex-add-keywords '(("path" "") ("url" "")) 'reference)
      (font-latex-add-keywords '(("Url" "")
                                ("UrlBigBreakPenalty" "")
                                ("UrlBigBreaks" "")
diff --git a/tex-buf.el b/tex-buf.el
index f458651..b8f901a 100644
--- a/tex-buf.el
+++ b/tex-buf.el
@@ -202,16 +202,12 @@ depend on it being positive instead of the entry in 
`TeX-command-list'."
        (TeX-command-region-end (point-max)))
     (TeX-command-region override-confirm)))
 
-(unless (featurep 'xemacs)
-  ;; This variable is not defined in XEmacs because XEmacs' version of
-  ;; `pop-to-buffer' doesn't support the optional NORECORD argument.  In
-  ;; XEmacs, the third arg is ON-FRAME (Emacs: NORECORD).
-  (defcustom TeX-record-buffer nil
-    "Whether to record buffer names of generated TeX buffers.
+(defcustom TeX-record-buffer nil
+  "Whether to record buffer names of generated TeX buffers.
 When non-nil, these buffers are put at the front of the list of
 recently selected ones."
-    :group 'TeX-command
-    :type 'boolean))
+  :group 'TeX-command
+  :type 'boolean)
 
 (defun TeX-pop-to-buffer (buffer &optional other-window norecord)
   "Compatibility wrapper for `pop-to-buffer'.
@@ -230,14 +226,8 @@ This uses the function `display-buffer' as a subroutine; 
see the documentation
 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.
-
-NORECORD is ignored in XEmacs."
-  ;; Make sure not to use third arg in XEmacs.  In XEmacs, the third arg is
-  ;; ON-FRAME (Emacs: NORECORD), so we set it to nil.
-  (pop-to-buffer buffer other-window (and norecord
-                                         (boundp 'TeX-record-buffer)
-                                         TeX-record-buffer)))
+at the front of the list of recently selected ones."
+  (pop-to-buffer buffer other-window (and norecord TeX-record-buffer)))
 
 (defun TeX-recenter-output-buffer (line)
   "Redisplay buffer of TeX job output so that most recent output can be seen.
@@ -319,9 +309,7 @@ message buffer and start at the first error."
   (if (or (null (TeX-active-buffer))
          (eq 'compilation-mode (with-current-buffer TeX-command-buffer
                                  major-mode)))
-      (if (featurep 'xemacs)
-         (next-error arg)
-       (next-error arg reparse))
+      (next-error arg reparse)
 
     ;; Force reparsing when the function is called with a universal-argument.
     (if (consp arg) (setq reparse t arg nil))
@@ -1285,7 +1273,7 @@ With support for MS-DOS, especially when dviout is used 
with PC-9801 series."
       (if TeX-after-start-process-function
          (funcall TeX-after-start-process-function process))
       (set-process-filter process #'TeX-background-filter)
-      (process-kill-without-query process))))
+      (set-process-query-on-exit-flag process nil))))
 
 (defun TeX-run-silent (name command _file)
   "Start process with second argument."
@@ -1298,7 +1286,7 @@ With support for MS-DOS, especially when dviout is used 
with PC-9801 series."
                                  TeX-shell-command-option command)))
       (if TeX-after-start-process-function
          (funcall TeX-after-start-process-function process))
-      (process-kill-without-query process))))
+      (set-process-query-on-exit-flag process nil))))
 
 (defun TeX-run-interactive (name command file)
   "Run TeX interactively.
@@ -2380,10 +2368,7 @@ already in an Emacs buffer) and the cursor is placed at 
the error."
                    (if (> arg 0)
                        (1+ TeX-error-last-visited)
                      (1- TeX-error-last-visited))
-                   item (if (natnump TeX-error-last-visited)
-                            (nth TeX-error-last-visited TeX-error-list)
-                          ;; XEmacs doesn't support `nth' with a negative 
index.
-                          nil))
+                   item (nth TeX-error-last-visited TeX-error-list))
              ;; Increase or decrease `arg' only if the warning isn't to be
              ;; skipped.
              (unless (TeX-error-list-skip-warning-p (nth 0 item) (nth 10 item))
@@ -2547,10 +2532,8 @@ Return non-nil if an error or warning is found."
            ;; Polish `file' string
            (setq file
                  (let ((string file))
-                   ;; Trim whitespaces at the front.  XXX: XEmacs doesn't
-                   ;; support character classes in regexps, like "[:space:]".
                    (setq string
-                         (if (string-match "\\'[ \t\n\r]*" string)
+                         (if (string-match "\\`[ \t\n\r]+" string)
                              (replace-match "" t t string)
                            string))
                    ;; Sometimes `file' is something like
@@ -3690,70 +3673,68 @@ forward, if negative)."
   "Show an overview of the errors occurred in the last TeX run."
   (interactive)
   ;; Check requirements before start.
-  (if (fboundp 'tabulated-list-mode)
-      (if (setq TeX-error-overview-active-buffer (TeX-active-buffer))
-         ;; `TeX-error-overview-list-entries' is going to be used only as value
-         ;; of `tabulated-list-entries' in `TeX-error-overview-mode'.  In
-         ;; principle, we don't need `TeX-error-overview-list-entries', but
-         ;; `tabulated-list-entries' is buffer-local and we need the list of
-         ;; entries before creating the error overview buffer in order to
-         ;; decide whether we need to show anything.
-         (if (setq TeX-error-overview-list-entries
-                   (TeX-error-overview-make-entries
-                    (TeX-master-directory)))
-             (progn
-               (setq TeX-error-overview-orig-window (selected-window)
-                     TeX-error-overview-orig-frame
-                     (window-frame TeX-error-overview-orig-window))
-               ;; Create the error overview buffer.  This is
-               ;; automatically killed before running TeX commands, so if
-               ;; exists it is up-to-date and doesn't need to be
-               ;; re-created.
-               (unless (get-buffer TeX-error-overview-buffer-name)
-                 (with-current-buffer
-                     (get-buffer-create TeX-error-overview-buffer-name)
-                   (TeX-error-overview-mode)))
-               ;; Move point to the line associated to the last visited
-               ;; error.
-               (with-current-buffer TeX-error-overview-buffer-name
-                 (goto-char (point-min))
-                 (forward-line (with-current-buffer
-                                   TeX-error-overview-active-buffer
-                                 TeX-error-last-visited))
-                 ;; Create a new frame for the error overview or display the
-                 ;; buffer in the same frame, depending on the setup.
-                 (if (TeX-error-overview-setup)
-                     (if (frame-live-p TeX-error-overview-frame)
-                         ;; Do not create a duplicate frame if there is
-                         ;; already one, just select it.
-                         (select-frame-set-input-focus
-                          TeX-error-overview-frame)
-                       ;; Create a new frame and store its name.
-                       (select-frame
-                        (setq TeX-error-overview-frame
-                              (make-frame
-                               TeX-error-overview-frame-parameters)))
-                       (set-window-buffer (selected-window)
-                                          TeX-error-overview-buffer-name)
-                       (set-window-dedicated-p (selected-window) t))
-                   (TeX-pop-to-buffer TeX-error-overview-buffer-name))))
-           (error (concat "No error or warning to show"
-                          ;; Suggest to display warnings and bad boxes with the
-                          ;; appropriate key-bindings if there are such
-                          ;; messages in the output buffer.  Rationale of the
-                          ;; test: `TeX-error-overview-list-entries' is nil,
-                          ;; but if `TeX-error-list' is not nil it means that
-                          ;; there are hidden warnings/bad boxes.
-                          (when (TeX-process-get-variable (TeX-active-master)
-                                                          'TeX-error-list)
-                            (format ".  Type `%s' and `%s' to display \
+  (if (setq TeX-error-overview-active-buffer (TeX-active-buffer))
+      ;; `TeX-error-overview-list-entries' is going to be used only as value
+      ;; of `tabulated-list-entries' in `TeX-error-overview-mode'.  In
+      ;; principle, we don't need `TeX-error-overview-list-entries', but
+      ;; `tabulated-list-entries' is buffer-local and we need the list of
+      ;; entries before creating the error overview buffer in order to
+      ;; decide whether we need to show anything.
+      (if (setq TeX-error-overview-list-entries
+               (TeX-error-overview-make-entries
+                (TeX-master-directory)))
+         (progn
+           (setq TeX-error-overview-orig-window (selected-window)
+                 TeX-error-overview-orig-frame
+                 (window-frame TeX-error-overview-orig-window))
+           ;; Create the error overview buffer.  This is
+           ;; automatically killed before running TeX commands, so if
+           ;; exists it is up-to-date and doesn't need to be
+           ;; re-created.
+           (unless (get-buffer TeX-error-overview-buffer-name)
+             (with-current-buffer
+                 (get-buffer-create TeX-error-overview-buffer-name)
+               (TeX-error-overview-mode)))
+           ;; Move point to the line associated to the last visited
+           ;; error.
+           (with-current-buffer TeX-error-overview-buffer-name
+             (goto-char (point-min))
+             (forward-line (with-current-buffer
+                               TeX-error-overview-active-buffer
+                             TeX-error-last-visited))
+             ;; Create a new frame for the error overview or display the
+             ;; buffer in the same frame, depending on the setup.
+             (if (TeX-error-overview-setup)
+                 (if (frame-live-p TeX-error-overview-frame)
+                     ;; Do not create a duplicate frame if there is
+                     ;; already one, just select it.
+                     (select-frame-set-input-focus
+                      TeX-error-overview-frame)
+                   ;; Create a new frame and store its name.
+                   (select-frame
+                    (setq TeX-error-overview-frame
+                          (make-frame
+                           TeX-error-overview-frame-parameters)))
+                   (set-window-buffer (selected-window)
+                                      TeX-error-overview-buffer-name)
+                   (set-window-dedicated-p (selected-window) t))
+               (TeX-pop-to-buffer TeX-error-overview-buffer-name))))
+       (error (concat "No error or warning to show"
+                      ;; Suggest to display warnings and bad boxes with the
+                      ;; appropriate key-bindings if there are such
+                      ;; messages in the output buffer.  Rationale of the
+                      ;; test: `TeX-error-overview-list-entries' is nil,
+                      ;; but if `TeX-error-list' is not nil it means that
+                      ;; there are hidden warnings/bad boxes.
+                      (when (TeX-process-get-variable (TeX-active-master)
+                                                      'TeX-error-list)
+                        (format ".  Type `%s' and `%s' to display \
 warnings and bad boxes"
-                                    (substitute-command-keys
-                                     
"\\<TeX-mode-map>\\[TeX-toggle-debug-warnings]")
-                                    (substitute-command-keys
-                                     
"\\<TeX-mode-map>\\[TeX-toggle-debug-bad-boxes]"))))))
-       (error "No process for this document"))
-    (error "Error overview is available only in Emacs 24 or later")))
+                                (substitute-command-keys
+                                 
"\\<TeX-mode-map>\\[TeX-toggle-debug-warnings]")
+                                (substitute-command-keys
+                                 
"\\<TeX-mode-map>\\[TeX-toggle-debug-bad-boxes]"))))))
+    (error "No process for this document")))
 
 ;;; Output mode
 
diff --git a/tex-fold.el b/tex-fold.el
index 356c268..16dacae 100644
--- a/tex-fold.el
+++ b/tex-fold.el
@@ -44,10 +44,9 @@
 
 ;;; Code:
 
-(eval-when-compile (require 'cl))
+(eval-when-compile
+  (require 'cl-lib))
 
-(when (featurep 'xemacs)
-  (require 'overlay))
 (require 'tex)
 (autoload 'LaTeX-forward-paragraph "latex")
 (autoload 'LaTeX-backward-paragraph "latex")
@@ -336,8 +335,8 @@ for macros and 'math for math macros."
                          ((eq type 'math) TeX-fold-math-spec-list-internal)
                          (t TeX-fold-macro-spec-list-internal)))
        (dolist (i (cadr item))
-          (pushnew (list i (car item)) fold-list :test #'equal)
-         (pushnew i item-list :test #'equal)))
+          (cl-pushnew (list i (car item)) fold-list :test #'equal)
+         (cl-pushnew i item-list :test #'equal)))
       (when item-list
        (setq regexp (cond ((and (eq type 'env)
                                 (eq major-mode 'context-mode))
@@ -570,22 +569,20 @@ 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."
-  (and (not (featurep 'xemacs)) ; Linebreaks in glyphs don't
-                               ; work in XEmacs anyway.
-       (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))))
+  (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.
@@ -635,12 +632,7 @@ of the resulting list."
                  (setq n (1- n)))
                t)
            (error nil))
-         (list (TeX-fold-buffer-substring content-start content-end)
-               (when (and (featurep 'xemacs)
-                          (extent-at content-start))
-                 ;; A glyph in XEmacs does not seem to be able to hold more
-                 ;; than one face, so we just use the first one we get.
-                 (car (extent-property (extent-at content-start) 'face))))
+         (list (TeX-fold-buffer-substring content-start content-end))
        nil))))
 
 (defun TeX-fold-buffer-substring (start end)
@@ -710,7 +702,7 @@ breaks will be replaced by spaces."
     (dolist (ov (overlays-at (point)))
       (when (and (eq (overlay-get ov 'category) 'TeX-fold)
                 (numberp (overlay-get ov 'TeX-fold-display-string-spec)))
-       (pushnew ov overlays)))
+       (cl-pushnew ov overlays)))
     (when overlays
       ;; Sort list according to descending starts.
       (setq overlays (sort (copy-sequence overlays)
@@ -833,34 +825,20 @@ That means, put respective properties onto overlay OV."
                                  (point))))
     (overlay-put ov 'mouse-face 'highlight)
     (overlay-put ov 'display display-string)
-    (if (featurep 'xemacs)
-       (let ((glyph (make-glyph (if (listp display-string)
-                                    (car display-string)
-                                  display-string))))
-         (overlay-put ov 'invisible t)
-         (when font-lock-mode
-           (if face
-               (set-glyph-property glyph 'face face)
-             (set-glyph-property glyph 'face TeX-fold-folded-face)))
-         (set-extent-property ov 'end-glyph glyph))
-      (when font-lock-mode
-       (overlay-put ov 'face TeX-fold-folded-face))
-      (unless (zerop TeX-fold-help-echo-max-length)
-       (overlay-put ov 'help-echo (TeX-fold-make-help-echo
-                                   (overlay-start ov) (overlay-end ov)))))))
+    (when font-lock-mode
+      (overlay-put ov 'face TeX-fold-folded-face))
+    (unless (zerop TeX-fold-help-echo-max-length)
+      (overlay-put ov 'help-echo (TeX-fold-make-help-echo
+                                 (overlay-start ov) (overlay-end ov))))))
 
 (defun TeX-fold-show-item (ov)
   "Show a single LaTeX macro or environment.
 Remove the respective properties from the overlay OV."
   (overlay-put ov 'mouse-face nil)
-  (if (featurep 'xemacs)
-      (progn
-       (set-extent-property ov 'end-glyph nil)
-       (overlay-put ov 'invisible nil))
-    (overlay-put ov 'display nil)
-    (overlay-put ov 'help-echo nil)
-    (when font-lock-mode
-      (overlay-put ov 'face TeX-fold-unfolded-face))))
+  (overlay-put ov 'display nil)
+  (overlay-put ov 'help-echo nil)
+  (when font-lock-mode
+    (overlay-put ov 'face TeX-fold-unfolded-face)))
 
 ;; Copy and adaption of `reveal-post-command' from reveal.el in GNU
 ;; Emacs on 2004-07-04.
@@ -904,10 +882,7 @@ Remove the respective properties from the overlay OV."
              ;; Close old overlays.
              (dolist (ol old-ols)
                (when (and (eq (current-buffer) (overlay-buffer ol))
-                          (not (rassq ol TeX-fold-open-spots))
-                          (or (not (featurep 'xemacs))
-                              (and (featurep 'xemacs)
-                                   (not (extent-detached-p ol)))))
+                          (not (rassq ol TeX-fold-open-spots)))
                  (if (and (>= (point) (overlay-start ol))
                           (<= (point) (overlay-end ol)))
                      ;; Still near the overlay: keep it open.
diff --git a/tex-font.el b/tex-font.el
index e2cb4b7..27c9cf2 100644
--- a/tex-font.el
+++ b/tex-font.el
@@ -121,9 +121,9 @@
        (list (concat slash citations opt arg) 3 'font-lock-constant-face)
        ;;
        ;; Text between `` quotes ''.
-       (cons (concat (regexp-opt `("``" "\"<" "\"`" "<<" "�") t)
-                     "[^'\">�]+"       ;a bit pessimistic
-                     (regexp-opt `("''" "\">" "\"'" ">>" "�") t))
+       (cons (concat (regexp-opt `("``" "\"<" "\"`" "<<" "«") t)
+                     "[^'\">»]+"       ;a bit pessimistic
+                     (regexp-opt `("''" "\">" "\"'" ">>" "»") t))
              'font-lock-string-face)
        ;;
        ;; Command names, special and general.
@@ -170,4 +170,8 @@
 
 (provide 'tex-font)
 
+;; Local Variables:
+;; coding: utf-8
+;; End:
+
 ;;; tex-font.el ends here
diff --git a/tex-info.el b/tex-info.el
index 4a96e11..f990f0f 100644
--- a/tex-info.el
+++ b/tex-info.el
@@ -25,7 +25,8 @@
 
 ;;; Code:
 
-(eval-when-compile (require 'cl))
+(eval-when-compile
+  (require 'cl-lib))
 
 (require 'tex)
 
@@ -297,7 +298,7 @@ character. Return the resulting string."
     (while (and (< pos (length
                        node-name)) (string-match "@\\(comma\\)[[:blank:]]*{}" 
node-name pos))
       (setq node-name (concat  (substring node-name 0 (match-beginning 0))
-                              (cdr (TeX-assoc-string (match-string 1 
node-name) map))
+                              (cdr (assoc-string (match-string 1 node-name) 
map))
                               (substring node-name (match-end 0)))
            pos (1+ (match-beginning 0)))))
   node-name)
@@ -311,7 +312,7 @@ commands. Return the resulting string."
         (re (regexp-opt (mapcar 'car map))) )
     (while (and (< pos (length node-name)) (string-match re node-name pos))
       (setq node-name (concat  (substring node-name 0 (match-beginning 0))
-                              "@" (cdr (TeX-assoc-string (match-string 0 
node-name) map))
+                              "@" (cdr (assoc-string (match-string 0 
node-name) map))
                               "{}"
                               (substring node-name (match-end 0)))
            pos (1+ (match-beginning 0)))))
@@ -327,16 +328,16 @@ commands. Return the resulting string."
     (let (nodes dups)
       (while (re-search-forward "address@hidden" nil t)
        (skip-chars-forward "[:blank:]")
-       (pushnew (list (Texinfo-nodename-de-escape
-                       (buffer-substring-no-properties
-                        (point) (progn (skip-chars-forward "^\r\n,")
-                                       (skip-chars-backward "[:blank:]")
-                                       (point)))))
-                nodes
-                :test (lambda (a b)
-                        (when (equal a b)
-                          (push (cons a (TeX-line-number-at-pos (point))) dups)
-                          t))))
+       (cl-pushnew (list (Texinfo-nodename-de-escape
+                          (buffer-substring-no-properties
+                           (point) (progn (skip-chars-forward "^\r\n,")
+                                          (skip-chars-backward "[:blank:]")
+                                          (point)))))
+                   nodes
+                   :test (lambda (a b)
+                           (when (equal a b)
+                             (push (cons a (line-number-at-pos (point))) dups)
+                             t))))
       (when dups
        (display-warning
         'AUCTeX
@@ -585,7 +586,7 @@ is assumed by default."
      "-"
      ("Commenting"
       ["Comment or Uncomment Region"
-       TeX-comment-or-uncomment-region
+       comment-or-uncomment-region
        :help "Comment or uncomment the currently selected region"]
       ["Comment or Uncomment Paragraph"
        TeX-comment-or-uncomment-paragraph
diff --git a/tex-jp.el b/tex-jp.el
index 81125ae..83e66af 100644
--- a/tex-jp.el
+++ b/tex-jp.el
@@ -303,20 +303,6 @@ See also a user custom option 
`TeX-japanese-process-input-coding-system'."
   :group 'AUCTeX-jp
   :type '(choice (const :tag "Default" nil) coding-system))
 
-;; $B=gD4$K9T$1$PITMW$K$J$k!#(B
-(defcustom japanese-TeX-command-default "pTeX"
-  "*The default command for `TeX-command' in the japanese-TeX mode."
-  :group 'AUCTeX-jp
-  :type 'string)
-  (make-variable-buffer-local 'japanese-TeX-command-default)
-
-;; $B=gD4$K9T$1$PITMW$K$J$k!#(B
-(defcustom japanese-LaTeX-command-default "LaTeX"
-  "*The default command for `TeX-command' in the japanese-LaTeX mode."
-  :group 'AUCTeX-jp
-  :type 'string)
-  (make-variable-buffer-local 'japanese-LaTeX-command-default)
-
 (defcustom japanese-LaTeX-default-style "jarticle"
   "*Default when creating new Japanese documents."
   :group 'AUCTeX-jp
@@ -404,29 +390,7 @@ See also a user custom option 
`TeX-japanese-process-input-coding-system'."
                   ;; address@hidden"(Blocale 
$B$,F|K\8l$r%5%]!<%H$7$J$$>l9g$O(B
                   ;; euc $B$K8GDj$9$k!#(B
                   (t
-                   (let ((lcs
-                          (cond
-                           ((boundp 'locale-coding-system)
-                            locale-coding-system)
-                           ;; XEmacs doesn't have `locale-coding-system'.
-                           ;; Instead xemacs 21.5 has
-                           ;; `get-coding-system-from-locale' and
-                           ;; `current-locale'.  They aren't available on
-                           ;; xemacs 21.4.
-                           ((and
-                             (featurep 'xemacs)
-                             (fboundp 'get-coding-system-from-locale))
-                            (get-coding-system-from-locale
-                             (if (fboundp 'current-locale)
-                                 (current-locale)
-                               ;; I don't know XEmacs well, so incorporate
-                               ;; the suggestion of
-                               ;; 
http://lists.gnu.org/archive/html/auctex-devel/2017-02/msg00079.html
-                               ;; as well.
-                               (or (getenv "LC_ALL")
-                                   (getenv "LC_CTYPE")
-                                   (getenv "LANG")
-                                   "")))))))
+                   (let ((lcs locale-coding-system))
                      (if (and lcs (japanese-TeX-coding-ejsu lcs))
                          lcs 'euc-jp)))))))
 
@@ -469,28 +433,18 @@ shift_jis: \"sjis\"
 utf-8:     \"utf8\"
 Return nil otherwise."
   (let ((base (coding-system-base coding-system)))
-    (if (featurep 'xemacs)
-       (setq base (coding-system-name base)))
     (cdr (assq base
               '((japanese-iso-8bit . "euc")
-                (euc-jp . "euc") ; for xemacs
                 (iso-2022-jp . "jis")
                 (japanese-shift-jis . "sjis")
-                (shift_jis . "sjis") ; for xemacs
                 (utf-8 . "utf8")
-                (mule-utf-8 . "utf8") ; for emacs 21, 22
-                ;; utf-8-auto $B$d(B utf-8-emacs 
$B$rF~$l$kI,MW$O$"$k$N$+!)(B
 
-                ;; xemacs 21.5 with mule $B$K$O!"(Bjisx0213 $B$N(B charset 
$B$O(B
-                ;; $B$"$k$,$=$lMQ$N(B coding system $B$O$J$$!#(B
                 (euc-jis-2004 . "euc")
                 (iso-2022-jp-2004 . "jis")
                 (japanese-shift-jis-2004 . "sjis")
 
                 (japanese-cp932 . "sjis")
-                (eucjp-ms . "euc")
-                (windows-932 . "sjis") ; for xemacs 21.5 with mule
-               )))))
+                (eucjp-ms . "euc"))))))
 
 (defun japanese-TeX-get-encoding-string ()
   "Return coding option string for Japanese pTeX family.
diff --git a/tex.el b/tex.el
index 5ee02b4..d9a0b93 100644
--- a/tex.el
+++ b/tex.el
@@ -1,6 +1,6 @@
 ;;; tex.el --- Support for TeX documents.
 
-;; Copyright (C) 1985-1987, 1991, 1993-2017 Free Software Foundation, Inc.
+;; Copyright (C) 1985-1987, 1991, 1993-2018 Free Software Foundation, Inc.
 
 ;; Maintainer: address@hidden
 ;; Keywords: tex
@@ -28,13 +28,13 @@
 
 ;;; Code:
 
-(when (< emacs-major-version 21)
-  (error "AUCTeX requires Emacs 21 or later"))
+(when (< emacs-major-version 24)
+  (error "AUCTeX requires Emacs 24 or later"))
 
 (require 'custom)
 (require 'tex-site)
 (eval-when-compile
-  (require 'cl))
+  (require 'cl-lib))
 
 (defgroup TeX-file nil
   "Files used by AUCTeX."
@@ -671,10 +671,6 @@ but does nothing in Emacs."
 Also does other stuff."
     (TeX-maybe-remove-help menu)))
 
-;;;###autoload
-(defalias 'TeX-assoc-string
-  (symbol-function  (if (featurep 'xemacs) 'assoc 'assoc-string)))
-
 ;;; Documentation for Info-goto-emacs-command-node and similar
 
 (eval-after-load 'info '(dolist (elt '("TeX" "LaTeX" "ConTeXt" "Texinfo"
@@ -776,84 +772,55 @@ overlays."
 ;;   (TeX-completing-read-multiple ...))
 ;;
 ;; which results in a void-variable error if crm hasn't been loaded before.
-;; XEmacs 21.4 `require' doesn't have the third NOERROR argument, thus we 
handle
-;; the file-error signal with a `condition-case' also in GNU Emacs.
-(condition-case nil
-    (require 'crm)
-  (file-error
-   (error "AUCTeX requires crm.el which is included in Emacs and
-edit-utils >= 2.32 for XEmacs.")))
-
-(if (fboundp 'completing-read-multiple)
-    (if (or (and (= emacs-major-version 24) (>= emacs-minor-version 4))
-           (>= emacs-major-version 25))
-       ;; For GNU Emacs 24.4 or later, based on `completing-read-multiple' of
-       ;; git commit b14abca9476cba2f500b5eda89441d593dd0f12b
-       ;;   2013-01-10  * lisp/emacs-lisp/crm.el: Allow any regexp for 
separators.
-       (defun TeX-completing-read-multiple
-           (prompt table &optional predicate require-match initial-input
-                   hist def inherit-input-method)
-         "Like `completing-read-multiple' which see.
+(require 'crm)
+
+(if (or (and (= emacs-major-version 24) (>= emacs-minor-version 4))
+       (>= emacs-major-version 25))
+    ;; For GNU Emacs 24.4 or later, based on `completing-read-multiple' of
+    ;; git commit b14abca9476cba2f500b5eda89441d593dd0f12b
+    ;;   2013-01-10  * lisp/emacs-lisp/crm.el: Allow any regexp for separators.
+    (defun TeX-completing-read-multiple
+       (prompt table &optional predicate require-match initial-input
+               hist def inherit-input-method)
+      "Like `completing-read-multiple' which see.
 Retain zero-length substrings but ensure that empty input results
 in nil across different emacs versions."
-         (unwind-protect
-             (progn
-               (add-hook 'choose-completion-string-functions
-                         'crm--choose-completion-string)
-               (let* ((minibuffer-completion-table #'crm--collection-fn)
-                      (minibuffer-completion-predicate predicate)
-                      ;; see completing_read in src/minibuf.c
-                      (minibuffer-completion-confirm
-                       (unless (eq require-match t) require-match))
-                      (crm-completion-table table)
-                      (map (if require-match
-                               crm-local-must-match-map
-                             crm-local-completion-map))
-                      ;; If the user enters empty input, `read-from-minibuffer'
-                      ;; returns the empty string, not DEF.
-                      (input (read-from-minibuffer
-                              prompt initial-input map
-                              nil hist def inherit-input-method))
-                      result)
-                 (and def (string-equal input "") (setq input def))
-                 (if (equal (setq result (split-string input crm-separator))
-                            '(""))
-                     nil
-                   result)))
-           (remove-hook 'choose-completion-string-functions
-                        'crm--choose-completion-string)))
-      ;; For GNU Emacs <= 24.3.
-      (defun TeX-completing-read-multiple
-         (prompt table &optional predicate require-match initial-input
-                 hist def inherit-input-method)
-       "Like `completing-read-multiple' which see.
-Ensures that empty input results in nil across different emacs versions."
-       (let ((result (completing-read-multiple prompt table predicate
-                                               require-match initial-input
-                                               hist def inherit-input-method)))
-         (if (equal result '("")) nil result))))
-  ;; For XEmacs.
+      (unwind-protect
+         (progn
+           (add-hook 'choose-completion-string-functions
+                     'crm--choose-completion-string)
+           (let* ((minibuffer-completion-table #'crm--collection-fn)
+                  (minibuffer-completion-predicate predicate)
+                  ;; see completing_read in src/minibuf.c
+                  (minibuffer-completion-confirm
+                   (unless (eq require-match t) require-match))
+                  (crm-completion-table table)
+                  (map (if require-match
+                           crm-local-must-match-map
+                         crm-local-completion-map))
+                  ;; If the user enters empty input, `read-from-minibuffer'
+                  ;; returns the empty string, not DEF.
+                  (input (read-from-minibuffer
+                          prompt initial-input map
+                          nil hist def inherit-input-method))
+                  result)
+             (and def (string-equal input "") (setq input def))
+             (if (equal (setq result (split-string input crm-separator))
+                        '(""))
+                 nil
+               result)))
+       (remove-hook 'choose-completion-string-functions
+                    'crm--choose-completion-string)))
+  ;; For GNU Emacs <= 24.3.
   (defun TeX-completing-read-multiple
       (prompt table &optional predicate require-match initial-input
              hist def inherit-input-method)
-    "Poor mans implementation of Emacs' `completing-read-multiple' for XEmacs.
-The XEmacs package edit-utils-2.32 includes `crm.el'."
-    (multi-prompt (if (boundp 'crm-separator) crm-separator ",") nil prompt
-                 table predicate require-match initial-input hist)))
-
-(if (fboundp 'line-number-at-pos)
-    (defalias 'TeX-line-number-at-pos 'line-number-at-pos)
-  ;; `line-number-at-pos' from `simple.el' in Emacs CVS (2006-06-07)
-  (defun TeX-line-number-at-pos (&optional pos)
-    "Return (narrowed) buffer line number at position POS.
-If POS is nil, use current buffer location."
-    (let ((opoint (or pos (point))) start)
-      (save-excursion
-       (goto-char (point-min))
-       (setq start (point))
-       (goto-char opoint)
-       (forward-line 0)
-       (1+ (count-lines start (point)))))))
+    "Like `completing-read-multiple' which see.
+Ensures that empty input results in nil across different emacs versions."
+    (let ((result (completing-read-multiple prompt table predicate
+                                           require-match initial-input
+                                           hist def inherit-input-method)))
+      (if (equal result '("")) nil result))))
 
 ;;; Special support for GNU Emacs
 
@@ -1165,11 +1132,7 @@ all the regular expressions must match for the element 
to apply."
     (output-html
      (string-match "html" (TeX-output-extension)))
     (has-no-display-manager
-     ;; Compatibility for Emacs <= 22: older Emacsen don't have FRAME argument
-     ;; to `getenv', later versions have the `display-graphic-p' function.
-     (not (if (< emacs-major-version 23)
-             (or window-system (getenv "DISPLAY"))
-           (display-graphic-p))))
+     (not (display-graphic-p)))
     (style-pstricks
      (TeX-match-style "^pstricks$\\|^pst-\\|^psfrag$"))
     (engine-omega
@@ -1355,12 +1318,7 @@ viewer."
                 :int32 (1+ (current-column)))
           :uint32 0)
           (when TeX-view-evince-keep-focus
-           (cond ((fboundp #'select-frame-set-input-focus)
-                  (select-frame-set-input-focus (selected-frame)))
-                 ((fboundp #'x-focus-frame)
-                  (x-focus-frame (selected-frame)))
-                 ((fboundp #'focus-frame)
-                  (focus-frame (selected-frame))))))
+            (select-frame-set-input-focus (selected-frame))))
       (error "Couldn't find the %s instance for %s" (capitalize app) uri))))
 
 (defun TeX-atril-sync-view ()
@@ -1812,8 +1770,7 @@ search, can set the variable.")
              (processp gnuserv-process)))
        ((and (boundp 'server-process)
              (processp server-process))
-        nil)
-       ((featurep 'xemacs))))
+        nil)))
 
 (defun TeX-source-correlate-server-enabled-p ()
   "Return non-nil if Emacs server or gnuserv is enabled."
@@ -1883,12 +1840,7 @@ If this is nil, an empty string will be returned."
        TeX-synctex-tex-flags)
     ""))
 
-(defvar TeX-source-correlate-map
-  (let ((map (make-sparse-keymap)))
-    ;; (if (featurep 'xemacs)
-    ;;    (define-key map [(control button1)] #'TeX-view-mouse)
-    ;;   (define-key map [C-down-mouse-1] #'TeX-view-mouse))
-    map)
+(defvar TeX-source-correlate-map (make-sparse-keymap)
   "Keymap for `TeX-source-correlate-mode'.
 You could use this for unusual mouse bindings.")
 
@@ -1904,7 +1856,7 @@ file and LINE to (+ LINE offset-of-region).  Else, return 
nil."
       ;; Same regexp used in `preview-parse-messages'.  XXX: XEmacs doesn't
       ;; support regexp classes, so we can't use "[:digit:]" here.
       (when (re-search-forward "!offset(\\([---0-9]+\\))" nil t)
-       (let ((offset (string-to-int (match-string-no-properties 1))))
+       (let ((offset (string-to-number (match-string-no-properties 1))))
          (when TeX-region-orig-buffer
            (list (expand-file-name (buffer-file-name TeX-region-orig-buffer))
                  (+ line offset) col)))))))
@@ -1948,14 +1900,10 @@ If the Emacs frame isn't raised, customize
   ;; FILE may be given as relative path to the TeX-master root document or as
   ;; absolute file:// URL.  In the former case, the tex file has to be already
   ;; opened.
-  (let* ((file (condition-case nil
-                  (progn
-                    (require 'url-parse)
-                    (require 'url-util)
-                    (url-unhex-string (aref (url-generic-parse-url file) 6)))
-                ;; For Emacs 21 compatibility, which doesn't have the
-                ;; url package.
-                (file-error (TeX-replace-regexp-in-string "^file://" "" 
file))))
+  (let* ((file (progn
+                (require 'url-parse)
+                (require 'url-util)
+                (url-unhex-string (aref (url-generic-parse-url file) 6))))
         (flc (or (apply #'TeX-source-correlate-handle-TeX-region file linecol)
                  (apply #'list file linecol)))
         (file (car flc))
@@ -2451,7 +2399,7 @@ this variable to \"<none>\"."
       (when (with-current-buffer buf
              (and (equal dir default-directory)
                   (stringp TeX-master)))
-       (return (with-current-buffer buf 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."
@@ -2757,19 +2705,16 @@ are returned."
          (setq TeX-kpathsea-path-delimiter nil)
        (let ((separators (format "[\n\r%s]" TeX-kpathsea-path-delimiter))
              path input-dir-list)
-         (dolist (item (condition-case nil
-                           (split-string path-list separators t)
-                         ;; COMPATIBILITY for XEmacs <= 21.4.15
-                         (error (delete "" (split-string path-list 
separators)))))
+         (dolist (item (split-string path-list separators t))
            (if subdirs
                (dolist (subdir subdirs)
                  (setq path (file-name-as-directory (concat item subdir)))
                  (when (file-exists-p path)
-                   (pushnew path input-dir-list :test #'equal)))
+                   (cl-pushnew path input-dir-list :test #'equal)))
              (setq path (file-name-as-directory item))
              (when (file-exists-p path)
-               (pushnew path input-dir-list :test #'equal))))
-         ;; No duplication in result is assured since `pushnew' is
+               (cl-pushnew path input-dir-list :test #'equal))))
+         ;; No duplication in result is assured since `cl-pushnew' is
          ;; used above.  Should we introduce an option for speed just
          ;; to accumulate all the results without care for
          ;; duplicates?
@@ -3020,7 +2965,7 @@ DIALECT-EXPR can also be an expression like one of the 
following:
 
 When omitted DIALECT-EXPR is equivalent to `(nor )', ie all
 dialected are allowed."
-  (let ((entry (TeX-assoc-string style TeX-style-hook-list)))
+  (let ((entry (assoc-string style TeX-style-hook-list)))
     (and dialect-expr (setq hook (vector 'TeX-style-hook hook
                                         (TeX-shdex-eval dialect-expr))))
     (cond ((null entry)
@@ -3052,7 +2997,7 @@ found in DIALECT-LIST and return the list thereof."
 the STYLE is only removed for those dialects in DIALECT-LIST.
 
 See variable `TeX-style-hook-dialect' for supported dialects."
-  (let ((style-data (TeX-assoc-string style TeX-style-hook-list)))
+  (let ((style-data (assoc-string style TeX-style-hook-list)))
     (if style-data
        (let ((hooks (and dialect-list (TeX-keep-hooks-in-dialect (cdr 
style-data) dialect-list))))
          (if hooks
@@ -3103,7 +3048,7 @@ See variable `TeX-style-hook-dialect' for supported 
dialects."
                            ;; styles in the order global, private, local
                            ;; (assuming TeX-style-path has that ordering,
                            ;; too).
-                           (reverse (cdr-safe (TeX-assoc-string style 
TeX-style-hook-list))))
+                           (reverse (cdr-safe (assoc-string style 
TeX-style-hook-list))))
                  ;; This happens in case some style added a new parser, and
                  ;; now the style isn't used anymore (user deleted
                  ;; \usepackage{style}).  Then we're left over with, e.g.,
@@ -3186,6 +3131,7 @@ FORCE is not nil."
 
 (defcustom TeX-complete-word 'ispell-complete-word
   "*Function to call for completing non-macros in `tex-mode'."
+  :type 'function
   :group 'TeX-macro)
 
 (defcustom TeX-complete-expert-commands nil
@@ -3413,7 +3359,7 @@ is called with \\[universal-argument]."
                                              TeX-esc)
                                      (TeX-symbol-list-filtered) nil nil nil
                                      'TeX-macro-history TeX-default-macro)))
-  (when (interactive-p)
+  (when (called-interactively-p 'any)
     (setq TeX-default-macro symbol))
   (TeX-parse-macro symbol (cdr-safe (assoc symbol (TeX-symbol-list))))
   (run-hooks 'TeX-after-insert-macro-hook))
@@ -3619,7 +3565,7 @@ See `TeX-parse-macro' for details."
                             (prin1-to-string head))))))
          (t (error "Unknown argument type %s" (prin1-to-string arg))))
     (when (and insert-flag (not optional) (TeX-active-mark))
-      (TeX-deactivate-mark))))
+      (deactivate-mark))))
 
 (defun TeX-argument-insert (name optional &optional prefix)
   "Insert NAME surrounded by curly braces.
@@ -3881,11 +3827,6 @@ The algorithm is as follows:
   ;; `(TeX-master-file nil nil t)' has to be called *before*
   ;; `TeX-update-style' as the latter will call `TeX-master-file'
   ;; without the `ask' bit set.
-  (when (featurep 'xemacs)
-    (unless (boundp 'find-file-hook)
-      (defvaralias 'find-file-hook 'find-file-hooks))
-    (when (not (emacs-version>= 21 5))
-      (make-local-hook 'find-file-hook)))
   (add-hook 'find-file-hook
            (lambda ()
              ;; Check if we are looking at a new or shared file.
@@ -4581,7 +4522,7 @@ EXTENSIONS defaults to `TeX-file-extensions'."
                                    "$TEXMFDIST")
                                   "latex"))
       (when (file-readable-p dir)
-        (pushnew dir list :test #'equal)))
+        (cl-pushnew dir list :test #'equal)))
     (nreverse list)))
 
 (defcustom TeX-tree-roots (TeX-tree-roots)
@@ -4832,15 +4773,6 @@ to look backward for."
     (skip-chars-backward " \t\n")
     (bobp)))
 
-(defun TeX-deactivate-mark ()
-  "Deactivate the mark.
-This is a compatibility function which works both in Emacs and
-XEmacs.  In XEmacs the region is deactivated instead of the
-mark which is sort of equivalent."
-  (if (featurep 'xemacs)
-      (zmacs-deactivate-region)
-    (deactivate-mark)))
-
 (defalias 'TeX-run-mode-hooks
   (if (fboundp 'run-mode-hooks) 'run-mode-hooks 'run-hooks))
 
@@ -4894,8 +4826,8 @@ element to ALIST-VAR."
   (modify-syntax-entry ?~  "."  TeX-mode-syntax-table)
   (modify-syntax-entry ?$  "$"  TeX-mode-syntax-table)
   (modify-syntax-entry ?'  "w"  TeX-mode-syntax-table)
-  (modify-syntax-entry ?�  "."  TeX-mode-syntax-table)
-  (modify-syntax-entry ?�  "."  TeX-mode-syntax-table)
+  (modify-syntax-entry ?«  "."  TeX-mode-syntax-table)
+  (modify-syntax-entry ?»  "."  TeX-mode-syntax-table)
   (modify-syntax-entry ?|  "."  TeX-mode-syntax-table))
 
 ;;; Menu Support
@@ -5039,10 +4971,10 @@ Brace insertion is only done if point is in a math 
construct and
     (define-key map "\e\t"     'TeX-complete-symbol) ;*** Emacs 19 way
 
     (define-key map "\C-c'"    'TeX-comment-or-uncomment-paragraph) ;*** Old 
way
-    (define-key map "\C-c:"    'TeX-comment-or-uncomment-region) ;*** Old way
+    (define-key map "\C-c:"    'comment-or-uncomment-region) ;*** Old way
     (define-key map "\C-c\""   'TeX-uncomment) ;*** Old way
 
-    (define-key map "\C-c;"    'TeX-comment-or-uncomment-region)
+    (define-key map "\C-c;"    'comment-or-uncomment-region)
     (define-key map "\C-c%"    'TeX-comment-or-uncomment-paragraph)
 
     (define-key map "\C-c\C-t\C-p"   'TeX-PDF-mode)
@@ -5065,14 +4997,9 @@ Brace insertion is only done if point is in a math 
construct and
     (define-key map "\C-c^" 'TeX-home-buffer)
     (define-key map "\C-c`"    'TeX-next-error)
     ;; Remap bindings of `next-error'
-    (if (featurep 'xemacs)
-       (substitute-key-definition 'next-error 'TeX-next-error map global-map)
-      (define-key map [remap next-error] 'TeX-next-error))
+    (define-key map [remap next-error] 'TeX-next-error)
     ;; Remap bindings of `previous-error'
-    (if (featurep 'xemacs)
-       (substitute-key-definition 'previous-error 'TeX-previous-error
-                                  map global-map)
-      (define-key map [remap previous-error] 'TeX-previous-error))
+    (define-key map [remap previous-error] 'TeX-previous-error)
     ;; From tex-fold.el
     (define-key map "\C-c\C-o\C-f" 'TeX-fold-mode)
 
@@ -5301,62 +5228,6 @@ Unlike the variable `comment-start-skip' it should not 
match any
 whitespace after the comment starter or any character before it.")
 (make-variable-buffer-local 'TeX-comment-start-regexp)
 
-(defun TeX-comment-region (beg end &optional arg)
-  "Comment each line in the region from BEG to END.
-Numeric prefix arg ARG means use ARG comment characters.
-If ARG is negative, delete that many comment characters instead."
-  (interactive "*r\nP")
-  ;; `comment-padding' will not be recognized in XEmacs' (21.4)
-  ;; `comment-region', so we temporarily modify `comment-start' to get
-  ;; proper spacing.  Unfortunately we have to check for the XEmacs
-  ;; version and cannot test if `comment-padding' is bound as this
-  ;; gets initialized in `VirTeX-common-initialization'.
-  (let ((comment-start (if (and (featurep 'xemacs)
-                               (= emacs-major-version 21)
-                               (<= emacs-minor-version 4))
-                          (concat comment-start (TeX-comment-padding-string))
-                        comment-start)))
-    (comment-region beg end arg)))
-
-(eval-and-compile
-  ;; COMPATIBILITY for Emacs <= 21.3
-  (if (fboundp 'comment-or-uncomment-region)
-      (defalias 'TeX-comment-or-uncomment-region 'comment-or-uncomment-region)
-    ;; The following function was copied from `newcomment.el' on
-    ;; 2004-01-30 and adapted accordingly
-    (defun TeX-comment-or-uncomment-region (beg end &optional arg)
-      "Comment or uncomment a the region from BEG to END.
-Call `TeX-comment-region', unless the region only consists of
-comments, in which case call `TeX-uncomment-region'.  If a prefix
-arg ARG is given, it is passed on to the respective function."
-      (interactive "*r\nP")
-      (funcall (if (save-excursion ;; check for already commented region
-                    (goto-char beg)
-                    (TeX-comment-forward (point-max))
-                    (<= end (point)))
-                  'TeX-uncomment-region 'TeX-comment-region)
-              beg end arg)))
-
-  ;; COMPATIBILITY for Emacs <= 20.  (Introduced in 21.1?)
-  (if (fboundp 'uncomment-region)
-      (defalias 'TeX-uncomment-region 'uncomment-region)
-    (defun TeX-uncomment-region (beg end &optional arg)
-      "Remove comment characters from the beginning of each line
-in the region from BEG to END.  Numeric prefix arg ARG means use
-ARG comment characters.  If ARG is negative, delete that many
-comment characters instead."
-      (interactive "*r\nP")
-      (or arg
-         ;; Determine the number of comment characters at the
-         ;; beginning of the first commented line.
-         (setq arg
-               (save-excursion
-                 (goto-char beg)
-                 (re-search-forward
-                  (concat "^" TeX-comment-start-regexp "+") end t)
-                 (length (match-string 0)))))
-      (comment-region beg end (- arg)))))
-
 (defun TeX-uncomment ()
   "Delete comment characters from the beginning of each line in a comment."
   (interactive)
@@ -5373,7 +5244,7 @@ comment characters instead."
                  (not (eobp)))
        (forward-line 1))
       ;; Uncomment region
-      (TeX-uncomment-region beg (point)))))
+      (uncomment-region beg (point)))))
 
 (defun TeX-comment-or-uncomment-paragraph ()
   "Comment or uncomment current paragraph."
@@ -5389,7 +5260,7 @@ comment characters instead."
       ;; commented without the user noticing.
       (unless (looking-at "^[ \t]*$")
        (mark-paragraph)
-       (TeX-comment-region (point) (mark))))))
+       (comment-region (point) (mark))))))
 
 (defun TeX-in-comment ()
   "Return non-nil if point is in a comment."
@@ -5497,27 +5368,12 @@ not move point to a position less than this value."
   (unless limit (setq limit (point-min)))
   (TeX-forward-comment-skip (- count) limit))
 
-;; Taken from `comment-forward' in Emacs' CVS on 2006-12-26.  Used as
-;; a compatibility function for XEmacs 21.4.
 (defun TeX-comment-forward (&optional n)
   "Skip forward over N comments.
 Just like `forward-comment' but only for positive N
 and can use regexps instead of syntax."
-  (when (fboundp 'comment-normalize-vars)
-    (comment-normalize-vars))
-  (if (fboundp 'comment-forward)
-      (comment-forward n)
-    (setq n (or n 1))
-    (if (< n 0) (error "No comment-backward")
-      (if comment-use-syntax (forward-comment n)
-       (while (> n 0)
-         (setq n
-               (if (or (forward-comment 1)
-                       (and (looking-at comment-start-skip)
-                            (goto-char (match-end 0))
-                            (re-search-forward comment-end-skip nil 'move)))
-                   (1- n) -1)))
-       (= n 0)))))
+  (comment-normalize-vars)
+  (comment-forward n))
 
 (defun TeX-comment-padding-string ()
   "Return  comment padding as a string.
@@ -5570,9 +5426,7 @@ regardless of its data type."
 ;;; Navigation
 
 (defvar TeX-search-syntax-table
-  (let ((table (make-syntax-table (make-char-table (if (featurep 'xemacs)
-                                                      'syntax
-                                                    'syntax-table)))))
+  (let ((table (make-syntax-table (make-char-table 'syntax-table))))
     ;; Preset mode-independent syntax entries.  (Mode-dependent
     ;; entries are set in the function `TeX-search-syntax-table'.)
     ;; ?\", ?\( and ?\) explicitely get whitespace syntax because
@@ -6373,14 +6227,36 @@ information about your AUCTeX version and AUCTeX 
configuration."
           'TeX-parse-self
           'TeX-master
           'TeX-command-list)
-     nil nil
-     "Remember to cover the basics, that is, what you expected to happen and
+     nil
+     ;; reporter adds too many new lines around salutation text, that we don't
+     ;; want, since it's itself a new line.
+     (lambda ()
+       (save-excursion
+        (goto-char (point-min))
+        (re-search-forward mail-header-separator)
+        (forward-char)
+        (delete-char 1)
+        (forward-char)
+        (delete-char 2)))
+     (propertize
+      "\n" 'display
+      (with-temp-buffer
+       (insert
+        "Remember to cover the basics, that is, what you expected to happen and
 what in fact did happen.
 
 Be sure to consult the FAQ section in the manual before submitting
 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 http://www.gnu.org/software/auctex/ if your
+available from ")
+       (insert-text-button
+        "http://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/";))
+        'follow-link t)
+       (insert " if your
 installation is older than the one available from the web site.
 
 If the bug is triggered by a specific \(La\)TeX file, you should try
@@ -6388,9 +6264,17 @@ to produce a minimal sample file showing the problem and 
include it
 in your report.
 
 Your report will be posted for the auctex package at the GNU bug
-tracker.  Visit http://debbugs.gnu.org/cgi/pkgreport.cgi?pkg=auctex
-to browse existing AUCTeX bugs.
-------------------------------------------------------------------------")))
+tracker.  Visit ")
+       (insert-text-button
+        "http://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";))
+        'follow-link t)
+       (insert "\nto browse existing AUCTeX bugs.
+------------------------------------------------------------------------\n\n")
+       (buffer-string))))))
 
 
 ;;; Documentation
@@ -6521,7 +6405,7 @@ NAME may be a package, a command, or a document."
       (when (memq major-mode (nth 1 elt))
        (let ((completions (funcall (nth 2 elt))))
          (unless (null completions)
-            (pushnew (cons completions (nth 0 elt)) docs :test #'equal)))))
+            (cl-pushnew (cons completions (nth 0 elt)) docs :test #'equal)))))
     (if (null docs)
        (progn
          (if (executable-find "texdoc")
@@ -6531,7 +6415,7 @@ NAME may be a package, a command, or a document."
            ;; Give up.
            (message "No documentation found")))
       ;; Ask the user about the package, command, or document.
-      (when (and (interactive-p)
+      (when (and (called-interactively-p 'any)
                 (or (not name) (string= name "")))
        (let ((symbol (thing-at-point 'symbol))
              contained completions doc)
@@ -6645,7 +6529,7 @@ of the car of `ispell-tex-skip-alists'.  This only 
happens if
     (let ((raws (car ispell-tex-skip-alists))
          (envs (cadr ispell-tex-skip-alists)))
       (dolist (x skip)
-       (pushnew x raws :test #'equal))
+       (cl-pushnew x raws :test #'equal))
       (setq ispell-tex-skip-alists (list raws envs)))))
 
 (defun TeX-ispell-skip-setcdr (skip)
@@ -6658,7 +6542,7 @@ of the cdr of `ispell-tex-skip-alists'.  This only 
happens if
     (let ((raws (car ispell-tex-skip-alists))
          (envs (cadr ispell-tex-skip-alists)))
       (dolist (x skip)
-       (pushnew x envs :test #'equal))
+       (cl-pushnew x envs :test #'equal))
       (setq ispell-tex-skip-alists (list raws envs)))))
 
 (defun TeX-ispell-tex-arg-end (&optional arg1 arg2 arg3)
@@ -6777,34 +6661,6 @@ error."
     (put 'TeX-insert-dollar 'delete-selection
         (lambda () (null TeX-electric-math))))
 
-(defun TeX-how-many (regexp &optional rstart rend)
-  "Compatibily function for `how-many'.
-Supports restriction to a region where the XEmacs version doesn't
-and always returns the number of matches, also in XEmacs and GNU
-Emacs 21."
-  ;; Emacs >= 22 does what we want.
-  (if (>= emacs-major-version 22)
-      (how-many regexp rstart rend)
-    ;; XEmacs and GNU Emacs 21 don't return the number of matches but only 
print
-    ;; it.
-    (let ((string
-          (if (featurep 'xemacs)
-              ;; XEmacs doesn't even support restriction to a region.
-              (save-excursion
-                (save-restriction
-                  (when (and (integer-or-marker-p rstart)
-                             (integer-or-marker-p rend))
-                    (narrow-to-region rstart rend)
-                    (goto-char (point-min)))
-                  (how-many regexp)))
-            (how-many regexp rstart rend))))
-      ;; Hide the message printed by `how-many'.
-      (message "")
-      ;; Select the number of occurrences and convert it to a number.
-      (if (string-match "\\([0-9]+\\).*" string)
-         (string-to-number (replace-match "\\1" nil nil string))
-       0))))
-
 (defun TeX--list-of-string-p (lst)
   "Return non-nil iff `LST' is a list of strings.
 Used as function for validating a variable's `safe-local-variable' property."
@@ -6818,7 +6674,7 @@ Used as function for validating a variable's 
`safe-local-variable' property."
 (provide 'tex)
 
 ;; Local Variables:
-;; coding: iso-8859-1
+;; coding: utf-8
 ;; End:
 
 ;;; tex.el ends here
diff --git a/texmathp.el b/texmathp.el
index 23e72f8..9f32179 100644
--- a/texmathp.el
+++ b/texmathp.el
@@ -53,7 +53,8 @@
 ;;
 ;;  To configure which macros and environments influence LaTeX math mode,
 ;;  customize the variable `texmathp-tex-commands'.  By default
-;;  it recognizes the LaTeX core as well as AMS-LaTeX (see the variable
+;;  it recognizes the plain TeX and LaTeX core as well as AMS-LaTeX and
+;;  packages mathtools, empheq and breqn (see the variable
 ;;  `texmathp-tex-commands-default', also as an example).
 ;;
 ;;  To try out the code interactively, use `M-x texmathp RET'.
@@ -152,7 +153,14 @@
     ("AmSgather"     env-on)      ("AmSgather*"    env-on)
     ("AmSmultline"   env-on)      ("AmSmultline*"  env-on)
     ("AmSflalign"    env-on)      ("AmSflalign*"   env-on)
-    ("AmSalignat"    env-on)      ("AmSalignat*"   env-on))
+    ("AmSalignat"    env-on)      ("AmSalignat*"   env-on)
+
+    ;; breqn
+    ("dmath"         env-on)      ("dmath*"        env-on)
+    ("dseries"       env-on)      ("dseries*"      env-on)
+    ("dgroup"        env-on)      ("dgroup*"       env-on)
+    ("darray"        env-on)      ("darray*"       env-on)
+    ("dsuspend"      env-off))
   "The default entries for `texmathp-tex-commands', which see.")
 
 (defun texmathp-compile ()
@@ -302,7 +310,7 @@ See the variable `texmathp-tex-commands' about which 
commands are checked."
 
     ;; Store info, show as message when interactive, and return
     (setq texmathp-why match)
-    (and (interactive-p)
+    (and (called-interactively-p 'any)
         (message "math-mode is %s: %s begins at buffer position %d"
                  (if math-on "on" "off")
                  (or (car match) "new paragraph")
diff --git a/toolbar-x.el b/toolbar-x.el
index bac32c8..79dacdc 100644
--- a/toolbar-x.el
+++ b/toolbar-x.el
@@ -106,7 +106,8 @@
 
 ;;; Code:
 
-(eval-when-compile (require 'cl))
+(eval-when-compile
+  (require 'cl-lib))
 
 ;; Note that this just gives a useful default.  Icons are expected to
 ;; be in subdirectory "images" or "toolbar" relative to the load-path.
@@ -179,7 +180,7 @@ different.  OPTION-LIST equal to nil is a good option list."
     (dotimes (i n)
       (when (> i 0)
        (setq temp-opt-list (cddr temp-opt-list)))
-      (pushnew (car temp-opt-list) list-diff :test #'equal)
+      (cl-pushnew (car temp-opt-list) list-diff :test #'equal)
       (setq elt-in-valid (and elt-in-valid
                              (memq (car temp-opt-list)
                                    valid-options))))
@@ -275,13 +276,8 @@ command, COMM is returned."
 ;; handle `menu titles' differently) meanwhile in XEmacs, menus are lists of
 ;; vectors
 
-(defmacro toolbarx--if-when-compile (test then else)
-  (declare (indent 1) (debug t))
-  (if (eval test) then else))
-
-(toolbarx--if-when-compile (not (featurep 'xemacs))
 (defun toolbarx-emacs-mount-popup-menu
-  (strings var type &optional title save)
+    (strings var type &optional title save)
   "Return an interactive `lambda'-expression that shows a popup menu.
 This function is the action of `toolbarx-mount-popup-menu' if
 inside Emacs. See documentation of that function for more."
@@ -310,7 +306,7 @@ inside Emacs. See documentation of that function for more."
     (dolist (i strings)
       ;; finding a new symbol
       (let* ((aux-count 0)
-           (i-symb (toolbarx-make-symbol-from-string i)))
+            (i-symb (toolbarx-make-symbol-from-string i)))
        (setq key i-symb)
        (while (memq key used-symbols)
          (setq aux-count (1+ aux-count))
@@ -323,7 +319,7 @@ inside Emacs. See documentation of that function for more."
                         ,(if (eq real-type 'radio)
                              `(setq ,var ,count)
                            `(if (memq ,count ,var)
-                               (setq ,var (delete ,count ,var))
+                                (setq ,var (delete ,count ,var))
                               (setq ,var (sort (cons ,count ,var) '<))))
                         (toolbarx-refresh))
                      (when (eq real-save 'always)
@@ -345,70 +341,11 @@ inside Emacs. See documentation of that function for 
more."
        (setq used-symbols (cons key used-symbols)))
       (define-key-after keymap (vector key)
        `(menu-item "Save state of this menu"
-                  (lambda nil (interactive)
-                    (customize-save-variable (quote ,var) ,var)))))
+                   (lambda nil (interactive)
+                     (customize-save-variable (quote ,var) ,var)))))
     ;; returns a `lambda'-expression
     `(lambda nil (interactive) (popup-menu (quote ,keymap)))))
 
-(defun toolbarx-xemacs-mount-popup-menu
-  (strings var type &optional title save)
-  "Return an interactive `lambda'-expression that shows a popup menu.
-This function is the action of `toolbarx-mount-popup-menu' if
-inside XEmacs. See documentation of that function for more."
-  (let* ((menu (if (and title (stringp title))
-                  (list title)
-                (setq title nil)
-                (list "Dropdown menu")))
-        (count 0)
-        (menu-item)
-        (menu-callback)
-        (real-type (if (eq type 'toggle) 'toggle 'radio))
-        (real-save (when save (if (eq save 'offer) 'offer 'always))))
-    ;; warn if type is not `radio' ot `toggle'; use `radio' if incorrect.
-    (unless (eq type real-type)
-      (warn (concat "TYPE should be symbols `radio' or `toggle', "
-                   "but %s found; using `radio'")
-            type))
-    ;; warn if save is not `nil', `offer' or `always'; use nil when incorrect
-    (unless (eq save real-save)
-      (setq real-save nil)
-      (display-warning 'toolbarx
-                      (format (concat "SAVE should be symbols `nil', "
-                                      "`offer' or `always', but %s found; "
-                                      "using `nil'")
-                              save)))
-    ;; making the menu list of vectors
-    (dolist (str strings)
-      (setq count (1+ count))
-      (setq menu-callback (list 'progn
-                               (if (eq real-type 'radio)
-                                   `(setq ,var ,count)
-                                 `(if (memq ,count ,var)
-                                      (setq ,var (delete ,count ,var))
-                                    (setq ,var (sort (cons ,count ,var) '<))))
-                               '(toolbarx-refresh)))
-      (when (eq real-save 'always)
-       (setq menu-callback (append menu-callback
-                                   (list (list 'customize-save-variable
-                                               (list 'quote var) var)))))
-      (setq menu-item (vector str menu-callback
-                             :style real-type
-                             :selected (if (eq real-type 'radio)
-                                            `(eq ,var ,count)
-                                          `(memq ,count ,var))))
-      (setq menu (append menu (list menu-item))))
-    (when (eq real-save 'offer)
-      (setq menu (append menu (list "--:shadowEtchedInDash")))
-      (setq menu (append menu (list
-                              (vector
-                               "Save state of this menu"
-                               `(customize-save-variable (quote ,var)
-                                                         ,var))))))
-    ;; returnung the lambda-expression
-    `(lambda nil (interactive)
-       (let ((popup-menu-titles ,(if title t nil)))
-        (popup-menu (quote ,menu)))))))
-
 (defun toolbarx-mount-popup-menu (strings var type &optional title save)
   "Return a command that show a popup menu.
 The return is a `lambda'-expression with a interactive declaration.
@@ -430,22 +367,15 @@ is nil, do not try to save anything.  If it is `offer', a 
menu
 item is added offering the user the possibiity to save state of
 that dropdown menu for future sesseions (using `custom').  If it
 is `always', state is saved every time that a item is clicked."
-  (if (featurep 'xemacs)
-      (toolbarx-xemacs-mount-popup-menu strings var type title save)
-    (toolbarx-emacs-mount-popup-menu strings var type title save)))
+  (toolbarx-emacs-mount-popup-menu strings var type title save))
 
 (defun toolbarx-option-value (opt)
-  "Return option value according to Emacs flavour.
-If OPT is a vector, return first element if in Emacs or
-second if in XEmacs.  Otherwise, return OPT.
-If OPT is vector and length is smaller than the necessary (like
-if in XEmacs and vector has length 1), then nil is returned."
+  "If OPT is a vector, return first element, otherwise, return OPT.
+If OPT is vector and length is smaller than the necessary, then
+nil is returned."
   (if (vectorp opt)
-      (if (featurep 'xemacs)
-         (when (> (length opt) 1)
-           (aref opt 1))
-       (when (> (length opt) 0)
-         (aref opt 0)))
+      (when (> (length opt) 0)
+       (aref opt 0))
     opt))
 
 (defun toolbarx-eval-function-or-symbol (object type-test-func)
@@ -482,44 +412,24 @@ documentation of function `toolbarx-process-symbol')."
           (let* ((val (toolbarx-option-value img))
                  (all-obj-ok t)
                  (good-obj
-                  (if (featurep 'xemacs)
-                      ;; if XEmacs
-                      (or (stringp val) ; a string
-                          (glyphp val)  ; or a glyph
-                          (and (symbolp val) ; or a symbol bound to a
-                               (boundp val)  ; glyph-list
-                               (check-toolbar-button-syntax
-                                (vector val
-                                        (lambda nil (interactive))
-                                        nil nil) t))
-                          (and (listp val) ; or a glyph-or-string list
-                               (> (length val) 0)
-                               (< (length val) 7)
-                               (dolist (i val all-obj-ok)
-                                 (setq all-obj-ok
-                                       (and all-obj-ok
-                                            (or (not i)
-                                                (stringp i)
-                                                (glyphp i)))))))
-                    ;; if Emacs
-                    (or (stringp val)    ; string
-                        (and (consp val) ; or image descriptor
-                             (eq (car val) 'image))
-                        (and (symbolp val) ; or a symbol bound to a
-                             (boundp val)  ; image descriptor
-                                           ; (defined with `defimage')
-                             (consp (eval val))
-                             (eq (car (eval val)) 'image))
-                        (and (listp val) ; or list with 4 strings or
-                                         ; image descriptors
-                             (= (length val) 4)
-                             (dolist (i val all-obj-ok)
-                               (setq all-obj-ok
-                                     (and all-obj-ok
-                                          (or (stringp i)
-                                              (and (consp i)
-                                                   (eq (car i)
-                                                       'image)))))))))))
+                  (or (stringp val)      ; string
+                      (and (consp val) ; or image descriptor
+                           (eq (car val) 'image))
+                      (and (symbolp val) ; or a symbol bound to a
+                           (boundp val)  ; image descriptor
+                                       ; (defined with `defimage')
+                           (consp (eval val))
+                           (eq (car (eval val)) 'image))
+                      (and (listp val) ; or list with 4 strings or
+                                       ; image descriptors
+                           (= (length val) 4)
+                           (dolist (i val all-obj-ok)
+                             (setq all-obj-ok
+                                   (and all-obj-ok
+                                        (or (stringp i)
+                                            (and (consp i)
+                                                 (eq (car i)
+                                                     'image))))))))))
             (cons good-obj val)))))
     (toolbarx-eval-function-or-symbol obj toolbarx-test-image-type-simple)))
 
@@ -530,12 +440,9 @@ documentation of function `toolbarx-process-symbol')."
   (let ((toolbarx-test-button-type-simple
         (lambda (but)
           (let* ((val (toolbarx-option-value but))
-                 (good-obj (if (featurep 'xemacs)
-                               ;; if XEmacs
-                               t
-                             ;; if Emacs
-                             (and (consp val)
-                                  (memq (car val) '(:toggle :radio))))))
+                 (good-obj
+                  (and (consp val)
+                       (memq (car val) '(:toggle :radio)))))
             (cons good-obj val)))))
     (toolbarx-eval-function-or-symbol obj toolbarx-test-button-type-simple)))
 
@@ -566,16 +473,7 @@ VAL (see documentation of function 
`toolbarx-process-symbol')."
           (let* ((val (toolbarx-option-value obj))
                  (all-but-def-opts '(top bottom left right))
                  (all-opts '(default top bottom left right))
-                 (good-obj
-                  (if (featurep 'xemacs)
-                      ;; if XEmacs
-                      (if (symbolp val)
-                          (memq val all-opts)
-                        (and (consp val)
-                             (memq (car val) all-but-def-opts)
-                             (memq (cdr val) all-but-def-opts)))
-                    ;; if Emacs
-                    t)))
+                 (good-obj t))
             (cons good-obj val)))))
     (toolbarx-eval-function-or-symbol obj toolbarx-test-toolbar-type-simple)))
 
@@ -1109,34 +1007,20 @@ in the end of SWITCHES, which is returned."
 
 (defun toolbarx-find-image (image)
   "Return image descriptor or glyph for IMAGE.
-In Emacs, return an image descriptor for IMAGE.  In XEmacs,
-return a glyph.
 
 IMAGE is string.  Usually IMAGE neither contains a directory nor
 an extension.  If the extension is omitted, `xpm', `xbm' and
 `pbm' are tried.  If the directory is omitted,
 `toolbarx-image-path' is searched."
-  ;; `find-image' in Emacs 21 looks in `load-path' and `data-directory'.  In
-  ;; Emacs 22, we have `image-load-path' which includes `load-path' and
-  ;; `data-directory'.
-  ;;
-  ;; If there's some API in XEmacs to find the images, we should use it
-  ;; instead of locate-library.
-  ;;
-  ;; Emacs 22 has locate-file, but the other Emacsen don't.  The
-  ;; following should hopefully get us to all images ultimately.
-
   (let ((file))
     (dolist (i '("" ".xpm" ".xbm" ".pbm"))
       (unless file
        (setq file (locate-library (concat image i) t toolbarx-image-path))))
-    (if (featurep 'xemacs)
-       (and file (make-glyph file))
-      (if file
-         (create-image file)
-       (find-image `((:type xpm :file ,(concat image ".xpm"))
-                     (:type xbm :file ,(concat image ".xbm"))
-                     (:type pbm :file ,(concat image ".pbm"))))))))
+    (if file
+       (create-image file)
+      (find-image `((:type xpm :file ,(concat image ".xpm"))
+                   (:type xbm :file ,(concat image ".xbm"))
+                   (:type pbm :file ,(concat image ".pbm")))))))
 
 ;; next variable interfaces between parsing and display engines
 (defvar toolbarx-internal-button-switches nil
@@ -1144,10 +1028,9 @@ an extension.  If the extension is omitted, `xpm', `xbm' 
and
 This variable can store different values for the different buffers.")
 
 
-(toolbarx--if-when-compile (not (featurep 'xemacs))
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;; Second engine: display parsed buttons in Emacs
-(progn
+
 (defun toolbarx-emacs-add-button (button used-keys keymap)
   "Insert a button where BUTTON is its description.
 USED-KEYS should be a list of symbols, where the first element is
@@ -1188,7 +1071,7 @@ function `toolbar-install-toolbar'."
                          (setq add-list (cons (cdr prop-good-val) add-list))))
                      (setq add-list (nreverse add-list))
                      (when (eq 2 (length add-list)) ; just 1 value, no
-                                                    ; add-function
+                                       ; add-function
                        (setq add-list (cadr add-list)))
                      (setq filtered-props-temp (append
                                                 (list (car p) add-list)
@@ -1218,7 +1101,7 @@ function `toolbar-install-toolbar'."
                    image)
                   ((and (symbolp image) ; or a symbol bound to a
                         (boundp image)  ; image descriptor (defined
-                                      ; with `defimage')g
+                                       ; with `defimage')g
                         (consp (eval image))
                         (eq (car (eval image)) 'image))
                    (eval image))
@@ -1226,9 +1109,9 @@ function `toolbar-install-toolbar'."
                                        ; with 4 strings or image
                                        ; descriptors
                    (apply 'vector (mapcar (lambda (img)
-                                             (if (stringp img)
-                                                 (toolbarx-find-image img)
-                                               img))
+                                            (if (stringp img)
+                                                (toolbarx-find-image img)
+                                              img))
                                           image))))))
               (command
                (let* ((com (nth 1 (memq :command filtered-props)))
@@ -1305,379 +1188,9 @@ is used and the default value of `toolbarx-map' is 
changed."
                                                          tool-bar-map-temp)
     (if global-flag
        (setq-default tool-bar-map tool-bar-map-temp)
-      (setq tool-bar-map tool-bar-map-temp)))))
+      (setq tool-bar-map tool-bar-map-temp))))
 
 
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;; Third engine: display parsed buttons in XEmacs
-(progn
-(defun toolbarx-xemacs-image-properties (image)
-  "Return a list of properties of IMAGE.
-IMAGE should be a string or a list of one to six strings or
-glyphs or nil, or a symbol bound to a list of one to six
-glyphs (them must be a valid image list, like one created with
-the function `toolbar-make-button-list').  Return a
-list (GLYPH-LIST HEIGHT WIDTH) where HEIGHT (resp. WIDTH) is the
-maximum of the heights (resp. widths) of all glyphs (or strings
-converted to glyphs) in GLYPH-LIST.  If IMAGE is not a list, it
-is treated as a list with IMAGE as only element.  Strings are
-converted to glyphs with the function `toolbarx-find-image'.  If,
-after possible string-to-glyph convertions, the list of glyphs
-has nil as first element, GLYPH-LIST becomes nil."
-  (let* ((glyph-list
-         (if (symbolp image)           ; if symbol, them must be a
-                                       ; valid image list, like
-                                       ; created by function
-                                       ; `toolbar-make-button-list'
-             (eval image)
-           (let ((img-list (if (listp image)
-                               image
-                             (list image)))
-                 (glyph-list-temp))
-             ;; glyph-list-temp
-             (setq glyph-list-temp
-                   (dolist (glyph img-list (nreverse glyph-list-temp))
-                     (if (stringp glyph)
-                         (setq glyph-list-temp
-                               (cons (toolbarx-find-image glyph)
-                                     glyph-list-temp))
-                       (setq glyph-list-temp (cons glyph glyph-list-temp)))))
-             (unless (car glyph-list-temp)
-               (setq glyph-list-temp nil))
-             glyph-list-temp)))
-        (usable-buttons
-         ;; computing inheritage
-         (let* ((usable-temp))
-           (if toolbar-captioned-p     ; problematic point :-(
-               (progn
-                 ;; CAP-UP:  cap-up -> up
-                 (setq usable-temp (cons (cond
-                                          ((nth 3 glyph-list))
-                                          ((nth 0 glyph-list)))
-                                         usable-temp))
-                 ;; CAP-DOWN:  cap-down -> cap-up -> down -> up
-                 (setq usable-temp (cons (cond
-                                          ((nth 4 glyph-list))
-                                          ((nth 3 glyph-list))
-                                          ((nth 1 glyph-list))
-                                          ((nth 0 glyph-list)))
-                                         usable-temp))
-                 ;; CAP-DISABLED:  cap-disabled -> cap-up -> disabled -> up
-                 (setq usable-temp (cons (cond
-                                          ((nth 5 glyph-list))
-                                          ((nth 3 glyph-list))
-                                          ((nth 2 glyph-list))
-                                          ((nth 0 glyph-list)))
-                                         usable-temp)))
-             ;; UP:  up
-             (setq usable-temp (cons (nth 0 glyph-list) usable-temp))
-             ;; DOWN:  down -> up
-             (setq usable-temp (cons (cond
-                                      ((nth 1 glyph-list))
-                                      ((nth 0 glyph-list)))
-                                     usable-temp))
-             ;; DISABLED:  disabled -> up
-             (setq usable-temp (cons (cond
-                                      ((nth 2 glyph-list))
-                                      ((nth 0 glyph-list)))
-                                     usable-temp)))
-           usable-temp))
-        (height (apply 'max 0 (mapcar (lambda (glyph)
-                                        (if glyph
-                                            (glyph-height glyph)
-                                          0))
-                                      usable-buttons)))
-        (width (apply 'max 0 (mapcar (lambda (glyph)
-                                       (if glyph
-                                           (glyph-width glyph)
-                                         0))
-                                     usable-buttons))))
-    (list (if (symbolp image) image glyph-list) height width)))
-
-
-
-(defun toolbarx-xemacs-button-properties (button)
-  "Return a list of properties of BUTTON.
-The result is either nil (if not to be inserted) or a list in the format
- (TOOLBAR HEIGHT WIDTH BUTTON-DESCRIPTION)
-where
-
-TOOLBAR is one of the symbols `default', `top', `right', `bottom'
-  or `left'.
-
-HEIGHT and WIDTH are the maximal dimentions of all the glyphs
-  involved.
-
-BUTTON-DESCRIPTION is button definition in XEmacs; see the
-  documentation of variable `default-toolbar'."
-  (let* ((filtered-props
-         (let* ((filtered-props-temp)
-                (prop-good-val)
-                (prop))
-           (dolist (p (nth 0 toolbarx-button-props) filtered-props-temp)
-             ;;    property           -> (car p)
-             ;;    test type function -> (cadr p)
-             ;;    add-function       -> (cddr p)
-             (setq prop (memq (car p) button))
-             ;; if so, check if value is of correct type
-             (when prop
-               ;; if property is of add-type, them the value is a list
-               ;; (:add-value-list VAL VAL). Each VAL should be checked.
-               (if (and (cddr p) (eq :add-value-list (car (cadr prop))))
-                   (let* ((add-list (list (cddr p))))
-                     (dolist (val (cdr (cadr prop)))
-                       (setq prop-good-val (funcall (cadr p) val))
-                       (when (car prop-good-val)
-                         (setq add-list (cons (cdr prop-good-val) add-list))))
-                     (setq add-list (nreverse add-list))
-                     (when (eq 2 (length add-list)) ; just 1 value, no
-                                                    ; add-function
-                       (setq add-list (cadr add-list)))
-                     (setq filtered-props-temp (append
-                                                (list (car p) add-list)
-                                                filtered-props-temp)))
-                 ;; if override-property
-                 (setq prop-good-val (funcall (cadr p) (cadr prop)))
-                 (when (car prop-good-val)
-                   (setq filtered-props-temp (append
-                                              (list (car p)
-                                                    (cdr prop-good-val))
-                                              filtered-props-temp))))))))
-        (insert (or (not (memq :insert filtered-props))
-                    ;; (memq :insert filtered-props) holds
-                    (eval (nth 1 (memq :insert filtered-props))))))
-    (when insert
-      (let* ((image-props (toolbarx-xemacs-image-properties
-                          (cadr (memq :image filtered-props))))
-            (glyph-list (car image-props))
-            (image-height (nth 1 image-props))
-            (image-width (nth 2 image-props))
-            (command
-             (let* ((com (nth 1 (memq :command filtered-props)))
-                    (app (nth 1 (memq :append-command filtered-props)))
-                    (prep (nth 1 (memq :prepend-command filtered-props))))
-               (when (or com app prep)
-                 (toolbarx-make-command com prep app))))
-            ;; enable defaults to `t'
-            (enable (if (memq :enable filtered-props)
-                        (cadr (memq :enable filtered-props))
-                      t))
-           ;; help defaults to nil
-            (help (when (memq :help filtered-props)
-                    (cadr (memq :help filtered-props))))
-            ;; toolbar defaults to `default'
-            (toolbar-prop (cons (memq :toolbar filtered-props)
-                                (cadr (memq :toolbar filtered-props))))
-            (toolbar (if (car toolbar-prop)
-                         (if (symbolp (cdr toolbar-prop))
-                             (cdr toolbar-prop)
-                           ;; (cdr toolbar-prop) is cons cell
-                           (if (eq (cadr toolbar-prop)
-                                         (default-toolbar-position))
-                                     (cddr toolbar-prop)
-                                  (cadr toolbar-prop)))
-                       'default)))
-       (when glyph-list
-         (list toolbar image-height image-width
-               (vector glyph-list command enable help)))))))
-
-(defun toolbarx-xemacs-refresh-process-button-or-insert-list (switches
-                                                             toolbar-props)
-  "Process SWITCHES, returning an updated version of TOOLBAR-PROPS.
-TOOLBAR-PROPS should be a list with 12 elements, each one representing
-properties (in this order) `locale', `default', `top', `right',
-`bottom', `left', `default-height', `default-width', `top-height',
-`right-width', `bottom-height' and `left-width'.  The return is a list
-with the same properties updated.
-
-NB: Buttons (vectors) are inserted in front of the lists
-represented by `default', `top', `right', `bottom' and `left', so
-the lists are built reversed."
-  (let ((locale                 (nth 0  toolbar-props))
-       (default         (nth 1  toolbar-props))
-       (top             (nth 2  toolbar-props))
-       (right           (nth 3  toolbar-props))
-       (bottom          (nth 4  toolbar-props))
-       (left            (nth 5  toolbar-props))
-       (default-height  (nth 6  toolbar-props))
-       (default-width   (nth 7  toolbar-props))
-       (top-height      (nth 8  toolbar-props))
-       (right-width     (nth 9  toolbar-props))
-       (bottom-height   (nth 10 toolbar-props))
-       (left-width      (nth 11 toolbar-props))
-       (toolbar-props-temp))
-    (dolist (button switches)
-      (if (eq (car button) :insert)
-         (when (eval (cadr button))
-           ;; if insert group, process `cddr'
-           (progn
-             (setq toolbar-props-temp
-                   (toolbarx-xemacs-refresh-process-button-or-insert-list
-                    (cddr button)
-                    (list locale default top right bottom left
-                          default-height default-width top-height
-                          right-width bottom-height left-width)))
-             (setq default        (nth 1  toolbar-props-temp))
-             (setq top            (nth 2  toolbar-props-temp))
-             (setq right          (nth 3  toolbar-props-temp))
-             (setq bottom         (nth 4  toolbar-props-temp))
-             (setq left           (nth 5  toolbar-props-temp))
-             (setq default-height (nth 6  toolbar-props-temp))
-             (setq default-width  (nth 7  toolbar-props-temp))
-             (setq top-height     (nth 8  toolbar-props-temp))
-             (setq right-width    (nth 9  toolbar-props-temp))
-             (setq bottom-height  (nth 10 toolbar-props-temp))
-             (setq left-width     (nth 11 toolbar-props-temp))))
-       ;; else, if normal button
-       (let* ((button-props (toolbarx-xemacs-button-properties button))
-              (toolbar (nth 0 button-props))
-              (height (nth 1 button-props))
-              (width (nth 2 button-props))
-              (button-description (nth 3 button-props)))
-         (when button-props
-           (cond
-            ;; default
-            ((eq toolbar 'default)
-             (setq default (cons button-description default))
-             (setq default-height (max default-height height))
-             (setq default-width (max default-width width)))
-            ;; top
-            ((eq toolbar 'top)
-             (setq top (cons button-description top))
-             (setq top-height (max top-height height)))
-            ;; right
-            ((eq toolbar 'right)
-             (setq right (cons button-description right))
-             (setq right-width (max right-width width)))
-            ;; bottom
-            ((eq toolbar 'bottom)
-             (setq bottom (cons button-description bottom))
-             (setq bottom-height (max bottom-height height)))
-            ;; left
-            ((eq toolbar 'left)
-             (setq left (cons button-description left))
-             (setq left-width (max left-width width))))))))
-    ;; return a list similar to toolbar-props
-    (list locale default top right bottom left default-height
-         default-width top-height right-width bottom-height left-width)))
-
-
-(defun toolbarx-xemacs-refresh (&optional global-flag)
-  "Refresh the toolbar in XEmacs."
-  (let* ((switches (if global-flag
-                      (if (default-boundp 'toolbarx-internal-button-switches)
-                          (default-value 'toolbarx-internal-button-switches)
-                        toolbarx-internal-button-switches)
-                    toolbarx-internal-button-switches))
-        (locale  (if global-flag 'global (current-buffer)))
-        (toolbar-init (list locale     ; locale
-                            nil        ; default
-                            nil        ; top
-                            nil        ; right
-                            nil        ; bottom
-                            nil        ; left
-                            0          ; default-height
-                            0          ; default-width
-                            0          ; top-height
-                            0          ; right-width
-                            0          ; bottom-height
-                            0))        ; left-width
-        (toolbar-props
-         (toolbarx-xemacs-refresh-process-button-or-insert-list switches
-                                                                toolbar-init))
-        ;; NB: Buttons (vectors) are inserted in front of the lists
-        ;; represented by `default', `top', `right', `bottom' and
-        ;; `left', so the lists are built reversed.
-        (default         (nreverse (nth 1  toolbar-props)))
-        (top             (nreverse (nth 2  toolbar-props)))
-        (right           (nreverse (nth 3  toolbar-props)))
-        (bottom          (nreverse (nth 4  toolbar-props)))
-        (left            (nreverse (nth 5  toolbar-props)))
-        (default-height  (nth 6  toolbar-props))
-        (default-width   (nth 7  toolbar-props))
-        (top-height      (nth 8  toolbar-props))
-        (right-width     (nth 9  toolbar-props))
-        (bottom-height   (nth 10 toolbar-props))
-        (left-width      (nth 11 toolbar-props))
-        (button-raised-border 2)
-        (default-border (specifier-instance default-toolbar-border-width))
-        (top-border (specifier-instance top-toolbar-border-width))
-        (right-border (specifier-instance right-toolbar-border-width))
-        (bottom-border (specifier-instance bottom-toolbar-border-width))
-        (left-border (specifier-instance left-toolbar-border-width)))
-    ;; adding borders
-    (when default
-      (setq default-height (+ (* 2 button-raised-border)
-                             (* 2 default-border)
-                             default-height))
-      (setq default-width (+ (* 2 button-raised-border)
-                            (* 2 default-border)
-                            default-width)))
-    (when top
-      (setq top-height (+ (* 2 button-raised-border)
-                         (* 2 top-border)
-                         top-height)))
-    (when right
-      (setq right-width (+ (* 2 button-raised-border)
-                          (* 2 right-border)
-                          right-width)))
-    (when bottom
-      (setq bottom-height (+ (* 2 button-raised-border)
-                            (* 2 bottom-border)
-                            bottom-height)))
-    (when left
-      (setq left-width (+ (* 2 button-raised-border)
-                         (* 2 left-border)
-                         left-width)))
-    ;; deal with specifiers
-    ;; - remove all specifiers for toolbars witout buttons
-    (if default
-       (progn
-         ;; Only activate the tool bar if it is already visible.
-         (when toolbar-visible-p
-           (set-specifier default-toolbar-visible-p (not (not default)) locale)
-           (if (memq (default-toolbar-position) '(top bottom))
-               (set-specifier default-toolbar-height default-height locale)
-             (set-specifier default-toolbar-width default-width locale)))
-         (set-specifier default-toolbar default locale))
-      (remove-specifier default-toolbar locale)
-      (remove-specifier default-toolbar-visible-p locale)
-      (remove-specifier default-toolbar-height locale)
-      (remove-specifier default-toolbar-width locale))
-    (if top
-       (progn
-         (set-specifier top-toolbar-visible-p (not (not top)) locale)
-         (set-specifier top-toolbar-height top-height locale)
-         (set-specifier top-toolbar top locale))
-      (remove-specifier top-toolbar locale)
-      (remove-specifier top-toolbar-visible-p locale)
-      (remove-specifier top-toolbar-height locale))
-    (if right
-       (progn
-         (set-specifier right-toolbar-visible-p (not (not right))
-                        locale)
-         (set-specifier right-toolbar-width right-width locale)
-         (set-specifier right-toolbar right locale))
-      (remove-specifier right-toolbar locale)
-      (remove-specifier right-toolbar-visible-p locale)
-      (remove-specifier right-toolbar-width locale))
-    (if bottom
-       (progn
-         (set-specifier bottom-toolbar-visible-p (not (not bottom)) locale)
-         (set-specifier bottom-toolbar-height bottom-height locale)
-         (set-specifier bottom-toolbar bottom locale))
-      (remove-specifier bottom-toolbar locale)
-      (remove-specifier bottom-toolbar-visible-p locale)
-      (remove-specifier bottom-toolbar-height locale))
-    (if left
-       (progn
-         (set-specifier left-toolbar-visible-p (not (not left)) locale)
-         (set-specifier left-toolbar-width left-width locale)
-         (set-specifier left-toolbar left locale))
-      (remove-specifier left-toolbar locale)
-      (remove-specifier left-toolbar-visible-p locale)
-      (remove-specifier left-toolbar-width locale))))))
-
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;; finishing parsing engine
@@ -1686,9 +1199,7 @@ the lists are built reversed."
   "Redraw the toolbar, peviously installed with `toolbarx'.
 Force global refresh if GLOBAL-FLAG is non-nil."
   (interactive "P")
-  (if (featurep 'xemacs)
-      (toolbarx-xemacs-refresh global-flag)
-    (toolbarx-emacs-refresh global-flag)))
+  (toolbarx-emacs-refresh global-flag))
 
 ;;;###autoload (autoload 'toolbarx-install-toolbar "toolbar-x")
 
@@ -1976,17 +1487,14 @@ this button is ignored."
                      switches)
       (set (make-local-variable 'toolbarx-internal-button-switches)
           switches)
-      (unless (featurep 'xemacs)
-       (make-local-variable 'tool-bar-map))))
+      (make-local-variable 'tool-bar-map)))
   (toolbarx-refresh global-flag))
 
 
 (defconst toolbarx-default-toolbar-meaning-alist
   `((separator :image "sep" :command t :enable nil :help "")
 
-    (,(if (and (not (featurep 'xemacs)) (>= emacs-major-version 22))
-         'new-file
-       'open-file)
+    ('new-file
      :image ["new" toolbar-file-icon]
      :command [find-file toolbar-open]
      :enable [(not (window-minibuffer-p
@@ -1994,17 +1502,14 @@ this button is ignored."
              t]
      :help ["Specify a new file's name, to edit the file" "Visit new file"])
 
-    ,(when (and (not (featurep 'xemacs)) (>= emacs-major-version 22))
-       '(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)))
-                           t]
-                  :help ["Read a file into an Emacs buffer" "Open a file"]))
-
-    (dired :image [,(if (>= emacs-major-version 22)
-                       "diropen"
-                     "open")
+    '(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)))
+                        t]
+               :help ["Read a file into an Emacs buffer" "Open a file"])
+
+    (dired :image ["diropen"
                   toolbar-folder-icon]
           :command [dired toolbar-dired]
           :help ["Read a directory, operate on its files" "Edit a directory"])



reply via email to

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