branch: elpa
commit 5489ef29d66eeace5bf22f737cd70bbed568949f
Merge: 9c24759 0c955d5
Author: Tassilo Horn <t...@gnu.org>
Commit: Tassilo Horn <t...@gnu.org>

    Merge branch 'master' into elpa
---
 Makefile.in       |    3 +-
 context.el        |    2 +-
 doc/auctex.texi   |   43 +++++-
 doc/changes.texi  |   11 ++
 font-latex.el     |   11 +-
 style/bidi.el     |   59 ++++++++
 style/graphics.el |    3 +-
 style/graphicx.el |  428 +++++++++++++++++++++++++----------------------------
 style/paracol.el  |    5 +-
 tex-buf.el        |   18 ++-
 tex-site.el.in    |    8 +-
 tex-style.el      |   42 ------
 tex.el            |    4 +-
 13 files changed, 343 insertions(+), 294 deletions(-)

diff --git a/Makefile.in b/Makefile.in
index 014f5be..84e2bd5 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -156,7 +156,8 @@ STYLESRC = style/prosper.el \
           style/hologo.el    style/theorem.el   style/ntheorem.el \
           style/splitidx.el  style/tikz.el      style/xcolor.el \
           style/pdflscape.el style/commath.el   style/empheq.el \
-          style/framed.el    style/paracol.el   style/menukeys.el
+          style/framed.el    style/paracol.el   style/menukeys.el \
+          style/bidi.el
 
 STYLEELC = $(STYLESRC:.el=.elc)
 
diff --git a/context.el b/context.el
index 25151e5..941057a 100644
--- a/context.el
+++ b/context.el
@@ -498,7 +498,7 @@ in your .emacs file."
 ;; Define before first use.
 (defcustom ConTeXt-Mark-version "II"
   "ConTeXt Mark version used for running ConTeXt."
-  :type "string"
+  :type 'string
   :group 'TeX-command)
 (make-variable-buffer-local 'ConTeXt-Mark-version)
 (put 'ConTeXt-Mark-version 'safe-local-variable 'stringp)
diff --git a/doc/auctex.texi b/doc/auctex.texi
index 673b6ad..9420dfb 100644
--- a/doc/auctex.texi
+++ b/doc/auctex.texi
@@ -1811,8 +1811,24 @@ Moreover, you can focus in a specific portion of the 
code by narrowing
 the buffer to the desired region.  @AUCTeX{} provides also functions to
 narrow the buffer to the current group and to @LaTeX{} environments.
 
-Lastly, @AUCTeX{} with Emacs 25 or later can display certain math macros
-using Unicode characters.  That's called prettification.
+@AUCTeX{} also provides some WYSIWYG features.
+
+First, you can customize @code{font-latex-fontify-script} to enable
+special formatting of @code{^} superscripts and @code{_} subscripts
+(@pxref{Font Locking}).
+
+Secondly, @AUCTeX{} with GNU Emacs 25 or later can display certain math
+macros using Unicode characters, e.g., @code{\alpha} as α.  This is
+called prettification and is lightweight and reasonable robust
+(@pxref{Prettifying}).
+
+A more accurate approach is provided by @previewlatex{}, a subsystem of
+@AUCTeX{}, see @ref{Top,,Introduction,preview-latex,The @previewlatex{}
+Manual}.  This system uses @LaTeX{} to generate images that are then
+displayed in your buffer.  It is extremely accurate but can be fragile
+with some packages (like older pgf versions).
+
+Please note that you can use prettification and @previewlatex{} together.
 
 @menu
 * Font Locking::                Font Locking
@@ -2172,11 +2188,21 @@ variables @code{font-latex-fontify-script} and
 @code{font-latex-script-display}.
 
 @defopt font-latex-fontify-script
-If non-nil, fontify subscript and superscript strings.
+If non-nil, fontify subscript and superscript strings.  Concretely, this
+means that the scripts are raised or lowered.
+
+Another possiblity is setting this variable to the symbol
+@code{multi-level}.  In this case, in a formula @code{x^y^z}, y is
+raised above x, and z is raised above y.  With many script levels, the
+text might become too small to be readable.
+
+Lastly, you can set this variable to @code{invisible} whose behavior is
+like @code{multi-level}, and in addition the super-/subscript characters
+@code{^} and @code{_} are not displayed.
 
-Note that this feature is not available on XEmacs, for which it is
-disabled per default.  In GNU Emacs raising and lowering is not enabled
-for versions 21.3 and before due to it working not properly.
+Note that this feature is not available on XEmacs, for which
+it is disabled per default.  In GNU Emacs raising and lowering is not
+enabled for versions 21.3 and before due to it working not properly.
 @end defopt
 
 @defopt font-latex-script-display
@@ -2595,7 +2621,10 @@ Lisp buffers.
 and greek letters using their Unicode representation, too.  For example,
 the @TeX{} code @code{\alpha \times \beta} will be displayed as @code{α
 × β}.  When point is on one of the characters, it'll be unprettified
-automatically, meaning you see the verbatim text again.
+automatically, meaning you see the verbatim text again.  For this
+behaviour however you need to set
+@code{prettify-symbols-unprettify-at-point} to t or @code{right-edge}
+which will unprettify the symbol when point moves into or near it.
 
 To enable prettification in @AUCTeX{}, simply add
 @code{prettify-symbols-mode} to @code{TeX-mode-hook}.  If you enabled
diff --git a/doc/changes.texi b/doc/changes.texi
index a14ff2e..16f96be 100644
--- a/doc/changes.texi
+++ b/doc/changes.texi
@@ -12,6 +12,17 @@
 
 @itemize @bullet
 @item
+The style @file{graphicx.el} went through a bigger overhaul.  The
+optional argument of command @samp{\includegraphics} now supports
+key-val query; keys can independently be chosen anytime by pressing the
+@key{,} key.  As a side effect, the variable
+@code{LaTeX-includegraphics-options-alist} is now no-op and is removed
+from @file{tex-style.el}.  You can safely remove any customization of it
+from your init file.  The mandatory argument of @samp{\includegraphics}
+knows about image file extensions supported by the used engine and
+offers them for inclusion.
+
+@item
 @AUCTeX{} has a new Ispell dictionary @file{tex-ispell.el} for macros
 and environments which will be skipped during spell checking.  The
 activiation of this feature is controlled by a new customize option
diff --git a/font-latex.el b/font-latex.el
index 12ebd04..fb7f8d6 100644
--- a/font-latex.el
+++ b/font-latex.el
@@ -805,7 +805,7 @@ Generated by `font-latex-make-user-keywords'.")))
             ;; Hack to remove the verbatim face from the \ in
             ;; \end{verbatim} and similar.  The same hack is used in
             ;; tex-mode.el.
-            ("^[ \t]*\\(\\\\\\)end"
+            ("\\(\\\\\\)end"
              (1 (get-text-property (match-end 1) 'face) t))))
     (add-to-list 'font-latex-keywords-1 item)
     (add-to-list 'font-latex-keywords-2 item))
@@ -940,8 +940,11 @@ have changed."
                       ;; After the optional argument, there may also be
                       ;; another mandatory argument(s) (e.g. with VerbatimOut 
or
                       ;; the minted envs or defined with `lstnewenvironment').
-                      "\\(?:{[^}]+}\\)*"
-                      "\\(\n\\)")
+                      "\\(?:{[^}]*}\\)*"
+                      ;; Now match the final newline.  The "." alternative
+                      ;; catches the case where verbatim content is written
+                      ;; immediately after the \begin{verbatim}.
+                      "\\(\n\\|.\\)")
                     (1 "|" t)))
       (add-to-list 'font-latex-syntactic-keywords
                   ;; Using the newline character for the syntax
@@ -951,7 +954,7 @@ have changed."
                   ;; the starting backslash of \end.  There is a hack
                   ;; in `font-latex-make-user-keywords' to remove the
                   ;; spurious fontification of the backslash.
-                  `(,(concat "^[ \t]*\\(\\\\\\)end *{\\(?:" verb-envs "\\)}")
+                  `(,(concat "\\(\\\\\\)end *{\\(?:" verb-envs "\\)}")
                     (1 "|" t))))
     (unless (= (length verb-macros-with-delims) 0)
       (add-to-list 'font-latex-syntactic-keywords
diff --git a/style/bidi.el b/style/bidi.el
new file mode 100755
index 0000000..69beb6a
--- /dev/null
+++ b/style/bidi.el
@@ -0,0 +1,59 @@
+;;; bidi.el --- AUCTeX style for the (XeLaTeX) bidi package
+
+;; Copyright (C) Free Software Foundation
+
+;; Author: Uwe Brauer <o...@mat.ucm.es>
+;; Created: 2016-03-06
+;; Keywords: tex
+
+;; This file is part of AUCTeX.
+
+;; AUCTeX is free software; you can redistribute it and/or modify it
+;; under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 3, or (at your option)
+;; any later version.
+
+;; AUCTeX is distributed in the hope that it will be useful, but
+;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+;; General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with AUCTeX; see the file COPYING.  If not, write to the Free
+;; Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+;; 02110-1301, USA.
+
+;;; Commentary:
+
+;; This file adds support for the bidi package.
+
+;;; Code:
+
+(defvar LaTeX-bidi-package-options '("RTLdocument" "rldocument")
+  "Package options for the bidi package.")
+
+(TeX-add-style-hook
+ "bidi"
+ (lambda ()
+   (TeX-check-engine-add-engines 'xetex)
+   (LaTeX-add-environments
+    "LTR"
+    "RTL")
+   ;; Fontification
+   (TeX-add-symbols
+    '("setRL" 0)
+    '("unsetRL" 0)
+    '("setRTL" 0)
+    '("unsetRTL" 0)
+    '("setLR" 0)
+    '("unsetLR" 0)
+    '("setLTR" 0)
+    '("unsetLTR" 0)
+    '("LR" 1)
+    '("LRE" 1)
+    '("RLE" 1)
+    '("RL" 1)))
+ LaTeX-dialect)
+
+
+;;; bidi.el ends here
diff --git a/style/graphics.el b/style/graphics.el
index ffe5bd1..a48e612 100644
--- a/style/graphics.el
+++ b/style/graphics.el
@@ -5,7 +5,8 @@
 (TeX-add-style-hook "graphics"
  (function
   (lambda ()
-    (TeX-run-style-hooks "graphicx")))
+    (TeX-run-style-hooks "graphicx")
+    (setq LaTeX-graphics-package-options LaTeX-graphicx-package-options)))
  LaTeX-dialect)
 
 ;;; graphics.el ends here.
diff --git a/style/graphicx.el b/style/graphicx.el
index a894dad..f7e1230 100644
--- a/style/graphicx.el
+++ b/style/graphicx.el
@@ -1,6 +1,6 @@
 ;;; graphicx.el --- AUCTeX style file for graphicx.sty
 
-;; Copyright (C) 2000, 2004, 2005, 2014 by Free Software Foundation, Inc.
+;; Copyright (C) 2000, 2004, 2005, 2014, 2016 by Free Software Foundation, Inc.
 
 ;; Author: Ryuichi Arafune <araf...@debian.org>
 ;; Created: 1999/3/20
@@ -32,41 +32,123 @@
 
 ;;; Code:
 
-(TeX-add-style-hook
- "graphicx"
- (lambda ()
-   (TeX-add-symbols
-    '("reflectbox" "Argument")
-    '("resizebox" "Width" "Height" "Argument")
-    '("resizebox*" "Width" "Total height" "Argument")
-    '("rotatebox" [ "Options" ] "Angle" "Argument")
-    '("scalebox" "Horizontal scale" [ "Vertical scale" ] "Argument")
-    '("includegraphics" LaTeX-arg-includegraphics))
-   ;; Fontification
-   (when (and (featurep 'font-latex)
-             (eq TeX-install-font-lock 'font-latex-setup))
-     (font-latex-add-keywords '(("reflectbox" "{")
-                               ("resizebox" "*{{{")
-                               ("rotatebox" "[{{")
-                               ("scalebox" "{[{"))
-                             'textual)
-     (font-latex-add-keywords '(("includegraphics" "*[[{")) 'reference)))
- LaTeX-dialect)
+(defvar LaTeX-graphicx-key-val-options
+  '(("bb")
+    ("bbllx")
+    ("bblly")
+    ("bburx")
+    ("bbury")
+    ("natheight")
+    ("natwidth")
+    ("viewport")
+    ("trim")
+    ("hiresbb" ("true" "false"))
+    ("angle")
+    ("origin")
+    ("width"           ("\\textwidth" "\\columnwidth" "\\linewidth"))
+    ("height"          ("\\textheight"))
+    ("totalheight"     ("\\textheight"))
+    ("keepaspectratio" ("true" "false"))
+    ("scale")
+    ("clip"  ("true" "false"))
+    ("draft" ("true" "false")))
+  "Key=value options for graphicx macros.")
+
+(defvar LaTeX-includegraphics-dvips-extensions
+  '("eps" "mps" "EPS")
+  "List of extensions for image files supported by \"dvips\".")
+
+(defvar LaTeX-includegraphics-pdftex-extensions
+  '("png" "pdf" "jpe?g" "jbig2" "jb2" "mps"
+    "PNG" "PDF" "JPE?G" "JBIG2" "JB2")
+  "List of extensions for image files supported by \"pdftex\" and \"luatex\".")
+
+(defvar LaTeX-includegraphics-xetex-extensions
+  '("pdf" "eps" "mps" "ps" "png" "jpe?g" "jp2" "jpf"
+    "PDF" "EPS" "MPS" "PS" "PNG" "JPE?G" "JP2" "JPF"
+    "bmp" "pict" "psd" "mac" "tga" "gif" "tif" "tiff"
+    "BMP" "PICT" "PSD" "MAC" "TGA" "GIF" "TIF" "TIFF")
+  "List of extensions for image files supported by \"xetex\".")
+
+(defun LaTeX-arg-graphicx-includegraphics-key-val (optional)
+  "Insert key-val for optional argument of \\includegraphics macro.
+If OPTIONAL is non-nil, insert argument in square brackets.
+Temporarily remove \"space\" from `crm-local-completion-map' and
+`minibuffer-local-completion-map' in order to be able to insert
+spaces conveniently.
+
+If `TeX-engine' is set to symbol 'default (while
+`TeX-PDF-from-DVI' is set to nil) or 'luatex and `TeX-PDF-mode'
+is non-nil, add the key \"page\" to list of key-val's."
+  (let ((crm-local-completion-map
+        (remove (assoc 32 crm-local-completion-map)
+                crm-local-completion-map))
+       (minibuffer-local-completion-map
+        (remove (assoc 32 minibuffer-local-completion-map)
+                minibuffer-local-completion-map)))
+    (TeX-argument-insert
+     (TeX-read-key-val optional
+                      (if (and (or (and (eq TeX-engine 'default)
+                                        (not (TeX-PDF-from-DVI)))
+                                   (eq TeX-engine 'luatex))
+                               TeX-PDF-mode)
+                          (append '(("page")) LaTeX-graphicx-key-val-options)
+                        LaTeX-graphicx-key-val-options))
+     optional)))
 
 (defun LaTeX-includegraphics-extensions (&optional list)
   "Return appropriate extensions for input files to \\includegraphics."
-  ;; FIXME: This function may check for latex/pdflatex later.
-  (concat "\\."
-         (mapconcat 'identity
-                    (or list LaTeX-includegraphics-extensions)
-                    "$\\|\\.")
-         "$"))
+  (let* ((temp (copy-sequence LaTeX-includegraphics-extensions))
+        (LaTeX-includegraphics-extensions
+         (cond (;; 'default TeX-engine:
+                (if (and (eq TeX-engine 'default)
+                         ;; we want to produce a pdf
+                         (if TeX-PDF-mode
+                             ;; Return t if default compiler produces PDF,
+                             ;; nil for "Dvips" or "Dvipdfmx"
+                             (not (TeX-PDF-from-DVI))
+                           ;; t if pdftex is used in dvi-mode
+                           TeX-DVI-via-PDFTeX))
+                    ;; We're using pdflatex in pdf-mode
+                    (delete-dups
+                     (append LaTeX-includegraphics-pdftex-extensions
+                             LaTeX-includegraphics-extensions))
+                  ;; We're generating a .dvi to process with dvips or dvipdfmx
+                  (progn
+                    (dolist (x '("jpe?g" "pdf" "png"))
+                      (setq temp (remove x temp)))
+                    (delete-dups
+                     (append LaTeX-includegraphics-dvips-extensions
+                             temp)))))
+               ;; Running luatex in pdf or dvi-mode:
+               ((eq TeX-engine 'luatex)
+                (if TeX-PDF-mode
+                    (delete-dups
+                     (append LaTeX-includegraphics-pdftex-extensions
+                             LaTeX-includegraphics-extensions))
+                  (progn
+                    (dolist (x '("jpe?g" "pdf" "png"))
+                      (setq temp (remove x temp)))
+                    (delete-dups
+                     (append LaTeX-includegraphics-dvips-extensions
+                             temp)))))
+               ;; Running xetex in any mode:
+               ((eq TeX-engine 'xetex)
+                (delete-dups (append LaTeX-includegraphics-xetex-extensions
+                                     LaTeX-includegraphics-extensions)))
+               ;; For anything else
+               (t
+                LaTeX-includegraphics-extensions))))
+    (concat "\\."
+           (mapconcat 'identity
+                      (or list LaTeX-includegraphics-extensions)
+                      "$\\|\\.")
+           "$")))
 
 (defun LaTeX-includegraphics-read-file-TeX ()
   "Read image file for \\includegraphics.
 Offers all graphic files found in the TeX search path.  See
 `LaTeX-includegraphics-read-file' for more."
-  ;; Drop latex/pdflatex differences for now.  Might be (re-)included later.
   (completing-read
    "Image file: "
    (TeX-delete-dups-by-car
@@ -88,198 +170,12 @@ doesn't works with Emacs 21.3 or XEmacs.  See
     ;; argument (Emacs 21.3: five args; XEmacs 21.4.15: sixth is HISTORY).
     (lambda (fname)
       (or (file-directory-p fname)
-         (string-match (LaTeX-includegraphics-extensions) fname))))
+         (string-match (LaTeX-includegraphics-extensions) fname))))
    (TeX-master-directory)))
 
 (defun LaTeX-arg-includegraphics (_prefix)
-  "Ask for mandantory and optional arguments for the \\includegraphics command.
-
-The extent of the optional arguments is determined by the prefix argument and
-`LaTeX-includegraphics-options-alist'."
-  (let* ((maybe-left-brace "[")
-        (maybe-comma "")
-        show-hint
-        (image-file (funcall LaTeX-includegraphics-read-file))
-        (incl-opts
-         (cond
-          ((numberp
-            (if (listp current-prefix-arg)
-                (setq current-prefix-arg (car current-prefix-arg))
-              current-prefix-arg))
-           (cdr
-            (assq current-prefix-arg LaTeX-includegraphics-options-alist)))
-          ;; If no prefix is given, use `0' and tell the user about the
-          ;; prefix.
-          ((eq current-prefix-arg nil)
-           (setq show-hint t)
-           (cdr (assq 0 LaTeX-includegraphics-options-alist)))
-          (t
-           (cdr (assq 0 LaTeX-includegraphics-options-alist)))))
-        ;; Order the optional aruments like in the tables in epslatex.ps,
-        ;; page 14.  But collect y-or-n options at the end, so that the use
-        ;; can skip some options by typing `RET RET ... RET n n n ... n'
-        ;;
-        ;; Options from Table 1 (epslatex.ps, page 14):
-        (totalheight
-         (TeX-arg-maybe
-          'totalheight incl-opts
-          '(TeX-read-string
-            (concat "Total Height (" TeX-default-unit-for-image "): "))))
-        (height
-         (TeX-arg-maybe
-          'height incl-opts
-          ;; Either totalheight or height make sense:
-          '(when (zerop (length totalheight))
-             (TeX-read-string
-              (concat "Figure height (" TeX-default-unit-for-image "): ")))))
-        (width
-         (TeX-arg-maybe
-          'width incl-opts
-          '(TeX-read-string
-            (concat "Figure width (" TeX-default-unit-for-image "): "))))
-        (scale
-         (TeX-arg-maybe
-          'angle incl-opts
-          ;; If size is already specified, don't ask for scale:
-          '(when (zerop (+ (length totalheight)
-                           (length height)
-                           (length width)))
-             (TeX-read-string "Scale: "))))
-        (angle
-         (TeX-arg-maybe
-          'angle incl-opts
-          '(TeX-read-string "Rotation angle: ")))
-        (origin
-         (TeX-arg-maybe
-          'origin incl-opts
-          '(TeX-read-string
-            (concat
-             "Origin (any combination of `lcr' (horizontal) "
-             "and `tcbB' (vertical)): "))))
-        (page ;; Not in any table; Only for PDF.
-         (TeX-arg-maybe
-          'page incl-opts
-          '(TeX-read-string "Page: ")))
-        (bb
-         (TeX-arg-maybe
-          'bb incl-opts
-          '(y-or-n-p "Set Bounding Box? ")))
-        ;; Table 2:
-        (viewport
-         (TeX-arg-maybe
-          'viewport incl-opts
-          '(y-or-n-p "Set viewport? ")))
-        (trim
-         (TeX-arg-maybe
-          'trim incl-opts
-          '(and (not viewport)
-                (y-or-n-p "Set trim? "))))
-        ;; Table 3:
-        (clip
-         (TeX-arg-maybe
-          'clip incl-opts
-          ;; If viewport, we also use clip.
-          '(or viewport
-               (y-or-n-p "Clipping figure? "))))
-        (keepaspectratio
-         (TeX-arg-maybe
-          'keepaspectratio incl-opts
-          ;; If we have width and [total]height...
-          '(or (and (not (zerop (length width)))
-                    (or (not (zerop (length totalheight)))
-                        (not (zerop (length height)))))
-               (y-or-n-p "Keep Aspectratio? "))))
-        ;; Used for bb, trim, viewport, ...:
-        llx lly urx ury)
-    ;; Now insert stuff...
-    (when (not (zerop (length totalheight)))
-      (insert
-       maybe-left-brace maybe-comma "totalheight="
-       (car (TeX-string-divide-number-unit totalheight))
-       (if (zerop
-           (length
-            (car (cdr (TeX-string-divide-number-unit totalheight)))))
-          TeX-default-unit-for-image
-        (car (cdr (TeX-string-divide-number-unit totalheight)))))
-      (setq maybe-comma ",")
-      (setq maybe-left-brace ""))
-    (when (not (zerop (length height)))
-      (insert maybe-left-brace maybe-comma
-             "height=" (car (TeX-string-divide-number-unit height))
-             (if (zerop
-                  (length
-                   (car (cdr (TeX-string-divide-number-unit height)))))
-                 TeX-default-unit-for-image
-               (car (cdr (TeX-string-divide-number-unit height)))))
-      (setq maybe-comma ",")
-      (setq maybe-left-brace ""))
-    (when (not (zerop (length width)))
-      (insert maybe-left-brace maybe-comma
-             "width=" (car (TeX-string-divide-number-unit width))
-             (if (zerop
-                  (length
-                   (car (cdr (TeX-string-divide-number-unit width)))))
-                 TeX-default-unit-for-image
-               (car (cdr (TeX-string-divide-number-unit width)))))
-      (setq maybe-comma ",")
-      (setq maybe-left-brace ""))
-    (when (not (zerop (length scale)))
-      (insert maybe-left-brace maybe-comma "scale=" scale)
-      (setq maybe-comma ",")
-      (setq maybe-left-brace ""))
-    (when (not (zerop (length angle)))
-      (insert maybe-left-brace maybe-comma "angle=" angle)
-      (setq maybe-comma ",")
-      (setq maybe-left-brace ""))
-    (when (not (zerop (length origin)))
-      (insert maybe-left-brace maybe-comma "origin=" origin)
-      (setq maybe-comma ",")
-      (setq maybe-left-brace ""))
-    (when bb
-      (setq llx (TeX-read-string "Bounding Box lower left x: "))
-      (setq lly (TeX-read-string "Bounding Box lower left y: "))
-      (setq urx (TeX-read-string "Bounding Box upper right x: "))
-      (setq ury (TeX-read-string "Bounding Box upper right y: "))
-      (insert maybe-left-brace maybe-comma
-             "bb=" llx " " lly " " urx " " ury)
-      (setq maybe-comma ",")
-      (setq maybe-left-brace ""))
-    ;;
-    (when viewport
-      (setq llx (TeX-read-string "Viewport lower left x: "))
-      (setq lly (TeX-read-string "Viewport lower left y: "))
-      (setq urx (TeX-read-string "Viewport upper right x: "))
-      (setq ury (TeX-read-string "Viewport upper right y: "))
-      (insert maybe-left-brace maybe-comma
-             "viewport=" llx " " lly " " urx " " ury)
-      (setq maybe-comma ",")
-      (setq maybe-left-brace ""))
-    (when trim
-      (setq llx (TeX-read-string "Trim lower left x: "))
-      (setq lly (TeX-read-string "Trim lower left y: "))
-      (setq urx (TeX-read-string "Trim Upper right x: "))
-      (setq ury (TeX-read-string "Trim Upper right y: "))
-      (insert maybe-left-brace maybe-comma
-             "trim=" llx " " lly " " urx " " ury)
-      (setq maybe-comma ",")
-      (setq maybe-left-brace ""))
-    ;;
-    (when clip
-      (insert maybe-left-brace maybe-comma "clip")
-      (setq maybe-comma ",")
-      (setq maybe-left-brace ""))
-    (when keepaspectratio
-      (insert maybe-left-brace maybe-comma "keepaspectratio")
-      (setq maybe-comma ",")
-      (setq maybe-left-brace ""))
-    ;;
-    (when (not (zerop (length page)))
-      (insert maybe-left-brace maybe-comma "page=" page)
-      (setq maybe-comma ",")
-      (setq maybe-left-brace ""))
-    ;;
-    (if (zerop (length maybe-left-brace))
-       (insert "]"))
+  "Ask for mandantory argument for the \\includegraphics command."
+  (let* ((image-file (funcall LaTeX-includegraphics-read-file)))
     (TeX-insert-braces 0)
     (insert
      (if LaTeX-includegraphics-strip-extension-flag
@@ -291,13 +187,95 @@ The extent of the optional arguments is determined by the 
prefix argument and
                                         nil t 1)
             (replace-match ""))
           (buffer-string))
-       image-file))
-    (when show-hint
-      (message
-       (concat
-       "Adding `C-u C-u' before the command asks for more optional arguments."
-       "\nSee `LaTeX-includegraphics-options-alist' for details."))
-      (sit-for 3))
-    t))
+       image-file))))
+
+(TeX-add-style-hook
+ "graphicx"
+ (lambda ()
+   (TeX-add-symbols
+    '("reflectbox" "Argument")
+
+    '("resizebox"
+      (TeX-arg-eval completing-read
+                   (TeX-argument-prompt optional nil "Width")
+                   (append '("\\width" "!")
+                           (mapcar
+                            (lambda (x) (concat TeX-esc (car x)))
+                            (LaTeX-length-list))))
+      (TeX-arg-eval completing-read
+                   (TeX-argument-prompt optional nil "Height")
+                   (append '("\\height" "\\totalheight" "\\depth" "!")
+                           (mapcar
+                            (lambda (x) (concat TeX-esc (car x)))
+                            (LaTeX-length-list))))
+      "Argument")
+
+    '("resizebox*"
+      (TeX-arg-eval completing-read
+                   (TeX-argument-prompt optional nil "Width")
+                   (append '("\\width" "!")
+                           (mapcar
+                            (lambda (x) (concat TeX-esc (car x)))
+                            (LaTeX-length-list))))
+      (TeX-arg-eval completing-read
+                   (TeX-argument-prompt optional nil "Height")
+                   (append '("\\height" "\\totalheight" "\\depth" "!")
+                           (mapcar
+                            (lambda (x) (concat TeX-esc (car x)))
+                            (LaTeX-length-list))))
+      "Argument")
+
+    '("rotatebox" (TeX-arg-conditional (member "graphics" (TeX-style-list))
+                                      ()
+                                    ([ TeX-arg-key-val (("x") ("y") ("origin") 
("units")) ]))
+      "Angle" "Argument")
+
+    '("scalebox" "Horizontal scale" [ "Vertical scale" ] "Argument")
+
+    '("includegraphics" (TeX-arg-conditional (member "graphics" 
(TeX-style-list))
+                                            (["llx,lly"] ["urx,ury"])
+                                          ([ 
LaTeX-arg-graphicx-includegraphics-key-val ]))
+      LaTeX-arg-includegraphics)
+
+    '("includegraphics*" (TeX-arg-conditional (member "graphics" 
(TeX-style-list))
+                                             (["llx,lly"] ["urx,ury"])
+                                           ([ 
LaTeX-arg-graphicx-includegraphics-key-val ]))
+      LaTeX-arg-includegraphics)
+
+    '("graphicspath" t)
+
+    '("DeclareGraphicsExtensions" t)
+
+    '("DeclareGraphicsRule" 4))
+
+   ;; Fontification
+   (when (and (featurep 'font-latex)
+             (eq TeX-install-font-lock 'font-latex-setup))
+     (font-latex-add-keywords '(("reflectbox" "{")
+                               ("resizebox" "*{{{")
+                               ("rotatebox" "[{{")
+                               ("scalebox" "{[{"))
+                             'textual)
+     (font-latex-add-keywords '(("includegraphics" "*[[{"))
+                             'reference)
+     (font-latex-add-keywords '(("graphicspath"              "{")
+                               ("DeclareGraphicsExtensions" "{")
+                               ("DeclareGraphicsRule"       "{{{{"))
+                             'function)))
+ LaTeX-dialect)
+
+(defvar LaTeX-graphicx-package-options
+  '("draft"       "final"         "debugshow"
+    "hiderotate"  "hidescale"     "hiresbb"
+    "setpagesize" "nosetpagesize" "demo"
+    "dvips"       "xdvi"
+    "dvipdf"      "dvipdfm"       "dvipdfmx"
+    "xetex"       "pdftex"        "luatex"
+    "dvisvgm"     "dvipsone"      "dviwindo"
+    "emtex"       "dviwin"        "oztex"
+    "textures"    "pctexps"       "pctexwin"
+    "pctexhp"     "pctex32"       "truetex"
+    "tcidvi"      "vtex")
+  "Package options for the graphicx package.")
 
 ;;; graphicx.el ends here
diff --git a/style/paracol.el b/style/paracol.el
index 7dfddc7..f8b5d85 100644
--- a/style/paracol.el
+++ b/style/paracol.el
@@ -124,7 +124,7 @@ If OPTIONAL is non-nil, insert the result in square 
brackets."
 
     ;; 7.4 Commands for Two-Sided Typesetting and Marginal Note Placement
     ;; \twosided[t1t2 ... tk]
-    '("twosided" "Features (combination of p, c, m, b)")
+    '("twosided" [ "Features (combination of p, c, m, b)" ])
 
     ;; \marginparthreshold{k}[k']
     '("marginparthreshold" "Number of columns" [ "Number of columns" ] )
@@ -219,7 +219,8 @@ If OPTIONAL is non-nil, insert the result in square 
brackets."
     '("addcontentsonly"
       (TeX-arg-eval completing-read
                    (TeX-argument-prompt optional nil "Content file")
-                   '("toc" "lof" "lot")))
+                   '("toc" "lof" "lot"))
+      "Column")
 
     '("flushpage" 0))
 
diff --git a/tex-buf.el b/tex-buf.el
index 575c1ed..d9648f8 100644
--- a/tex-buf.el
+++ b/tex-buf.el
@@ -1649,8 +1649,9 @@ Rerun to get mark in right position\\." nil t)
              "\\<TeX-mode-map>\\[TeX-recenter-output-buffer]")))
    (t
     (message (concat "BibTeX finished successfully. "
-                    "Run LaTeX again to get citations right."))
-  (setq TeX-command-next TeX-command-default))))
+                    "Run LaTeX again to get citations right."))))
+  ;; In any case, run the default next command.
+  (setq TeX-command-next TeX-command-default))
 
 (defun TeX-Biber-sentinel (_process _name)
   "Cleanup TeX output buffer after running Biber."
@@ -2321,8 +2322,11 @@ already in an Emacs buffer) and the cursor is placed at 
the error."
            (while (null (zerop arg))
              (setq TeX-error-last-visited
                    ;; Increase or decrese `TeX-error-last-visited' depending on
-                   ;; the sign of `arg'.
-                   (+ (signum arg) TeX-error-last-visited)
+                   ;; the sign of `arg'.  Note: `signum' is a function from
+                   ;; `cl' library, do not be tempted to use it.
+                   (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.
@@ -2330,7 +2334,11 @@ already in an Emacs buffer) and the cursor is placed at 
the error."
              ;; Increase or decrease `arg' only if the warning isn't to be
              ;; skipped.
              (unless (TeX-error-list-skip-warning-p (nth 0 item) (nth 10 item))
-               (setq arg (- arg (signum arg)))))
+               ;; Note: `signum' is a function from `cl' library, do not be
+               ;; tempted to use it.
+               (setq arg (if (> arg 0)
+                             (1- arg)
+                           (1+ arg)))))
            (if (< TeX-error-last-visited -1)
                (setq TeX-error-last-visited -1))
            (cond ((or (null item)
diff --git a/tex-site.el.in b/tex-site.el.in
index eb5d87c..dc4b803 100644
--- a/tex-site.el.in
+++ b/tex-site.el.in
@@ -1,6 +1,6 @@
 ;;; tex-site.el - Site specific variables.  Don't edit.
 
-;; Copyright (C) 2005, 2013 Free Software Foundation, Inc.
+;; Copyright (C) 2005, 2013, 2016 Free Software Foundation, Inc.
 ;;
 ;; completely rewritten.
 
@@ -39,7 +39,7 @@
 ;;; Code:
 
 (if (< emacs-major-version 21)
-  (error "AUCTeX requires Emacs 21 or later"))
+    (error "AUCTeX requires Emacs 21 or later"))
 
 ;; Define here in order for `M-x customize-group <RET> AUCTeX <RET>'
 ;; to work if the main AUCTeX files are not loaded yet.
@@ -132,14 +132,14 @@ definition."
               (get elt 'tex-saved))))))))
 
 (defcustom TeX-modes
-  (mapcar 'car TeX-mode-alist)
+  (mapcar #'car TeX-mode-alist)
   "List of modes provided by AUCTeX.
 
 This variable can't be set normally; use customize for that, or
 set it with `TeX-modes-set'."
   :type (cons 'set
              (mapcar (lambda(x) (list 'const (car x))) TeX-mode-alist))
-  :set 'TeX-modes-set
+  :set #'TeX-modes-set
   :group 'AUCTeX
   :initialize(lambda (var value)
               (custom-initialize-reset var value)
diff --git a/tex-style.el b/tex-style.el
index d25bccc..b6e2e4d 100644
--- a/tex-style.el
+++ b/tex-style.el
@@ -312,48 +312,6 @@ automatically get the list of fonts.  This requires
                       :tag "Other"
                       (string))))
 
-(defcustom LaTeX-includegraphics-options-alist
-  '((0 width)
-    ;; (1 width height clip)
-    ;; (2 width height keepaspectratio clip)
-    (4) ;; --> (4 nil)
-    (5 trim)
-    (16
-     ;; Table 1 in epslatex.ps: ``includegraphics Options''
-     height totalheight width scale angle origin bb
-     ;; Table 2 in epslatex.ps: ``cropping Options''
-     viewport trim
-     ;; Table 3 in epslatex.ps: ``Boolean Options''
-     ;; [not implemented:] noclip draft final
-     clip keepaspectratio
-     ;; Only for PDF:
-     page))
-  "Controls for which optional arguments of \\includegraphics you get prompted.
-
-An alist, consisting of \(NUMBER . LIST\) pairs.  Valid elements of LIST are
-`width', `height', `keepaspectratio', `clip', `angle', `totalheight', `trim'
-and `bb' \(Bounding Box\).
-
-The list corresponding to 0 is used if no prefix is given.  Note that 4 \(one
-\\[universal-argument]\) and 16 \(two \\[universal-argument]'s\) are easy to
-type and should be used for frequently needed combinations."
-  :group 'LaTeX-style
-  :type '(repeat (cons (integer :tag "Argument")
-                      (list (set :inline t
-                                 (const height)
-                                 (const totalheight)
-                                 (const width)
-                                 (const scale)
-                                 (const angle)
-                                 (const origin)
-                                 (const :tag "Bounding Box" bb)
-                                 ;;
-                                 (const viewport)
-                                 (const trim)
-                                 ;;
-                                 (const clip)
-                                 (const keepaspectratio))))))
-
 (defcustom LaTeX-includegraphics-strip-extension-flag t
   "Non-nil means to strip known extensions from image file name."
   :group 'LaTeX-style
diff --git a/tex.el b/tex.el
index 4f1fdd8..1836f66 100644
--- a/tex.el
+++ b/tex.el
@@ -632,7 +632,7 @@ is equivalent to
 but takes care of byte-compilation issues where the byte-code for
 the latter could signal an error if it has been compiled with
 emacs 24.1 and is then later run by emacs 24.5."
-  (declare (indent 2) (debug (symbolp form)))
+  (declare (indent 2) (debug (symbolp form &rest form)))
   (if (fboundp name)            ;If macro exists at compile-time, just use it.
       then
     `(if (fboundp ',name)       ;Else, check if it exists at run-time.
@@ -4561,7 +4561,7 @@ upon a file search.  Note that the directories have to 
end with a
 directory separator.
 
 Each AUCTeX mode should set the variable buffer-locally with a
-more specific value.  See `LateX-search-files-type-alist' for an
+more specific value.  See `LaTeX-search-files-type-alist' for an
 example.")
 
 (defun TeX-search-files-by-type (filetype &optional scope nodir strip)

Reply via email to