[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
main 358b4d07 220/257: Merge remote-tracking branch 'origin/master' into
From: |
Tassilo Horn |
Subject: |
main 358b4d07 220/257: Merge remote-tracking branch 'origin/master' into externals/auctex |
Date: |
Fri, 19 Apr 2024 15:37:01 -0400 (EDT) |
branch: main
commit 358b4d07859335381aa50899a4c195150fd1718d
Merge: 945aba3d 643d39a1
Author: Tassilo Horn <tsdh@gnu.org>
Commit: Tassilo Horn <tsdh@gnu.org>
Merge remote-tracking branch 'origin/master' into externals/auctex
---
Makefile.in | 3 +-
context.el | 241 ++++++++++-----
doc/macros.texi | 30 +-
font-latex.el | 6 +-
latex.el | 287 ++++++++---------
multi-prompt.el | 12 +-
plain-tex.el | 2 +-
style/CJK.el | 27 +-
style/acro.el | 9 +-
style/amsthm.el | 139 ++++-----
style/array.el | 10 +-
style/attachfile.el | 22 +-
style/babel.el | 115 +++----
style/beamer.el | 702 ++++++++++++++++++++++++++++--------------
style/beamerarticle.el | 6 +-
style/bigstrut.el | 15 +-
style/booktabs.el | 13 +-
style/breqn.el | 65 ++--
style/catchfilebetweentags.el | 18 +-
style/changelog.el | 96 +++---
style/changes.el | 92 ++----
style/cleveref.el | 70 +++--
style/comment.el | 43 +--
style/csquotes.el | 126 ++++----
style/doc.el | 59 ++--
style/empheq.el | 208 +++++++------
style/enumitem.el | 40 +--
style/fancyvrb.el | 91 +++---
style/floatrow.el | 138 ++++++---
style/fontspec.el | 22 +-
style/footmisc.el | 30 +-
style/fvextra.el | 18 +-
style/geometry.el | 25 +-
style/graphics.el | 8 +-
style/graphicx.el | 69 ++---
style/hologo.el | 144 ++++-----
style/hyperref.el | 18 +-
style/ifthen.el | 28 +-
style/l3doc.el | 12 +-
style/listings.el | 10 +-
style/ltablex.el | 16 +-
style/ltugboat.el | 26 +-
style/ltxdoc.el | 10 +-
style/ltxtable.el | 9 +-
style/mathtools.el | 144 +++++----
style/mdframed.el | 40 ++-
style/minted.el | 71 ++---
style/natbib.el | 3 +-
style/ntheorem.el | 179 +++++------
style/physics.el | 418 +++++++++++++++++++++++++
style/pstricks.el | 2 +
style/theorem.el | 4 +-
style/tikz.el | 28 +-
style/xcolor.el | 23 +-
tests/tex/navigation.el | 75 +++--
tex-info.el | 10 +-
tex-style.el | 7 +
tex.el | 113 +++----
58 files changed, 2523 insertions(+), 1724 deletions(-)
diff --git a/Makefile.in b/Makefile.in
index a2bb2d9d..f64125c7 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -195,7 +195,8 @@ STYLESRC = style/prosper.el \
style/ifxetex.el style/multibib.el style/ltcaption.el \
style/keyval.el style/kvoptions.el style/kvsetkeys.el \
style/proc.el style/microtype.el style/tcolorboxlib-theorems.el
\
- style/amsaddr.el style/parskip.el style/catchfilebetweentags.el
+ style/amsaddr.el style/parskip.el style/catchfilebetweentags.el \
+ style/physics.el
STYLEELC = $(STYLESRC:.el=.elc)
diff --git a/context.el b/context.el
index 40eacda8..ae546b6a 100644
--- a/context.el
+++ b/context.el
@@ -363,35 +363,19 @@ section."
(defun ConTeXt-numbered-section-name (level)
"Return the name of the section corresponding to LEVEL."
- (let ((entry (TeX-member level ConTeXt-numbered-section-list
- (function (lambda (a b) (equal a (nth 1 b)))))))
- (if entry
- (nth 0 entry)
- nil)))
+ (car (rassoc (list level) ConTeXt-numbered-section-list)))
(defun ConTeXt-unnumbered-section-name (level)
"Return the name of the section corresponding to LEVEL."
- (let ((entry (TeX-member level ConTeXt-unnumbered-section-list
- (function (lambda (a b) (equal a (nth 1 b)))))))
- (if entry
- (nth 0 entry)
- nil)))
+ (car (rassoc (list level) ConTeXt-unnumbered-section-list)))
(defun ConTeXt-numbered-section-level (name)
"Return the level of the section NAME."
- (let ((entry (TeX-member name ConTeXt-numbered-section-list
- (function (lambda (a b) (equal a (nth 0 b)))))))
- (if entry
- (nth 1 entry)
- nil)))
+ (cadr (assoc name ConTeXt-numbered-section-list)))
(defun ConTeXt-unnumbered-section-level (name)
"Return the level of the section NAME."
- (let ((entry (TeX-member name ConTeXt-unnumbered-section-list
- (function (lambda (a b) (equal a (nth 0 b)))))))
- (if entry
- (nth 1 entry)
- nil)))
+ (cadr (assoc name ConTeXt-unnumbered-section-list)))
;;; Section Hooks.
@@ -411,32 +395,34 @@ The following variables are set before the hooks are run
`ConTeXt-level'.
`ConTeXt-title' - The title of the section, default to an empty
string.
+`ConTeXt-reference' - Comma separated list of reference.
`ConTeXt-done-mark' - Position of point afterwards, default nil
(meaning end).
The following standard hooks exist -
-ConTeXt-numbered-section-heading: Query the user about the name
+`ConTeXt-numbered-section-heading': Query the user about the name
of the sectioning command. Modifies `ConTeXt-level' and
`ConTeXt-name'.
-ConTeXt-section-title: Query the user about the title of the
+`ConTeXt-section-title': Query the user about the title of the
section. Modifies `ConTeXt-title'.
-ConTeXt-section-section: Insert ConTeXt section command according
+`ConTeXt-section-section': Insert ConTeXt section command according
to `ConTeXt-name', `ConTeXt-title', and `ConTeXt-reference'. If
`ConTeXt-title' is an empty string, `ConTeXt-done-mark' will be
placed at the point they should be inserted.
-ConTeXt-section-ref: Insert a reference for this section command.
+`ConTeXt-section-ref': Query the user about a reference for this
+section command. Modifies `ConTeXt-reference'.
To get a full featured `ConTeXt-section' command, insert
(setq ConTeXt-numbered-section-hook
\\='(ConTeXt-numbered-section-heading
ConTeXt-section-title
- ConTeXt-section-section
- ConTeXt-section-ref))
+ ConTeXt-section-ref
+ ConTeXt-section-section))
in your init file such as .emacs.d/init.el or .emacs."
:group 'ConTeXt-macro
@@ -463,32 +449,34 @@ The following variables are set before the hooks are run
`ConTeXt-level'.
`ConTeXt-title' - The title of the section, default to an empty
string.
+`ConTeXt-reference' - Comma separated list of reference.
`ConTeXt-done-mark' - Position of point afterwards, default nil
(meaning end).
The following standard hooks exist -
-ConTeXt-unnumbered-section-heading: Query the user about the name
+`ConTeXt-unnumbered-section-heading': Query the user about the name
of the sectioning command. Modifies `ConTeXt-level' and
`ConTeXt-name'.
-ConTeXt-section-title: Query the user about the title of the
+`ConTeXt-section-title': Query the user about the title of the
section. Modifies `ConTeXt-title'.
-ConTeXt-section-section: Insert ConTeXt section command according
+`ConTeXt-section-section': Insert ConTeXt section command according
to `ConTeXt-name', `ConTeXt-title', and `ConTeXt-reference'. If
`ConTeXt-title' is an empty string, `ConTeXt-done-mark' will be
placed at the point they should be inserted.
-ConTeXt-section-ref: Insert a reference for this section command.
+`ConTeXt-section-ref': Query the user about a reference for this
+section command. Modifies `ConTeXt-reference'.
To get a full featured `ConTeXt-section' command, insert
(setq ConTeXt-unnumbered-section-hook
\\='(ConTeXt-unnumbered-section-heading
ConTeXt-section-title
- ConTeXt-section-section
- ConTeXt-section-ref))
+ ConTeXt-section-ref
+ ConTeXt-section-section))
in your init file such as .emacs.d/init.el or .emacs."
:group 'ConTeXt-macro
@@ -598,7 +586,7 @@ for a label to be inserted after the sectioning command."
(cond ((TeX-TeX-sentinel-check process name))
((save-excursion
;; in a full ConTeXt run there will multiple texutil
- ;; outputs. Just looking for "another run needed" would
+ ;; outputs. Just looking for "another run needed" would
;; find the first occurence
(goto-char (point-max))
(re-search-backward "TeXUtil " nil t)
@@ -759,45 +747,156 @@ With optional ARG, modify current environment."
(end-of-line)
(newline))
+(defvar ConTeXt-after-insert-env-hook nil
+ "List of functions to be run at the end of `ConTeXt-insert-environment'.
+Each function is called with three arguments: the name of the
+environment just inserted, the buffer position just before
+\\start... and the position just before \\stop....")
+
+;;; Copy and adaptation of `LaTeX-insert-environment'. (2022-08-13)
(defun ConTeXt-insert-environment (environment &optional extra)
- "Insert ENVIRONMENT, with optional argument EXTRA."
- (if (and (TeX-active-mark)
- (not (eq (mark) (point))))
+ "Insert ConTeXt ENVIRONMENT with optional argument EXTRA."
+ (let ((active-mark (and (TeX-active-mark) (not (eq (mark) (point)))))
+ content-start env-start env-end additional-indent)
+ (when (and active-mark (< (mark) (point))) (exchange-point-and-mark))
+ ;; What to do with the line containing point.
+ ;; - Open a new empty line for later insertion of "\startfoo" and
+ ;; put the point there.
+ ;; - If there were at first any non-whitespace texts between the
+ ;; point and EOL, send them into their new own line.
+ (cond (;; When the entire line consists of whitespaces...
+ (save-excursion (beginning-of-line)
+ (looking-at "[ \t]*$"))
+ ;; ...make the line empty and put the point there.
+ (delete-region (match-beginning 0) (match-end 0)))
+ (;; When there are only whitespaces between the point and
+ ;; BOL (including the case the point is at BOL)...
+ (TeX-looking-at-backward "^[ \t]*"
+ (line-beginning-position))
+ ;; ...in this case, we have non-whitespace texts between
+ ;; the point and EOL, so send the entire line into a new
+ ;; next line and put the point on the empty line just
+ ;; created.
+ (beginning-of-line)
+ (newline)
+ (beginning-of-line 0)
+ ;; Take note that there are texts to be indented later
+ ;; unless the region is activated.
+ (unless active-mark
+ (setq additional-indent t)))
+ (;; In all other cases...
+ t
+ ;; ...insert a new empty line after deleting all
+ ;; whitespaces around the point, put the point there...
+ (delete-horizontal-space)
+ (if (eolp)
+ (newline)
+ ;; ...and if there were at first any non-whitespace texts
+ ;; between (the original position of) the point and EOL,
+ ;; send them into a new next line.
+ (newline 2)
+ (beginning-of-line 0)
+ ;; Take note that there are texts to be indented later
+ ;; unless the region is activated.
+ (unless active-mark
+ (setq additional-indent t)))))
+ ;; What to do with the line containing mark.
+ ;; If there is active region...
+ (when active-mark
+ ;; - Open a new empty line for later insertion of "\stopfoo"
+ ;; and put the mark there.
+ ;; - If there were at first any non-whitespace texts between the
+ ;; mark and EOL, pass them over the empty line and put them on
+ ;; their own line.
(save-excursion
- (if (< (mark) (point))
- (exchange-point-and-mark))
- (insert TeX-esc (ConTeXt-environment-start-name) environment)
- (newline)
- (forward-line -1)
- (indent-according-to-mode)
- (if extra (insert extra))
(goto-char (mark))
- (or (TeX-looking-at-backward "^[ \t]*")
- (newline))
- (insert TeX-esc (ConTeXt-environment-stop-name) environment)
- (newline)
- (forward-line -1)
- (indent-according-to-mode)
- ;;(goto-char (point))
- )
- (or (TeX-looking-at-backward "^[ \t]*")
- (newline))
+ (cond (;; When the entire line consists of whitespaces...
+ (save-excursion (beginning-of-line)
+ (looking-at "[ \t]*$"))
+ ;; ...make the line empty and put the mark there.
+ (delete-region (match-beginning 0) (match-end 0)))
+ (;; When there are only whitespaces between the mark and
+ ;; BOL (including the case the mark is at BOL)...
+ (TeX-looking-at-backward "^[ \t]*"
+ (line-beginning-position))
+ ;; ...in this case, we have non-whitespace texts
+ ;; between the mark and EOL, so send the entire line
+ ;; into a new next line and put the mark on the empty
+ ;; line just created.
+ (beginning-of-line)
+ (set-mark (point))
+ (newline)
+ ;; Take note that there are texts to be indented later.
+ (setq additional-indent t))
+ (;; In all other cases...
+ t
+ ;; ...make a new empty line after deleting all
+ ;; whitespaces around the mark, put the mark there...
+ (delete-horizontal-space)
+ (insert-before-markers "\n")
+ ;; ...and if there were at first any non-whitespace
+ ;; texts between (the original position of) the mark
+ ;; and EOL, send them into a new next line.
+ (unless (eolp)
+ (newline)
+ ;; Take note that there are texts to be indented
+ ;; later.
+ (setq additional-indent t))))))
+ ;; Now insert the environment.
+ (setq env-start (point))
(insert TeX-esc (ConTeXt-environment-start-name) environment)
(indent-according-to-mode)
- (if extra (insert extra))
- (end-of-line)
- (newline-and-indent)
- (newline)
+ (when extra (insert extra))
+ (setq content-start (line-beginning-position 2))
+ (unless active-mark
+ (newline)
+ (newline))
+ (when active-mark (goto-char (mark)))
(insert TeX-esc (ConTeXt-environment-stop-name) environment)
- (or (looking-at "[ \t]*$")
- (save-excursion (newline-and-indent)))
- (indent-according-to-mode)
- (end-of-line 0)))
+ (end-of-line 0)
+ (if active-mark
+ (progn
+ ;; TODO: Do filling when context.el obtains
+ ;; `ConTeXt-fill-region' in future.
+ (indent-region content-start (line-beginning-position 2))
+ (set-mark content-start))
+ (indent-according-to-mode))
+ ;; Indent \stopfoo.
+ (save-excursion (beginning-of-line 2) (indent-according-to-mode)
+ (when additional-indent
+ ;; Indent texts sent after the inserted
+ ;; environment.
+ (forward-line 1) (indent-according-to-mode)))
+ (setq env-end (save-excursion
+ (search-forward
+ (concat TeX-esc (ConTeXt-environment-stop-name)
+ environment))
+ (match-beginning 0)))
+ (run-hook-with-args 'ConTeXt-after-insert-env-hook
+ environment env-start env-end)))
+
+(defun ConTeXt--env-parse-args (args)
+ "Helper function to insert arguments defined by ARGS.
+This function checks if `TeX-exit-mark' is set, otherwise it's
+set to the point where this function starts. Point will be at
+`TeX-exit-mark' when this function exits."
+ (let ((TeX-exit-mark (or TeX-exit-mark
+ (point-marker))))
+ (ConTeXt-find-matching-start)
+ (end-of-line)
+ (TeX-parse-arguments args)
+ (goto-char TeX-exit-mark)
+ (set-marker TeX-exit-mark nil)))
+
+(defun ConTeXt-env-args (environment &rest args)
+ "Insert ENVIRONMENT and arguments defined by ARGS."
+ (ConTeXt-insert-environment environment)
+ (ConTeXt--env-parse-args args))
-;; with the following we can call a function on an environment. Say
+;; with the following we can call a function on an environment. Say
;; you have metapost stuff within your TeX file, go to the environment
-;; and run ConTeXt-work-on-environment (suggested Key: C-c !). AUCTeX
+;; and run ConTeXt-work-on-environment (suggested Key: C-c !). AUCTeX
;; sees that you are inside e.g. \startMPpage....\stopMPpage and
;; looks in ConTeXt-environment-helper for a function to be called.
@@ -842,7 +941,7 @@ An entry looks like: (\"environment\" . function)")
(context-mode)
(widen))
-;; find smarter name. Suggestions welcome
+;; find smarter name. Suggestions welcome
(defun ConTeXt-work-on-environment ()
"Takes current environment and does something on it (todo: documentation)."
(interactive)
@@ -938,10 +1037,10 @@ If INNER is non-nil, go to the point just past the
\\start... macro."
(setq level (1- level))))))
;; now we have to look if we want to start behind the \start... macro
(when inner
- ;; \startfoo can have 0 or more {} and [] pairs. I assume that
- ;; skipping all those parens will be smart enough. It fails when
+ ;; \startfoo can have 0 or more {} and [] pairs. I assume that
+ ;; skipping all those parens will be smart enough. It fails when
;; the first part in the \start-\stop-environment is { or [, like
- ;; in \startquotation {\em important} \stopquotation. There is
+ ;; in \startquotation {\em important} \stopquotation. There is
;; yet another pitfall: \startsetups SomeSetup foo bar
;; \stopsetups will use SomeSetup as the argument and the
;; environment
@@ -1151,7 +1250,7 @@ An optional fourth (or sixth) element means always
replace if t."
(match-string 1)
(buffer-substring-no-properties (point) (line-end-position)))))
-;; This imenu also includes commented out chapters. Perhaps a feature
+;; This imenu also includes commented out chapters. Perhaps a feature
;; for LaTeX, not sure we want or need that for ConTeXt.
(defun ConTeXt-imenu-create-index-function ()
@@ -1654,7 +1753,7 @@ Use `ConTeXt-Mark-version' to choose the command."
(let ((engine (eval (nth 4 (TeX-engine-in-engine-alist TeX-engine)) t)))
(when engine
(format "--engine=%s " engine)))
- (unless (eq ConTeXt-current-interface "en")
+ (unless (string= ConTeXt-current-interface "en")
(format "--interface=%s " ConTeXt-current-interface))
(when TeX-source-correlate-mode
(format "--passon=\"%s\" "
@@ -1688,7 +1787,7 @@ Use `ConTeXt-Mark-version' to choose the command."
(defconst ConTeXt-dialect :context
"Default dialect for use with function `TeX-add-style-hook' for
argument DIALECT-EXPR when the hook is to be run only on ConTeXt
-file, or any mode derived thereof. See variable
+file, or any mode derived thereof. See variable
`TeX-style-hook-dialect'." )
(defcustom ConTeXt-clean-intermediate-suffixes
@@ -1740,7 +1839,7 @@ that is, you do _not_ have to cater for this yourself by
adding \\\\\\=' or $."
(setq ConTeXt-indent-item-re (concat "\\\\\\(" (mapconcat #'identity
ConTeXt-item-list "\\|") "\\)\\>"))
;; What's the deepest level at we can collapse a document?
- ;; set only if user has not set it. Need to be set before menu is created.
+ ;; set only if user has not set it. Need to be set before menu is created.
;; level 2 is "section"
(or ConTeXt-largest-level
(setq ConTeXt-largest-level 2))
diff --git a/doc/macros.texi b/doc/macros.texi
index 4162d052..478ac18a 100644
--- a/doc/macros.texi
+++ b/doc/macros.texi
@@ -50,30 +50,30 @@ font-latex
@end ifset
@tex
\global\let\savedTeX\TeX
-\gdef\TeX#1{\savedTeX#1}
-\gdef\LaTeX{%
+\gdef\TeX#{\savedTeX}
+\gdef\LaTeX#{%
L\kern-.36em\raise.3ex\hbox{\sc{a}}\kern-.15em\TeX}
-\gdef\previewlatex#1{%
- {\sf preview-latex}#1}
-\gdef\fontlatex#1{%
- {\sf font-latex}#1}
-\gdef\AUCTeX{AUC\TeX}
-\gdef\ConTeXt#1{%
- Con\TeX t#1}
+\gdef\previewlatex#{%
+ {\textsf preview-latex}}
+\gdef\fontlatex#{%
+ {\textsf font-latex}}
+\gdef\AUCTeX#{AUC\TeX}
+\gdef\ConTeXt#{%
+ Con\TeX{}t}
\toks0\expandafter{\indexnofonts
- \def\TeX#1{TeX#1}%
- \def\LaTeX#1{LaTeX#1}\def\previewlatex#1{preview-latex#1}}
+ \def\TeX#{TeX}%
+ \def\LaTeX#{LaTeX}\def\previewlatex#{preview-latex}}
\xdef\indexnofonts{\the\toks0}
\ifx\commondummies\undefined \else
\toks0\expandafter{\commondummies
- \def\TeX#1{TeX#1}%
- \def\LaTeX#1{LaTeX#1}\def\previewlatex#1{preview-latex#1}}
+ \def\TeX#{TeX}%
+ \def\LaTeX#1{LaTeX}\def\previewlatex#1{preview-latex}}
\xdef\commondummies{\the\toks0}
\fi
\ifx\definedummies\undefined \else
\toks0\expandafter{\definedummies
- \def\TeX#1{TeX#1}%
- \def\LaTeX#1{LaTeX#1}\def\previewlatex#1{preview-latex#1}}
+ \def\TeX#{TeX}%
+ \def\LaTeX#{LaTeX}\def\previewlatex#{preview-latex}}
\xdef\definedummies{\the\toks0}
\fi
\ifx\acronym\undefined \gdef\acronym#1{{\smallcaps \lowercase{#1}}} \fi
diff --git a/font-latex.el b/font-latex.el
index 4067564d..b78cf58a 100644
--- a/font-latex.el
+++ b/font-latex.el
@@ -631,12 +631,12 @@ use."
(if (eq type 'command)
"\
This must be a list where each element is a list consisting of a
-keyword string \(not a regular expression\) omitting the leading
+keyword string (not a regular expression) omitting the leading
backslash and a format specifier as described in the doc string of
`font-latex-user-keyword-classes'."
"\
-This must be a list where each element is a keyword string \(not a
-regular expression\) omitting the leading backslash.")
+This must be a list where each element is a keyword string (not a
+regular expression) omitting the leading backslash.")
"\n\n\
This is an internal variable which should not be set directly.
diff --git a/latex.el b/latex.el
index 744257e3..56992d54 100644
--- a/latex.el
+++ b/latex.el
@@ -259,20 +259,14 @@ used in style files."
(defun LaTeX-section-name (level)
"Return the name of the section corresponding to LEVEL."
- (let ((entry (TeX-member level LaTeX-section-list
- (lambda (a b) (equal a (nth 1 b))))))
- (if entry
- (nth 0 entry)
- nil)))
+ (car (rassoc (list level) LaTeX-section-list)))
(defun LaTeX-section-level (name)
- "Return the level of the section NAME."
- (let ((entry (TeX-member name LaTeX-section-list
- (lambda (a b) (equal a (nth 0 b))))))
-
- (if entry
- (nth 1 entry)
- nil)))
+ "Return the level of the section NAME.
+NAME can be starred variant."
+ (if (string-suffix-p "*" name)
+ (setq name (substring-no-properties name 0 -1)))
+ (cadr (assoc name LaTeX-section-list)))
(defcustom TeX-outline-extra nil
"List of extra TeX outline levels.
@@ -392,30 +386,35 @@ If so, return the second element, otherwise return nil."
The following variables are set before the hooks are run
-LaTeX-level - numeric section level, see the documentation of `LaTeX-section'.
-LaTeX-name - name of the sectioning command, derived from `LaTeX-level'.
-LaTeX-title - The title of the section, default to an empty string.
-LaTeX-toc - Entry for the table of contents list, default nil.
-LaTeX-done-mark - Position of point afterwards, default nil (meaning end).
+`LaTeX-level' - numeric section level, see the documentation of
+ `LaTeX-section'.
+`LaTeX-name' - name of the sectioning command, derived from
+ `LaTeX-level'.
+`LaTeX-title' - The title of the section, default to an empty
+ string.
+`LaTeX-toc' - Entry for the table of contents list, default
+ nil.
+`LaTeX-done-mark' - Position of point afterwards, default nil
+ (meaning end).
The following standard hooks exist -
-LaTeX-section-heading: Query the user about the name of the
+`LaTeX-section-heading': Query the user about the name of the
sectioning command. Modifies `LaTeX-level' and `LaTeX-name'.
-LaTeX-section-title: Query the user about the title of the
+`LaTeX-section-title': Query the user about the title of the
section. Modifies `LaTeX-title'.
-LaTeX-section-toc: Query the user for the toc entry. Modifies
+`LaTeX-section-toc': Query the user for the toc entry. Modifies
`LaTeX-toc'.
-LaTeX-section-section: Insert LaTeX section command according to
+`LaTeX-section-section': Insert LaTeX section command according to
`LaTeX-name', `LaTeX-title', and `LaTeX-toc'. If `LaTeX-toc' is
nil, no toc entry is inserted. If `LaTeX-toc' or `LaTeX-title'
are empty strings, `LaTeX-done-mark' will be placed at the point
they should be inserted.
-LaTeX-section-label: Insert a label after the section command.
+`LaTeX-section-label': Insert a label after the section command.
Controled by the variable `LaTeX-section-label'.
To get a full featured `LaTeX-section' command, insert
@@ -474,7 +473,12 @@ Insert this hook into `LaTeX-section-hook' to allow the
user to change
the name of the sectioning command inserted with \\[LaTeX-section]."
(let ((string (completing-read
(concat "Level (default " LaTeX-name "): ")
- LaTeX-section-list
+ (append
+ ;; Include starred variants in candidates.
+ (mapcar (lambda (sct)
+ (list (concat (car sct) "*")))
+ LaTeX-section-list)
+ LaTeX-section-list)
nil nil nil nil LaTeX-name)))
;; Update LaTeX-name
(if (not (zerop (length string)))
@@ -844,10 +848,9 @@ environment just inserted, the buffer position just before
"Return the regexp matching the name of a LaTeX environment.
This matches everything different from a TeX closing brace but
allowing one level of TeX group braces."
- (concat "\\([^" (regexp-quote TeX-grcl) (regexp-quote TeX-grop) "]*\\("
- (regexp-quote TeX-grop) "[^" (regexp-quote TeX-grcl)
- (regexp-quote TeX-grop) "]*" (regexp-quote TeX-grcl) "\\)*[^"
- (regexp-quote TeX-grcl) (regexp-quote TeX-grop) "]*\\)"))
+ (concat "\\([^" TeX-grcl TeX-grop "]*\\(" (regexp-quote TeX-grop)
+ "[^" TeX-grcl TeX-grop "]*" (regexp-quote TeX-grcl) "\\)*[^"
+ TeX-grcl TeX-grop "]*\\)"))
(defvar LaTeX-after-modify-env-hook nil
"List of functions to be run at the end of `LaTeX-modify-environment'.
@@ -863,34 +866,32 @@ position just before \\begin and the position just before
(re-search-backward (concat (regexp-quote TeX-esc)
"end"
(regexp-quote TeX-grop)
- "\\("
(LaTeX-environment-name-regexp)
- "\\)"
(regexp-quote TeX-grcl))
- (save-excursion (beginning-of-line 1)
(point)))))
+ (line-beginning-position))))
(goto-begin (lambda ()
(LaTeX-find-matching-begin)
(prog1 (point)
(re-search-forward (concat (regexp-quote TeX-esc)
"begin"
(regexp-quote TeX-grop)
- "\\("
(LaTeX-environment-name-regexp)
- "\\)"
(regexp-quote TeX-grcl))
- (save-excursion (end-of-line 1)
(point)))))))
+ (line-end-position))))))
(save-excursion
(funcall goto-end)
- (let ((old-env (match-string 1)))
+ (let ((old-env (match-string-no-properties 1))
+ beg-pos)
(replace-match environment t t nil 1)
- (beginning-of-line 1)
- (funcall goto-begin)
+ ;; This failed when \begin and \end lie on the same line. (bug#58689)
+ ;; (beginning-of-line 1)
+ (setq beg-pos (funcall goto-begin))
(replace-match environment t t nil 1)
- (end-of-line 1)
+ ;; (end-of-line 1)
(run-hook-with-args 'LaTeX-after-modify-env-hook
environment old-env
- (save-excursion (funcall goto-begin))
- (progn (funcall goto-end) (point)))))))
+ beg-pos
+ (funcall goto-end))))))
(defvar LaTeX-syntactic-comments) ;; Defined further below.
@@ -904,34 +905,50 @@ environment in commented regions with the same comment
prefix.
The functions `LaTeX-find-matching-begin' and `LaTeX-find-matching-end'
work analogously."
+ (save-excursion
+ (if (LaTeX-backward-up-environment arg)
+ (progn
+ (re-search-forward (concat
+ TeX-grop (LaTeX-environment-name-regexp)
+ TeX-grcl))
+ (match-string-no-properties 1))
+ "document")))
+
+(defun LaTeX-backward-up-environment (&optional arg)
+ "Move backward out of the enclosing environment.
+Helper function of `LaTeX-current-environment' and
+`LaTeX-find-matching-begin'.
+With optional ARG>=1, find that outer level.
+Return non-nil if the operation succeeded.
+
+Assume the current point is on neither \"begin{foo}\" nor \"end{foo}\"."
(setq arg (if arg (if (< arg 1) 1 arg) 1))
(let* ((in-comment (TeX-in-commented-line))
(comment-prefix (and in-comment (TeX-comment-prefix)))
(case-fold-search nil))
- (save-excursion
- (while (and (/= arg 0)
- (re-search-backward
- "\\\\\\(begin\\|end\\) *{\\([^}]+\\)}" nil t))
- (when (or (and LaTeX-syntactic-comments
- (eq in-comment (TeX-in-commented-line))
- (or (not in-comment)
- ;; Consider only matching prefixes in the
- ;; commented case.
- (string= comment-prefix (TeX-comment-prefix))))
- (and (not LaTeX-syntactic-comments)
- (not (TeX-in-commented-line)))
- ;; macrocode*? in docTeX-mode is special since we
- ;; have also regular code lines not starting with a
- ;; comment-prefix. Hence, the next check just looks
- ;; if we're inside such a group and returns t to
- ;; recognize such a situation.
- (and (eq major-mode 'doctex-mode)
- (member (match-string-no-properties 2)
- '("macrocode" "macrocode*"))))
- (setq arg (if (string= (match-string 1) "end") (1+ arg) (1- arg)))))
- (if (/= arg 0)
- "document"
- (match-string-no-properties 2)))))
+ (while (and (/= arg 0)
+ (re-search-backward
+ (concat (regexp-quote TeX-esc) "\\(begin\\|end\\)\\b") nil t))
+ (when (or (and LaTeX-syntactic-comments
+ (eq in-comment (TeX-in-commented-line))
+ (or (not in-comment)
+ ;; Consider only matching prefixes in the
+ ;; commented case.
+ (string= comment-prefix (TeX-comment-prefix))))
+ (and (not LaTeX-syntactic-comments)
+ (not (TeX-in-commented-line)))
+ ;; macrocode*? in docTeX-mode is special since we have
+ ;; also regular code lines not starting with a
+ ;; comment-prefix. Hence, the next check just looks
+ ;; if we're inside such a group and returns non-nil to
+ ;; recognize such a situation.
+ (and (eq major-mode 'doctex-mode)
+ (looking-at-p (concat (regexp-quote TeX-esc)
+ "\\(?:begin\\|end\\) *{macrocode\\*?}"))))
+ (setq arg (if (= (char-after (match-beginning 1)) ?e)
+ (1+ arg)
+ (1- arg)))))
+ (= arg 0)))
(defun docTeX-in-macrocode-p ()
"Determine if point is inside a macrocode environment."
@@ -1433,7 +1450,7 @@ Just like array and tabular."
(defun LaTeX-env-contents (environment)
"Insert ENVIRONMENT with optional argument and filename for contents."
- (let* ((opt '("overwrite" "force" "nosearch"))
+ (let* ((opt '("overwrite" "force" "nosearch" "nowarn"))
(arg (mapconcat #'identity
(TeX-completing-read-multiple
(TeX-argument-prompt t nil "Options")
@@ -2403,9 +2420,9 @@ string."
optional))
(defun TeX-arg-define-macro-arguments (optional &optional prompt)
- "Prompt for the number of arguments for a LaTeX macro. If this
-is non-zero, also prompt for the default value for the first
-argument.
+ "Prompt for the number of arguments for a LaTeX macro.
+If this is non-zero, also prompt for the default value for the
+first argument.
If OPTIONAL is non-nil, insert the resulting value as an optional
argument, otherwise as a mandatory one. Use PROMPT as the prompt
@@ -3260,9 +3277,11 @@ reading an optional argument. KEY-VAL-ALIST can be
- A symbol returning an alist
- An alist
-The car of each element should be a string representing a key and
-the optional cdr should be a list with strings to be used as
-values for the key.
+Each entry of this alist is a list. The first element of each
+list is a string representing a key and the optional second
+element is a list with strings to be used as values for the key.
+The second element can also be a variable returning a list of
+strings.
PROMPT replaces the standard one where \\=' (k=v): \\=' is
appended to it. If you want the full control over the prompt,
@@ -5050,7 +5069,7 @@ code comment.
If LaTeX syntax is taken into consideration during filling
depends on the value of `LaTeX-syntactic-comments'."
- (interactive "P")
+ (interactive "*P")
(if (save-excursion
(beginning-of-line)
(looking-at (concat TeX-comment-start-regexp "*[ \t]*$")))
@@ -5262,12 +5281,15 @@ environment in commented regions with the same comment
prefix."
(in-comment (TeX-in-commented-line))
(comment-prefix (and in-comment (TeX-comment-prefix)))
(case-fold-search nil))
+ ;; The following code until `while' handles exceptional cases that
+ ;; the point is on "\begin{foo}" or "\end{foo}".
+ ;; Note that it doesn't work for "\end{\foo{bar}}". See bug#19281.
(let ((pt (point)))
- (skip-chars-backward (concat "a-zA-Z \t" (regexp-quote TeX-grop)))
+ (skip-chars-backward (concat "a-zA-Z* \t" TeX-grop))
(unless (bolp)
(backward-char 1)
(if (and (looking-at regexp)
- (char-equal (char-after (1+ (match-beginning 0))) ?e))
+ (char-equal (char-after (match-beginning 1)) ?e))
(setq level 0)
(goto-char pt))))
(while (and (> level 0) (re-search-forward regexp nil t))
@@ -5278,10 +5300,18 @@ environment in commented regions with the same comment
prefix."
(or (not in-comment)
(string= comment-prefix (TeX-comment-prefix))))
(and (not LaTeX-syntactic-comments)
- (not (TeX-in-commented-line))))
- (if (= (char-after (1+ (match-beginning 0))) ?b) ;;begin
- (setq level (1+ level))
- (setq level (1- level)))))
+ (not (TeX-in-commented-line)))
+ ;; macrocode*? in docTeX-mode is special since we have
+ ;; also regular code lines not starting with a
+ ;; comment-prefix. Hence, the next check just looks
+ ;; if we're inside such a group and returns non-nil to
+ ;; recognize such a situation.
+ (and (eq major-mode 'doctex-mode)
+ (looking-at-p " *{macrocode\\*?}")))
+ (setq level
+ (if (= (char-after (match-beginning 1)) ?b) ;;begin
+ (1+ level)
+ (1- level)))))
(if (= level 0)
(re-search-forward
(concat TeX-grop (LaTeX-environment-name-regexp) TeX-grcl))
@@ -5294,30 +5324,17 @@ If function is called inside a comment and
`LaTeX-syntactic-comments' is enabled, try to find the
environment in commented regions with the same comment prefix."
(interactive)
- (let* ((regexp (concat (regexp-quote TeX-esc) "\\(begin\\|end\\)\\b"))
- (level 1)
- (in-comment (TeX-in-commented-line))
- (comment-prefix (and in-comment (TeX-comment-prefix)))
- (case-fold-search nil))
- (skip-chars-backward (concat "a-zA-Z \t" (regexp-quote TeX-grop)))
+ (let (done)
+ ;; The following code until `or' handles exceptional cases that
+ ;; the point is on "\begin{foo}" or "\end{foo}".
+ ;; Note that it doesn't work for "\end{\foo{bar}}". See bug#19281.
+ (skip-chars-backward (concat "a-zA-Z* \t" TeX-grop))
(unless (bolp)
(backward-char 1)
- (and (looking-at regexp)
- (char-equal (char-after (1+ (match-beginning 0))) ?b)
- (setq level 0)))
- (while (and (> level 0) (re-search-backward regexp nil t))
- (when (or (and LaTeX-syntactic-comments
- (eq in-comment (TeX-in-commented-line))
- ;; If we are in a commented line, check if the
- ;; prefix matches the one we started out with.
- (or (not in-comment)
- (string= comment-prefix (TeX-comment-prefix))))
- (and (not LaTeX-syntactic-comments)
- (not (TeX-in-commented-line))))
- (if (= (char-after (1+ (match-beginning 0))) ?e) ;;end
- (setq level (1+ level))
- (setq level (1- level)))))
- (or (= level 0)
+ (and (looking-at (concat (regexp-quote TeX-esc) "begin\\b"))
+ (setq done t)))
+ (or done
+ (LaTeX-backward-up-environment)
(error "Can't locate beginning of current environment"))))
(defun LaTeX-mark-environment (&optional count)
@@ -6298,8 +6315,8 @@ See also `LaTeX-math-menu'."
(defun LaTeX--completion-annotation-from-math-menu (sym)
"Return a completion annotation for a SYM.
The annotation is usually a unicode representation of the macro
-SYM's compiled representation, e.g., if SYM is alpha, α is
-returned."
+SYM's compiled representation, for example, if SYM is alpha, α
+is returned."
(catch 'found
(dolist (var (list LaTeX-math-list LaTeX-math-default))
(dolist (e var)
@@ -6915,7 +6932,7 @@ by too many \\thanks commands.")
("Environment [^ ]* undefined." .
"LaTeX has encountered a \\begin command for a nonexistent environment.
-You probably misspelled the environment name. ")
+You probably misspelled the environment name.")
("Float(s) lost." .
"You put a figure or table environment or a \\marginpar command inside a
@@ -7250,7 +7267,7 @@ on this line than it should.")
("Overfull \\\\vbox .*" .
"Because it couldn't find a good place for a page break, TeX put more
-on the page than it should. ")
+on the page than it should.")
("Underfull \\\\hbox .*" .
"Check your output for extra vertical space. If you find some, it was
@@ -7261,7 +7278,7 @@ by inserting a \\linebreak command.")
("Underfull \\\\vbox .*" .
"TeX could not find a good place to break the page, so it produced a
-page without enough text on it. ")
+page without enough text on it.")
;; New list items should be placed here
;;
@@ -7379,10 +7396,13 @@ this point. If nil, limit to the previous 15 lines."
(error nil))
;; Set the initial value of argument counter
(setq cnt 1)
- ;; Note that we count also the right opt. or man. arg:
- (setq cnt-opt (if (= (following-char) ?\{) 0 1))
- ;; Record if we're inside a mand. or opt. argument
- (setq type (if (= (following-char) ?\{) 'mandatory 'optional))
+ ;; Note that we count also the right opt. or man. arg and
+ ;; record if we're inside a mand. or opt. argument
+ (if (= (following-char) ?\{)
+ (setq cnt-opt 0
+ type 'mandatory)
+ (setq cnt-opt 1
+ type 'optional))
;; Move back over any touching sexps
(while (and (LaTeX-move-to-previous-arg bound)
(condition-case nil
@@ -7526,7 +7546,7 @@ COLLECTION is an list of strings."
(defun LaTeX-completion-parse-args (entry)
"Return the match of buffer position ENTRY with AUCTeX macro definitions.
ENTRY is generated by the function `LaTeX-what-macro'. This
-function matches the current buffer position (i.e., which macro
+function matches the current buffer position (that is, which macro
argument) with the corresponding definition in `TeX-symbol-list'
or `LaTeX-environment-list' and returns it."
(let* ((name (nth 0 entry))
@@ -7554,17 +7574,22 @@ or `LaTeX-environment-list' and returns it."
(pop arg-list))
;; Check for `TeX-arg-conditional' here and change `arg-list'
- ;; accordingly
+ ;; accordingly.
+ ;; FIXME: Turn `y-or-n-p' into `always' otherwise there will be a
+ ;; query during in-buffer completion. This will work for most
+ ;; cases, but will also fail for example in hyperref.el. This
+ ;; decision should revisited at a later stage:
(when (assq 'TeX-arg-conditional arg-list)
- (while (and arg-list
- (setq arg (car arg-list)))
- (if (and (listp arg) (eq (car arg) 'TeX-arg-conditional))
- (setq result (append (reverse (if (eval (nth 1 arg) t)
- (nth 2 arg)
- (nth 3 arg)))
- result))
- (push arg result))
- (pop arg-list))
+ (cl-letf (((symbol-function 'y-or-n-p) #'always))
+ (while (and arg-list
+ (setq arg (car arg-list)))
+ (if (and (listp arg) (eq (car arg) 'TeX-arg-conditional))
+ (setq result (append (reverse (if (eval (nth 1 arg) t)
+ (nth 2 arg)
+ (nth 3 arg)))
+ result))
+ (push arg result))
+ (pop arg-list)))
(setq arg-list (nreverse result)))
;; Now parse the `arg-list':
@@ -8092,17 +8117,17 @@ function would return non-nil and `(match-string 1)'
would return
'("newcommand" TeX-arg-define-macro [ TeX-arg-define-macro-arguments ] t)
'("renewcommand" TeX-arg-macro [ TeX-arg-define-macro-arguments ] t)
'("newenvironment" TeX-arg-define-environment
- [ "Number of arguments"] t t)
+ [ TeX-arg-define-macro-arguments ] 2)
'("renewenvironment" TeX-arg-environment
- [ "Number of arguments"] t t)
+ [ TeX-arg-define-macro-arguments ] 2)
'("providecommand" TeX-arg-define-macro [ TeX-arg-define-macro-arguments ]
t)
'("providecommand*" TeX-arg-define-macro [ TeX-arg-define-macro-arguments ]
t)
'("newcommand*" TeX-arg-define-macro [ TeX-arg-define-macro-arguments ] t)
'("renewcommand*" TeX-arg-macro [ TeX-arg-define-macro-arguments ] t)
'("newenvironment*" TeX-arg-define-environment
- [ "Number of arguments"] t t)
+ [ TeX-arg-define-macro-arguments ] 2)
'("renewenvironment*" TeX-arg-environment
- [ "Number of arguments"] t t)
+ [ TeX-arg-define-macro-arguments ] 2)
'("newtheorem" TeX-arg-define-environment
[ TeX-arg-environment "Numbered like" ]
t [ (TeX-arg-eval progn (if (eq (save-excursion
@@ -8543,22 +8568,6 @@ function would return non-nil and `(match-string 1)'
would return
(setq TeX-font-list LaTeX-font-list)
(setq TeX-font-replace-function #'TeX-font-replace-macro)
(TeX-add-symbols
- '("newcommand" TeX-arg-define-macro
- [ TeX-arg-define-macro-arguments ] t)
- '("renewcommand" TeX-arg-macro
- [ TeX-arg-define-macro-arguments ] t)
- '("providecommand" TeX-arg-define-macro
- [ TeX-arg-define-macro-arguments ] t)
- '("providecommand*" TeX-arg-define-macro
- [ TeX-arg-define-macro-arguments ] t)
- '("newcommand*" TeX-arg-define-macro
- [ TeX-arg-define-macro-arguments ] t)
- '("renewcommand*" TeX-arg-macro
- [ TeX-arg-define-macro-arguments ] t)
- '("newenvironment" TeX-arg-define-environment
- [ TeX-arg-define-macro-arguments ] t t)
- '("renewenvironment" TeX-arg-environment
- [ TeX-arg-define-macro-arguments ] t t)
'("usepackage" LaTeX-arg-usepackage)
'("RequirePackage" LaTeX-arg-usepackage)
'("ProvidesPackage" (TeX-arg-file-name-sans-extension "Package name")
diff --git a/multi-prompt.el b/multi-prompt.el
index b8632711..5ce11d51 100644
--- a/multi-prompt.el
+++ b/multi-prompt.el
@@ -171,7 +171,7 @@ This is achieved by eval'ing all variables in the value
parts of
the alist elements."
(mapcar (lambda (x)
(if (and (cadr x) (symbolp (cadr x)) (not (functionp (cadr x))))
- (cons (car x) (list (eval (cadr x) t)))
+ (cons (car x) (list (symbol-value (cadr x))))
x))
table))
@@ -185,9 +185,13 @@ the alist elements."
hist def inherit-input-method)
"Read multiple strings, with completion and key=value support.
PROMPT is a string to prompt with, usually ending with a colon
-and a space. TABLE is an alist. The car of each element should
-be a string representing a key and the optional cdr should be a
-list with strings to be used as values for the key.
+and a space.
+
+TABLE is an alist where each entry is a list. The first element
+of each list is a string representing a key and the optional
+second element is a list with strings to be used as values for
+the key. The second element can also be a variable returning a
+list of strings.
See the documentation for `completing-read' for details on the
other arguments: PREDICATE, REQUIRE-MATCH, INITIAL-INPUT, HIST,
diff --git a/plain-tex.el b/plain-tex.el
index 4f06a026..0800b2f3 100644
--- a/plain-tex.el
+++ b/plain-tex.el
@@ -105,7 +105,7 @@ Install tool bar if `plain-TeX-enable-toolbar' and
(defconst plain-TeX-dialect :plain-tex
"Default dialect for use with function `TeX-add-style-hook' for
argument DIALECT-EXPR when the hook is to be run only on
-plain-TeX file, or any mode derived thereof. See variable
+plain-TeX file, or any mode derived thereof. See variable
`TeX-style-hook-dialect'." )
(defcustom plain-TeX-mode-hook nil
diff --git a/style/CJK.el b/style/CJK.el
index baee5d93..030cc8c5 100644
--- a/style/CJK.el
+++ b/style/CJK.el
@@ -1,6 +1,6 @@
;;; CJK.el --- AUCTeX style for the CJK package. -*- lexical-binding: t; -*-
-;; Copyright (C) 2009-2021 Free Software Foundation, Inc.
+;; Copyright (C) 2009-2022 Free Software Foundation, Inc.
;; Author: Ralf Angeli <angeli@caeruleus.net>
;; Maintainer: auctex-devel@gnu.org
@@ -43,17 +43,9 @@
"CNS2" "CNS3" "CNS4" "CNS5" "CNS6" "CNS7" "CEFX" "CEFY")
"List of encodings supported by the CJK package.")
-(defun LaTeX-env-CJK (env)
- "Prompt for the arguments of ENV and insert it.
-The function can be used for CJK and CJK* environments."
- (LaTeX-insert-environment
- env
- (concat
- (let ((font-enc (TeX-read-string "(Optional) Font encoding: ")))
- (unless (zerop (length font-enc)) (format "[%s]" font-enc)))
- (format "{%s}" (completing-read "Encoding: "
- (mapcar #'list LaTeX-CJK-enc-list)))
- (format "{%s}" (TeX-read-string "Font family: ")))))
+(defvar LaTeX-CJK-fontenc-list
+ '("pmC" "dnp" "wn" "HL")
+ "List of font encodings supported by the CJK package.")
(TeX-add-style-hook
"CJK"
@@ -90,8 +82,15 @@ The function can be used for CJK and CJK* environments."
"CJKverbatim")
;; New environments
(LaTeX-add-environments
- '("CJK" LaTeX-env-CJK)
- '("CJK*" LaTeX-env-CJK)))
+ '("CJK" LaTeX-env-args
+ [TeX-arg-completing-read LaTeX-CJK-fontenc-list "Font encoding"]
+ (TeX-arg-completing-read LaTeX-CJK-enc-list "Encoding")
+ "Font family")
+
+ '("CJK*" LaTeX-env-args
+ [TeX-arg-completing-read LaTeX-CJK-fontenc-list "Font encoding"]
+ (TeX-arg-completing-read LaTeX-CJK-enc-list "Encoding")
+ "Font family")))
TeX-dialect)
;;; CJK.el ends here
diff --git a/style/acro.el b/style/acro.el
index 56291a1b..26e32b8d 100644
--- a/style/acro.el
+++ b/style/acro.el
@@ -152,11 +152,10 @@ in its optional argument.")
(defun LaTeX-arg-acro-key-val (optional prompt key-val-alist)
"Prompt for keys and values in KEY-VAL-ALIST.
<SPC> key binding in minibuffer is removed temporarily. Insert
-the given value as a TeX macro argument. If OPTIONAL is non-nil,
-insert it as an optional argument. Use PROMPT as the prompt
-string. KEY-VAL-ALIST is an alist. The car of each element
-should be a string representing a key and the optional cdr should
-be a list with strings to be used as values for the key."
+the given value as a TeX macro argument.
+
+See `TeX-read-key-val' for explanation of OPTIONAL, PROMPT and
+KEY-VAL-ALIST."
;; Remove <SPC> key binding from map used in `multi-prompt-key-value' (called
;; by `TeX-arg-key-val') with `require-match' set to `nil'.
(let ((crm-local-completion-map
diff --git a/style/amsthm.el b/style/amsthm.el
index 64589c5b..ad06ff89 100644
--- a/style/amsthm.el
+++ b/style/amsthm.el
@@ -1,6 +1,6 @@
;;; amsthm.el --- Style hook for the AMS-LaTeX amsthm package. -*-
lexical-binding: t; -*-
-;; Copyright (C) 1997, 2013--2015, 2018, 2020 Free Software Foundation, Inc.
+;; Copyright (C) 1997--2022 Free Software Foundation, Inc.
;; Author: Carsten Dominik <dominik@strw.leidenuniv.nl>
;; Maintainer: auctex-devel@gnu.org
@@ -24,10 +24,23 @@
;;; Commentary:
-;; The style provides the function `LaTeX-amsthm-env-label' which
-;; enables new defined environments with "\newtheoreom" to interact
-;; with AUCTeX and RefTeX mechanisms for inserting labels. Check
-;; docstring of `LaTeX-amsthm-env-label' for instructions.
+;; This file adds support for `theorem.sty' (v2.2c) from 2014/10/28.
+;; `theorem.sty' is a standard LaTeX package and part of TeXLive.
+
+;; This style interacts with AUCTeX and RefTeX mechanisms for
+;; inserting labels into new defined environments with "\newtheoreom".
+;; AUCTeX users need to add the new environment to `LaTeX-label-alist'
+;; via customize or in init-file like this:
+;;
+;; (add-to-list 'LaTeX-label-alist '("lemma" . "lem:"))
+;;
+;; RefTeX users have to add the value to both `LaTeX-label-alist' and
+;; `reftex-label-alist' like this:
+;;
+;; (add-to-list 'LaTeX-label-alist '("lemma" . "lem:"))
+;; (add-to-list 'reftex-label-alist
+;; '("lemma" ?m "lem:" "~ref{%s}"
+;; nil ("Lemma" "lemma") nil))
;;; Code:
@@ -42,60 +55,6 @@
(defvar LaTeX-amsthm-package-options nil
"Package options for the amsthm package.")
-(defvar LaTeX-amsthm-fontdecl
- '(;; family
- "rmfamily" "sffamily" "ttfamily"
- ;; series
- "mdseries" "bfseries"
- ;; shape
- "upshape" "itshape" "slshape" "scshape"
- ;; size
- "tiny" "scriptsize" "footnotesize"
- "small" "normalsize" "large"
- "Large" "LARGE" "huge" "Huge"
- ;; reset macro
- "normalfont")
- "List of font declaration commands for \"\\newtheoremstyle\".")
-
-(defun LaTeX-arg-amsthm-fontdecl (optional &optional prompt)
- "Prompt for font declaration commands in \"\\newtheoremstyle\".
-If OPTIONAL is non-nil, insert the resulting value as an optional
-argument. Use PROMPT as the prompt string."
- (let* ((crm-separator (regexp-quote TeX-esc))
- (fontdecl (mapconcat #'identity
- (TeX-completing-read-multiple
- (TeX-argument-prompt optional prompt "Font: \\"
t)
- LaTeX-amsthm-fontdecl)
- TeX-esc)))
- (TeX-argument-insert fontdecl
- optional
- (when (and fontdecl (not (string= fontdecl "")))
- TeX-esc))))
-
-(defun LaTeX-amsthm-env-label (environment)
- "Insert ENVIRONMENT, query for an optional argument and prompt
-for label. AUCTeX users should add ENVIRONMENT to
-`LaTeX-label-alist' via customize or in init-file with:
-
- (add-to-list \\='LaTeX-label-alist \\='(\"lemma\" . \"lem:\"))
-
-RefTeX users should customize or add ENVIRONMENT to
-`LaTeX-label-alist' and `reftex-label-alist', for example
-
- (add-to-list \\='LaTeX-label-alist \\='(\"lemma\" . \"lem:\"))
- (add-to-list \\='reftex-label-alist
- \\='(\"lemma\" ?m \"lem:\" \"~\\ref{%s}\"
- nil (\"Lemma\" \"lemma\") nil))"
- (let ((opthead (TeX-read-string
- (TeX-argument-prompt t nil "Heading"))))
- (LaTeX-insert-environment environment
- (when (and opthead
- (not (string= opthead "")))
- (format "[%s]" opthead))))
- (when (LaTeX-label environment 'environment)
- (LaTeX-newline)
- (indent-according-to-mode)))
-
;; Setup parsing for \newtheorem
(TeX-auto-add-type "amsthm-newtheorem" "LaTeX")
@@ -112,7 +71,7 @@ RefTeX users should customize or add ENVIRONMENT to
"Move parsed results from `LaTeX-auto-amsthm-newtheorem' and
make them available as new environments."
(dolist (newthm (mapcar #'car (LaTeX-amsthm-newtheorem-list)))
- (LaTeX-add-environments (list newthm #'LaTeX-amsthm-env-label))))
+ (LaTeX-add-environments (list newthm #'LaTeX-env-label-args ["Heading"]))))
(add-hook 'TeX-auto-prepare-hook #'LaTeX-amsthm-auto-prepare t)
(add-hook 'TeX-auto-cleanup-hook #'LaTeX-amsthm-auto-cleanup t)
@@ -127,18 +86,17 @@ make them available as new environments."
"remark")
(LaTeX-add-environments
- '("proof" LaTeX-amsthm-env-label))
+ '("proof" LaTeX-env-label-args ["Heading"]))
(TeX-add-symbols
;; Overrule the defintion in `latex.el':
- '("newtheorem"
- (TeX-arg-eval
- (lambda ()
+ `("newtheorem"
+ ,(lambda (optional)
(let ((nthm (TeX-read-string
- (TeX-argument-prompt nil nil "Environment"))))
+ (TeX-argument-prompt optional nil "Environment"))))
(LaTeX-add-amsthm-newtheorems nthm)
- (LaTeX-add-environments (list nthm #'LaTeX-amsthm-env-label))
- (format "%s" nthm))))
+ (LaTeX-add-environments (list nthm #'LaTeX-env-label-args
["Heading"]))
+ (TeX-argument-insert nthm optional)))
[ TeX-arg-environment "Numbered like" ]
t [ (TeX-arg-eval progn (if (eq (save-excursion
(backward-char 2)
@@ -147,35 +105,50 @@ make them available as new environments."
(TeX-arg-counter t "Within counter"))
"") ])
- '("newtheorem*"
- (TeX-arg-eval
- (lambda ()
+ `("newtheorem*"
+ ,(lambda (optional)
(let ((nthm (TeX-read-string
- (TeX-argument-prompt nil nil "Environment")))
- (heading (TeX-read-string
- (TeX-argument-prompt nil nil "Heading"))))
+ (TeX-argument-prompt optional nil "Environment"))))
(LaTeX-add-amsthm-newtheorems nthm)
- (LaTeX-add-environments (list nthm #'LaTeX-amsthm-env-label))
- (insert (concat TeX-grop nthm TeX-grcl))
- (format "%s" heading)))))
+ ;; NOTE: Using `LaTeX-env-label-args' on environments
+ ;; defined with \newtheorem* is semi-accurate since these
+ ;; environments are not numbered. But numbering depends on
+ ;; an entry in `LaTeX-label-alist' and we assume that users
+ ;; will not add an entry to it. Hence,
+ ;; `LaTeX-env-label-args' will not insert a label and we
+ ;; don't need to differentiate.
+ (LaTeX-add-environments (list nthm #'LaTeX-env-label-args
["Heading"]))
+ (TeX-argument-insert nthm optional)))
+ "Heading")
'("theoremstyle"
(TeX-arg-completing-read (LaTeX-amsthm-newtheoremstyle-list) "Style"))
"qedhere"
"swapnumbers"
- '("newtheoremstyle"
- (TeX-arg-eval
- (lambda ()
+ `("newtheoremstyle"
+ ,(lambda (optional)
(let ((nthmstyle (TeX-read-string
- (TeX-argument-prompt nil nil "Style name"))))
+ (TeX-argument-prompt optional nil "Style name"))))
(LaTeX-add-amsthm-newtheoremstyles nthmstyle)
- (format "%s" nthmstyle))))
+ (TeX-argument-insert nthmstyle optional)))
(TeX-arg-length "Space above")
(TeX-arg-length "Space below")
- (LaTeX-arg-amsthm-fontdecl "Body font: \\")
+ (TeX-arg-completing-read-multiple
+ ,(lambda () (append LaTeX-font-family
+ LaTeX-font-series
+ LaTeX-font-shape
+ LaTeX-font-size))
+ "Body font" nil nil ,(regexp-quote TeX-esc) ,TeX-esc
+ nil nil nil nil ,TeX-esc)
"Indent amount"
- (LaTeX-arg-amsthm-fontdecl "Theorem head font: \\")
+ (TeX-arg-completing-read-multiple
+ ,(lambda () (append LaTeX-font-family
+ LaTeX-font-series
+ LaTeX-font-shape
+ LaTeX-font-size))
+ "Theorem head font" nil nil ,(regexp-quote TeX-esc) ,TeX-esc
+ nil nil nil nil ,TeX-esc)
"Punctuation after head"
(TeX-arg-length "Space after head")
"Theorem head spec"))
diff --git a/style/array.el b/style/array.el
index b564e055..001044ec 100644
--- a/style/array.el
+++ b/style/array.el
@@ -73,13 +73,13 @@ package.")
(TeX-auto-add-regexp LaTeX-array-newcolumntype-regexp)
(TeX-add-symbols
- '("newcolumntype"
- (TeX-arg-eval
- (lambda ()
- (let ((col (TeX-read-string "Column type: ")))
+ `("newcolumntype"
+ ,(lambda (optional)
+ (let ((col (TeX-read-string
+ (TeX-argument-prompt optional nil "Column type"))))
(LaTeX-add-array-newcolumntypes col)
(LaTeX-array-update-column-letters)
- (format "%s" col))))
+ (TeX-argument-insert col optional)))
[ "Number of arguments" ] t)
'("showcols" 0)
'("firsthline" 0)
diff --git a/style/attachfile.el b/style/attachfile.el
index c090b5a4..e3fe5eb7 100644
--- a/style/attachfile.el
+++ b/style/attachfile.el
@@ -1,6 +1,6 @@
;;; attachfile.el --- AUCTeX style for `attachfile.sty' (v1.6) -*-
lexical-binding: t; -*-
-;; Copyright (C) 2015, 2018, 2020 Free Software Foundation, Inc.
+;; Copyright (C) 2015--2022 Free Software Foundation, Inc.
;; Author: Arash Esbati <arash@gnu.org>
;; Maintainer: auctex-devel@gnu.org
@@ -80,26 +80,26 @@
(TeX-add-symbols
;; \attachfile[<options>]{<filename>}
- '("attachfile"
+ `("attachfile"
[TeX-arg-key-val LaTeX-attachfile-key-val-options]
- (TeX-arg-eval
- (lambda ()
+ ,(lambda (optional)
(let ((atfi (file-relative-name
- (read-file-name "File to attach: "))))
- (format "%s" atfi)))))
+ (read-file-name
+ (TeX-argument-prompt optional nil "File to attach")))))
+ (TeX-argument-insert atfi optional))))
;; \noattachfile[<options>]
'("noattachfile"
[TeX-arg-key-val LaTeX-attachfile-key-val-options] )
;; \textattachfile[<options>]{<filename>}{<text>}
- '("textattachfile"
+ `("textattachfile"
[TeX-arg-key-val LaTeX-attachfile-key-val-options]
- (TeX-arg-eval
- (lambda ()
+ ,(lambda (optional)
(let ((atfi (file-relative-name
- (read-file-name "File to attach: "))))
- (format "%s" atfi))))
+ (read-file-name
+ (TeX-argument-prompt optional nil "File to attach")))))
+ (TeX-argument-insert atfi optional)))
t)
;; \notextattachfile[<options>]{<text>}
diff --git a/style/babel.el b/style/babel.el
index c58ea9fa..70cc5658 100644
--- a/style/babel.el
+++ b/style/babel.el
@@ -40,6 +40,9 @@
(declare-function font-latex-add-keywords
"font-latex"
(keywords class))
+(declare-function LaTeX-fontspec-auto-cleanup
+ "fontspec"
+ ())
(defvar LaTeX-babel-language-list
'("afrikaans"
@@ -202,10 +205,9 @@
(let ((fam (concat elt "family"))
(def (concat elt "default"))
(mac (concat "text" elt)))
- (apply #'TeX-add-symbols
- `((,fam -1)
- (,def -1)
- (,mac t)))
+ (apply #'TeX-add-symbols `((,fam -1)
+ (,def -1)
+ (,mac t)))
;; Cater for fontification:
(when (and (featurep 'font-latex)
(eq TeX-install-font-lock 'font-latex-setup))
@@ -229,20 +231,6 @@
(add-hook 'TeX-auto-cleanup-hook #'LaTeX-babel-auto-cleanup t)
(add-hook 'TeX-update-style-hook #'TeX-auto-parse t)
-(defun TeX-arg-babel-lang (optional &optional prompt)
- "Prompt for a language with completion and insert it as an argument."
- (TeX-argument-insert
- (completing-read
- (TeX-argument-prompt optional prompt "Language")
- (LaTeX-babel-active-languages))
- optional))
-
-(defun LaTeX-env-babel-lang (env)
- "Prompt for a language and insert it as an argument of ENV."
- (LaTeX-insert-environment
- env (format "{%s}" (completing-read "Language: "
- (LaTeX-babel-active-languages)))))
-
(defun LaTeX-babel-load-languages ()
"Load style files of babel active languages."
;; Run style hooks for every active language in loading order, so
@@ -263,22 +251,29 @@
(TeX-add-symbols
;; 1.7 Basic language selectors
- '("selectlanguage" TeX-arg-babel-lang)
- '("foreignlanguage" TeX-arg-babel-lang t)
+ '("selectlanguage"
+ (TeX-arg-completing-read (LaTeX-babel-active-languages)
+ "Language"))
+ '("foreignlanguage"
+ (TeX-arg-completing-read (LaTeX-babel-active-languages)
+ "Language")
+ t)
;; 1.9 More on selection
'("babeltags" t)
- '("babelensure" (TeX-arg-key-val
- (("include") ("exclude")
- ("fontenc" (;; 128+ glyph encodings (text)
- "OT1" "OT2" "OT3" "OT4" "OT6"
- ;; 256 glyph encodings (text)
- "T1" "T2A" "T2B" "T2C" "T3" "T4" "T5"
- ;; 256 glyph encodings (text extended)
- "X2"
- ;; Other encodings
- "LY1" "LV1" "LGR"))))
- TeX-arg-babel-lang)
+ '("babelensure"
+ (TeX-arg-key-val
+ (("include") ("exclude")
+ ("fontenc" (;; 128+ glyph encodings (text)
+ "OT1" "OT2" "OT3" "OT4" "OT6"
+ ;; 256 glyph encodings (text)
+ "T1" "T2A" "T2B" "T2C" "T3" "T4" "T5"
+ ;; 256 glyph encodings (text extended)
+ "X2"
+ ;; Other encodings
+ "LY1" "LV1" "LGR"))))
+ (TeX-arg-completing-read (LaTeX-babel-active-languages)
+ "Language"))
;; 1.10 Shorthands
'("shorthandon" "Shorthands list")
'("shorthandoff" "Shorthands list")
@@ -289,7 +284,9 @@
[TeX-arg-completing-read-multiple (LaTeX-babel-active-languages)
"Language(s)"]
t nil)
- '("languageshorthands" TeX-arg-babel-lang)
+ '("languageshorthands"
+ (TeX-arg-completing-read (LaTeX-babel-active-languages)
+ "Language"))
'("babelshorthand" "Short hand")
'("ifbabelshorthand" "Character" t nil)
'("aliasshorthand" "Original" "Alias")
@@ -300,24 +297,26 @@
t)
;; 1.14 Selecting fonts
- '("babelfont"
+ `("babelfont"
[TeX-arg-completing-read-multiple LaTeX-babel-language-list
"Language(s)"]
- (TeX-arg-eval let ((fontfam (completing-read
- (TeX-argument-prompt nil nil "font family")
- '("rm" "sf" "tt"))))
- ;; Run `TeX-check-engine-add-engines' and then
- ;; load `fontspec.el' if not already loaded and
- ;; make sure the key-vals are up to date.
- (unless (member "fontspec" (TeX-style-list))
- (TeX-check-engine-add-engines 'luatex 'xetex)
- (TeX-run-style-hooks "fontspec")
- (LaTeX-fontspec-auto-cleanup))
- (LaTeX-add-babel-babelfonts fontfam)
- (LaTeX-babel-cleanup-babelfont)
- (format "%s" fontfam))
+ (TeX-arg-completing-read ("rm" "sf" "tt") "Font family")
[TeX-arg-key-val (LaTeX-fontspec-font-features)]
- LaTeX-fontspec-arg-font)
+ LaTeX-fontspec-arg-font
+ ,(lambda (_)
+ ;; Run `TeX-check-engine-add-engines' and then
+ ;; load `fontspec.el' if not already loaded and
+ ;; make sure the key-vals are up to date.
+ (unless (member "fontspec" (TeX-style-list))
+ (TeX-check-engine-add-engines 'luatex 'xetex)
+ (TeX-run-style-hooks "fontspec")
+ (LaTeX-fontspec-auto-cleanup))
+ ;; Now search back for the Font family arg:
+ (save-excursion
+ (re-search-backward "\\\\babelfont\\(?:\\[[^]]*\\]\\)?{\\([^}]+\\)}"
+ (line-beginning-position) t)
+ (LaTeX-add-babel-babelfonts (match-string-no-properties 1))
+ (LaTeX-babel-cleanup-babelfont))))
;; 1.16 Creating a language
'("babelprovide"
@@ -326,7 +325,10 @@
;; 1.19 Accessing language info
'("languagename" 0)
- '("iflanguage" TeX-arg-babel-lang t nil)
+ '("iflanguage"
+ (TeX-arg-completing-read (LaTeX-babel-active-languages)
+ "Language")
+ t nil)
;; 1.20 Hyphenation and line breaking
'("babelhyphen"
@@ -343,7 +345,10 @@
'("ensureascii" "Text")
;; 1.25 Language attributes
- '("languageattribute" TeX-arg-babel-lang t))
+ '("languageattribute"
+ (TeX-arg-completing-read (LaTeX-babel-active-languages)
+ "Language")
+ t))
;; Don't increase indentation at various \if* macros:
(let ((exceptions '("ifbabelshorthand"
@@ -354,9 +359,15 @@
;; New environments: 1.8 Auxiliary language selectors
(LaTeX-add-environments
- '("otherlanguage" LaTeX-env-babel-lang)
- '("otherlanguage*" LaTeX-env-babel-lang)
- '("hyphenrules" LaTeX-env-babel-lang))
+ '("otherlanguage" LaTeX-env-args
+ (TeX-arg-completing-read (LaTeX-babel-active-languages)
+ "Language"))
+ '("otherlanguage*" LaTeX-env-args
+ (TeX-arg-completing-read (LaTeX-babel-active-languages)
+ "Language"))
+ '("hyphenrules" LaTeX-env-args
+ (TeX-arg-completing-read (LaTeX-babel-active-languages)
+ "Language")))
;; Fontification
(when (and (featurep 'font-latex)
diff --git a/style/beamer.el b/style/beamer.el
index 589a26ad..9a33b348 100644
--- a/style/beamer.el
+++ b/style/beamer.el
@@ -1,8 +1,9 @@
;;; beamer.el --- AUCTeX style for the latex-beamer class -*-
lexical-binding: t; -*-
-;; Copyright (C) 2003-2021 Free Software Foundation, Inc.
+;; Copyright (C) 2003-2022 Free Software Foundation, Inc.
;; Author: Thomas Baumann <thomas.baumann@ch.tum.de>
+;; Maintainer: auctex-devel@gnu.org
;; Created: 2003-12-20
;; Keywords: tex
@@ -41,7 +42,7 @@
"Do beamer-specific stuff after the insertion of an environment."
;; Add `fragile' as an optional argument to the frame environment if
;; a verbatim environment is inserted.
- (when (and (TeX-member env (LaTeX-verbatim-environments) #'string-equal)
+ (when (and (member env (LaTeX-verbatim-environments))
(save-excursion
(goto-char start)
(string-equal (LaTeX-current-environment) "frame")))
@@ -49,6 +50,7 @@
(when (re-search-backward "\\\\begin[ \t]*{frame}" nil t)
(let ((end-of-begin (match-end 0)))
(goto-char end-of-begin)
+ ;; FIXME: Add support for skipping over overlay options.
(while (forward-comment 1))
(if (eq (char-after) (string-to-char LaTeX-optop))
(progn
@@ -70,16 +72,26 @@
(TeX-run-style-hooks "amsmath" "amssymb" "amsthm" "color" "geometry"
"hyperref" "inputenc" "translator" "xcolor")
- (unless LaTeX-beamer-section-labels-flag
- (make-local-variable 'LaTeX-section-hook)
- (setq LaTeX-section-hook
- '(LaTeX-section-heading
- LaTeX-section-title
- LaTeX-section-section)))
+ (LaTeX-section-list-add-locally
+ '(("part" 0)
+ ("section" 1)
+ ("subsection" 2)
+ ("subsubsection" 3))
+ t)
+ (LaTeX-largest-level-set "part")
+ (make-local-variable 'LaTeX-section-hook)
+ (setq LaTeX-section-hook
+ '(LaTeX-section-heading
+ LaTeX-section-title
+ LaTeX-beamer-section))
+ (if LaTeX-beamer-section-labels-flag
+ (setq LaTeX-section-hook
+ (append LaTeX-section-hook '(LaTeX-section-label))))
(setq LaTeX-item-list
(append '(("itemize" . LaTeX-item-beamer)
- ("enumerate" . LaTeX-item-beamer))
+ ("enumerate" . LaTeX-item-beamer)
+ ("thebibliography" . LaTeX-bibitem-beamer))
LaTeX-item-list))
(setq LaTeX-default-document-environment "frame")
@@ -87,96 +99,240 @@
(LaTeX-paragraph-commands-add-locally "frametitle")
(TeX-add-symbols
- '("alert" [ TeX-arg-beamer-overlay-spec ] 1)
- '("alt" [ TeX-arg-beamer-overlay-spec ] 2)
+ '("AtBeginSection" ["Special star text"] t)
+ '("AtBeginSubsection" ["Special star text"] t)
+ '("AtBeginSubsubsection" ["Special star text"] t)
+ '("AtBeginPart" t)
+ '("AtBeginLecture" t)
+ '("AtBeginNote" t)
+ '("AtEndNote" t)
+ '("action" [TeX-arg-beamer-overlay-spec "Action spec"] t)
+ '("againframe" [TeX-arg-beamer-overlay-spec]
+ [TeX-arg-beamer-default-overlay-spec]
+ ["Options"] "Frame label")
+ '("alert" [TeX-arg-beamer-overlay-spec] 1)
+ '("alt" TeX-arg-beamer-overlay-spec "Text on specified slides"
+ "Text on other slides")
+ '("appendix" [TeX-arg-beamer-overlay-spec "Mode spec"])
+ '("author" [LaTeX-arg-author "Short author names"] LaTeX-arg-author)
+ '("beamerdefaultoverlayspecification"
+ TeX-arg-beamer-default-overlay-spec)
'("beamerbutton" 1)
'("beamergotobutton" 1)
'("beamerreturnbutton" 1)
'("beamerskipbutton" 1)
- '("frame" TeX-arg-beamer-frametitle)
+ '("column" [TeX-arg-beamer-overlay-spec] ["Placement(t,T,c,b)"]
+ (TeX-arg-length "Column width"))
+ '("date" [TeX-arg-date "Short date"] TeX-arg-date)
+ ;; Beamer frame macro is obsolete, and standard LaTeX frame macro
+ ;; is available in frame environment.
+ ;; '("frame" TeX-arg-beamer-frametitle)
+ "framebreak" "noframebreak"
+ '("framelatex" t)
'("frametitle"
- (TeX-arg-eval TeX-read-string "Title: " nil
'LaTeX-beamer-frametitle-history))
- '("hyperlink" [ TeX-arg-beamer-overlay-spec ] 2)
- '("hyperlinkslideprev" [ TeX-arg-beamer-overlay-spec ] 1)
- '("hyperlinkslidenext" [ TeX-arg-beamer-overlay-spec ] 1)
- '("hyperlinkframestart" [ TeX-arg-beamer-overlay-spec ] 1)
- '("hyperlinkframeend" [ TeX-arg-beamer-overlay-spec ] 1)
- '("hyperlinkframestartnext" [ TeX-arg-beamer-overlay-spec ] 1)
- '("hyperlinkframeendprev" [ TeX-arg-beamer-overlay-spec ] 1)
- '("hyperlinkpresentationstart" [ TeX-arg-beamer-overlay-spec ] 1)
- '("hyperlinkpresentationend" [ TeX-arg-beamer-overlay-spec ] 1)
- '("hyperlinkappendixstart" [ TeX-arg-beamer-overlay-spec ] 1)
- '("hyperlinkappendixend" [ TeX-arg-beamer-overlay-spec ] 1)
- '("hyperlinkdocumentstart" [ TeX-arg-beamer-overlay-spec ] 1)
- '("hyperlinkdocumentend" [ TeX-arg-beamer-overlay-spec ] 1)
- '("hypertarget" [ TeX-arg-beamer-overlay-spec ] 2)
- '("institute" 1)
- '("invisible" [ TeX-arg-beamer-overlay-spec ] 1)
- '("label" [ TeX-arg-beamer-overlay-spec ] 1)
+ [TeX-arg-beamer-overlay-spec] ["Short title"]
+ (TeX-arg-string "Title" nil LaTeX-beamer-frametitle-history))
+ '("framesubtitle" [TeX-arg-beamer-overlay-spec] "Subtitle")
+ '("framezoom" (TeX-arg-beamer-overlay-spec "Overlay having button")
+ (TeX-arg-beamer-overlay-spec "Zoomed overlay") ["Options"]
+ (TeX-arg-pair "Upper left X" "Upper left Y")
+ (TeX-arg-pair "Zoom area width" "Zoom area depth"))
+ '("hyperlink" [TeX-arg-beamer-overlay-spec] "Target name" t)
+ '("hyperlinkslideprev" [TeX-arg-beamer-overlay-spec] 1)
+ '("hyperlinkslidenext" [TeX-arg-beamer-overlay-spec] 1)
+ '("hyperlinkframestart" [TeX-arg-beamer-overlay-spec] 1)
+ '("hyperlinkframeend" [TeX-arg-beamer-overlay-spec] 1)
+ '("hyperlinkframestartnext" [TeX-arg-beamer-overlay-spec] 1)
+ '("hyperlinkframeendprev" [TeX-arg-beamer-overlay-spec] 1)
+ '("hyperlinksectionstart" [TeX-arg-beamer-overlay-spec] 1)
+ '("hyperlinksectionend" [TeX-arg-beamer-overlay-spec] 1)
+ '("hyperlinksectionstartnext" [TeX-arg-beamer-overlay-spec] 1)
+ '("hyperlinksectionendprev" [TeX-arg-beamer-overlay-spec] 1)
+ '("hyperlinksubsectionstart" [TeX-arg-beamer-overlay-spec] 1)
+ '("hyperlinksubsectionend" [TeX-arg-beamer-overlay-spec] 1)
+ '("hyperlinksubsectionstartnext" [TeX-arg-beamer-overlay-spec] 1)
+ '("hyperlinksubsectionendprev" [TeX-arg-beamer-overlay-spec] 1)
+ '("hyperlinkpresentationstart" [TeX-arg-beamer-overlay-spec] 1)
+ '("hyperlinkpresentationend" [TeX-arg-beamer-overlay-spec] 1)
+ '("hyperlinkappendixstart" [TeX-arg-beamer-overlay-spec] 1)
+ '("hyperlinkappendixend" [TeX-arg-beamer-overlay-spec] 1)
+ '("hyperlinkdocumentstart" [TeX-arg-beamer-overlay-spec] 1)
+ '("hyperlinkdocumentend" [TeX-arg-beamer-overlay-spec] 1)
+ '("hypertarget" [TeX-arg-beamer-overlay-spec] "Target name" t)
+ '("includegraphics" [TeX-arg-beamer-overlay-spec]
+ [LaTeX-arg-graphicx-includegraphics-key-val] LaTeX-arg-includegraphics)
+ '("includeonlyframes" "Frame label(s)")
+ '("includeonlylecture" "Lecture label")
+ '("includeslide" ["Options"] "Label")
+ '("institute" ["Short institute name"] t)
+ '("invisible" [TeX-arg-beamer-overlay-spec] 1)
+ '("keywords" t)
+ '("label" [TeX-arg-beamer-overlay-spec] TeX-arg-label)
+ '("lecture" ["Short lecture name"] "Lecture name" "Lecture label")
'("logo" 1)
- '("note" TeX-arg-beamer-note 1)
- '("only" [ TeX-arg-beamer-overlay-spec ] 1)
- '("onslide" [ TeX-arg-beamer-overlay-spec ])
- '("partpage")
+ '("mode" [TeX-arg-beamer-overlay-spec "Mode"] t)
+ "mode*"
+
+ ;; Adapted copies from latex.el
+ '("newcommand<>" TeX-arg-define-macro [TeX-arg-define-macro-arguments] t)
+ '("renewcommand<>" TeX-arg-macro [TeX-arg-define-macro-arguments] t)
+ '("newenvironment<>" TeX-arg-define-environment
+ [TeX-arg-define-macro-arguments] 2)
+ '("renewenvironment<>" TeX-arg-environment
+ [TeX-arg-define-macro-arguments] 2)
+
+ ;; TODO: Support the case \note is used outside frame env.
+ '("note" [TeX-arg-beamer-overlay-spec] ["Options"] t)
+ '("only" [TeX-arg-beamer-overlay-spec] 1)
+ '("onslide" [TeX-arg-beamer-overlay-spec])
+ "partpage"
'("pause" ["Slide number"])
- '("structure" [ TeX-arg-beamer-overlay-spec ] 1)
- '("temporal" [ TeX-arg-beamer-overlay-spec ] 3)
- '("titlepage")
+ '("resetcounteronoverlays" TeX-arg-counter)
+ "sectionpage"
+ '("setbeameroption" t)
+ '("setbeamersize" t)
+ '("setjobnamebeamerversion" "Filename without extension")
+ '("structure" [TeX-arg-beamer-overlay-spec] 1)
+ "subsectionpage"
+ '("subtitle" ["Short subtitle"] t)
+ '("subject" t)
+ '("tableofcontents" ["Options"])
+ '("temporal" TeX-arg-beamer-overlay-spec
+ "Before slide text" "Default text" "After slide text")
+ "titlepage"
+ '("title" ["Short title"] t)
'("titlegraphic" 1)
- '("uncover" [ TeX-arg-beamer-overlay-spec ] 1)
- '("usetheme" LaTeX-arg-beamer-theme)
- '("useinnertheme" LaTeX-arg-beamer-inner-theme)
- '("useoutertheme" LaTeX-arg-beamer-outer-theme)
- '("usecolortheme" LaTeX-arg-beamer-color-theme)
- '("usefonttheme" LaTeX-arg-beamer-font-theme)
- '("usetheme" LaTeX-arg-beamer-theme)
- '("visible" [ TeX-arg-beamer-overlay-spec ] 1))
+
+ '("transblindshorizontal" [TeX-arg-beamer-overlay-spec] ["Options"])
+ '("transblindsvertical" [TeX-arg-beamer-overlay-spec] ["Options"])
+ '("transboxin" [TeX-arg-beamer-overlay-spec] ["Options"])
+ '("transboxout" [TeX-arg-beamer-overlay-spec] ["Options"])
+ '("transcover" [TeX-arg-beamer-overlay-spec] ["Options"])
+ '("transdissolve" [TeX-arg-beamer-overlay-spec] ["Options"])
+ '("transfade" [TeX-arg-beamer-overlay-spec] ["Options"])
+ '("transfly" [TeX-arg-beamer-overlay-spec] ["Options"])
+ '("transglitter" [TeX-arg-beamer-overlay-spec] ["Options"])
+ '("transpush" [TeX-arg-beamer-overlay-spec] ["Options"])
+ '("transreplace" [TeX-arg-beamer-overlay-spec] ["Options"])
+ '("transsplitverticalin" [TeX-arg-beamer-overlay-spec] ["Options"])
+ '("transsplitverticalout" [TeX-arg-beamer-overlay-spec] ["Options"])
+ '("transsplithorizontalin" [TeX-arg-beamer-overlay-spec] ["Options"])
+ '("transsplithorizontalout" [TeX-arg-beamer-overlay-spec] ["Options"])
+ '("transwipe" [TeX-arg-beamer-overlay-spec] ["Options"])
+ '("transduration" [TeX-arg-beamer-overlay-spec] "Seconds")
+
+ '("uncover" [TeX-arg-beamer-overlay-spec] t)
+ '("usetheme" ["Options"]
+ (TeX-arg-completing-read (LaTeX-beamer-themes-list) "Theme"))
+ '("useinnertheme" ["Options"]
+ (TeX-arg-completing-read (LaTeX-beamer-inner-themes-list) "Theme"))
+ '("useoutertheme" ["Options"]
+ (TeX-arg-completing-read (LaTeX-beamer-outer-themes-list) "Theme"))
+ '("usecolortheme" ["Options"]
+ (TeX-arg-completing-read (LaTeX-beamer-color-themes-list) "Theme"))
+ '("usefonttheme" ["Options"]
+ (TeX-arg-completing-read (LaTeX-beamer-font-themes-list) "Theme"))
+ '("setbeamercolor" "Beamer color" "Color specification")
+ '("setbeamercolor*" "Beamer color" "Color specification")
+ '("usebeamercolor" ["fg or bg"] "Beamer color")
+ '("usebeamercolor*" ["fg or bg"] "Beamer color")
+ '("setbeamerfont" "Beamer font" "Font attributes")
+ '("setbeamerfont*" "Beamer font" "Font attributes")
+ '("usebeamerfont" "Beamer font")
+ '("usebeamerfont*" "Beamer font")
+ '("setbeamertemplate" "Element" ["Predefined option"] t)
+ '("addtobeamertemplate" "Element" "Pre text" "Post test")
+ '("defbeamertemplate" [TeX-arg-beamer-overlay-spec "Mode spec"]
+ "Element" "Predefined option" [TeX-arg-define-macro-arguments] t)
+ '("defbeamertemplatealias" "Element" "New predefined option"
+ "Existing predefined option")
+ '("defbeamertemplateparent" "Parent template name"
+ ["Predefined option"] "Child template list"
+ [TeX-arg-define-macro-arguments] t)
+ '("ifbeamercolorempty" ["fg or bg"] "Beamer color name"
+ "If undefined" "If defined")
+ '("setbeamercovered" "Options")
+ '("opaqueness" [TeX-arg-beamer-overlay-spec] "Opaqueness (in %)")
+
+ '("visible" [TeX-arg-beamer-overlay-spec] 1))
+
+ ;; TODO: Font commands accept overlay specs.
+ ;; Support commands to manipulate templates?
(LaTeX-add-environments
- '("actionenv")
- '("alertblock" 1)
- '("beamerboxesrounded" 1)
- '("block" (lambda (env &rest ignore)
- (LaTeX-insert-environment
- env (format "{%s}" (TeX-read-string "Title: ")))))
- '("column" "Width")
- "columns"
- "columnsonlytextwidth"
- '("exampleblock" 1)
- '("frame" (lambda (env &rest ignore)
- (let ((title (TeX-read-string "(Optional) Title: " nil
-
'LaTeX-beamer-frametitle-history)))
- (LaTeX-insert-environment env)
- (unless (zerop (length title))
- (save-excursion
- (LaTeX-find-matching-begin)
- (end-of-line)
- (LaTeX-newline)
- ;; Indent the next macro insertion and don't
- ;; rely on the fill-function to do it:
- (indent-according-to-mode)
- (insert (format "\\frametitle{%s}" title))
- ;; This works because \frametitle is a
- ;; paragraph command.
- (when auto-fill-function
- (backward-char)
- (LaTeX-fill-paragraph)))))))
- '("onlyenv" (lambda (env &rest ignore)
- (LaTeX-insert-environment
- env
- (let ((overlay (TeX-read-string "(Optional) Overlay: ")))
- (unless (zerop (length overlay))
- (format "<%s>" overlay))))))
- '("overlayarea" "Area width" "Area height")
- '("overprint" (lambda (env &rest ignore)
- (LaTeX-insert-environment
- env
- (let ((width (TeX-read-string "(Optional) Area width:
")))
- (unless (zerop (length width))
- (format "[%s]" width))))))
- "semiverbatim")
-
- (LaTeX-largest-level-set "section")
+ '("abstract" LaTeX-env-args
+ [TeX-arg-beamer-overlay-spec "Action spec"])
+ '("actionenv" LaTeX-env-args
+ [TeX-arg-beamer-overlay-spec "Action spec"])
+ '("alertblock" LaTeX-env-args
+ [TeX-arg-beamer-overlay-spec "Action spec"] "Title")
+ '("beamerboxesrounded" ["Options"] "Header")
+ '("beamercolorbox" ["Options"] "Beamer color")
+ '("block" LaTeX-env-args
+ [TeX-arg-beamer-overlay-spec "Action spec"] "Title")
+ '("column" LaTeX-env-args [TeX-arg-beamer-overlay-spec]
+ ["Placement(t,T,c,b)"] (TeX-arg-length "Width"))
+ '("columns" LaTeX-env-args [TeX-arg-beamer-overlay-spec] ["Options"])
+ ;; FIXME: Not on user reference.
+ ;; "columnsonlytextwidth"
+ '("exampleblock" LaTeX-env-args
+ [TeX-arg-beamer-overlay-spec "Action spec"] "Title")
+ '("frame" LaTeX-env-args [TeX-arg-beamer-overlay-spec]
+ [TeX-arg-beamer-default-overlay-spec]
+ [TeX-arg-key-val (("allowdisplaybreaks" ("0" "1" "2" "3" "4"))
+ ("allowframebreaks") ("b") ("c") ("t") ("s")
+ ("noframenumbering")
+ ("fragile" ("singleslide"))
+ ("environment") ("label") ("plain") ("shrink")
+ ("squeeze"))]
+ LaTeX-beamer-env-frame)
+
+ '("onlyenv" LaTeX-env-args [TeX-arg-beamer-overlay-spec])
+ '("altenv" LaTeX-env-args [TeX-arg-beamer-overlay-spec]
+ "Begin text" "End text" "Alternate begin text" "Alternate end text")
+ '("visibleenv" LaTeX-env-args [TeX-arg-beamer-overlay-spec])
+ '("uncoverenv" LaTeX-env-args [TeX-arg-beamer-overlay-spec])
+ '("invisibleenv" LaTeX-env-args [TeX-arg-beamer-overlay-spec])
+
+ '("structureenv" LaTeX-env-args [TeX-arg-beamer-overlay-spec])
+ '("alertenv" LaTeX-env-args [TeX-arg-beamer-overlay-spec])
+
+ '("theorem" LaTeX-env-args
+ [TeX-arg-beamer-overlay-spec "Action spec"] ["Additional text"])
+ '("corollary" LaTeX-env-args
+ [TeX-arg-beamer-overlay-spec "Action spec"] ["Additional text"])
+ '("definition" LaTeX-env-args
+ [TeX-arg-beamer-overlay-spec "Action spec"] ["Additional text"])
+ '("definitions" LaTeX-env-args
+ [TeX-arg-beamer-overlay-spec "Action spec"] ["Additional text"])
+ '("fact" LaTeX-env-args
+ [TeX-arg-beamer-overlay-spec "Action spec"] ["Additional text"])
+ '("lemma" LaTeX-env-args
+ [TeX-arg-beamer-overlay-spec "Action spec"] ["Additional text"])
+ '("example" LaTeX-env-args
+ [TeX-arg-beamer-overlay-spec "Action spec"] ["Additional text"])
+ '("examples" LaTeX-env-args
+ [TeX-arg-beamer-overlay-spec "Action spec"] ["Additional text"])
+ '("proof" LaTeX-env-args
+ [TeX-arg-beamer-overlay-spec "Action spec"] ["Proof name"])
+
+ '("overlayarea" LaTeX-env-args
+ (TeX-arg-length "Area width") (TeX-arg-length "Area height"))
+ '("overprint" LaTeX-env-args [TeX-arg-length "Area width"])
+ "semiverbatim"
+
+ '("verse" LaTeX-env-args
+ [TeX-arg-beamer-overlay-spec "Action spec"])
+ '("quotation" LaTeX-env-args
+ [TeX-arg-beamer-overlay-spec "Action spec"])
+ '("quote" LaTeX-env-args
+ [TeX-arg-beamer-overlay-spec "Action spec"]))
+
+ ;; TODO: itemize, enumerate and description envs accept default
+ ;; overlay spec as optional argument.
+ ;; We definitely need more completion support for both macros and
+ ;; environments.
+
(LaTeX-add-counters "lecture" "part" "section" "subsection" "subsubsection"
"subsectionslide" "framenumber" "figure" "table"
"beamerpauses")
@@ -192,7 +348,67 @@
("subtitle" "[{")
("author" "[{")
("date" "[{")
- ("frametitle" "<[{")) 'slide-title)))
+ ("institute" "[{")
+ ("frametitle" "<[{")
+ ("framesubtitle" "<[{"))
+ 'slide-title)
+ (font-latex-add-keywords '(("item" "<[")
+ ("bibitem" "<[{"))
+ 'textual)
+ (font-latex-add-keywords '(("textbf" "<{")
+ ("textsc" "<{")
+ ("textup" "<{"))
+ 'bold-command)
+ (font-latex-add-keywords '(("emph" "<{")
+ ("textit" "<{")
+ ("textsl" "<{"))
+ 'italic-command)
+ (font-latex-add-keywords '(("textmd" "<{")
+ ("textrm" "<{")
+ ("textsf" "<{")
+ ("texttt" "<{")
+ ("textnormal" "<{")
+ ("textcolor" "<[{"))
+ 'type-command)
+ (font-latex-add-keywords '(("color" "<[{"))
+ 'type-declaration)
+ (font-latex-add-keywords '(("label" "<{")
+ ("hyperlink" "<{{<")
+ ("hypertarget" "<{{"))
+ 'reference)
+ (font-latex-add-keywords '(("pause" "[")
+ ("logo" "{")
+ ("newcommand" "<|{\\[[{")
+ ("renewcommand" "<|{\\[[{")
+ ("newenvironment" "<{[[{{")
+ ("renewenvironment" "<{[[{{")
+ ("AtBeginSection" "[{")
+ ("AtBeginSubsection" "[{")
+ ("AtBeginSubsubsection" "[{")
+ ("AtBeginPart" "{")
+ ("AtBeginLecture" "{")
+ ("titlepage" "")
+ ("sectionpage" "")
+ ("subsectionpage" "")
+ ("partpage" "")
+ ("tableofcontents" "[")
+ ("column" "<[{")
+ ("againframe" "<[[{")
+ ("usetheme" "[{")
+ ("usecolortheme" "[{")
+ ("usefonttheme" "[{")
+ ("useinnertheme" "[{")
+ ("useoutertheme" "[{")
+ ("includeonlyframes" "{")
+ ("includeonlylecture" "{"))
+ 'function)
+ (font-latex-add-keywords '(("resetcounteronoverlays" "{"))
+ 'variable))
+ ;; TODO: Adjust section commands to accept <> option.
+
+ ;; Additional intermediate files
+ (add-to-list (make-local-variable 'LaTeX-clean-intermediate-suffixes)
+ "\\.vrb"))
TeX-dialect)
(defun TeX-arg-beamer-overlay-spec (optional &optional prompt)
@@ -200,47 +416,55 @@
If OPTIONAL is non-nil, insert the specification only if
non-empty and enclosed in \"<>\". PROMPT replaces the standard
one."
- (let ((TeX-arg-opening-brace "<")
- (TeX-arg-closing-brace ">"))
- (TeX-argument-insert
- (TeX-read-string
- (TeX-argument-prompt optional prompt "Overlay"))
- optional)
- (indent-according-to-mode)))
-
-(defun TeX-arg-beamer-frametitle (_optional &optional _prompt)
- "Prompt for the frametitle."
- (let ((title (TeX-read-string "Title: " nil
'LaTeX-beamer-frametitle-history)))
- (if (not (zerop (length title)))
- (insert TeX-grop TeX-esc "frametitle" TeX-grop
- title TeX-grcl TeX-grcl)
- (insert TeX-grop TeX-grcl))))
-
-(defun LaTeX-item-beamer ()
- "Insert a new item with an optional overlay argument. You
-can turn off the prompt for the overlay argument by setting
-`LaTeX-beamer-item-overlay-flag' to nil. Calling the function
+ (TeX-arg-string optional (or prompt "Overlay") nil nil nil "<" ">")
+ (indent-according-to-mode))
+
+(defun TeX-arg-beamer-default-overlay-spec (optional)
+ "Prompt for default overlay specification.
+If OPTIONAL is non-nil, insert the specification only if
+non-empty and enclosed in \"<>\". If empty and OPTIONAL is nil,
+insert just \"{}\"."
+ (let ((spec (TeX-read-string
+ (TeX-argument-prompt optional nil "Default overlay"))))
+ (cond
+ ((< 0 (length spec))
+ (TeX-argument-insert (concat "<" spec ">") optional))
+ ((not optional)
+ ;; Clear default for \beamerdefaultoverlayspecification.
+ (insert TeX-grop TeX-grcl))
+ (t
+ ;; Nop for clarity.
+ nil))))
+
+;; (defun TeX-arg-beamer-frametitle (_optional &optional _prompt)
+;; "Prompt for the frametitle."
+;; (let ((title (TeX-read-string "Title: " nil
'LaTeX-beamer-frametitle-history)))
+;; (if (not (zerop (length title)))
+;; (insert TeX-grop TeX-esc "frametitle" TeX-grop
+;; title TeX-grcl TeX-grcl)
+;; (insert TeX-grop TeX-grcl))))
+
+(defun LaTeX-item-beamer (&optional macro)
+ "Insert a new item with an optional overlay argument.
+You can turn off the prompt for the overlay argument by setting
+`LaTeX-beamer-item-overlay-flag' to nil. Calling the function
with a prefix argument prompts for the overlay specification
-unconditionally."
- (if (listp current-prefix-arg)
- (setq current-prefix-arg (car current-prefix-arg))
- current-prefix-arg)
- (TeX-insert-macro "item")
+unconditionally.
+
+Optional MACRO can be, for example, \"bibitem\"."
+ (TeX-insert-macro (or macro "item"))
(delete-horizontal-space)
(if (or current-prefix-arg LaTeX-beamer-item-overlay-flag)
- (TeX-arg-beamer-overlay-spec 0))
- (insert " ")
- (indent-according-to-mode))
+ (TeX-arg-beamer-overlay-spec t))
+ (insert " "))
-(defun TeX-arg-beamer-note (_optional &optional _prompt)
- "Prompt for overlay specification and optional argument."
- (let ((overlay (TeX-read-string "(Optional) Overlay: "))
- (options (TeX-read-string "(Optional) Options: ")))
- (unless (zerop (length overlay))
- (insert "<" overlay ">"))
- (unless (zerop (length options))
- (insert "[" options "]"))
- (indent-according-to-mode)))
+(defun LaTeX-bibitem-beamer ()
+ "Insert a new bibitem with an optional overlay argument.
+You can turn off the prompt for the overlay argument by setting
+`LaTeX-beamer-item-overlay-flag' to nil. Calling the function
+with a prefix argument prompts for the overlay specification
+unconditionally."
+ (LaTeX-item-beamer "bibitem"))
(defun LaTeX-beamer-search-themes (&optional regexp extensions length)
"Search for beamer themes matching REGEXP with EXTENSIONS.
@@ -252,7 +476,7 @@ also be a string. Then the length of the string is used."
(chars (cond ((integerp length)
length)
((stringp length)
- (string-width length))
+ (length length))
;; Try some DWIM magic...
((and (not length)
(string-match "beamer[A-Za-z0-9]*theme" match))
@@ -265,117 +489,139 @@ also be a string. Then the length of the string is
used."
(lambda (file)
(let ((case-fold-search nil))
(and (numberp (string-match match file))
- (substring file chars))))
+ (substring-no-properties file chars))))
(TeX-search-files nil exts t t))))))
-(defun LaTeX-arg-beamer-theme (&rest _ignore)
- "Prompt for beamer theme with completion."
- (TeX-argument-insert
- (completing-read
- (TeX-argument-prompt nil nil "Theme")
- (mapcar #'list
- (cond ((eq LaTeX-beamer-themes 'local)
- (set (make-local-variable 'LaTeX-beamer-themes)
- (LaTeX-beamer-search-themes)))
- ((functionp LaTeX-beamer-themes)
- (funcall LaTeX-beamer-themes))
- ((listp LaTeX-beamer-themes)
- LaTeX-beamer-themes)
- (t (error
- "`LaTeX-beamer-themes' should be a list: `%s'"
- LaTeX-beamer-themes))))
- nil nil nil)
- t))
-
-(defun LaTeX-arg-beamer-inner-theme (&rest _ignore)
- "Prompt for beamer inner theme with completion."
- (TeX-argument-insert
- (completing-read
- (TeX-argument-prompt nil nil "Theme")
- (mapcar #'list
- (cond ((eq LaTeX-beamer-inner-themes 'local)
- (set (make-local-variable 'LaTeX-beamer-inner-themes)
- (LaTeX-beamer-search-themes "^beamerinnertheme")))
- ((functionp LaTeX-beamer-inner-themes)
- (funcall LaTeX-beamer-inner-themes))
- ((listp LaTeX-beamer-inner-themes)
- LaTeX-beamer-inner-themes)
- (t (error
- "`LaTeX-beamer-inner-themes' should be a list: `%s'"
- LaTeX-beamer-inner-themes))))
- nil nil nil)
- t))
-
-(defun LaTeX-arg-beamer-outer-theme (&rest _ignore)
- "Prompt for beamer outer theme with completion."
- (TeX-argument-insert
- (completing-read
- (TeX-argument-prompt nil nil "Theme")
- (mapcar #'list
- (cond ((eq LaTeX-beamer-outer-themes 'local)
- (set (make-local-variable 'LaTeX-beamer-outer-themes)
- (LaTeX-beamer-search-themes "^beameroutertheme")))
- ((functionp LaTeX-beamer-outer-themes)
- (funcall LaTeX-beamer-outer-themes))
- ((listp LaTeX-beamer-outer-themes)
- LaTeX-beamer-outer-themes)
- (t (error
- "`LaTeX-beamer-outer-themes' should be a list: `%s'"
- LaTeX-beamer-outer-themes))))
- nil nil nil)
- t))
-
-(defun LaTeX-arg-beamer-color-theme (&rest _ignore)
- "Prompt for beamer color theme with completion."
- (TeX-argument-insert
- (completing-read
- (TeX-argument-prompt nil nil "Theme")
- (mapcar #'list
- (cond ((eq LaTeX-beamer-color-themes 'local)
- (set (make-local-variable 'LaTeX-beamer-color-themes)
- (LaTeX-beamer-search-themes "^beamercolortheme")))
- ((functionp LaTeX-beamer-color-themes)
- (funcall LaTeX-beamer-color-themes))
- ((listp LaTeX-beamer-color-themes)
- LaTeX-beamer-color-themes)
- (t (error
- "`LaTeX-beamer-color-themes' should be a list: `%s'"
- LaTeX-beamer-color-themes))))
- nil nil nil)
- t))
-
-(defun LaTeX-arg-beamer-font-theme (&rest _ignore)
- "Prompt for beamer font theme with completion."
- (TeX-argument-insert
- (completing-read
- (TeX-argument-prompt nil nil "Theme")
- (mapcar #'list
- (cond ((eq LaTeX-beamer-font-themes 'local)
- (set (make-local-variable 'LaTeX-beamer-font-themes)
- (LaTeX-beamer-search-themes "^beamerfonttheme")))
- ((functionp LaTeX-beamer-font-themes)
- (funcall LaTeX-beamer-font-themes))
- ((listp LaTeX-beamer-font-themes)
- LaTeX-beamer-font-themes)
- (t (error
- "`LaTeX-beamer-font-themes' should be a list: `%s'"
- LaTeX-beamer-font-themes))))
- nil nil nil)
- t))
+(defun LaTeX-beamer-themes-list ()
+ "Return a list of beamer themes for completion."
+ (cond ((eq LaTeX-beamer-themes 'local)
+ (set (make-local-variable 'LaTeX-beamer-themes)
+ (LaTeX-beamer-search-themes)))
+ ((functionp LaTeX-beamer-themes)
+ (funcall LaTeX-beamer-themes))
+ ((listp LaTeX-beamer-themes)
+ LaTeX-beamer-themes)
+ (t (error
+ "`LaTeX-beamer-themes' should be a list: `%s'"
+ LaTeX-beamer-themes))))
+
+(defun LaTeX-beamer-inner-themes-list ()
+ "Return a list of beamer inner themes for completion."
+ (cond ((eq LaTeX-beamer-inner-themes 'local)
+ (set (make-local-variable 'LaTeX-beamer-inner-themes)
+ (LaTeX-beamer-search-themes "^beamerinnertheme")))
+ ((functionp LaTeX-beamer-inner-themes)
+ (funcall LaTeX-beamer-inner-themes))
+ ((listp LaTeX-beamer-inner-themes)
+ LaTeX-beamer-inner-themes)
+ (t (error
+ "`LaTeX-beamer-inner-themes' should be a list: `%s'"
+ LaTeX-beamer-inner-themes))))
+
+(defun LaTeX-beamer-outer-themes-list ()
+ "Return a list of beamer outer themes for completion."
+ (cond ((eq LaTeX-beamer-outer-themes 'local)
+ (set (make-local-variable 'LaTeX-beamer-outer-themes)
+ (LaTeX-beamer-search-themes "^beameroutertheme")))
+ ((functionp LaTeX-beamer-outer-themes)
+ (funcall LaTeX-beamer-outer-themes))
+ ((listp LaTeX-beamer-outer-themes)
+ LaTeX-beamer-outer-themes)
+ (t (error
+ "`LaTeX-beamer-outer-themes' should be a list: `%s'"
+ LaTeX-beamer-outer-themes))))
+
+(defun LaTeX-beamer-color-themes-list ()
+ "Return a list of beamer color themes for completion."
+ (cond ((eq LaTeX-beamer-color-themes 'local)
+ (set (make-local-variable 'LaTeX-beamer-color-themes)
+ (LaTeX-beamer-search-themes "^beamercolortheme")))
+ ((functionp LaTeX-beamer-color-themes)
+ (funcall LaTeX-beamer-color-themes))
+ ((listp LaTeX-beamer-color-themes)
+ LaTeX-beamer-color-themes)
+ (t (error
+ "`LaTeX-beamer-color-themes' should be a list: `%s'"
+ LaTeX-beamer-color-themes))))
+
+(defun LaTeX-beamer-font-themes-list ()
+ "Return a list of beamer font themes for completion."
+ (cond ((eq LaTeX-beamer-font-themes 'local)
+ (set (make-local-variable 'LaTeX-beamer-font-themes)
+ (LaTeX-beamer-search-themes "^beamerfonttheme")))
+ ((functionp LaTeX-beamer-font-themes)
+ (funcall LaTeX-beamer-font-themes))
+ ((listp LaTeX-beamer-font-themes)
+ LaTeX-beamer-font-themes)
+ (t (error
+ "`LaTeX-beamer-font-themes' should be a list: `%s'"
+ LaTeX-beamer-font-themes))))
+
+(defun LaTeX-beamer-env-frame (_ignored)
+ "Insert beamer frame environment title."
+ (let ((title (TeX-read-string "(Optional) Title: " nil
+ 'LaTeX-beamer-frametitle-history)))
+ (unless (zerop (length title))
+ (save-excursion
+ (LaTeX-newline)
+ ;; Indent the next macro insertion and don't rely on the
+ ;; fill-function to do it:
+ (indent-according-to-mode)
+ (insert (format "\\frametitle{%s}" title))
+ ;; This works because \frametitle is a paragraph command.
+ (when auto-fill-function
+ (backward-char)
+ (LaTeX-fill-paragraph))))))
+
+(defun LaTeX-beamer-section ()
+ "Hook to prompt for beamer section and insert it."
+ (let ((star (string-suffix-p "*" LaTeX-name))
+ mode-spec short-title)
+ (when (and LaTeX-level (< LaTeX-level 4))
+ (setq mode-spec (TeX-read-string "(Optional) Mode spec: ")
+ short-title (unless star
+ (TeX-read-string "(Optional) Short title: "))))
+ ;; The rest of this function is adapted copy of
+ ;; `LaTeX-section-section'.
+ (unless (save-excursion
+ (re-search-backward
+ (concat "^\\s-*\n\\s-*\\=\\|^\\s-*" (regexp-quote TeX-esc)
+ "begin")
+ (line-beginning-position 0) t))
+ (LaTeX-newline))
+ (insert TeX-esc (if star
+ (substring-no-properties LaTeX-name 0 -1)
+ LaTeX-name))
+ (if (< 0 (length mode-spec))
+ (insert "<" mode-spec ">"))
+ (if star (insert "*"))
+ (if (< 0 (length short-title))
+ (insert LaTeX-optop short-title LaTeX-optcl))
+ (insert TeX-grop)
+ (if (zerop (length LaTeX-title))
+ (set-marker LaTeX-done-mark (point)))
+ (insert LaTeX-title TeX-grcl)
+ (LaTeX-newline)
+ ;; If RefTeX is available, tell it that we've just made a new section
+ (and (fboundp 'reftex-notice-new-section)
+ (reftex-notice-new-section))))
(defun LaTeX-beamer-class-options ()
"Read the beamer class options from the user."
(TeX-load-style "hyperref")
+ (TeX-load-style "color")
+ (TeX-load-style "xcolor")
(TeX-read-key-val t '(("usepdftitle" ("false")) ("envcountsect")
("notheorems") ("noamsthm") ("compress") ("t") ("c")
- ("leqno") ("fleqn") ("handout") ("trans") ("pdftex")
- ("nativepdf") ("pdfmark") ("dvips") ("dviwindo")
- ("dvipsone") ("vtex") ("ps2pdf") ("ignorenonframetext")
+ ("leqno") ("fleqn") ("handout") ("trans")
+ ("ignorenonframetext") ("onlytextwidth")
("noamssymb") ("bigger") ("smaller") ("8pt") ("9pt")
("10pt") ("11pt") ("12pt") ("14pt") ("17pt") ("20pt")
("draft") ("CJK") ("cjk") ("pgf")
("hyperref" LaTeX-hyperref-package-options-list)
- ("color") ("xcolor") ("ucs") ("utf8x") ("utf8")
- ("aspectratio" ("1610" "169" "149" "54" "43" "32")))))
+ ("color" LaTeX-color-package-options)
+ ("xcolor" LaTeX-xcolor-package-options)
+ ("ucs") ("utf8x") ("utf8")
+ ("aspectratio" ("2013" "1610" "169" "149" "141" "54"
"43" "32")))))
;;; beamer.el ends here
diff --git a/style/beamerarticle.el b/style/beamerarticle.el
index 136947ac..09d58163 100644
--- a/style/beamerarticle.el
+++ b/style/beamerarticle.el
@@ -32,4 +32,8 @@
(TeX-add-style-hook
"beamerarticle"
(lambda ()
- (TeX-run-style-hooks "beamer")))
+ (TeX-run-style-hooks "beamer")
+
+ (LaTeX-section-list-add-locally
+ '(("paragraph" 4)
+ ("subparagraph" 5)))))
diff --git a/style/bigstrut.el b/style/bigstrut.el
index 874a1180..ae14b3b2 100644
--- a/style/bigstrut.el
+++ b/style/bigstrut.el
@@ -41,7 +41,9 @@
"bigstrut"
(lambda ()
(TeX-add-symbols
- '("bigstrut" [ TeX-arg-bigstrut ]))
+ '("bigstrut"
+ [TeX-arg-completing-read ("t" "b")
+ "Strut to top (t) or bottom (b)"]))
(LaTeX-add-lengths "bigstrutjot")
@@ -52,17 +54,6 @@
'function)))
TeX-dialect)
-(defun TeX-arg-bigstrut (optional &optional prompt)
- "Prompt for the optional argument in \\bigstrut.
-If OPTIONAL is non-nil, insert the argument in brackets. PROMPT
-replaces the standard one."
- (TeX-argument-insert
- (completing-read
- (TeX-argument-prompt
- optional prompt "Strut to top (t) or bottom (b)")
- '("t" "b"))
- optional))
-
(defvar LaTeX-bigstrut-package-options nil
"Package options for the bigstrut package.")
diff --git a/style/booktabs.el b/style/booktabs.el
index 79571ea3..bf3c0f53 100644
--- a/style/booktabs.el
+++ b/style/booktabs.el
@@ -1,6 +1,6 @@
;;; booktabs.el -- AUCTeX style for booktabs.sty -*- lexical-binding: t; -*-
-;; Copyright (C) 2003, 2004, 2013, 2018, 2020 Free Software Foundation, Inc.
+;; Copyright (C) 2003--2022 Free Software Foundation, Inc.
;; Author: Ralf Angeli <angeli@iwi.uni-sb.de>
;; Maintainer: auctex-devel@gnu.org
@@ -37,14 +37,6 @@
"font-latex"
(keywords class))
-(defun LaTeX-booktabs-arg-paren (optional prompt)
- "Prompt for a value and use parentheses when it is inserted.
-If OPTIONAL is non-nil the parameter is labeled as optional.
-PROMPT is the value of the prompt to be shown."
- (let ((TeX-arg-opening-brace "(")
- (TeX-arg-closing-brace ")"))
- (TeX-parse-argument optional prompt)))
-
(TeX-add-style-hook
"booktabs"
(lambda ()
@@ -61,7 +53,8 @@ PROMPT is the value of the prompt to be shown."
'("bottomrule" [ "Thickness" ])
;; The `ignore' resets `TeX-last-optional-rejected' to nil so that the trim
;; argument is prompted also when the thickness is skipped.
- '("cmidrule" [ "Thickness" ] (ignore) [ LaTeX-booktabs-arg-paren "Trim" ]
+ '("cmidrule" [ "Thickness" ] (ignore)
+ [TeX-arg-string "Trim" nil nil nil "(" ")"]
"Column(s)")
'("addlinespace" [ "Height" ])
'("morecmidrules")
diff --git a/style/breqn.el b/style/breqn.el
index 03520556..bdca5283 100644
--- a/style/breqn.el
+++ b/style/breqn.el
@@ -1,6 +1,6 @@
;;; breqn.el --- AUCTeX style for `breqn.sty' (v0.98j) -*- lexical-binding:
t; -*-
-;; Copyright (C) 2017--2020 Free Software Foundation, Inc.
+;; Copyright (C) 2017--2022 Free Software Foundation, Inc.
;; Author: Arash Esbati <arash@gnu.org>
;; Maintainer: auctex-devel@gnu.org
@@ -64,6 +64,17 @@
"Key=value options for breqn environments.
The keys \"label\" and \"labelprefix\" are omitted.")
+(defun LaTeX-breqn-key-val-options ()
+ "Return updated key=val's based on the current \"breqn\" environment."
+ (let ((currenv (LaTeX-current-environment)))
+ (cond ((string-match-p "\\`dgroup" currenv)
+ (append '(("noalign") ("brace"))
+ LaTeX-breqn-key-val-options))
+ ((string-match-p "\\`darray" currenv)
+ (append '(("noalign") ("brace") ("cols" ("{}")))
+ LaTeX-breqn-key-val-options))
+ (t LaTeX-breqn-key-val-options))))
+
(defvar LaTeX-breqn-key-val-label-regexp
`(,(concat
"\\\\begin{"
@@ -73,26 +84,6 @@ The keys \"label\" and \"labelprefix\" are omitted.")
1 LaTeX-auto-label)
"Matches the label inside an optional argument after
\\begin{<breqn-env's>}.")
-(defun LaTeX-breqn-env (env)
- "Insert ENV from breqn package incl. optional key=val argument.
-Keys offered for key=val query depend on ENV. \"label\" and
-\"labelprefix\" are omitted."
- (let ((keyvals
- (TeX-read-key-val t
- (cond ((or (string= env "dgroup")
- (string= env "dgroup*"))
- (append '(("noalign") ("brace"))
- LaTeX-breqn-key-val-options))
- ((or (string= env "darray")
- (string= env "darray*"))
- (append '(("noalign") ("brace") ("cols"
("{}")))
- LaTeX-breqn-key-val-options))
- (t LaTeX-breqn-key-val-options)))))
- (LaTeX-insert-environment env (when (and keyvals
- (not (string= keyvals "")))
- (concat LaTeX-optop keyvals LaTeX-optcl)))
- (LaTeX-env-label-as-keyval nil nil keyvals env)))
-
(add-hook 'TeX-update-style-hook #'TeX-auto-parse t)
(TeX-add-style-hook
@@ -119,14 +110,30 @@ Keys offered for key=val query depend on ENV. \"label\"
and
(reftex-add-label-environments '(("darray" ?e nil nil eqnarray-like))))
(LaTeX-add-environments
- '("dmath" LaTeX-breqn-env)
- '("dmath*" LaTeX-breqn-env)
- '("dseries" LaTeX-breqn-env)
- '("dseries*" LaTeX-breqn-env)
- '("dgroup" LaTeX-breqn-env)
- '("dgroup*" LaTeX-breqn-env)
- '("darray" LaTeX-breqn-env)
- '("darray*" LaTeX-breqn-env)
+ '("dmath" LaTeX-env-args
+ [TeX-arg-key-val (LaTeX-breqn-key-val-options)]
+ LaTeX-env-label-as-keyval)
+ '("dmath*" LaTeX-env-args
+ [TeX-arg-key-val (LaTeX-breqn-key-val-options)])
+
+ '("dseries" LaTeX-env-args
+ [TeX-arg-key-val (LaTeX-breqn-key-val-options)]
+ LaTeX-env-label-as-keyval)
+ '("dseries*" LaTeX-env-args
+ [TeX-arg-key-val (LaTeX-breqn-key-val-options)])
+
+ '("dgroup" LaTeX-env-args
+ [TeX-arg-key-val (LaTeX-breqn-key-val-options)]
+ LaTeX-env-label-as-keyval)
+ '("dgroup*" LaTeX-env-args
+ [TeX-arg-key-val (LaTeX-breqn-key-val-options)])
+
+ '("darray" LaTeX-env-args
+ [TeX-arg-key-val (LaTeX-breqn-key-val-options)]
+ LaTeX-env-label-as-keyval)
+ '("darray*" LaTeX-env-args
+ [TeX-arg-key-val (LaTeX-breqn-key-val-options)])
+
'("dsuspend"))
(TeX-add-symbols
diff --git a/style/catchfilebetweentags.el b/style/catchfilebetweentags.el
index 27c67e23..6354f15f 100644
--- a/style/catchfilebetweentags.el
+++ b/style/catchfilebetweentags.el
@@ -51,7 +51,7 @@
(setq LaTeX-catchfilebetweentags-counter 0)
(save-excursion
(goto-char (point-min))
- (while (re-search-forward (concat "^%<\\*\\([^>]+\\)>$")
+ (while (re-search-forward "^%<\\*[^:]*:\\([^>]+\\)>$"
(point-max) t)
(let ((fn (string-to-number (match-string 1))))
(when (> fn LaTeX-catchfilebetweentags-counter)
@@ -62,11 +62,18 @@
(defun LaTeX-env-catchfilebetweentags (_environment)
"Insert a tag-skeleton defined by `LaTeX-catchfilebetweentags'.
ENVIRONMENT is ignored."
- (let* ((fn (when LaTeX-catchfilebetweentags-use-numeric-label
+ ;; The following code, adds the file name as a prefix to the tag, in
+ ;; a similar way reftex does this, which is useful for combining
+ ;; several external files to a singular one.
+ (let* ((file (file-name-sans-extension
+ (file-name-nondirectory
+ (buffer-file-name (current-buffer)))))
+ (fn (when LaTeX-catchfilebetweentags-use-numeric-label
(LaTeX-catchfilebetweentags-counter-inc)))
- (tag (TeX-read-string
- (if fn (format "Tag (default %s): " fn) "Tag: ")
- nil nil (when fn (number-to-string fn)))))
+ (tag (concat file ":"
+ (TeX-read-string
+ (if fn (format "Tag (default %s): " fn) "Tag: ")
+ nil nil (when fn (number-to-string fn))))))
(unless (bolp)
(newline)
(delete-horizontal-space))
@@ -85,7 +92,6 @@ ENVIRONMENT is ignored."
[TeX-arg-input-file "File" t] "Tag")
'("ExecuteMetaData*"
[TeX-arg-input-file "File" t] "Tag")
-
'("CatchFileBetweenTags"
TeX-arg-define-macro (TeX-arg-input-file "File-name" t) "Tag")
'("CatchFileBetweenTags*"
diff --git a/style/changelog.el b/style/changelog.el
index a4ebb43c..1f7dccea 100644
--- a/style/changelog.el
+++ b/style/changelog.el
@@ -1,6 +1,6 @@
;;; changelog.el --- AUCTeX style for `changelog.sty' (v2.0.0) -*-
lexical-binding: t; -*-
-;; Copyright (C) 2019, 2020 Free Software Foundation, Inc.
+;; Copyright (C) 2019--2022 Free Software Foundation, Inc.
;; Author: Arash Esbati <arash@gnu.org>
;; Maintainer: auctex-devel@gnu.org
@@ -57,67 +57,71 @@ The keys sectioncmd and label are added in the function
("short" ("true" "false")))
"key=value options for version environment.")
-(defun LaTeX-env-changelog (environment)
- "Insert ENVIRONMENT, ask for optional argument and insert a label."
- (let* ((seccmds (mapcar #'car LaTeX-section-list))
- ;; Collect the key=vals acc. to environment & documentclass
- (opts (TeX-read-key-val
- t
- (if (string= environment "changelog")
- (append
- `(("sectioncmd"
- ,(if (< (LaTeX-largest-level) 2)
- (append
- (mapcar (lambda (cmd) (concat TeX-esc cmd))
- seccmds)
- (mapcar (lambda (cmd) (concat TeX-esc cmd "*"))
- seccmds))
- (append
- (mapcar (lambda (cmd) (concat TeX-esc cmd))
- (remove "chapter" seccmds))
- (mapcar (lambda (cmd) (concat TeX-esc cmd "*"))
- (remove "chapter" seccmds))))))
- LaTeX-changelog-env-key-val-options
- LaTeX-changelog-version-env-key-val-options)
- LaTeX-changelog-version-env-key-val-options)))
+(defun LaTeX-changelog-key-val-options ()
+ "Return an updated list of key=vals from changelog package."
+ (let ((currenv (LaTeX-current-environment))
+ (seccmds (mapcar #'car LaTeX-section-list)))
+ (if (string= currenv "changelog")
+ (append
+ `(("sectioncmd"
+ ,(if (< (LaTeX-largest-level) 2)
+ (append (mapcar (lambda (cmd) (concat TeX-esc cmd))
+ seccmds)
+ (mapcar (lambda (cmd) (concat TeX-esc cmd "*"))
+ seccmds))
+ (append (mapcar (lambda (cmd) (concat TeX-esc cmd))
+ (remove "chapter" seccmds))
+ (mapcar (lambda (cmd) (concat TeX-esc cmd "*"))
+ (remove "chapter" seccmds))))))
+ LaTeX-changelog-env-key-val-options
+ LaTeX-changelog-version-env-key-val-options)
+ LaTeX-changelog-version-env-key-val-options)))
+
+(defun LaTeX-env-changelog (_optional)
+ "Insert a label into the optional argument of changelog environment.
+OPTIONAL is ignored."
+ (let* ((s (save-excursion
+ (LaTeX-find-matching-begin)
+ (point)))
+ (currenv LaTeX-current-environment)
;; Extract the chosen sectioning command
- (sec (progn
- (string-match "sectioncmd=\\\\\\([a-z]+\\)\\(\\*?\\)" opts)
- (match-string-no-properties 1 opts)))
+ (sec (save-excursion
+ (re-search-backward
+ (concat "sectioncmd=\\\\\\([a-z]+\\)\\(\\*?\\)"
+ "\\|"
+ "\\<\\(section\\)\\(?:=true\\)?")
+ s t)
+ (or (match-string-no-properties 1)
+ (match-string-no-properties 3))))
;; Temp. re-bind `LaTeX-label-alist' and pick the label
;; prefix from `LaTeX-section-label'
(LaTeX-label-alist
- (when (and (string= environment "changelog")
- (match-string 2 opts)
- (not (string= (match-string 2 opts) "*")))
- `(,(cons environment
+ (when (or (and (match-string 2)
+ (not (string= (match-string 2) "*")))
+ (match-string 3))
+ `(,(cons currenv
(cdr (assoc sec LaTeX-section-label))))))
;; Temp. re-bind `reftex-label-alist' as well and make
;; `reftex-label' DTRT:
(reftex-label-alist
(when (and (boundp 'reftex-label-alist)
- LaTeX-label-alist
- (string= environment "changelog"))
- `((,environment ?s ,(cdr (assoc sec LaTeX-section-label)) nil
t)))))
- (LaTeX-insert-environment
- environment
- (when (and opts (not (string= opts "")))
- (concat LaTeX-optop opts LaTeX-optcl)))
+ LaTeX-label-alist)
+ `((,currenv ?s ,(cdr (assoc sec LaTeX-section-label)) nil t)))))
;; Add a label into the opt. argument
- (when (string= environment "changelog")
- (LaTeX-env-label-as-keyval nil "sectioncmd" nil environment))
- ;; Add an \item in version environment
- (when (string= environment "version")
- (TeX-insert-macro "item")
- (indent-according-to-mode))))
+ (when LaTeX-label-alist
+ (LaTeX-env-label-as-keyval nil "\\<section\\(?:cmd\\)?\\>"
+ nil currenv))))
(TeX-add-style-hook
"changelog"
(lambda ()
(LaTeX-add-environments
- '("changelog" LaTeX-env-changelog)
- '("version" LaTeX-env-changelog))
+ '("changelog" LaTeX-env-args
+ [TeX-arg-key-val (LaTeX-changelog-key-val-options)]
+ LaTeX-env-changelog)
+ '("version" LaTeX-env-item-args
+ [TeX-arg-key-val (LaTeX-changelog-key-val-options)]))
(TeX-add-symbols
'("added" 0)
diff --git a/style/changes.el b/style/changes.el
index ba38bc5d..b0277686 100644
--- a/style/changes.el
+++ b/style/changes.el
@@ -60,56 +60,22 @@
(add-hook 'TeX-auto-prepare-hook #'LaTeX-changes-auto-prepare t)
(add-hook 'TeX-update-style-hook #'TeX-auto-parse t)
-(defun LaTeX-arg-changes-definechangesauthor (optional)
- "Prompt for the arguments of \\definechangesauthor macro.
-While reading the first optional argument, remove space from
-`crm-local-completion-map' and `minibuffer-local-completion-map'.
-Insert the argument in brackets if OPTIONAL is non-nil."
- (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-last-optional-rejected nil)
- (keyval (LaTeX-check-insert-macro-default-style
- (TeX-read-key-val
- t
- `(("name")
- ("color"
- ,(cond
- ((and (member "xcolor" (TeX-style-list))
- (fboundp 'LaTeX-xcolor-definecolor-list))
- (mapcar #'car (LaTeX-xcolor-definecolor-list)))
- ((and (member "color" (TeX-style-list))
- (fboundp 'LaTeX-color-definecolor-list))
- (mapcar #'car (LaTeX-color-definecolor-list)))
- (t nil)))))))
- (TeX-arg-opening-brace LaTeX-optop)
- (TeX-arg-closing-brace LaTeX-optcl))
- (when keyval (TeX-argument-insert keyval t)))
- (let ((id (TeX-read-string
- (TeX-argument-prompt optional nil "Author ID"))))
- (LaTeX-add-changes-definechangesauthors id)
- (TeX-argument-insert id optional)))
-
-(defun LaTeX-arg-changes-markup (optional)
- "Prompt for the argument of various markup commands.
-Remove space from `crm-local-completion-map' and
-`minibuffer-local-completion-map' while reading user input.
-Insert the argument in brackets if OPTIONAL is non-nil."
- (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))
- (keyval (TeX-read-key-val
- optional
- `(("id" ,(mapcar #'car
- (LaTeX-changes-definechangesauthor-list)))
- ("comment")))))
- (TeX-argument-insert keyval optional)))
+(defun LaTeX-changes-definechangesauthor-key-val-options ()
+ "Return a key=val list for the \\definechangesauthor macro."
+ `(("name")
+ ("color" ,(cond ((and (member "xcolor" (TeX-style-list))
+ (fboundp 'LaTeX-xcolor-definecolor-list))
+ (mapcar #'car (LaTeX-xcolor-definecolor-list)))
+ ((and (member "color" TeX-active-styles)
+ (fboundp 'LaTeX-color-definecolor-list))
+ (mapcar #'car (LaTeX-color-definecolor-list)))
+ (t nil)))))
+
+(defun LaTeX-changes-key-val-options ()
+ "Return a key=val list for the change management macros."
+ `(("id" ,(mapcar #'car
+ (LaTeX-changes-definechangesauthor-list)))
+ ("comment")))
(TeX-add-style-hook
"changes"
@@ -134,17 +100,16 @@ Insert the argument in brackets if OPTIONAL is non-nil."
(TeX-add-symbols
;; 4.2 Change management
- '("added" [ LaTeX-arg-changes-markup ] 1)
- '("deleted" [ LaTeX-arg-changes-markup ] 1)
- '("replaced" [ LaTeX-arg-changes-markup ] 2)
+ '("added" [TeX-arg-key-val LaTeX-changes-key-val-options nil nil ?\s] 1)
+ '("deleted" [TeX-arg-key-val LaTeX-changes-key-val-options nil nil ?\s] 1)
+ '("replaced" [TeX-arg-key-val LaTeX-changes-key-val-options nil nil ?\s] 2)
;; 4.3 Highlighting and Comments
- '("highlight" [ LaTeX-arg-changes-markup ] 1)
- '("comment"
- [TeX-arg-eval
- TeX-read-key-val t `(("id"
- ,(mapcar #'car
-
(LaTeX-changes-definechangesauthor-list))))]
+ '("highlight" [TeX-arg-key-val LaTeX-changes-key-val-options nil nil ?\s]
1)
+ `("comment"
+ [TeX-arg-key-val
+ ,(lambda ()
+ `(("id" ,(mapcar #'car (LaTeX-changes-definechangesauthor-list)))))]
1)
;; 4.4 Overview of changes
@@ -155,7 +120,14 @@ Insert the argument in brackets if OPTIONAL is non-nil."
"replaced" "highlight" "comment")))])
;; 4.5 Author management \definechangesauthor
- '("definechangesauthor" LaTeX-arg-changes-definechangesauthor)
+ `("definechangesauthor"
+ [TeX-arg-key-val (LaTeX-changes-definechangesauthor-key-val-options)
+ nil nil ?\s]
+ ,(lambda (optional)
+ (let ((id (TeX-read-string
+ (TeX-argument-prompt optional nil "Author ID"))))
+ (LaTeX-add-changes-definechangesauthors id)
+ (TeX-argument-insert id optional))))
;; 4.6 Adaption of the output:
'("setaddedmarkup" "Definition")
diff --git a/style/cleveref.el b/style/cleveref.el
index 373dcd85..9d91c262 100644
--- a/style/cleveref.el
+++ b/style/cleveref.el
@@ -1,6 +1,6 @@
;;; cleveref.el --- AUCTeX style for `cleveref.sty' (v0.21.4) -*-
lexical-binding: t; -*-
-;; Copyright (C) 2014--2020 Free Software Foundation, Inc.
+;; Copyright (C) 2014--2022 Free Software Foundation, Inc.
;; Author: Matthew Leach <matthew@mattleach.net>
;; Maintainer: auctex-devel@gnu.org
@@ -55,18 +55,12 @@ string."
(labels-string (mapconcat #'identity labels ",")))
(TeX-argument-insert labels-string optional))))
-(defun TeX-arg-cleveref-crossref-type (optional &optional prompt)
- "Insert the cross-reference type for macros of cleveref package.
-If OPTIONAL is non-nil, insert the resulting value in brackets.
-Use PROMPT as the prompt string."
- (let* ((type (mapcar #'list
- '("appendix" "subappendix" "subsubappendix"
- "subsubsubappendix" "subfigure" "subtable"
- "subequation")))
- (types (append (LaTeX-counter-list) type)))
- (TeX-argument-insert
- (completing-read (TeX-argument-prompt optional prompt "Type") types)
- optional)))
+(defun LaTeX-cleveref-crossref-type ()
+ "Return a list of cross-reference types for cleveref package macros."
+ (let ((type (mapcar #'list '("appendix" "subappendix"
+ "subsubappendix" "subsubsubappendix"
+ "subfigure" "subtable" "subequation"))))
+ (append (LaTeX-counter-list) type)))
(defvar LaTeX-cleveref-label-regexp
'("\\\\label\\[[^]]*\\]{\\([^\n\r%\\{}]+\\)}" 1 LaTeX-auto-label)
@@ -100,32 +94,56 @@ Use PROMPT as the prompt string."
'("labelcpageref" TeX-arg-cleveref-multiple-labels)
;; 6 Overriding the Cross-Reference Type
'("crefalias" TeX-arg-counter "Type")
- '("label" [ TeX-arg-cleveref-crossref-type ] TeX-arg-define-label)
+ '("label"
+ [TeX-arg-completing-read (LaTeX-cleveref-crossref-type) "Type"]
+ TeX-arg-define-label)
;; 8.1.1 Global Customisation
'("crefdefaultlabelformat" t)
;; 8.1.2 Customising Individual Cross-Reference Types
- '("crefname" TeX-arg-cleveref-crossref-type
+ '("crefname"
+ (TeX-arg-completing-read (LaTeX-cleveref-crossref-type) "Type")
"Singular name" "Plural name")
- '("Crefname" TeX-arg-cleveref-crossref-type
+ '("Crefname"
+ (TeX-arg-completing-read (LaTeX-cleveref-crossref-type) "Type")
"Singular name" "Plural name")
- '("creflabelformat" TeX-arg-cleveref-crossref-type t)
- '("crefrangelabelformat" TeX-arg-cleveref-crossref-type t)
+ '("creflabelformat"
+ (TeX-arg-completing-read (LaTeX-cleveref-crossref-type) "Type")
+ t)
+ '("crefrangelabelformat"
+ (TeX-arg-completing-read (LaTeX-cleveref-crossref-type) "Type")
+ t)
;; 8.2.1 Single Cross-References
- '("crefformat" TeX-arg-cleveref-crossref-type t)
- '("Crefformat" TeX-arg-cleveref-crossref-type t)
+ '("crefformat"
+ (TeX-arg-completing-read (LaTeX-cleveref-crossref-type) "Type")
+ t)
+ '("Crefformat"
+ (TeX-arg-completing-read (LaTeX-cleveref-crossref-type) "Type")
+ t)
;; 8.2.2 Reference Ranges
- '("crefrangeformat" TeX-arg-cleveref-crossref-type t)
- '("Crefrangeformat" TeX-arg-cleveref-crossref-type t)
+ '("crefrangeformat"
+ (TeX-arg-completing-read (LaTeX-cleveref-crossref-type) "Type")
+ t)
+ '("Crefrangeformat"
+ (TeX-arg-completing-read (LaTeX-cleveref-crossref-type) "Type")
+ t)
;; 8.2.3 Multiple Cross-References
- '("crefmultiformat" TeX-arg-cleveref-crossref-type 4)
- '("Crefmultiformat" TeX-arg-cleveref-crossref-type 4)
- '("crefrangemultiformat" TeX-arg-cleveref-crossref-type 4)
- '("Crefrangemultiformat" TeX-arg-cleveref-crossref-type 4))
+ '("crefmultiformat"
+ (TeX-arg-completing-read (LaTeX-cleveref-crossref-type) "Type")
+ 4)
+ '("Crefmultiformat"
+ (TeX-arg-completing-read (LaTeX-cleveref-crossref-type) "Type")
+ 4)
+ '("crefrangemultiformat"
+ (TeX-arg-completing-read (LaTeX-cleveref-crossref-type) "Type")
+ 4)
+ '("Crefrangemultiformat"
+ (TeX-arg-completing-read (LaTeX-cleveref-crossref-type) "Type")
+ 4))
;; These macros aren't used particularly often during the course of
;; normal referencing.
diff --git a/style/comment.el b/style/comment.el
index 11a14192..b9edd1c9 100644
--- a/style/comment.el
+++ b/style/comment.el
@@ -112,26 +112,29 @@
;; New symbols
(TeX-add-symbols
- '("includecomment"
- (TeX-arg-eval let ((env (TeX-read-string
- (TeX-argument-prompt nil nil "Name"))))
- (LaTeX-add-comment-incl-excls `(,env "include"))
- (LaTeX-comment-auto-cleanup)
- (format "%s" env)))
-
- '("excludecomment"
- (TeX-arg-eval let ((env (TeX-read-string
- (TeX-argument-prompt nil nil "Name"))))
- (LaTeX-add-comment-incl-excls `(,env "exclude"))
- (LaTeX-comment-auto-cleanup)
- (format "%s" env)))
-
- '("specialcomment"
- (TeX-arg-eval let ((env (TeX-read-string
- (TeX-argument-prompt nil nil "Name"))))
- (LaTeX-add-comment-incl-excls `(,env "special"))
- (LaTeX-comment-auto-cleanup)
- (format "%s" env))
+ `("includecomment"
+ ,(lambda (optional)
+ (let ((env (TeX-read-string
+ (TeX-argument-prompt optional nil "Name"))))
+ (LaTeX-add-comment-incl-excls `(,env "include"))
+ (LaTeX-comment-auto-cleanup)
+ (TeX-argument-insert env optional))))
+
+ `("excludecomment"
+ ,(lambda (optional)
+ (let ((env (TeX-read-string
+ (TeX-argument-prompt optional nil "Name"))))
+ (LaTeX-add-comment-incl-excls `(,env "exclude"))
+ (LaTeX-comment-auto-cleanup)
+ (TeX-argument-insert env optional))))
+
+ `("specialcomment"
+ ,(lambda (optional)
+ (let ((env (TeX-read-string
+ (TeX-argument-prompt optional nil "Name"))))
+ (LaTeX-add-comment-incl-excls `(,env "special"))
+ (LaTeX-comment-auto-cleanup)
+ (TeX-argument-insert env optional)))
"Before commands" "After commands")
'("processcomment" "Name" "Each-line commands"
diff --git a/style/csquotes.el b/style/csquotes.el
index d6d06816..9caf2a3b 100644
--- a/style/csquotes.el
+++ b/style/csquotes.el
@@ -39,35 +39,16 @@
"font-latex"
(keywords class))
-(defun LaTeX-csquotes-read-language (optional &optional prompt)
- "Read and return a language for csquotes macros.
-If OPTIONAL is non-nil, indicate it in minibuffer while reading
-user input. PROMPT replaces the standard one \"Language\". This
-function checks if the functions `LaTeX-babel-active-languages'
-or `LaTeX-polyglossia-active-languages' are bound and use them to
-retrieve the active languages. If none available, user is
-requested to enter a language."
- (cond ((and (fboundp 'LaTeX-babel-active-languages)
- (LaTeX-babel-active-languages))
- (completing-read
- (TeX-argument-prompt optional prompt "Language")
- (LaTeX-babel-active-languages)))
- ((and (fboundp 'LaTeX-polyglossia-active-languages)
- (LaTeX-polyglossia-active-languages))
- (completing-read
- (TeX-argument-prompt optional prompt "Language")
- (LaTeX-polyglossia-active-languages)))
- (t
- (TeX-read-string
- (TeX-argument-prompt optional prompt "Language")))))
-
-(defun LaTeX-arg-csquotes-language (optional &optional prompt)
- "Insert a language for csquotes macros.
-If OPTIONAL is non-nil, insert the language in square brackets.
-PROMPT replaces the standard one \"Language\"."
- (TeX-argument-insert
- (LaTeX-csquotes-read-language optional prompt)
- optional))
+(defun LaTeX-csquotes-language-list ()
+ "Return a list of active languages for csquotes macros.
+This function checks if the functions
+`LaTeX-babel-active-languages' or
+`LaTeX-polyglossia-active-languages' are bound and use them to
+retrieve the active languages."
+ (or (and (fboundp 'LaTeX-babel-active-languages)
+ (LaTeX-babel-active-languages))
+ (and (fboundp 'LaTeX-polyglossia-active-languages)
+ (LaTeX-polyglossia-active-languages))))
(TeX-add-style-hook
"csquotes"
@@ -92,10 +73,14 @@ PROMPT replaces the standard one \"Language\"."
'("enquote*" 1)
;; 3.2 Quoting Text in a Foreign Language
- '("foreignquote" LaTeX-arg-csquotes-language 1)
- '("foreignquote*" LaTeX-arg-csquotes-language 1)
- '("hyphenquote" LaTeX-arg-csquotes-language 1)
- '("hyphenquote*" LaTeX-arg-csquotes-language 1)
+ '("foreignquote"
+ (TeX-arg-completing-read (LaTeX-csquotes-language-list)) t)
+ '("foreignquote*"
+ (TeX-arg-completing-read (LaTeX-csquotes-language-list)) t)
+ '("hyphenquote"
+ (TeX-arg-completing-read (LaTeX-csquotes-language-list)) t)
+ '("hyphenquote*"
+ (TeX-arg-completing-read (LaTeX-csquotes-language-list)) t)
;; 3.3 Formal Quoting of Regular Text
'("textquote" ["Citation"] ["Punctuation"] t)
@@ -103,24 +88,31 @@ PROMPT replaces the standard one \"Language\"."
;; 3.4 Formal Quoting of Text in a Foreign Language
'("foreigntextquote"
- LaTeX-arg-csquotes-language ["Citation"] ["Punctuation"] t)
+ (TeX-arg-completing-read (LaTeX-csquotes-language-list))
+ ["Citation"] ["Punctuation"] t)
'("foreigntextquote*"
- LaTeX-arg-csquotes-language ["Citation"] ["Punctuation"] t)
+ (TeX-arg-completing-read (LaTeX-csquotes-language-list))
+ ["Citation"] ["Punctuation"] t)
'("hyphentextquote"
- LaTeX-arg-csquotes-language ["Citation"] ["Punctuation"] t)
+ (TeX-arg-completing-read (LaTeX-csquotes-language-list))
+ ["Citation"] ["Punctuation"] t)
'("hyphentextquote*"
- LaTeX-arg-csquotes-language ["Citation"] ["Punctuation"] t)
+ (TeX-arg-completing-read (LaTeX-csquotes-language-list))
+ ["Citation"] ["Punctuation"] t)
;; 3.5 Block Quoting of Regular Text
'("blockquote" ["Citation"] ["Punctuation"] t)
;; 3.6 Block Quoting of Text in a Foreign Language
'("foreignblockquote"
- LaTeX-arg-csquotes-language ["Citation"] ["Punctuation"] t)
+ (TeX-arg-completing-read (LaTeX-csquotes-language-list))
+ ["Citation"] ["Punctuation"] t)
'("hyphenblockquote"
- LaTeX-arg-csquotes-language ["Citation"] ["Punctuation"] t)
+ (TeX-arg-completing-read (LaTeX-csquotes-language-list))
+ ["Citation"] ["Punctuation"] t)
'("hybridblockquote"
- LaTeX-arg-csquotes-language ["Citation"] ["Punctuation"] t)
+ (TeX-arg-completing-read (LaTeX-csquotes-language-list))
+ ["Citation"] ["Punctuation"] t)
;; 3.7 Selecting Quote Styles
`("setquotestyle"
@@ -137,14 +129,18 @@ PROMPT replaces the standard one \"Language\"."
'("MakeAutoQuote*" "Opening quotation mark" "Closing quotation mark")
;; 4.2 Quoting Text in a Foreign Language
- '("MakeForeignQuote" LaTeX-arg-csquotes-language
+ '("MakeForeignQuote"
+ (TeX-arg-completing-read (LaTeX-csquotes-language-list))
"Opening quotation mark" "Closing quotation mark")
- '("MakeForeignQuote*" LaTeX-arg-csquotes-language
+ '("MakeForeignQuote*"
+ (TeX-arg-completing-read (LaTeX-csquotes-language-list))
"Opening quotation mark" "Closing quotation mark")
- '("MakeHyphenQuote" LaTeX-arg-csquotes-language
+ '("MakeHyphenQuote"
+ (TeX-arg-completing-read (LaTeX-csquotes-language-list))
"Opening quotation mark" "Closing quotation mark")
- '("MakeHyphenQuote" LaTeX-arg-csquotes-language
+ '("MakeHyphenQuote"
+ (TeX-arg-completing-read (LaTeX-csquotes-language-list))
"Opening quotation mark" "Closing quotation mark")
;; 4.3 Block Quoting of Regular Text
@@ -152,11 +148,14 @@ PROMPT replaces the standard one \"Language\"."
"Closing quotation mark")
;; 4.4 Block Quoting of Text in a Foreign Language
- '("MakeForeignBlockQuote" LaTeX-arg-csquotes-language
+ '("MakeForeignBlockQuote"
+ (TeX-arg-completing-read (LaTeX-csquotes-language-list))
"Opening quotation mark" "Delimiter for citation" "Closing quotation
mark")
- '("MakeHyphenBlockQuote" LaTeX-arg-csquotes-language
+ '("MakeHyphenBlockQuote"
+ (TeX-arg-completing-read (LaTeX-csquotes-language-list))
"Opening quotation mark" "Delimiter for citation" "Closing quotation
mark")
- '("MakeHybridBlockQuote" LaTeX-arg-csquotes-language
+ '("MakeHybridBlockQuote"
+ (TeX-arg-completing-read (LaTeX-csquotes-language-list))
"Opening quotation mark" "Delimiter for citation" "Closing quotation
mark")
;; 4.5 Controlling Active Quotes
@@ -170,24 +169,31 @@ PROMPT replaces the standard one \"Language\"."
'("textcquote*" ["Pre-note"] ["Post-note"] "Key" ["Punctuation"] t)
;; 5.2 Formal Quoting of Text in a Foreign Language
- '("foreigntextcquote" LaTeX-arg-csquotes-language
+ '("foreigntextcquote"
+ (TeX-arg-completing-read (LaTeX-csquotes-language-list))
["Pre-note"] ["Post-note"] "Key" ["Punctuation"] t)
- '("foreigntextcquote*" LaTeX-arg-csquotes-language
+ '("foreigntextcquote*"
+ (TeX-arg-completing-read (LaTeX-csquotes-language-list))
["Pre-note"] ["Post-note"] "Key" ["Punctuation"] t)
- '("hyphentextcquote" LaTeX-arg-csquotes-language
+ '("hyphentextcquote"
+ (TeX-arg-completing-read (LaTeX-csquotes-language-list))
["Pre-note"] ["Post-note"] "Key" ["Punctuation"] t)
- '("hyphentextcquote*" LaTeX-arg-csquotes-language
+ '("hyphentextcquote*"
+ (TeX-arg-completing-read (LaTeX-csquotes-language-list))
["Pre-note"] ["Post-note"] "Key" ["Punctuation"] t)
;; 5.3 Block Quoting of Regular Text
'("blockcquote" ["Pre-note"] ["Post-note"] "Key" ["Punctuation"] t)
;; 5.4 Block Quoting of Text in a Foreign Language
- '("foreignblockcquote" LaTeX-arg-csquotes-language
+ '("foreignblockcquote"
+ (TeX-arg-completing-read (LaTeX-csquotes-language-list))
["Pre-note"] ["Post-note"] "Key" ["Punctuation"] t)
- '("hyphenblockcquote" LaTeX-arg-csquotes-language
+ '("hyphenblockcquote"
+ (TeX-arg-completing-read (LaTeX-csquotes-language-list))
["Pre-note"] ["Post-note"] "Key" ["Punctuation"] t)
- '("hybridblockcquote" LaTeX-arg-csquotes-language
+ '("hybridblockcquote"
+ (TeX-arg-completing-read (LaTeX-csquotes-language-list))
["Pre-note"] ["Post-note"] "Key" ["Punctuation"] t)
;; 7 Auxiliary Commands
@@ -266,20 +272,24 @@ PROMPT replaces the standard one \"Language\"."
["Citation"] ["Punctuation"])
'("foreigndisplayquote" LaTeX-env-args
- LaTeX-arg-csquotes-language ["Citation"] ["Punctuation"])
+ (TeX-arg-completing-read (LaTeX-csquotes-language-list))
+ ["Citation"] ["Punctuation"])
'("hyphendisplayquote" LaTeX-env-args
- LaTeX-arg-csquotes-language ["Citation"] ["Punctuation"])
+ (TeX-arg-completing-read (LaTeX-csquotes-language-list))
+ ["Citation"] ["Punctuation"])
;; 6.2 Integrated Display Environments
'("displaycquote" LaTeX-env-args
["Pre-note"] ["Post-note"] "Key" ["Punctuation"])
'("foreigndisplaycquote" LaTeX-env-args
- LaTeX-arg-csquotes-language["Pre-note"] ["Post-note"] "Key"
["Punctuation"])
+ (TeX-arg-completing-read (LaTeX-csquotes-language-list))
+ ["Pre-note"] ["Post-note"] "Key" ["Punctuation"])
'("hyphendisplaycquote" LaTeX-env-args
- LaTeX-arg-csquotes-language["Pre-note"] ["Post-note"] "Key"
["Punctuation"]))
+ (TeX-arg-completing-read (LaTeX-csquotes-language-list))
+ ["Pre-note"] ["Post-note"] "Key" ["Punctuation"]))
;; Quotation marks
(when (and (> (length LaTeX-csquotes-open-quote) 0)
diff --git a/style/doc.el b/style/doc.el
index d57e1e05..cb210be3 100644
--- a/style/doc.el
+++ b/style/doc.el
@@ -249,44 +249,52 @@ percent sign at the beginning of a line before
'("theglossary" LaTeX-env-item))
(TeX-add-symbols
- ;; 2.1 The driver file
- '("DocInput"
- (TeX-arg-eval
- (lambda ()
+ ;; 2.1 The driver file: Note that `l3doc.el' also loads `doc.el'
+ ;; but `\DocInput' behaves differently. With `l3doc.el', it takes
+ ;; comma-separated arguments, with `doc.el' it takes only one
+ ;; argument.
+ `("DocInput"
+ (TeX-arg-conditional (member "l3doc" (TeX-style-list))
+ (,(lambda (optional)
+ (let ((file (TeX-read-string
+ (TeX-argument-prompt optional nil
+ (format "File(s) to input
(default %s)"
+ (buffer-name)))
+ nil nil (buffer-name))))
+ (TeX-argument-insert file optional))))
+ (,(lambda (optional)
+ (let ((file (file-relative-name
+ (read-file-name
+ (TeX-argument-prompt optional nil
+ (format "File to input (default
%s)"
+ (buffer-name)))
+ nil (buffer-name) nil nil
+ (lambda (x)
+ (or (file-directory-p x)
+ (string-match "\\.\\(fdd\\|dtx\\)\\'" x))))
+ (TeX-master-directory))))
+ (TeX-argument-insert file optional))))))
+
+ `("IndexInput"
+ ,(lambda (optional)
(let ((file (file-relative-name
(read-file-name
- "File to input: " nil nil nil nil
- (lambda (x)
- (or (file-directory-p x)
- (string-match "\\.\\(fdd\\|dtx\\)\\'" x))))
- (TeX-master-directory))))
- (format "%s" file)))))
-
- '("IndexInput"
- (TeX-arg-eval
- (lambda ()
- (let ((file (file-relative-name
- (read-file-name
- "File to input: " nil nil nil nil
+ (TeX-argument-prompt optional nil "File to input")
+ nil nil nil nil
(lambda (x)
(or (file-directory-p x)
(string-match "\\.\\(tex\\|ltx\\|fdd\\|dtx\\)\\'"
x))))
(TeX-master-directory))))
- (format "%s" file)))))
+ (TeX-argument-insert file optional))))
;; 2.2 Package options
'("SetupDoc" (TeX-arg-completing-read-multiple LaTeX-doc-package-options
"Options"))
;; 2.4 Describing the usage of macros and environments
- '("DescribeMacro"
+ `("DescribeMacro"
[TeX-arg-completing-read ("noindex" "noprint") "Suppress option"]
- (TeX-arg-eval
- (lambda ()
- (let ((name (TeX-read-string
- (TeX-argument-prompt nil nil "Macro")
- TeX-esc)))
- (format "%s" name)))))
+ (TeX-arg-string "Macro" ,TeX-esc))
'("DescribeEnv"
[TeX-arg-completing-read ("noindex" "noprint") "Suppress option"]
"Environment")
@@ -434,7 +442,6 @@ percent sign at the beginning of a line before
(font-latex-add-keywords '(("meta" "{"))
'textual)
(font-latex-add-keywords '(("DocInput" "{")
- ("DocInclude" "{" )
("IndexInput" "{"))
'reference)))
TeX-dialect)
diff --git a/style/empheq.el b/style/empheq.el
index b9f32b16..39c3f00e 100644
--- a/style/empheq.el
+++ b/style/empheq.el
@@ -1,6 +1,6 @@
;;; empheq.el --- AUCTeX style for `empheq.sty' (v2.14) -*- lexical-binding:
t; -*-
-;; Copyright (C) 2016-2021 Free Software Foundation, Inc.
+;; Copyright (C) 2016-2022 Free Software Foundation, Inc.
;; Author: Arash Esbati <arash@gnu.org>
;; Maintainer: auctex-devel@gnu.org
@@ -162,69 +162,31 @@ delimiters and prepends them to variable
("right" ,rvals))))
LaTeX-empheq-key-val-options))
-(defun LaTeX-empheq-env (env)
- "Query for a supported amsmath environment and insert it accordingly.
-ENV is the name of environment passed to the function in the style hook."
- (let* ((keyvals (TeX-read-key-val t (LaTeX-empheq-key-val-options)))
- (amsenv (completing-read
- (TeX-argument-prompt nil nil "amsmath environment")
- LaTeX-empheq-supported-amsmath-envs))
- (ncols (when (or (string= amsenv "alignat")
- (string= amsenv "alignat*"))
- (TeX-read-string
- (TeX-argument-prompt nil nil "Number of columns"))))
- num)
- (LaTeX-insert-environment
- env
- (concat
- (when (and keyvals (not (string= keyvals "")))
- (concat LaTeX-optop keyvals LaTeX-optcl))
- TeX-grop
- (if (and ncols (not (string= ncols "")))
- (concat amsenv "=" ncols)
- amsenv)
- TeX-grcl))
- (when (and (assoc amsenv LaTeX-label-alist)
- (LaTeX-label amsenv 'environment))
- (LaTeX-newline)
- (indent-according-to-mode))
- (when (and ncols (not (string= ncols "")))
- (setq num (string-to-number ncols))
+(defun LaTeX-empheq-env (optional)
+ "Insert a label inside empheq environment.
+In addition, query for a column number for the alignat*?
+environments and insert suitable number of ampersands. If
+OPTIONAL is non-nil, indicate it in the prompt."
+ (save-excursion
+ (TeX-looking-at-backward (concat TeX-grop "\\([^" TeX-grcl "]+\\)"
TeX-grcl)
+ 20))
+ (let* ((amsenv (match-string-no-properties 1))
+ ncols)
+ (when (string-match-p "\\`alignat" amsenv)
+ (setq ncols (read-number
+ (TeX-argument-prompt optional nil "Number of columns")))
(save-excursion
- (insert (make-string (+ num num -1) ?&))))))
-
-(defun LaTeX-empheq-env-overload (env &optional _ignore)
- "Insert amsmath ENV's when option overload is given to empheq package.
-This function combines the capabilities of `LaTeX-env-label' and
-`LaTeX-amsmath-env-alignat'. It overwrites the definitions of
-`amsmath.el'."
- (if (or (string= env "alignat")
- (string= env "alignat*"))
- (let ((ncols (TeX-read-string
- (TeX-argument-prompt nil nil "Number of columns")))
- (keyvals (TeX-read-key-val t
- (LaTeX-empheq-key-val-options)
- "empheq options (k=v)")))
- (LaTeX-insert-environment env
- (concat TeX-grop ncols TeX-grcl
- (when (and keyvals
- (not (string= keyvals
"")))
- (concat LaTeX-optop
- keyvals
- LaTeX-optcl))))
- (LaTeX-item-equation-alignat t))
- (let ((keyvals
- (TeX-read-key-val t
- (LaTeX-empheq-key-val-options)
- "empheq options (k=v)")))
- (LaTeX-insert-environment env
- (when (and keyvals
- (not (string= keyvals "")))
- (concat LaTeX-optop
- keyvals
- LaTeX-optcl)))
- (when (and (assoc env LaTeX-label-alist)
- (LaTeX-label env 'environment))
+ (goto-char (match-end 1))
+ (insert "=" (number-to-string ncols))
+ (goto-char TeX-exit-mark)
+ (insert-char ?& (+ ncols ncols -1))
+ (indent-according-to-mode)))
+ (save-excursion
+ (goto-char TeX-exit-mark)
+ (beginning-of-line)
+ (when (and (assoc amsenv LaTeX-label-alist)
+ (LaTeX-label amsenv 'environment))
+ (indent-according-to-mode)
(LaTeX-newline)
(indent-according-to-mode)))))
@@ -233,7 +195,7 @@ This function combines the capabilities of
`LaTeX-env-label' and
Put line break macro on the last line. Next, if the current
environment wants \\label, insert it also. And insert suitable
number of ampersands if possible."
- (let ((env (LaTeX-current-environment))
+ (let ((env "empheq")
amsenv ncols match)
(save-excursion
(LaTeX-find-matching-begin)
@@ -243,7 +205,7 @@ number of ampersands if possible."
(forward-sexp))
(re-search-forward "[ \t\n\r%]*{\\([^}]+\\)}")
(setq match (replace-regexp-in-string "[ \t\n\r%]" ""
- (match-string-no-properties
1)))
+ (match-string-no-properties 1)))
(if (string-match "=" match)
(progn
(setq amsenv (car (split-string match "=")))
@@ -251,19 +213,17 @@ number of ampersands if possible."
(setq amsenv match)))
;; Do not ask for "\\" if in "equation" or "equation*" since these
;; are single line equations only
- (if (or (string= amsenv "equation")
- (string= amsenv "equation*"))
+ (if (member amsenv '("equation" "equation*"))
;; Nullify the effect of `M-RET'
(progn
(message "This environment does not support multi-line equations")
(end-of-line 0)
(kill-line 1))
- (progn
- (end-of-line 0)
- (just-one-space)
- (TeX-insert-macro "\\")
- (forward-line 1)
- (indent-according-to-mode)))
+ (end-of-line 0)
+ (just-one-space)
+ (TeX-insert-macro "\\")
+ (forward-line 1)
+ (indent-according-to-mode))
;; Add a new label only if not in "equation"
(when (and (not (string= amsenv "equation"))
(assoc amsenv LaTeX-label-alist)
@@ -272,7 +232,7 @@ number of ampersands if possible."
(indent-according-to-mode))
(when ncols
(save-excursion
- (insert (make-string (+ ncols ncols -1) ?&))))))
+ (insert-char ?& (+ ncols ncols -1))))))
(TeX-add-style-hook
"empheq"
@@ -285,7 +245,11 @@ number of ampersands if possible."
(TeX-run-style-hooks "amsmath" "mathtools")
(LaTeX-add-environments
- '("empheq" LaTeX-empheq-env))
+ '("empheq" LaTeX-env-args
+ [TeX-arg-key-val (LaTeX-empheq-key-val-options)]
+ (TeX-arg-completing-read LaTeX-empheq-supported-amsmath-envs
+ "amsmath environment")
+ LaTeX-empheq-env))
;; Add "empheq" to `LaTeX-item-list' and run
;; `LaTeX-empheq-item-equation' when `M-RET' is invoked
@@ -365,18 +329,53 @@ number of ampersands if possible."
(when (or (LaTeX-provided-package-options-member "empheq" "overload")
(LaTeX-provided-package-options-member "empheq" "overload2"))
(LaTeX-add-environments
- '("align" LaTeX-empheq-env-overload)
- '("alignat" LaTeX-empheq-env-overload)
- '("equation" LaTeX-empheq-env-overload)
- '("flalign" LaTeX-empheq-env-overload)
- '("gather" LaTeX-empheq-env-overload)
- '("multline" LaTeX-empheq-env-overload)
- '("align*" LaTeX-env-args [TeX-arg-key-val
(LaTeX-empheq-key-val-options)])
- '("alignat*" LaTeX-empheq-env-overload)
- '("equation*" LaTeX-env-args [TeX-arg-key-val
(LaTeX-empheq-key-val-options)])
- '("flalign*" LaTeX-env-args [TeX-arg-key-val
(LaTeX-empheq-key-val-options)])
- '("gather*" LaTeX-env-args [TeX-arg-key-val
(LaTeX-empheq-key-val-options)])
- '("multline*" LaTeX-env-args [TeX-arg-key-val
(LaTeX-empheq-key-val-options)])
+ '("align" LaTeX-env-label-args
+ [TeX-arg-key-val (LaTeX-empheq-key-val-options) "empheq options"])
+
+ `("alignat" LaTeX-env-args
+ "Number of columns"
+ [TeX-arg-key-val (LaTeX-empheq-key-val-options) "empheq options"]
+ ,(lambda (_)
+ (goto-char TeX-exit-mark)
+ (beginning-of-line)
+ (LaTeX-item-equation-alignat t)
+ (end-of-line 0)
+ (indent-according-to-mode)
+ (goto-char TeX-exit-mark)))
+
+ '("equation" LaTeX-env-label-args
+ [TeX-arg-key-val (LaTeX-empheq-key-val-options) "empheq options"])
+
+ '("flalign" LaTeX-env-label-args
+ [TeX-arg-key-val (LaTeX-empheq-key-val-options) "empheq options"])
+
+ '("gather" LaTeX-env-label-args
+ [TeX-arg-key-val (LaTeX-empheq-key-val-options) "empheq options"])
+
+ '("multline" LaTeX-env-label-args
+ [TeX-arg-key-val (LaTeX-empheq-key-val-options) "empheq options"])
+
+ '("align*" LaTeX-env-args
+ [TeX-arg-key-val (LaTeX-empheq-key-val-options) "empheq options"])
+
+ `("alignat*" LaTeX-env-args
+ "Number of columns"
+ [TeX-arg-key-val (LaTeX-empheq-key-val-options) "empheq options"]
+ ,(lambda (_)
+ (goto-char TeX-exit-mark)
+ (LaTeX-item-equation-alignat t)))
+
+ '("equation*" LaTeX-env-args
+ [TeX-arg-key-val (LaTeX-empheq-key-val-options) "empheq options"])
+
+ '("flalign*" LaTeX-env-args
+ [TeX-arg-key-val (LaTeX-empheq-key-val-options) "empheq options"])
+
+ '("gather*" LaTeX-env-args
+ [TeX-arg-key-val (LaTeX-empheq-key-val-options) "empheq options"])
+
+ '("multline*" LaTeX-env-args
+ [TeX-arg-key-val (LaTeX-empheq-key-val-options) "empheq options"])
;; Original definitions are stored prefixed with "AmS"
'("AmSalign" LaTeX-env-label)
@@ -404,14 +403,13 @@ number of ampersands if possible."
;; RefTeX support: Add original definitions with
`reftex-add-label-environments'
(when (fboundp 'reftex-add-label-environments)
- (let ((envs '(("AmSalign" ?e nil nil eqnarray-like)
- ("AmSequation" ?e nil nil t)
- ("AmSgather" ?e nil nil eqnarray-like)
- ("AmSmultline" ?e nil nil t)
- ("AmSflalign" ?e nil nil eqnarray-like)
- ("AmSalignat" ?e nil nil alignat-like))))
- (dolist (env envs)
- (reftex-add-label-environments `(,env)))))
+ (reftex-add-label-environments
+ '(("AmSalign" ?e nil nil eqnarray-like)
+ ("AmSequation" ?e nil nil t)
+ ("AmSgather" ?e nil nil eqnarray-like)
+ ("AmSmultline" ?e nil nil t)
+ ("AmSflalign" ?e nil nil eqnarray-like)
+ ("AmSalignat" ?e nil nil alignat-like))))
;; Append original definitions to `LaTeX-item-list'; functions
;; are provided by amsmath.el
@@ -441,25 +439,25 @@ number of ampersands if possible."
;; 4.1 Creating your own delimiters
(TeX-add-symbols
- '("DeclareLeftDelimiter"
+ `("DeclareLeftDelimiter"
[ "Space adjustment" ]
- (TeX-arg-eval
- (lambda ()
- (let ((delim (TeX-read-string (concat "Delimiter: " TeX-esc))))
+ ,(lambda (optional)
+ (let ((delim (TeX-read-string
+ (TeX-argument-prompt optional nil "Delimiter: \\" t))))
(TeX-add-symbols (concat "empheq" delim)
(concat "empheqbig" delim))
(LaTeX-add-empheq-declaredelimiters `(,delim "Left"))
- (concat TeX-esc delim)))))
+ (TeX-argument-insert delim optional TeX-esc))))
- '("DeclareRightDelimiter"
+ `("DeclareRightDelimiter"
[ "Space adjustment" ]
- (TeX-arg-eval
- (lambda ()
- (let ((delim (TeX-read-string (concat "Delimiter: " TeX-esc))))
+ ,(lambda (optional)
+ (let ((delim (TeX-read-string
+ (TeX-argument-prompt optional nil "Delimiter: \\" t))))
(TeX-add-symbols (concat "empheq" delim)
(concat "empheqbig" delim))
(LaTeX-add-empheq-declaredelimiters `(,delim "Right"))
- (concat TeX-esc delim))))))
+ (TeX-argument-insert delim optional TeX-esc)))))
;; 4.2 Fine-tuning of delimiters
(LaTeX-add-lengths "EmphEqdelimitershortfall")
diff --git a/style/enumitem.el b/style/enumitem.el
index f8e8737b..5c120e33 100644
--- a/style/enumitem.el
+++ b/style/enumitem.el
@@ -238,8 +238,7 @@
`(,env LaTeX-env-item-args
[TeX-arg-key-val (LaTeX-enumitem-key-val-options)]))
;; Tell AUCTeX about parsed description like environments.
- (when (or (string-equal type "description")
- (string-equal type "description*"))
+ (when (member type '("description" "description*"))
(add-to-list 'LaTeX-item-list `(,env . LaTeX-item-argument)))
;; Add new env's to `ispell-tex-skip-alist': skip the opt. arg:
(TeX-ispell-skip-setcdr `((,env ispell-tex-arg-end 0))))))
@@ -343,25 +342,29 @@ macro. Insert the value in brackets if OPTIONAL is
non-nil."
;; But we go the extra mile to improve the user experience and add
;; the arguments directly to appropriate lists.
;; \newlist{<name>}{<type>}{<max-depth>}
- '("newlist"
- (TeX-arg-eval
- (lambda ()
- (let ((name (TeX-read-string "Name: "))
- (type (completing-read
- "Type: "
- (mapcar #'cadr (LaTeX-enumitem-newlist-list))))
- (depth (TeX-read-string "Max-depth: ")))
- (when (or (string-equal type "description")
- (string-equal type "description*"))
- (add-to-list 'LaTeX-item-list `(,name . LaTeX-item-argument)))
+ `("newlist"
+ ,(lambda (optional)
+ (let ((name (TeX-read-string
+ (TeX-argument-prompt optional nil "Name"))))
(LaTeX-add-environments
`(,name LaTeX-env-item-args
[TeX-arg-key-val (LaTeX-enumitem-key-val-options)]))
- (LaTeX-add-enumitem-newlists (list name type))
(TeX-ispell-skip-setcdr `((,name ispell-tex-arg-end 0)))
- (TeX-argument-insert name nil)
- (TeX-argument-insert type nil)
- (format "%s" depth)))))
+ (TeX-argument-insert name optional)))
+ (TeX-arg-completing-read ,(lambda ()
+ (mapcar #'cadr
+ (LaTeX-enumitem-newlist-list)))
+ "Type")
+ "Max-depth"
+ ,(lambda (_optional)
+ (save-excursion
+ (re-search-backward "\\\\newlist{\\([^}]+\\)}{\\([^}]+\\)}"
+ (line-beginning-position) t))
+ (let ((name (match-string-no-properties 1))
+ (type (match-string-no-properties 2)))
+ (when (member type '("description" "description*"))
+ (add-to-list 'LaTeX-item-list `(,name . LaTeX-item-argument)))
+ (LaTeX-add-enumitem-newlists (list name type)))))
;; \renewlist{<name>}{<type>}{<max-depth>}
`("renewlist"
@@ -428,8 +431,7 @@ macro. Insert the value in brackets if OPTIONAL is
non-nil."
(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*"))
+ (when (member type '("enumerate" "enumerate*"))
(push env enums))))
enums))
"List name"))
diff --git a/style/fancyvrb.el b/style/fancyvrb.el
index 6703a30e..ccf68d2a 100644
--- a/style/fancyvrb.el
+++ b/style/fancyvrb.el
@@ -308,13 +308,14 @@ RECUSTOM is non-nil, delete macros from the variable
(TeX-add-symbols
`(,mac-name
[TeX-arg-key-val (LaTeX-fancyvrb-key-val-options)]
- (TeX-arg-eval
- (lambda ()
+ ,(lambda (optional)
(let ((name (TeX-read-string
- (TeX-argument-prompt nil nil "Save name"))))
+ (TeX-argument-prompt optional nil "Save
name"))))
(LaTeX-add-fancyvrb-saveverbs name)
- (format "%s" name))))
- TeX-arg-verb))
+ (TeX-argument-insert name optional)))
+ (TeX-arg-conditional (member "fvextra" (TeX-style-list))
+ (TeX-arg-verb-delim-or-brace)
+ (TeX-arg-verb))))
(when (and (fboundp 'font-latex-add-keywords)
(eq TeX-install-font-lock 'font-latex-setup))
(font-latex-add-keywords `((,mac-name "[{"))
@@ -333,16 +334,23 @@ RECUSTOM is non-nil, delete macros from the variable
(TeX-add-symbols
`(,mac-name
[TeX-arg-key-val (LaTeX-fancyvrb-key-val-options)]
- TeX-arg-verb)
+ (TeX-arg-conditional (member "fvextra" (TeX-style-list))
+ (TeX-arg-verb-delim-or-brace)
+ (TeX-arg-verb)))
;; Defined macros have a starred version where the
;; `showspaces' key is set to true
`(,(concat mac-name "*")
[TeX-arg-key-val (LaTeX-fancyvrb-key-val-options)]
- TeX-arg-verb))
- (add-to-list 'LaTeX-verbatim-macros-with-delims-local
- mac-name t)
- (add-to-list 'LaTeX-verbatim-macros-with-delims-local
- (concat mac-name "*") t)
+ (TeX-arg-conditional (member "fvextra" (TeX-style-list))
+ (TeX-arg-verb-delim-or-brace)
+ (TeX-arg-verb))))
+ (dolist (elt `(,mac-name ,(concat mac-name "*")))
+ (add-to-list 'LaTeX-verbatim-macros-with-delims-local
+ elt t))
+ (when (member "fvextra" (TeX-style-list))
+ (dolist (elt `(,mac-name ,(concat mac-name "*")))
+ (add-to-list 'LaTeX-verbatim-macros-with-braces-local
+ elt t)))
(when (and (fboundp 'font-latex-add-keywords)
(eq TeX-install-font-lock 'font-latex-setup))
(font-latex-add-keywords `((,mac-name "*["))
@@ -570,21 +578,15 @@ ENV is the name of current environment as a string."
;; Improved verbatim commands
'("Verb" [TeX-arg-key-val (LaTeX-fancyvrb-key-val-options)]
(TeX-arg-conditional (member "fvextra" (TeX-style-list))
- (TeX-arg-verb-delim-or-brace)
- (TeX-arg-verb)))
+ (TeX-arg-verb-delim-or-brace)
+ (TeX-arg-verb)))
;; \Verb also has a starred version
'("Verb*" [TeX-arg-key-val (LaTeX-fancyvrb-key-val-options)]
(TeX-arg-conditional (member "fvextra" (TeX-style-list))
- (TeX-arg-verb-delim-or-brace)
- (TeX-arg-verb)))
- '("DefineShortVerb" (TeX-arg-eval
- TeX-read-string
- (TeX-argument-prompt nil nil "Character")
- TeX-esc))
- '("UndefineShortVerb" (TeX-arg-eval
- TeX-read-string
- (TeX-argument-prompt nil nil "Character")
- TeX-esc))
+ (TeX-arg-verb-delim-or-brace)
+ (TeX-arg-verb)))
+ `("DefineShortVerb" (TeX-arg-string "Character" ,TeX-esc))
+ `("UndefineShortVerb" (TeX-arg-string "Character" ,TeX-esc))
;; Verbatim environments
'("fvset" (TeX-arg-key-val (LaTeX-fancyvrb-key-val-options)))
;; Changing individual line formatting
@@ -611,17 +613,16 @@ ENV is the name of current environment as a string."
(LaTeX-fancyvrb-arg-define-macro nil t))
;; Saving and restoring verbatim text and environments
- '("SaveVerb"
+ `("SaveVerb"
[TeX-arg-key-val (LaTeX-fancyvrb-key-val-options)]
- (TeX-arg-eval
- (lambda ()
+ ,(lambda (optional)
(let ((name (TeX-read-string
- (TeX-argument-prompt nil nil "Save name"))))
+ (TeX-argument-prompt optional nil "Save name"))))
(LaTeX-add-fancyvrb-saveverbs name)
- (format "%s" name))))
+ (TeX-argument-insert name optional)))
(TeX-arg-conditional (member "fvextra" (TeX-style-list))
- (TeX-arg-verb-delim-or-brace)
- (TeX-arg-verb)))
+ (TeX-arg-verb-delim-or-brace)
+ (TeX-arg-verb)))
'("UseVerb" (TeX-arg-completing-read (LaTeX-fancyvrb-saveverb-list)
"Saved name"))
;; \UseVerb also has a starred version
@@ -661,26 +662,16 @@ ENV is the name of current environment as a string."
'("LVerbatim*" LaTeX-env-args
[TeX-arg-key-val (LaTeX-fancyvrb-key-val-options)]
LaTeX-fancyvrb-env-reflabel-key-val)
- '("SaveVerbatim"
- (lambda (env)
- (let ((options (TeX-read-key-val t (LaTeX-fancyvrb-key-val-options)))
- (name (TeX-read-string "Save name: ")))
- (LaTeX-insert-environment
- env
- (concat
- (unless (zerop (length options))
- (concat LaTeX-optop options LaTeX-optcl))
- (concat TeX-grop name TeX-grcl)))
- (LaTeX-add-fancyvrb-saveverbatims name))))
- '("VerbatimOut"
- (lambda (env)
- (let ((options (TeX-read-key-val t (LaTeX-fancyvrb-key-val-options)))
- (file (TeX-read-string "Output file: ")))
- (LaTeX-insert-environment
- env
- (concat (unless (zerop (length options))
- (concat LaTeX-optop options LaTeX-optcl))
- (concat TeX-grop file TeX-grcl)))))))
+ `("SaveVerbatim" LaTeX-env-args
+ [TeX-arg-key-val (LaTeX-fancyvrb-key-val-options)]
+ ,(lambda (optional)
+ (let ((name (TeX-read-string
+ (TeX-argument-prompt optional nil "Save name"))))
+ (LaTeX-add-fancyvrb-saveverbatims name)
+ (TeX-argument-insert name optional))))
+ '("VerbatimOut" LaTeX-env-args
+ [TeX-arg-key-val (LaTeX-fancyvrb-key-val-options)]
+ "Output file"))
(let ((envs '("BVerbatim" "BVerbatim*"
"LVerbatim" "LVerbatim*"
diff --git a/style/floatrow.el b/style/floatrow.el
index 57596ee7..00c2a4be 100644
--- a/style/floatrow.el
+++ b/style/floatrow.el
@@ -296,7 +296,20 @@
;; Process new float commands like \ffigbox:
(when (LaTeX-floatrow-newfloatcommand-list)
(dolist (cmd (mapcar #'car (LaTeX-floatrow-newfloatcommand-list)))
- (TeX-add-symbols `(,cmd LaTeX-floatrow-arg-floatbox))
+ (TeX-add-symbols
+ `(,cmd
+ [TeX-arg-completing-read ,(lambda ()
+ (mapcar (lambda (x)(concat TeX-esc (car
x)))
+ (LaTeX-length-list)))
+ "Width"]
+ [TeX-arg-completing-read ,(lambda ()
+ (mapcar (lambda (x)
+ (concat TeX-esc (car x)))
+ (LaTeX-length-list)))
+ "Height"]
+ [TeX-arg-completing-read ("t" "c" "b" "s")
+ "Vertical alignment"]
+ LaTeX-floatrow-arg-floatbox))
(when (and (featurep 'font-latex)
(eq TeX-install-font-lock 'font-latex-setup))
(font-latex-add-keywords `((,cmd "[[["))
@@ -355,44 +368,10 @@
(defun LaTeX-floatrow-arg-floatbox (optional)
"Query and insert arguments of float box commands from floatrow.sty.
If OPTIONAL is non-nil, indicate optional argument during query."
- ;; Query for the optional arguments; ask for "vertpos" only if
- ;; "height" is given. let-bind `TeX-arg-*-brace' for
- ;; `TeX-argument-insert':
- (let* ((TeX-arg-opening-brace "[")
- (TeX-arg-closing-brace "]")
- (TeX-last-optional-rejected nil)
- (width (LaTeX-check-insert-macro-default-style
- (completing-read
- (TeX-argument-prompt t nil "Width")
- (mapcar (lambda (x) (concat TeX-esc (car x)))
- (LaTeX-length-list)))))
- (TeX-last-optional-rejected (or (not width)
- (and width (string= width ""))))
- (height (LaTeX-check-insert-macro-default-style
- (completing-read
- (TeX-argument-prompt t nil "Height")
- (mapcar (lambda (x) (concat TeX-esc (car x)))
- (LaTeX-length-list)))))
- (TeX-last-optional-rejected (or (not height)
- (and height (string= height ""))))
- (vertpos (LaTeX-check-insert-macro-default-style
- (if (string= height "")
- ""
- (completing-read
- (TeX-argument-prompt t nil "Vertical alignment")
- '("t" "c" "b" "s"))))))
- (and width (TeX-argument-insert width t))
- ;; Insert an extra pair of brackets if only `height' is given,
- ;; otherwise it will become `width'
- (when (and width (string= width "")
- height (not (string= height "")))
- (insert "[]"))
- (and height (TeX-argument-insert height t))
- (and vertpos (TeX-argument-insert vertpos t)))
- ;; Now query for the (short-)caption. Also check for the
- ;; float-type; if we're inside (sub)?floatrow*?, then check for the
- ;; next outer environment:
- (let* ((currenv (if (string-match "floatrow\\*?\\_>"
(LaTeX-current-environment))
+ ;; Query for the (short-)caption. Also check for the float-type; if
+ ;; we're inside (sub)?floatrow*?, then check for the next outer
+ ;; environment:
+ (let* ((currenv (if (string-match "floatrow\\*?\\'"
(LaTeX-current-environment))
(LaTeX-current-environment 2)
(LaTeX-current-environment)))
(caption (TeX-read-string
@@ -561,23 +540,48 @@ only the parsed items."
(TeX-add-symbols
;; 2.1 The \floatbox Macro
;; \floatbox[<preamble>]{<captype>}[<width>][<height>][<vert
pos>]{<caption>}{<object>}
- '("floatbox"
+ `("floatbox"
[TeX-arg-completing-read ("\\capbeside" "\\nocapbeside" "\\captop")
"Preamble"]
(TeX-arg-completing-read LaTeX-floatrow-supported-float-types
"Float type")
+ [TeX-arg-completing-read ,(lambda ()
+ (mapcar (lambda (x)
+ (concat TeX-esc (car x)))
+ (LaTeX-length-list)))
+ "Width"]
+ [TeX-arg-completing-read ,(lambda ()
+ (mapcar (lambda (x)
+ (concat TeX-esc (car x)))
+ (LaTeX-length-list)))
+ "Height"]
+ [TeX-arg-completing-read ("t" "c" "b" "s")
+ "Vertical alignment"]
LaTeX-floatrow-arg-floatbox)
;; 2.2 Creation of Personal Commands for Float Boxes
- '("newfloatcommand"
- (TeX-arg-eval
- (lambda ()
+ `("newfloatcommand"
+ ,(lambda (optional)
(let ((cmd (TeX-read-string
- (TeX-argument-prompt nil nil "Command"))))
+ (TeX-argument-prompt optional nil "Command"))))
(LaTeX-add-floatrow-newfloatcommands cmd)
(TeX-add-symbols
- `(,cmd LaTeX-floatrow-arg-floatbox))
- (format "%s" cmd))))
+ `(,cmd [TeX-arg-completing-read
+ ,(lambda ()
+ (mapcar (lambda (x)
+ (concat TeX-esc (car x)))
+ (LaTeX-length-list)))
+ "Width"]
+ [TeX-arg-completing-read
+ ,(lambda ()
+ (mapcar (lambda (x)
+ (concat TeX-esc (car x)))
+ (LaTeX-length-list)))
+ "Height"]
+ [TeX-arg-completing-read ("t" "c" "b" "s")
+ "Vertical alignment"]
+ LaTeX-floatrow-arg-floatbox))
+ (TeX-argument-insert cmd optional)))
(TeX-arg-completing-read ("figure" "table") "Float type")
[ 2 ])
@@ -588,13 +592,49 @@ only the parsed items."
[ 2 ])
;; 2.2.2 Predefined Float Box Commands
- '("ffigbox"
+ `("ffigbox"
+ [TeX-arg-completing-read ,(lambda ()
+ (mapcar (lambda (x)
+ (concat TeX-esc (car x)))
+ (LaTeX-length-list)))
+ "Width"]
+ [TeX-arg-completing-read ,(lambda ()
+ (mapcar (lambda (x)
+ (concat TeX-esc (car x)))
+ (LaTeX-length-list)))
+ "Height"]
+ [TeX-arg-completing-read ("t" "c" "b" "s")
+ "Vertical alignment"]
LaTeX-floatrow-arg-floatbox)
- '("ttabbox"
+ `("ttabbox"
+ [TeX-arg-completing-read ,(lambda ()
+ (mapcar (lambda (x)
+ (concat TeX-esc (car x)))
+ (LaTeX-length-list)))
+ "Width"]
+ [TeX-arg-completing-read ,(lambda ()
+ (mapcar (lambda (x)
+ (concat TeX-esc (car x)))
+ (LaTeX-length-list)))
+ "Height"]
+ [TeX-arg-completing-read ("t" "c" "b" "s")
+ "Vertical alignment"]
LaTeX-floatrow-arg-floatbox)
- '("fcapside"
+ `("fcapside"
+ [TeX-arg-completing-read ,(lambda ()
+ (mapcar (lambda (x)
+ (concat TeX-esc (car x)))
+ (LaTeX-length-list)))
+ "Width"]
+ [TeX-arg-completing-read ,(lambda ()
+ (mapcar (lambda (x)
+ (concat TeX-esc (car x)))
+ (LaTeX-length-list)))
+ "Height"]
+ [TeX-arg-completing-read ("t" "c" "b" "s")
+ "Vertical alignment"]
LaTeX-floatrow-arg-floatbox)
;; 2.3.1 Mixed Row
diff --git a/style/fontspec.el b/style/fontspec.el
index 90018a21..a19d5ce5 100644
--- a/style/fontspec.el
+++ b/style/fontspec.el
@@ -390,18 +390,16 @@ to appropriate keys which are eventually prepended to
"Existing feature")
"New name")
- '("aliasfontfeatureoption"
- (TeX-arg-eval
- (lambda ()
- (let* ((key (completing-read
- (TeX-argument-prompt nil nil "Feature")
- (LaTeX-fontspec-font-features)))
- (val (completing-read
- (TeX-argument-prompt nil nil "Existing name")
- (cadr (assoc key (LaTeX-fontspec-font-features))))))
- (TeX-argument-insert key nil)
- (format "%s" val))))
- "New name") )
+ `("aliasfontfeatureoption"
+ (TeX-arg-completing-read (LaTeX-fontspec-font-features) "Feature")
+ (TeX-arg-completing-read
+ ,(lambda ()
+ (save-excursion
+ (re-search-backward "\\\\aliasfontfeatureoption{\\([^}]+\\)}"
+ (line-beginning-position) t))
+ (cadr (assoc (match-string-no-properties 1)
+ (LaTeX-fontspec-font-features)))))
+ "New Name") )
(LaTeX-add-environments
;; 4.6 Strong emphasis
diff --git a/style/footmisc.el b/style/footmisc.el
index 2fb0385f..02dd833d 100644
--- a/style/footmisc.el
+++ b/style/footmisc.el
@@ -37,6 +37,10 @@
"font-latex"
(keywords class))
+(defvar LaTeX-footmisc-fnsymbols-set '("bringhurst" "chicago" "wiley"
+ "lamport" "lamport*")
+ "Sets of footnote symbols provided by the footmisc package.")
+
(TeX-add-style-hook
"footmisc"
(lambda ()
@@ -47,34 +51,24 @@
;; 1.7 The \setfnsymbol and \DefineFNsymbols commands
'("DefineFNsymbols"
- (TeX-arg-completing-read ("bringhurst" "chicago" "wiley"
- "lamport" "lamport*")
- "Name")
+ (TeX-arg-completing-read LaTeX-footmisc-fnsymbols-set "Name")
[TeX-arg-completing-read ("text" "math") "Style"]
1)
'("DefineFNsymbols*"
- (TeX-arg-completing-read ("bringhurst" "chicago" "wiley"
- "lamport" "lamport*")
- "Name")
+ (TeX-arg-completing-read LaTeX-footmisc-fnsymbols-set "Name")
[TeX-arg-completing-read ("text" "math") "Style"]
1)
;; These two commands define both text and math variants of the
;; footnote symbols
'("DefineFNsymbolsTM"
- (TeX-arg-completing-read ("bringhurst" "chicago" "wiley"
- "lamport" "lamport*")
- "Name")
+ (TeX-arg-completing-read LaTeX-footmisc-fnsymbols-set "Name")
1)
'("DefineFNsymbolsTM*"
- (TeX-arg-completing-read ("bringhurst" "chicago" "wiley"
- "lamport" "lamport*")
- "Name")
+ (TeX-arg-completing-read LaTeX-footmisc-fnsymbols-set "Name")
1)
'("setfnsymbol"
- (TeX-arg-completing-read ("bringhurst" "chicago" "wiley"
- "lamport" "lamport*")
- "Name"))
+ (TeX-arg-completing-read LaTeX-footmisc-fnsymbols-set "Name"))
;; 1.11 Option hang
"hangfootparskip"
@@ -85,8 +79,6 @@
"multfootsep"
;; 1.16 User interface
- ;; The following command references a label inside in a footnote
- '("footref" TeX-arg-ref)
"mpfootnotemark")
;; 1.9 Option marginal
@@ -103,9 +95,7 @@
(font-latex-add-keywords '(("DefineFNsymbols" "*{[{")
("DefineFNsymbolsTM" "*{{")
("setfnsymbol" "{"))
- 'function)
- (font-latex-add-keywords '(("footref"))
- 'reference)))
+ 'function)))
TeX-dialect)
(defvar LaTeX-footmisc-package-options '("perpage" "side" "ragged"
diff --git a/style/fvextra.el b/style/fvextra.el
index 3bb11e81..c74baf13 100644
--- a/style/fvextra.el
+++ b/style/fvextra.el
@@ -26,7 +26,7 @@
;;; Commentary:
-;; This file adds support for `fvextra.sty' (v1.4) from 2019/02/04.
+;; This file adds support for `fvextra.sty' (v1.5) from 2022/11/30.
;; `fvextra.sty' is part of TeXLive.
;;; Code:
@@ -75,7 +75,7 @@
("tabcolor" ("none"))
;; 7.1 Line breaking options
("breakafter" ("none"))
- ("breakaftergroup" ("true" "false"))
+ ("breakafterinrun" ("true" "false"))
("breakaftersymbolpre")
("breakaftersymbolpost")
("breakanywhere" ("true" "false"))
@@ -83,12 +83,13 @@
("breakanywheresymbolpost")
("breakautoindent" ("true" "false"))
("breakbefore")
- ("breakbeforegroup" ("true" "false"))
+ ("breakbeforeinrun" ("true" "false"))
("breakbeforesymbolpre")
("breakbeforesymbolpost")
("breakindent")
("breakindentnchars")
("breaklines" ("true" "false"))
+ ("breaknonspaceingroup" ("true" "false"))
("breaksymbol")
("breaksymbolleft")
("breaksymbolright")
@@ -118,6 +119,7 @@
'("fvinlineset" (TeX-arg-key-val (LaTeX-fancyvrb-key-val-options)))
;; 4.2 Line and text formatting
+ "FancyVerbFormatInline"
"FancyVerbFormatText"
;; 6 New commands and environments
@@ -136,6 +138,16 @@
"FancyVerbBreakBeforeBreak"
"FancyVerbBreakAfterBreak")
+ ;; 6.2 VerbEnv environment
+ (LaTeX-add-environments
+ '("VerbEnv" LaTeX-env-args
+ [TeX-arg-key-val (LaTeX-fancyvrb-key-val-options)]))
+
+ ;; Filling
+ (add-to-list 'LaTeX-verbatim-environments-local "VerbEnv")
+ (add-to-list (make-local-variable 'LaTeX-indent-environment-list)
+ '("VerbEnv" current-indentation) t)
+
;; Add \Verb*? and \EscVerb*? to
;; `LaTeX-verbatim-macros-with-braces-local':
(let ((macs '("Verb" "Verb*"
diff --git a/style/geometry.el b/style/geometry.el
index cc93d840..f1cab730 100644
--- a/style/geometry.el
+++ b/style/geometry.el
@@ -1,6 +1,6 @@
;;; geometry.el --- AUCTeX style for `geometry.sty' (v5.6) -*-
lexical-binding: t; -*-
-;; Copyright (C) 2015, 2018, 2020 Free Software Foundation, Inc.
+;; Copyright (C) 2015--2022 Free Software Foundation, Inc.
;; Author: Arash Esbati <arash@gnu.org>
;; Maintainer: auctex-devel@gnu.org
@@ -113,27 +113,24 @@ package.")
;; geometry commands:
(TeX-add-symbols
- '("geometry"
- (TeX-arg-eval TeX-read-key-val nil
- (append LaTeX-geometry-preamble-key-val-options
- LaTeX-geometry-always-key-val-options)))
+ `("geometry"
+ (TeX-arg-key-val ,(append LaTeX-geometry-preamble-key-val-options
+ LaTeX-geometry-always-key-val-options)))
'("newgeometry"
(TeX-arg-key-val LaTeX-geometry-always-key-val-options))
'("restoregeometry" 0)
- '("savegeometry"
- (TeX-arg-eval
- (lambda ()
- (let ((name (TeX-read-string "Name: ")))
+ `("savegeometry"
+ ,(lambda (optional)
+ (let ((name (TeX-read-string
+ (TeX-argument-prompt optional nil "Name"))))
(LaTeX-add-geometry-savegeometries name)
- (format "%s" name)))))
+ (TeX-argument-insert name optional))))
'("loadgeometry"
- (TeX-arg-eval
- (lambda ()
- (completing-read "Name: "
- (LaTeX-geometry-savegeometry-list))))))
+ (TeX-arg-completing-read (LaTeX-geometry-savegeometry-list)
+ "Name")))
;; Fontification
(when (and (featurep 'font-latex)
diff --git a/style/graphics.el b/style/graphics.el
index 4cdd31c1..d7f2682d 100644
--- a/style/graphics.el
+++ b/style/graphics.el
@@ -11,10 +11,10 @@
(TeX-load-style "graphicx")
(defvar LaTeX-graphics-package-options LaTeX-graphicx-package-options)
-(TeX-add-style-hook "graphics"
- (function
- (lambda ()
- (TeX-run-style-hooks "graphicx")))
+(TeX-add-style-hook
+ "graphics"
+ (lambda ()
+ (TeX-run-style-hooks "graphicx"))
TeX-dialect)
;;; graphics.el ends here.
diff --git a/style/graphicx.el b/style/graphicx.el
index 36e8dada..bc0dd8fc 100644
--- a/style/graphicx.el
+++ b/style/graphicx.el
@@ -66,6 +66,25 @@
("alt"))
"Key=value options for graphicx macros.")
+(defun LaTeX-graphicx-key-val-options ()
+ "Return an updated list of key=vals from graphicx package.
+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 keys \"page\" and \"pagebox\" to list of
+key=vals."
+ (if (and (or (and (eq TeX-engine 'default)
+ (not (TeX-PDF-from-DVI)))
+ (eq TeX-engine 'luatex)
+ ;; dvipdfmx can handle page and
+ ;; pagebox options.
+ (string= (TeX-PDF-from-DVI) "Dvipdfmx"))
+ TeX-PDF-mode)
+ (append '(("page")
+ ("pagebox" ("mediabox" "cropbox" "bleedbox"
+ "trimbox" "artbox")))
+ LaTeX-graphicx-key-val-options)
+ LaTeX-graphicx-key-val-options))
+
(defvar LaTeX-includegraphics-dvips-extensions
'("eps" "mps" "EPS")
"List of extensions for image files supported by \"dvips\".")
@@ -82,42 +101,6 @@
"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 keys \"page\" and \"pagebox\" 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)
- ;; dvipdfmx can handle page and
- ;; pagebox options.
- (string= (TeX-PDF-from-DVI) "Dvipdfmx"))
- TeX-PDF-mode)
- (append '(("page")
- ("pagebox" ("mediabox"
- "cropbox"
- "bleedbox"
- "trimbox"
- "artbox")))
- LaTeX-graphicx-key-val-options)
- LaTeX-graphicx-key-val-options))
- optional)))
-
(defun LaTeX-includegraphics-extensions-list ()
"Return appropriate extensions for input files to \\includegraphics.
Return value is a list of regexps."
@@ -272,20 +255,22 @@ subdirectories and inserts the relative file name. See
"Argument")
'("rotatebox" (TeX-arg-conditional (member "graphics" (TeX-style-list))
- ()
- ([ TeX-arg-key-val (("x") ("y")
("origin") ("units")) ]))
+ ()
+ ([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 ]))
+ (["llx,lly"] ["urx,ury"])
+ ([TeX-arg-key-val (LaTeX-graphicx-key-val-options)
+ nil nil ?\s]))
LaTeX-arg-includegraphics)
'("includegraphics*" (TeX-arg-conditional (member "graphics"
(TeX-style-list))
- (["llx,lly"] ["urx,ury"])
- ([
LaTeX-arg-graphicx-includegraphics-key-val ]))
+ (["llx,lly"] ["urx,ury"])
+ ([TeX-arg-key-val (LaTeX-graphicx-key-val-options)
+ nil nil ?\s]))
LaTeX-arg-includegraphics)
'("graphicspath" t)
diff --git a/style/hologo.el b/style/hologo.el
index 7e460893..edf24dbb 100644
--- a/style/hologo.el
+++ b/style/hologo.el
@@ -32,6 +32,7 @@
;;; Code:
(require 'tex)
+(require 'latex)
;; Silence the compiler:
(declare-function font-latex-add-keywords
@@ -106,17 +107,18 @@
"space" "hyphen" "runtogether"))) ; plainTeX
"Local key=value options for hologo macros.")
-(defun LaTeX-hologo--arg-use-region-or-query-logo-name (optional)
- (if (and (use-region-p)
- (member (buffer-substring (region-beginning) (region-end))
- LaTeX-hologo-logo-names))
- (progn
- (insert TeX-grop)
- (goto-char (region-end))
- (insert TeX-grcl))
- (TeX-argument-insert
- (completing-read "Logo name: " LaTeX-hologo-logo-names)
- optional)))
+(defun LaTeX-hologo--arg-use-region-or-query-logo-name ()
+ "Check if region is active and over element from `LaTeX-hologo-logo-names'."
+ (and (use-region-p)
+ (member (buffer-substring (region-beginning) (region-end))
+ LaTeX-hologo-logo-names)))
+
+(defun LaTeX-hologo--arg-use-region (_optional)
+ "Wrap region around braces.
+OPTIONAL is ignored."
+ (insert TeX-grop)
+ (goto-char (region-end))
+ (insert TeX-grcl))
(TeX-add-style-hook
"hologo"
@@ -124,35 +126,40 @@
(TeX-add-symbols
;; Insert logo macros
- '("hologo" LaTeX-hologo--arg-use-region-or-query-logo-name)
- '("Hologo" LaTeX-hologo--arg-use-region-or-query-logo-name)
+ `("hologo"
+ (TeX-arg-conditional (LaTeX-hologo--arg-use-region-or-query-logo-name)
+ (LaTeX-hologo--arg-use-region)
+ ((TeX-arg-completing-read LaTeX-hologo-logo-names "Logo name"))))
+ `("Hologo"
+ (TeX-arg-conditional (LaTeX-hologo--arg-use-region-or-query-logo-name)
+ (LaTeX-hologo--arg-use-region)
+ ((TeX-arg-completing-read LaTeX-hologo-logo-names "Logo name"))))
;; Setup macros
'("hologoSetup" (TeX-arg-key-val LaTeX-hologo-key-val-options-global))
- '("hologoLogoSetup"
- (TeX-arg-eval
- (lambda ()
- (let* ((logo (completing-read "Logo name: "
LaTeX-hologo-logo-names))
- (keyval (TeX-read-key-val
- nil
- (cond ((string= logo "BibTeX")
- (append '(("variant" ("sf" "sc")))
- LaTeX-hologo-key-val-options-global))
- ((string= logo "ConTeXt")
- (append '(("variant" ("narrow" "simple")))
- LaTeX-hologo-key-val-options-global))
- ((string= logo "plainTeX")
- (append '(("variant" ("space" "hyphen"
"runtogether")))
- LaTeX-hologo-key-val-options-global))
- ((or (string= logo "SLiTeX")
- (string= logo "SliTeX"))
- (append '(("variant" ("lift" "narrow" "lift")))
- LaTeX-hologo-key-val-options-global))
- (t
- LaTeX-hologo-key-val-options-global)))))
- (TeX-argument-insert logo nil)
- (format "%s" keyval)))))
+ `("hologoLogoSetup"
+ (TeX-arg-completing-read LaTeX-hologo-logo-names "Logo name")
+ (TeX-arg-key-val ,(lambda ()
+ (save-excursion
+ (re-search-backward
"\\\\hologoLogoSetup{\\([^}]+\\)}"
+ (line-beginning-position) t))
+ (let ((logo (match-string-no-properties 1)))
+ (cond ((string= logo "BibTeX")
+ (append '(("variant" ("sf" "sc")))
+
LaTeX-hologo-key-val-options-global))
+ ((string= logo "ConTeXt")
+ (append '(("variant" ("narrow" "simple")))
+
LaTeX-hologo-key-val-options-global))
+ ((string= logo "plainTeX")
+ (append '(("variant" ("space" "hyphen"
"runtogether")))
+
LaTeX-hologo-key-val-options-global))
+ ((or (string= logo "SLiTeX")
+ (string= logo "SliTeX"))
+ (append '(("variant" ("lift" "narrow"
"lift")))
+
LaTeX-hologo-key-val-options-global))
+ (t
+ LaTeX-hologo-key-val-options-global))))))
'("hologoDriverSetup" (TeX-arg-completing-read
("pdftex" "luatex"
@@ -165,47 +172,44 @@
(TeX-arg-key-val (("general") ("bibsf")
("rm") ("sc") ("sf") ("sy") ("logo"))))
- '("hologoLogoFontSetup"
- (TeX-arg-eval
- (lambda ()
- (let* ((logo (completing-read "Logo name: "
- '("BibTeX"
- "ExTeX"
- "SliTeX"
- "AmS"
- "NTS"
- "KOMAScript"
- "METAFONT"
- "METAPOST")))
- (keyval (TeX-read-key-val
- nil
- (cond ((string= logo "BibTeX")
- '(("bibsf") ("sc")))
- ((string= logo "ExTeX")
- '(("rm") ("sy")))
- ((string= logo "SliTeX")
- '(("rm") ("sc")))
- ((or (string= logo "AmS")
- (string= logo "NTS"))
- '(("sy")))
- ((string= logo "KOMAScript")
- '(("sf")))
- ((or (string= logo "METAFONT")
- (string= logo "METAPOST"))
- '(("logo")))
- (t
- nil)))))
- (TeX-argument-insert logo nil)
- (format "%s" keyval)))))
+ `("hologoLogoFontSetup"
+ (TeX-arg-completing-read ("BibTeX" "ExTeX" "SliTeX" "AmS" "NTS"
+ "KOMAScript" "METAFONT" "METAPOST")
+ "Logo name")
+ (TeX-arg-key-val ,(lambda ()
+ (save-excursion
+ (re-search-backward
"\\\\hologoLogoFontSetup{\\([^}]+\\)}"
+ (line-beginning-position) t))
+ (let ((logo (match-string-no-properties 1)))
+ (cond ((string= logo "BibTeX")
+ '(("bibsf") ("sc")))
+ ((string= logo "ExTeX")
+ '(("rm") ("sy")))
+ ((string= logo "SliTeX")
+ '(("rm") ("sc")))
+ ((or (string= logo "AmS")
+ (string= logo "NTS"))
+ '(("sy")))
+ ((string= logo "KOMAScript")
+ '(("sf")))
+ ((or (string= logo "METAFONT")
+ (string= logo "METAPOST"))
+ '(("logo")))
+ (t
+ nil))))))
;; Additional user macros
`("hologoVariant"
- LaTeX-hologo--arg-use-region-or-query-logo-name
+ (TeX-arg-conditional (LaTeX-hologo--arg-use-region-or-query-logo-name)
+ (LaTeX-hologo--arg-use-region)
+ ((TeX-arg-completing-read LaTeX-hologo-logo-names "Logo name")))
(TeX-arg-key-val ,(append LaTeX-hologo-key-val-options-local
LaTeX-hologo-key-val-options-global)))
`("HologoVariant"
- LaTeX-hologo--arg-use-region-or-query-logo-name
+ (TeX-arg-conditional (LaTeX-hologo--arg-use-region-or-query-logo-name)
+ (LaTeX-hologo--arg-use-region)
+ ((TeX-arg-completing-read LaTeX-hologo-logo-names "Logo name")))
(TeX-arg-key-val ,(append LaTeX-hologo-key-val-options-local
LaTeX-hologo-key-val-options-global)))
diff --git a/style/hyperref.el b/style/hyperref.el
index c225359b..7c123a91 100644
--- a/style/hyperref.el
+++ b/style/hyperref.el
@@ -226,7 +226,7 @@
(TeX-add-symbols
'("hypersetup" (TeX-arg-key-val LaTeX-hyperref-package-options-list))
- '("href" [ (TeX-arg-key-val LaTeX-hyperref-href-options) ] "URL" "Text")
+ '("href" [TeX-arg-key-val LaTeX-hyperref-href-options] "URL" "Text")
;; Completion for \url is provided via url.el. Hence the entry in
;; this style is commented:
;; '("url" "URL" ignore)
@@ -236,8 +236,8 @@
'("hyperdef" "Category" "Name" "Text")
'("hyperref"
(TeX-arg-conditional (y-or-n-p "Insert a label and text? ")
- ([TeX-arg-ref] "Text")
- ("URL" "Category" "Name" "Text")))
+ ([TeX-arg-ref] "Text")
+ ("URL" "Category" "Name" "Text")))
'("hyperlink" "Name" "Text")
'("hypertarget" "Name" "Text")
'("phantomsection" 0)
@@ -258,12 +258,12 @@
;; The next 6 macros take Key-vals defined in
;; "LaTeX-hyperref-forms-options". For an example, see
;; https://github.com/latex3/hyperref/blob/main/test/testform.tex
- '("TextField" [ (TeX-arg-key-val LaTeX-hyperref-forms-options) ] "Label")
- '("CheckBox" [ (TeX-arg-key-val LaTeX-hyperref-forms-options) ] "Label")
- '("ChoiceMenu" [ (TeX-arg-key-val LaTeX-hyperref-forms-options) ] "Label"
"Choices")
- '("PushButton" [ (TeX-arg-key-val LaTeX-hyperref-forms-options) ] "Label")
- '("Submit" [ (TeX-arg-key-val LaTeX-hyperref-forms-options) ] "Label")
- '("Reset" [ (TeX-arg-key-val LaTeX-hyperref-forms-options) ] "Label")
+ '("TextField" [TeX-arg-key-val LaTeX-hyperref-forms-options] "Label")
+ '("CheckBox" [TeX-arg-key-val LaTeX-hyperref-forms-options] "Label")
+ '("ChoiceMenu" [TeX-arg-key-val LaTeX-hyperref-forms-options] "Label"
"Choices")
+ '("PushButton" [TeX-arg-key-val LaTeX-hyperref-forms-options] "Label")
+ '("Submit" [TeX-arg-key-val LaTeX-hyperref-forms-options] "Label")
+ '("Reset" [TeX-arg-key-val LaTeX-hyperref-forms-options] "Label")
'("LayoutTextField" "Label" "Field")
'("LayoutChoiceField" "Label" "Field")
'("LayoutCheckField" "Label" "Field")
diff --git a/style/ifthen.el b/style/ifthen.el
index 6610f88e..0650975e 100644
--- a/style/ifthen.el
+++ b/style/ifthen.el
@@ -31,33 +31,29 @@
;;; Code:
(require 'tex)
+(require 'latex)
;; Silence the compiler:
(declare-function font-latex-add-keywords
"font-latex"
(keywords class))
-(defun LaTeX-arg-ifthen-test (optional &optional prompt)
- "Query and insert skeleton for a test in ifthen macros."
- (TeX-argument-insert
- (completing-read
- (TeX-argument-prompt optional prompt "Test")
- '("<" "=" ">"
- "\\isodd{}"
- "\\isundefined{}"
- "\\equal{}{}"
- "\\lengthtest{<}"
- "\\lengthtest{=}"
- "\\lengthtest{>}"
- "\\boolean{}"))
- optional))
+(defvar LaTeX-ifthen-test '("<" "=" ">"
+ "\\isodd{}"
+ "\\isundefined{}"
+ "\\equal{}{}"
+ "\\lengthtest{<}"
+ "\\lengthtest{=}"
+ "\\lengthtest{>}"
+ "\\boolean{}")
+ "List of tests in ifthen macros.")
(TeX-add-style-hook
"ifthen"
(lambda ()
(TeX-add-symbols
- '("ifthenelse" LaTeX-arg-ifthen-test t nil)
- '("whiledo" LaTeX-arg-ifthen-test t)
+ '("ifthenelse" (TeX-arg-completing-read LaTeX-ifthen-test "Test") t nil)
+ '("whiledo" (TeX-arg-completing-read LaTeX-ifthen-test "Test") t)
"AND"
"OR"
"NOT"
diff --git a/style/l3doc.el b/style/l3doc.el
index de11ee0f..a13f2179 100644
--- a/style/l3doc.el
+++ b/style/l3doc.el
@@ -186,13 +186,7 @@ For syntax environment from l3doc class."
'("NB" "Tag" t)
- '("DocInput"
- (TeX-arg-eval
- (lambda ()
- (let ((file (TeX-read-string
- (format "File(s) to include (default %s): "
(current-buffer))
- nil nil (current-buffer))))
- (format "%s" file)))))
+ ;; "DocInput": This macro is supplied in `doc.el'
;; 4.5 Describing functions in the implementation
'("TestFiles" "File(s)")
@@ -245,9 +239,7 @@ For syntax environment from l3doc class."
("TestFiles" "{")
("UnitTested" "")
("TestMissing" "{"))
- 'function)
- (font-latex-add-keywords '("DocInput" "{")
- 'reference)))
+ 'function)))
TeX-dialect)
(defvar LaTeX-l3doc-class-options
diff --git a/style/listings.el b/style/listings.el
index 43d1c191..d9352fc7 100644
--- a/style/listings.el
+++ b/style/listings.el
@@ -412,12 +412,12 @@ caption key is found, an error is issued."
;; New symbols
(TeX-add-symbols
'("lstalias" ["Alias dialect"] "Alias" ["Dialect"] "Language")
- '("lstdefinestyle"
- (TeX-arg-eval
- (lambda ()
- (let ((name (TeX-read-string "Style name: ")))
+ `("lstdefinestyle"
+ ,(lambda (optional)
+ (let ((name (TeX-read-string
+ (TeX-argument-prompt optional nil "Style name"))))
(LaTeX-add-listings-lstdefinestyles name)
- (format "%s" name))))
+ (TeX-argument-insert name optional)))
(TeX-arg-key-val (LaTeX-listings-key-val-options)))
'("lstinline" [TeX-arg-key-val (LaTeX-listings-key-val-options)]
TeX-arg-verb-delim-or-brace)
diff --git a/style/ltablex.el b/style/ltablex.el
index 1a6c0148..828abfce 100644
--- a/style/ltablex.el
+++ b/style/ltablex.el
@@ -1,6 +1,6 @@
;;; ltablex.el --- AUCTeX style for `ltablex.sty' (v1.1) -*- lexical-binding:
t; -*-
-;; Copyright (C) 2015, 2020 Free Software Foundation, Inc.
+;; Copyright (C) 2015--2022 Free Software Foundation, Inc.
;; Author: Arash Esbati <arash@gnu.org>
;; Maintainer: auctex-devel@gnu.org
@@ -34,6 +34,11 @@
;;; Code:
+;; Silence the compiler:
+(declare-function font-latex-add-keywords
+ "font-latex"
+ (keywords class))
+
(require 'tex)
(TeX-add-style-hook
@@ -42,7 +47,14 @@
(TeX-run-style-hooks "tabularx" "longtable")
(TeX-add-symbols
'("keepXColumns" 0)
- '("convertXColumns" 0)))
+ '("convertXColumns" 0))
+
+ ;; Fontification
+ (when (and (featurep 'font-latex)
+ (eq TeX-install-font-lock 'font-latex-setup))
+ (font-latex-add-keywords '(("keepXColumns" "")
+ ("convertXColumns" ""))
+ 'function)))
TeX-dialect)
(defvar LaTeX-ltablex-package-options nil
diff --git a/style/ltugboat.el b/style/ltugboat.el
index 92811dde..67d58e63 100644
--- a/style/ltugboat.el
+++ b/style/ltugboat.el
@@ -40,23 +40,6 @@
"font-latex"
(keywords class))
-(defun LaTeX-env-ltugboat-verbatim (environment)
- "Insert verbatim environment with an optional argument."
- (let* ((crm-separator (regexp-quote TeX-esc))
- (opts (mapconcat #'identity
- (TeX-completing-read-multiple
- (TeX-argument-prompt t nil "command(s)")
- '("\\tiny" "\\scriptsize" "\\footnotesize"
- "\\small" "\\normalsize" "\\large"
- "\\Large" "\\LARGE" "\\huge"
- "\\Huge" "\\makevmeta" "\\ruled")
- nil nil TeX-esc)
- TeX-esc)))
- (LaTeX-insert-environment environment
- (when (and opts
- (not (string= opts "")))
- (concat LaTeX-optop opts LaTeX-optcl)))))
-
(TeX-add-style-hook
"ltugboat"
(lambda ()
@@ -106,7 +89,14 @@
;; 8 Verbatim text
(LaTeX-add-environments
- '("verbatim" LaTeX-env-ltugboat-verbatim))
+ `("verbatim" LaTeX-env-args
+ [TeX-arg-completing-read-multiple ("tiny" "scriptsize" "footnotesize"
+ "small" "normalsize" "large"
+ "Large" "LARGE" "huge"
+ "Huge" "makevmeta" "ruled")
+ "Command(s)" nil nil
+ ,(regexp-quote TeX-esc)
+ ,TeX-esc nil nil nil nil ,TeX-esc]))
;; 10.1 Acronyms and logos
(TeX-add-symbols
diff --git a/style/ltxdoc.el b/style/ltxdoc.el
index 48040c46..112a9b2b 100644
--- a/style/ltxdoc.el
+++ b/style/ltxdoc.el
@@ -56,17 +56,17 @@
'("oarg" "Optional argument")
'("parg" "Picture mode argument")
- '("DocInclude"
- (TeX-arg-eval
- (lambda ()
+ `("DocInclude"
+ ,(lambda (optional)
(let ((file (file-relative-name
(read-file-name
- "File to include: " nil nil nil nil
+ (TeX-argument-prompt optional nil "File to include")
+ nil nil nil nil
(lambda (x)
(or (file-directory-p x)
(string-match "\\.\\(fdd\\|dtx\\)\\'" x))))
(TeX-master-directory))))
- (format "%s" file))))))
+ (TeX-argument-insert file optional)))))
;; Fontification
(when (and (featurep 'font-latex)
diff --git a/style/ltxtable.el b/style/ltxtable.el
index 51b9b025..3a0b97ea 100644
--- a/style/ltxtable.el
+++ b/style/ltxtable.el
@@ -58,19 +58,18 @@ The regexp for the 2. argument is the same as for \"input\"
and
(TeX-run-style-hooks "tabularx" "longtable")
(TeX-add-symbols
- '("LTXtable"
+ `("LTXtable"
(TeX-arg-length "Width" "1.0\\linewidth")
- (TeX-arg-eval
- (lambda ()
+ ,(lambda (optional)
(let ((longtable (file-relative-name
(read-file-name
- "File with longtable: "
+ (TeX-argument-prompt optional nil "File with
longtable")
nil nil nil nil
(lambda (x)
(or (file-directory-p x)
(string-match "\\.\\(tex\\|ltx\\)\\'" x))))
(TeX-master-directory))))
- (format "%s" longtable))))))
+ (TeX-argument-insert longtable optional)))))
;; Make sure that \LTXtable stays in its own line:
(LaTeX-paragraph-commands-add-locally "LTXtable")
diff --git a/style/mathtools.el b/style/mathtools.el
index 505c1571..6a7928e9 100644
--- a/style/mathtools.el
+++ b/style/mathtools.el
@@ -129,14 +129,17 @@
(dolist (delim (LaTeX-mathtools-DeclarePairedDelimiter-list))
(let ((cmd (car delim))
(arg (cadr delim)))
- (TeX-add-symbols `(,cmd [ LaTeX-mathtools-arg-mathsize-completion ]
- ,(if (string= arg "")
- 1
- (string-to-number arg)))
- `(,(concat cmd "*")
- ,(if (string= arg "")
- 1
- (string-to-number arg)))))))
+ (TeX-add-symbols
+ `(,cmd
+ [TeX-arg-completing-read ("\\big" "\\Big" "\\bigg" "\\Bigg")
+ "Command" nil nil nil nil nil nil "\\"]
+ ,(if (string= arg "")
+ 1
+ (string-to-number arg)))
+ `(,(concat cmd "*")
+ ,(if (string= arg "")
+ 1
+ (string-to-number arg)))))))
(when (LaTeX-mathtools-newgathered-list)
(dolist (env (mapcar #'car (LaTeX-mathtools-newgathered-list)))
(LaTeX-add-environments env)
@@ -151,41 +154,30 @@
(add-hook 'TeX-auto-cleanup-hook #'LaTeX-mathtools-auto-cleanup t)
(add-hook 'TeX-update-style-hook #'TeX-auto-parse t)
-(defun LaTeX-mathtools-arg-mathstyle-completion (optional)
- "Query and insert mathstyle argument to various commands.
-If OPTIONAL, insert it as optional argument in brackets."
- (TeX-argument-insert
- (completing-read
- (TeX-argument-prompt optional nil
- (concat "Math style: " TeX-esc) t)
- '("displaystyle" "textstyle"
- "scriptstyle" "scriptscriptstyle"))
- optional TeX-esc))
-
-(defun LaTeX-mathtools-arg-mathsize-completion (optional)
- "Query and insert math size argument to various commands.
-If OPTIONAL, insert it as optional argument in brackets."
- (TeX-argument-insert
- (completing-read
- (TeX-argument-prompt optional nil
- (concat "Size command: " TeX-esc) t)
- '("big" "Big" "bigg" "Bigg"))
- optional TeX-esc))
+(defvar LaTeX-mathtools-mathstyle-list
+ '("\\displaystyle" "\\textstyle"
+ "\\scriptstyle" "\\scriptscriptstyle")
+ "List of math styles supported by the mathtools package.")
(defun LaTeX-mathtools-arg-declarepaireddelimiter (optional &optional X)
- "Query and insert various \\DeclarePairedDelimiter macros from mathtools
package."
+ "Query and insert various \\DeclarePairedDelimiter macros from mathtools
package.
+If X is non-nil, be aware of the macros \\DeclarePairedDelimiterX
+and \\DeclarePairedDelimiterXPP."
(let ((cmd (TeX-read-string (concat "Command: " TeX-esc)))
(arg (when X (TeX-read-string
(TeX-argument-prompt t nil "Number of arguments")))))
- (TeX-add-symbols `(,cmd [ LaTeX-mathtools-arg-mathsize-completion ]
- ,(if X
- ;; This is no precaution, arg has to be > 0
- (string-to-number arg)
- 1))
- `(,(concat cmd "*")
- ,(if X
- (string-to-number arg)
- 1)))
+ (TeX-add-symbols
+ `(,cmd
+ [TeX-arg-completing-read ("\\big" "\\Big" "\\bigg" "\\Bigg")
+ "Command" nil nil nil nil nil nil "\\"]
+ ,(if X
+ ;; This is no precaution, arg has to be > 0
+ (string-to-number arg)
+ 1))
+ `(,(concat cmd "*")
+ ,(if X
+ (string-to-number arg)
+ 1)))
(LaTeX-add-mathtools-DeclarePairedDelimiters
`(,cmd ,(if X arg "")))
(TeX-argument-insert cmd optional TeX-esc)
@@ -289,17 +281,38 @@ Put line break macro on the last line. Next, insert an
ampersand."
(TeX-add-symbols
'("mathtoolsset" (TeX-arg-key-val LaTeX-mathtools-key-val-options))
;; 3.1.1 A complement to \smash, \llap, and \rlap
- '("mathllap" [ LaTeX-mathtools-arg-mathstyle-completion ] t)
- '("mathrlap" [ LaTeX-mathtools-arg-mathstyle-completion ] t)
- '("mathclap" [ LaTeX-mathtools-arg-mathstyle-completion ] t)
- '("mathmakebox" [ (TeX-arg-length "Width") ] [ "Position" ] 1)
+ '("mathllap"
+ [TeX-arg-completing-read LaTeX-mathtools-mathstyle-list
+ "Math style" nil nil nil nil nil nil "\\"]
+ t)
+ '("mathrlap"
+ [TeX-arg-completing-read LaTeX-mathtools-mathstyle-list
+ "Math style" nil nil nil nil nil nil "\\"]
+ t)
+ '("mathclap"
+ [TeX-arg-completing-read LaTeX-mathtools-mathstyle-list
+ "Math style" nil nil nil nil nil nil "\\"]
+ t)
+ '("mathmakebox" [TeX-arg-length "Width"] [ "Position" ] 1)
'("clap" 1)
'("mathmbox" 1)
;; 3.1.2 Forcing a cramped style
- '("cramped" [ LaTeX-mathtools-arg-mathstyle-completion ] 1)
- '("crampedllap" [ LaTeX-mathtools-arg-mathstyle-completion ] t)
- '("crampedrlap" [ LaTeX-mathtools-arg-mathstyle-completion ] t)
- '("crampedclap" [ LaTeX-mathtools-arg-mathstyle-completion ] t)
+ '("cramped"
+ [TeX-arg-completing-read LaTeX-mathtools-mathstyle-list
+ "Math style" nil nil nil nil nil nil "\\"]
+ 1)
+ '("crampedllap"
+ [TeX-arg-completing-read LaTeX-mathtools-mathstyle-list
+ "Math style" nil nil nil nil nil nil "\\"]
+ t)
+ '("crampedrlap"
+ [TeX-arg-completing-read LaTeX-mathtools-mathstyle-list
+ "Math style" nil nil nil nil nil nil "\\"]
+ t)
+ '("crampedclap"
+ [TeX-arg-completing-read LaTeX-mathtools-mathstyle-list
+ "Math style" nil nil nil nil nil nil "\\"]
+ t)
;; 3.1.3 Smashing an operator
'("smashoperator" [ "Position (l, r or lr (default)" ] 1)
;; 3.1.4 Adjusting the limits of operators
@@ -307,13 +320,12 @@ Put line break macro on the last line. Next, insert an
ampersand."
;; 3.1.5 Swapping space above AMS display math environments
'("SwapAboveDisplaySkip" 0)
;; 3.2.1 The appearance of tags
- '("newtagform"
- (TeX-arg-eval
- (lambda ()
+ `("newtagform"
+ ,(lambda (optional)
(let ((newtag (TeX-read-string
- (TeX-argument-prompt nil nil "Name"))))
+ (TeX-argument-prompt optional nil "Name"))))
(LaTeX-add-mathtools-newtagforms newtag)
- (format "%s" newtag))))
+ (TeX-argument-insert newtag optional)))
[ "Inner format" ] "Left" "Right")
'("renewtagform"
(TeX-arg-completing-read (LaTeX-mathtools-newtagform-list) "Name")
@@ -338,17 +350,17 @@ Put line break macro on the last line. Next, insert an
ampersand."
'("xrightleftharpoons" ["Below"] "Above")
'("xleftrightharpoons" ["Below"] "Above")
;; 3.3.2 Braces and brackets
- '("underbracket" [ (TeX-arg-length "Rule thickness") ]
+ '("underbracket" [TeX-arg-length "Rule thickness"]
[ (TeX-arg-length "Bracket height") ] t)
- '("overbracket" [ (TeX-arg-length "Rule thickness") ]
+ '("overbracket" [TeX-arg-length "Rule thickness"]
[ (TeX-arg-length "Bracket height") ] t)
'("underbrace" 1)
'("overbrace" 1)
'("LaTeXunderbrace" 1)
'("LaTeXoverbrace" 1)
;; 3.4.2
- '("shoveleft" [ (TeX-arg-length "Dimension") ] 1)
- '("shoveright" [ (TeX-arg-length "Dimension") ] 1)
+ '("shoveleft" [TeX-arg-length "Dimension"] 1)
+ '("shoveright" [TeX-arg-length "Dimension"] 1)
;; 3.4.4
'("MoveEqLeft" [ "Number" ])
;; 3.4.5 Boxing a single line in an alignment
@@ -377,13 +389,12 @@ Put line break macro on the last line. Next, insert an
ampersand."
"Pre-code" "Left delimiter" "Right delimiter" 2)
'("delimsize" 0)
;; 3.6.1 Expert use
- '("reDeclarePairedDelimiterInnerWrapper"
- (TeX-arg-eval
- (lambda ()
- (let ((cmd (completing-read
- (concat "Command: " TeX-esc)
- (mapcar #'car
(LaTeX-mathtools-DeclarePairedDelimiter-list)))))
- (concat TeX-esc cmd))))
+ `("reDeclarePairedDelimiterInnerWrapper"
+ (TeX-arg-completing-read
+ ,(lambda ()
+ (mapcar (lambda (x) (concat TeX-esc (car x)))
+ (LaTeX-mathtools-DeclarePairedDelimiter-list)))
+ "Command" nil nil nil nil nil nil "\\")
(TeX-arg-completing-read ("star" "nostar") "star or nostar")
t)
;; 3.7.1 Left and right parentheses
@@ -401,18 +412,17 @@ Put line break macro on the last line. Next, insert an
ampersand."
;; 4.3 Declaring math sizes
'("DeclareMathSizes" 4)
;; 4.5 Gathered environments
- '("newgathered"
- (TeX-arg-eval
- (lambda ()
+ `("newgathered"
+ ,(lambda (optional)
(let ((env (TeX-read-string
- (TeX-argument-prompt nil nil "Name"))))
+ (TeX-argument-prompt optional nil "Name"))))
(LaTeX-add-environments env)
(LaTeX-add-mathtools-newgathereds env)
(add-to-list 'LaTeX-item-list
`(,env . LaTeX-item-equation) t)
(add-to-list 'LaTeX-label-alist
`(,env . LaTeX-amsmath-label) t)
- (format "%s" env))))
+ (TeX-argument-insert env optional)))
3)
'("renewgathered"
(TeX-arg-completing-read (LaTeX-mathtools-newgathered-list) "Name")
diff --git a/style/mdframed.el b/style/mdframed.el
index 53981d62..b04f2f37 100644
--- a/style/mdframed.el
+++ b/style/mdframed.el
@@ -276,17 +276,16 @@ and prepends them to variable
`LaTeX-mdframed-key-val-options'."
'("mdfsetup"
(TeX-arg-key-val (LaTeX-mdframed-key-val-options)))
- '("newmdenv"
+ `("newmdenv"
[TeX-arg-key-val (LaTeX-mdframed-key-val-options)]
- (TeX-arg-eval
- (lambda ()
+ ,(lambda (optional)
(let ((env (TeX-read-string
- (TeX-argument-prompt nil nil "Environment"))))
+ (TeX-argument-prompt optional nil "Environment"))))
(LaTeX-add-environments
`(,env LaTeX-env-args [TeX-arg-key-val
(LaTeX-mdframed-key-val-options)]))
;; Add new env's to `ispell-tex-skip-alist': skip the optional
argument
(TeX-ispell-skip-setcdr `((,env ispell-tex-arg-end 0)))
- (format "%s" env)))))
+ (TeX-argument-insert env optional))))
'("renewmdenv"
[TeX-arg-key-val (LaTeX-mdframed-key-val-options)]
@@ -306,13 +305,12 @@ and prepends them to variable
`LaTeX-mdframed-key-val-options'."
"Length"))
;; 5. Defining your own style
- '("mdfdefinestyle"
- (TeX-arg-eval
- (lambda ()
+ `("mdfdefinestyle"
+ ,(lambda (optional)
(let ((style (TeX-read-string
- (TeX-argument-prompt nil nil "Style name"))))
+ (TeX-argument-prompt optional nil "Style name"))))
(LaTeX-add-mdframed-mdfdefinestyles style)
- (format "%s" style))))
+ (TeX-argument-insert style optional)))
(TeX-arg-key-val (LaTeX-mdframed-key-val-options)))
'("mdfapptodefinestyle"
@@ -325,15 +323,14 @@ and prepends them to variable
`LaTeX-mdframed-key-val-options'."
"Subtitle")
;; 8. Theorems
- '("newmdtheoremenv"
+ `("newmdtheoremenv"
[TeX-arg-key-val (LaTeX-mdframed-key-val-options)]
- (TeX-arg-eval
- (lambda ()
+ ,(lambda (optional)
(let ((nthm (TeX-read-string
- (TeX-argument-prompt nil nil "Environment"))))
+ (TeX-argument-prompt optional nil "Environment"))))
(LaTeX-add-environments (list nthm (vector "Heading")))
- (format "%s" nthm))))
- [ TeX-arg-environment "Numbered like" ]
+ (TeX-argument-insert nthm optional)))
+ [TeX-arg-environment "Numbered like"]
t [ (TeX-arg-eval progn (if (eq (save-excursion
(backward-char 2)
(preceding-char))
@@ -342,16 +339,15 @@ and prepends them to variable
`LaTeX-mdframed-key-val-options'."
(TeX-arg-counter t "Within counter"))
"") ])
- '("mdtheorem"
+ `("mdtheorem"
[TeX-arg-key-val (LaTeX-mdframed-key-val-options)]
- (TeX-arg-eval
- (lambda ()
+ ,(lambda (optional)
(let ((nthm (TeX-read-string
- (TeX-argument-prompt nil nil "Environment"))))
+ (TeX-argument-prompt optional nil "Environment"))))
(LaTeX-add-environments (list nthm (vector "Heading"))
(list (concat nthm "*") (vector "Heading")))
- (format "%s" nthm))))
- [ TeX-arg-environment "Numbered like" ]
+ (TeX-argument-insert nthm optional)))
+ [TeX-arg-environment "Numbered like"]
t [ (TeX-arg-eval progn (if (eq (save-excursion
(backward-char 2)
(preceding-char))
diff --git a/style/minted.el b/style/minted.el
index 354213be..a3e721fe 100644
--- a/style/minted.el
+++ b/style/minted.el
@@ -1,6 +1,6 @@
;;; minted.el --- AUCTeX style for `minted.sty' (v2.5) -*- lexical-binding:
t; -*-
-;; Copyright (C) 2014-2021 Free Software Foundation, Inc.
+;; Copyright (C) 2014--2023 Free Software Foundation, Inc.
;; Author: Tassilo Horn <tsdh@gnu.org>
;; Maintainer: auctex-devel@gnu.org
@@ -132,18 +132,17 @@
;; in a .tex file, Emacs asks to apply a variable which is not
;; safe and does not restore the window; the splitted frame
;; remains. I couldn't figure out why, so for now, I add the
- ;; styles from Pygments version 2.11 here.
+ ;; styles from Pygments version 2.14.0 here.
("style" ("abap" "algol" "algol_nu" "arduino" "autumn"
"borland" "bw" "colorful" "default" "dracula"
"emacs" "friendly" "friendly_grayscale" "fruity"
- "gruvbox-dark" "gruvbox-light" "igor" "inkpot"
- "lilypond" "lovelace" "manni" "material"
- "monokai" "murphy" "native" "one-dark"
- "paraiso-dark" "paraiso-light" "pastie" "perldoc"
- "rainbow_dash" "rrt" "sas" "solarized-dark"
- "solarized-light" "stata-dark" "stata-light"
- "stata" "tango" "trac" "vim" "vs" "xcode"
- "zenburn"))
+ "github-dark" "gruvbox-dark" "gruvbox-light"
+ "igor" "inkpot" "lilypond" "lovelace" "manni" "material"
+ "monokai" "murphy" "native" "nord" "nord-darker"
+ "one-dark" "paraiso-dark" "paraiso-light" "pastie" "perldoc"
+ "rainbow_dash" "rrt" "sas" "solarized-dark" "solarized-light"
+ "staroffice" "stata" "stata-dark" "stata-light"
+ "tango" "trac" "vim" "vs" "xcode" "zenburn"))
("stepnumber")
("stepnumberfromfirst")
("stepnumberoffsetvalues" ("true" "false"))
@@ -197,15 +196,6 @@ Update the variable `LaTeX-minted-language-list' if still
nil."
(setq LaTeX-minted-language-list languages))
LaTeX-minted-language-list))))
-(defun LaTeX-arg-minted-language (optional &optional prompt)
- "Insert a selected pygmentize language as argument for macros from
minted.sty.
-If OPTIONAL is non-nil, insert it as optional argument in
-brackets. PROMPT replaces the standard one."
- (TeX-argument-insert
- (completing-read (TeX-argument-prompt optional prompt "Language")
- (LaTeX-minted-language-list))
- optional))
-
(defvar LaTeX-minted-style-list nil
"List containing styles provided by pymentize program.")
@@ -225,15 +215,6 @@ Update the variable `LaTeX-minted-style-list' if still
nil."
(setq LaTeX-minted-style-list styles))
LaTeX-minted-style-list))))
-(defun LaTeX-arg-minted-style (optional &optional prompt)
- "Insert a selected pygmentize style as argument for macros from minted.sty.
-If OPTIONAL is non-nil, insert it as optional argument in
-brackets. PROMPT replaces the standard one."
- (TeX-argument-insert
- (completing-read (TeX-argument-prompt optional prompt "Style")
- (LaTeX-minted-style-list))
- optional))
-
(defvar LaTeX-minted-auto-newminted nil)
(defvar LaTeX-minted-newminted-regexp
'("\\\\newminted\\(?:\\[\\([^]]+\\)\\]\\)?{\\([^}]+\\)}{[^}]*}"
@@ -373,38 +354,46 @@ a list of strings."
(TeX-add-symbols
'("mint"
[TeX-arg-key-val (LaTeX-minted-key-val-options)]
- LaTeX-arg-minted-language TeX-arg-verb)
+ (TeX-arg-completing-read (LaTeX-minted-language-list) "Language")
+ TeX-arg-verb)
'("mintinline"
[TeX-arg-key-val (LaTeX-minted-key-val-options)]
- LaTeX-arg-minted-language TeX-arg-verb-delim-or-brace)
- '("newminted" ["Environment Name"] LaTeX-arg-minted-language
+ (TeX-arg-completing-read (LaTeX-minted-language-list) "Language")
+ TeX-arg-verb-delim-or-brace)
+ '("newminted" ["Environment Name"]
+ (TeX-arg-completing-read (LaTeX-minted-language-list) "Language")
(TeX-arg-key-val (LaTeX-minted-key-val-options)))
- '("newmint" ["Macro Name"] LaTeX-arg-minted-language
+ '("newmint" ["Macro Name"]
+ (TeX-arg-completing-read (LaTeX-minted-language-list) "Language")
(TeX-arg-key-val (LaTeX-minted-key-val-options)))
- '("newmintinline" ["Macro Name"] LaTeX-arg-minted-language
+ '("newmintinline" ["Macro Name"]
+ (TeX-arg-completing-read (LaTeX-minted-language-list) "Language")
(TeX-arg-key-val (LaTeX-minted-key-val-options)))
- '("newmintedfile" ["Macro Name"] LaTeX-arg-minted-language
+ '("newmintedfile" ["Macro Name"]
+ (TeX-arg-completing-read (LaTeX-minted-language-list) "Language")
(TeX-arg-key-val (LaTeX-minted-key-val-options)))
;; 3.3 Formatting source code
'("inputminted"
- [TeX-arg-key-val (LaTeX-minted-key-val-options)]
- (LaTeX-arg-minted-language)
+ [TeX-arg-key-val (LaTeX-minted-key-vaLaTeX-arg-minted-languagel-options)]
+ (TeX-arg-completing-read (LaTeX-minted-language-list) "Language")
TeX-arg-file)
;; 3.4 Using different styles
'("usemintedstyle"
- [ LaTeX-arg-minted-language ] LaTeX-arg-minted-style)
+ [TeX-arg-completing-read (LaTeX-minted-language-list) "Language"]
+ (TeX-arg-completing-read (LaTeX-minted-style-list) "Style"))
;; 5.2 Macro option usage
'("setminted"
- [ LaTeX-arg-minted-language ]
+ [TeX-arg-completing-read (LaTeX-minted-language-list) "Language"]
(TeX-arg-key-val (LaTeX-minted-key-val-options)))
'("setmintedinline"
- [ LaTeX-arg-minted-language ]
+ [TeX-arg-completing-read (LaTeX-minted-language-list) "Language"]
(TeX-arg-key-val (LaTeX-minted-key-val-options))))
;; New environments
(LaTeX-add-environments
- '("minted" LaTeX-env-args [TeX-arg-key-val (LaTeX-minted-key-val-options)]
- LaTeX-arg-minted-language))
+ '("minted" LaTeX-env-args
+ [TeX-arg-key-val (LaTeX-minted-key-val-options)]
+ (TeX-arg-completing-read (LaTeX-minted-language-list) "Language")))
;; 4 Floating listings: If option "newfloat" is given, run the
;; style hook and use the interface provided by the style,
diff --git a/style/natbib.el b/style/natbib.el
index 00ea4b39..3cac5960 100644
--- a/style/natbib.el
+++ b/style/natbib.el
@@ -1,6 +1,6 @@
;;; natbib.el --- AUCTeX style for `natbib.sty' version 8.31b -*-
lexical-binding: t; -*-
-;; Copyright (C) 1997, 1998, 2004, 2007, 2014--2022 Free Software Foundation,
Inc.
+;; Copyright (C) 1997, 1998, 2004, 2007, 2014--2023 Free Software Foundation,
Inc.
;; Authors: Berwin Turlach <statba@nus.edu.sg>
;; Carsten Dominik <dominik@strw.leidenuniv.nl>
@@ -148,6 +148,7 @@
("citealp" "*[[{")
("citeauthor" "*[[{")
("citefullauthor" "[[{")
+ ("citetext" "{")
("citeyear" "[[{")
("citeyearpar" "[[{")
("shortcites" "{")
diff --git a/style/ntheorem.el b/style/ntheorem.el
index aa28c31f..59455b99 100644
--- a/style/ntheorem.el
+++ b/style/ntheorem.el
@@ -29,10 +29,20 @@
;; This file adds support for `ntheorem.sty' (v1.33) from 2011/08/15.
;; `ntheorem.sty' is and part of TeXLive.
-;; The style provides the function `LaTeX-ntheorem-env-label' which
-;; enables new defined environments with "\newtheoreom" to interact
-;; with AUCTeX and RefTeX mechanisms for inserting labels. Check
-;; docstring of `LaTeX-ntheorem-env-label' for instructions.
+;; This style interacts with AUCTeX and RefTeX mechanisms for
+;; inserting labels into new defined environments with "\newtheoreom".
+;; AUCTeX users need to add the new environment to `LaTeX-label-alist'
+;; via customize or in init-file like this:
+;;
+;; (add-to-list 'LaTeX-label-alist '("lemma" . "lem:"))
+;;
+;; RefTeX users have to add the value to both `LaTeX-label-alist' and
+;; `reftex-label-alist' like this:
+;;
+;; (add-to-list 'LaTeX-label-alist '("lemma" . "lem:"))
+;; (add-to-list 'reftex-label-alist
+;; '("lemma" ?m "lem:" "~ref{%s}"
+;; nil ("Lemma" "lemma") nil))
;;; Code
@@ -65,60 +75,6 @@ defined with \"\\newtheoremstyle\".")
\"\\theoremlisttype\" provided by `ntheorem.el' and new ones
defined with \"\\newtheoremlisttype\".")
-(defvar LaTeX-ntheorem-fontdecl
- '(;; family
- "rmfamily" "sffamily" "ttfamily"
- ;; series
- "mdseries" "bfseries"
- ;; shape
- "upshape" "itshape" "slshape" "scshape"
- ;; size
- "tiny" "scriptsize" "footnotesize"
- "small" "normalsize" "large"
- "Large" "LARGE" "huge" "Huge"
- ;; reset macro
- "normalfont")
- "List of font declaration commands for \"\\newtheoremstyle\".")
-
-(defun LaTeX-arg-ntheorem-fontdecl (optional &optional prompt)
- "Prompt for font declaration commands in \"\\theorem(body|header)font\".
-If OPTIONAL is non-nil, insert the resulting value as an optional
-argument. Use PROMPT as the prompt string."
- (let* ((crm-separator (regexp-quote TeX-esc))
- (fontdecl (mapconcat #'identity
- (TeX-completing-read-multiple
- (TeX-argument-prompt optional prompt "Font
declaration: \\" t)
- LaTeX-ntheorem-fontdecl)
- TeX-esc)))
- (TeX-argument-insert fontdecl
- optional
- (when (and fontdecl (not (string= fontdecl "")))
- TeX-esc))))
-
-(defun LaTeX-ntheorem-env-label (environment)
- "Insert ENVIRONMENT, query for an optional argument and prompt
-for label. AUCTeX users should add ENVIRONMENT to
-`LaTeX-label-alist' via customize or in init-file with:
-
- (add-to-list \\='LaTeX-label-alist \\='(\"lemma\" . \"lem:\"))
-
-RefTeX users should customize or add ENVIRONMENT to
-`LaTeX-label-alist' and `reftex-label-alist', for example
-
- (add-to-list \\='LaTeX-label-alist \\='(\"lemma\" . \"lem:\"))
- (add-to-list \\='reftex-label-alist
- \\='(\"lemma\" ?m \"lem:\" \"~\\ref{%s}\"
- nil (\"Lemma\" \"lemma\") nil))"
- (let ((opthead (TeX-read-string
- (TeX-argument-prompt t nil "Heading"))))
- (LaTeX-insert-environment environment
- (when (and opthead
- (not (string= opthead "")))
- (format "[%s]" opthead))))
- (when (LaTeX-label environment 'environment)
- (LaTeX-newline)
- (indent-according-to-mode)))
-
;; Setup parsing for \newtheorem
(TeX-auto-add-type "ntheorem-newtheorem" "LaTeX")
@@ -141,9 +97,10 @@ make them available as new environments. Update
`LaTeX-ntheorem-theoremstyle-list' with styles defined with
\"\\newtheoremstyle\"."
(dolist (newthm (mapcar #'car (LaTeX-ntheorem-newtheorem-list)))
- (LaTeX-add-environments (list newthm #'LaTeX-ntheorem-env-label))
+ (LaTeX-add-environments (list newthm
+ #'LaTeX-env-label-args ["Heading"]))
(LaTeX-add-environments (list (concat newthm "*")
- #'LaTeX-ntheorem-env-label)))
+ #'LaTeX-env-label-args ["Heading"])))
(dolist (newthmstyle (LaTeX-ntheorem-newtheoremstyle-list))
(add-to-list (make-local-variable 'LaTeX-ntheorem-theoremstyle-list)
newthmstyle))
@@ -183,16 +140,16 @@ make them available as new environments. Update
(TeX-add-symbols
;; 2.2 Defining New Theorem Sets
;; Overrule the defintion in `latex.el':
- '("newtheorem"
- (TeX-arg-eval
- (lambda ()
+ `("newtheorem"
+ ,(lambda (optional)
(let ((nthm (TeX-read-string
- (TeX-argument-prompt nil nil "Environment"))))
+ (TeX-argument-prompt optional nil "Environment"))))
(LaTeX-add-ntheorem-newtheorems nthm)
- (LaTeX-add-environments (list nthm #'LaTeX-ntheorem-env-label))
+ (LaTeX-add-environments (list nthm
+ #'LaTeX-env-label-args ["Heading"]))
(LaTeX-add-environments (list (concat nthm "*")
- #'LaTeX-ntheorem-env-label))
- (format "%s" nthm))))
+ #'LaTeX-env-label-args ["Heading"]))
+ (TeX-argument-insert nthm optional)))
[ TeX-arg-environment "Numbered like" ]
t [ (TeX-arg-eval progn (if (eq (save-excursion
(backward-char 2)
@@ -216,11 +173,23 @@ make them available as new environments. Update
'("theoremstyle"
(TeX-arg-completing-read LaTeX-ntheorem-theoremstyle-list "Style"))
- '("theorembodyfont"
- (LaTeX-arg-ntheorem-fontdecl "Body font"))
+ `("theorembodyfont"
+ (TeX-arg-completing-read-multiple
+ ,(lambda () (append LaTeX-font-family
+ LaTeX-font-series
+ LaTeX-font-shape
+ LaTeX-font-size))
+ "Body font" nil nil ,(regexp-quote TeX-esc) ,TeX-esc
+ nil nil nil nil ,TeX-esc))
'("theoremheaderfont"
- (LaTeX-arg-ntheorem-fontdecl "Header font"))
+ (TeX-arg-completing-read-multiple
+ ,(lambda () (append LaTeX-font-family
+ LaTeX-font-series
+ LaTeX-font-shape
+ LaTeX-font-size))
+ "Header font" nil nil ,(regexp-quote TeX-esc) ,TeX-esc
+ nil nil nil nil ,TeX-esc))
'("theoremnumbering"
(TeX-arg-completing-read ("arabic" "roman" "Roman" "alph" "Alph"
@@ -259,21 +228,22 @@ make them available as new environments. Update
"Proof" "Beweis")))
(dolist (elt env)
(LaTeX-add-ntheorem-newtheorems elt)
- (LaTeX-add-environments (list elt #'LaTeX-ntheorem-env-label))
+ (LaTeX-add-environments (list elt
+ #'LaTeX-env-label-args ["Heading"]))
(LaTeX-add-environments (list (concat elt "*")
- #'LaTeX-ntheorem-env-label)))))
+ #'LaTeX-env-label-args ["Heading"])))))
;; 2.3.7 Framed and Boxed Theorems
- '("newframedtheorem"
- (TeX-arg-eval
- (lambda ()
+ `("newframedtheorem"
+ ,(lambda (optional)
(let ((nthm (TeX-read-string
- (TeX-argument-prompt nil nil "Environment"))))
+ (TeX-argument-prompt optional nil "Environment"))))
(LaTeX-add-ntheorem-newtheorems nthm)
- (LaTeX-add-environments (list nthm #'LaTeX-ntheorem-env-label))
+ (LaTeX-add-environments (list nthm
+ #'LaTeX-env-label-args ["Heading"]))
(LaTeX-add-environments (list (concat nthm "*")
- #'LaTeX-ntheorem-env-label))
- (format "%s" nthm))))
+ #'LaTeX-env-label-args ["Heading"]))
+ (TeX-argument-insert nthm optional)))
[ TeX-arg-environment "Numbered like" ]
t [ (TeX-arg-eval progn (if (eq (save-excursion
(backward-char 2)
@@ -282,16 +252,16 @@ make them available as new environments. Update
(TeX-arg-counter t "Within counter"))
"") ])
- '("newshadedtheorem"
- (TeX-arg-eval
- (lambda ()
+ `("newshadedtheorem"
+ ,(lambda (optional)
(let ((nthm (TeX-read-string
- (TeX-argument-prompt nil nil "Environment"))))
+ (TeX-argument-prompt optional nil "Environment"))))
(LaTeX-add-ntheorem-newtheorems nthm)
- (LaTeX-add-environments (list nthm #'LaTeX-ntheorem-env-label))
+ (LaTeX-add-environments (list nthm
+ #'LaTeX-env-label-args ["Heading"]))
(LaTeX-add-environments (list (concat nthm "*")
- #'LaTeX-ntheorem-env-label))
- (format "%s" nthm))))
+ #'LaTeX-env-label-args ["Heading"]))
+ (TeX-argument-insert nthm optional)))
[ TeX-arg-environment "Numbered like" ]
t [ (TeX-arg-eval progn (if (eq (save-excursion
(backward-char 2)
@@ -299,16 +269,15 @@ make them available as new environments. Update
()
(TeX-arg-counter t "Within counter"))
"") ])
- '("shadecolor"
- (TeX-arg-eval
- (lambda ()
- (let ((color (cond ((member "xcolor" (TeX-style-list))
- (completing-read "Color name: "
(LaTeX-xcolor-definecolor-list)))
- ((member "color" (TeX-style-list))
- (completing-read "Color name: "
(LaTeX-color-definecolor-list)))
- (t
- (TeX-read-string "Color name: ")))))
- (format "%s" color)))))
+ `("shadecolor"
+ (TeX-arg-conditional (TeX-member "\\`x?color\\'" (TeX-style-list)
#'string-match)
+ ((TeX-arg-completing-read ,(lambda ()
+ (or (and (fboundp
'LaTeX-xcolor-definecolor-list)
+
(LaTeX-xcolor-definecolor-list))
+ (and (fboundp
'LaTeX-color-definecolor-list)
+
(LaTeX-color-definecolor-list))))
+ "Color name"))
+ ("Color name")))
'("theoremframepreskip"
(TeX-arg-length "Skip before framed theorem"))
@@ -344,15 +313,14 @@ make them available as new environments. Update
t)
;; 2.5.1 Defining New Theorem Layouts
- '("newtheoremstyle"
- (TeX-arg-eval
- (lambda ()
+ `("newtheoremstyle"
+ ,(lambda (optional)
(let ((style (TeX-read-string
- (TeX-argument-prompt nil nil "Style name"))))
+ (TeX-argument-prompt optional nil "Style name"))))
(LaTeX-add-ntheorem-newtheoremstyles style)
(add-to-list (make-local-variable 'LaTeX-ntheorem-theoremstyle-list)
(list style))
- (format "%s" style))))
+ (TeX-argument-insert style optional)))
2)
'("renewtheoremstyle"
@@ -361,15 +329,14 @@ make them available as new environments. Update
2)
;; 2.5.2 Defining New Theorem List Layouts
- '("newtheoremlisttype"
- (TeX-arg-eval
- (lambda ()
+ `("newtheoremlisttype"
+ ,(lambda (optional)
(let ((layout (TeX-read-string
- (TeX-argument-prompt nil nil "List layout name"))))
+ (TeX-argument-prompt optional nil "List layout
name"))))
(LaTeX-add-ntheorem-newtheoremlisttypes layout)
(add-to-list (make-local-variable 'LaTeX-ntheorem-listtype-list)
(list layout))
- (format "%s" layout))))
+ (TeX-argument-insert layout optional)))
3)
'("renewtheoremlisttype"
diff --git a/style/physics.el b/style/physics.el
new file mode 100644
index 00000000..f805df1b
--- /dev/null
+++ b/style/physics.el
@@ -0,0 +1,418 @@
+;;; physics.el --- AUCTeX style for `physics' (v1.3). -*- lexical-binding: t;
-*-
+
+;; Copyright (C) 2022 Free Software Foundation, Inc.
+
+;; Author: Ikumi Keita <ikumikeita@jcom.home.ne.jp>
+;; Maintainer: auctex-devel@gnu.org
+;; Created: 2022-12-20
+;; 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 `physics.sty' (v1.3) from 2012/12/12
+;; `physics.sty' is part of TeX Live.
+
+;;; Code:
+
+(require 'tex)
+
+;; List of supported braces by macros in physics package
+;; | () | [] | || | {} |null| big
+;; ----+----+----+----+----+--- +----
+;; qty | + | + | + | + | ! | +
+;; abs | ! | ! | ! | @ | ! | +
+;; eval| * | * | ! | - | ! | !
+;; grad| + | + | | @ | = | !
+;; sin | + | ^ | | @ | = | !
+;; exp | + | + | | + | | !
+;; tr | + | + | | + | | !
+;; erf | | | | @ | = | !
+;; Res | + | + | | + | | !
+;; pv | | | | @ | = | !
+;; Re | | | | + | | !
+;; dd | + | ^ | | @ | | !
+;; bra | | | | + | = | !
+;; mqty| + | + | + | @ | ! | !
+;;mqty*| + | | | @ | ! | !
+;;
+;; + ... supported
+;; ! ... error or wrong result
+;; @ ... works, but missing "{}" in the output
+;; * ... supported, but the right brace must be "|"
+;; - ... works, with only right "|" in the output
+;; = ... same as {}
+;; ^ ... interpreted as power optional argument
+;;
+;; Special note
+;; + \sin[2]x and \sin[2]{x} aren't supported.
+;; + "\dd{x}" and "\dd x" give different output.
+;; + mqty* is only meaningful when followed by "(...)".
+;; + as opposed to the document, \tr and \trace aren't equivalent.
+;; + dv accepts one or two arguments except optional argument.
+;; o 1 arg ... {derivative variable}
+;; o 2 arg ... {function to derive}{derivative variable}
+;; O 1 arg + () ... {derivative variable}(function to derive)
+;; + pdv accepts one, two or three arguments except optional argument.
+;; o 1 arg ... {derivative variable}
+;; o 2 args ... {function to derive}{derivative variable}
+;; o 3 args ... {func. to der.}{der. var.1}{der. var.2}
+;; o 1 arg + () ... {derivative variable}(function to derive)
+;; - 2 args + ()... NA
+;; - 3 args + ()... NA
+
+(defun TeX-arg-physics-big (_optional)
+ "Prompt for various \\big specification and insert it without braces.
+\\Big, \\bigg and \\Bigg are also allowed."
+ (TeX-arg-completing-read t '("big" "Big" "bigg" "Bigg")
+ "bigness specification: " t TeX-esc "" "" nil t))
+
+(defun TeX-physics--arg-any-braces (paren bracket vert brace
+ &optional default close)
+ "Template to query and insert various braces.
+Boolean arguments PAREN, BRACKET, VERT and BRACE mean to support (...),
+[...], |...| and {...}, respectively.
+Optional argument DEFAULT specifies default open brace.
+Non-nil CLOSE specifies close brace unconditionally."
+ (let* ((candidates
+ (let (lst)
+ (if paren (push '("(" . ")") lst))
+ (if bracket (push (cons LaTeX-optop LaTeX-optcl) lst))
+ (if vert (push '("|" . "|") lst))
+ (if brace (push (cons TeX-grop TeX-grcl) lst))
+ lst))
+ (open (completing-read
+ (concat "Which brace?"
+ (cond
+ (default
+ (format " (default \"%s\")" default))
+ (brace
+ " (RET to omit)")
+ (t
+ ""))
+ ": ")
+ candidates nil t nil nil default)))
+ (or close
+ (setq close (cdr (assoc open candidates))))
+ ;; When `default' is nil and the user gave empty answer,
+ ;; - If `brace' is nil, use "{}".
+ ;; - Otherwise do nothing.
+ (if (and (= 0 (length open))
+ (not brace))
+ (setq open TeX-grop
+ close TeX-grcl))
+ (when (< 0 (length open))
+ (setq TeX-arg-opening-brace open
+ TeX-arg-closing-brace close)
+ (let ((content
+ (if (TeX-active-mark)
+ (prog1
+ (buffer-substring-no-properties (point) (mark))
+ (delete-region (point) (mark)))
+ "")))
+ (TeX-argument-insert content nil)))))
+
+(defun TeX-arg-physics-qty (_optional)
+ "Query and insert (), [], || or {}.
+Default ()."
+ (TeX-physics--arg-any-braces t t t t "("))
+
+(defun TeX-arg-physics-eval (_optional)
+ "Query and insert (| or [|.
+When the user declined, supplement {} instead."
+ (TeX-physics--arg-any-braces t t nil nil nil "|"))
+
+(defun TeX-arg-physics-grad (_optional)
+ "Query and insert () or [].
+When the user declined, supplement {} instead."
+ (TeX-physics--arg-any-braces t t nil nil))
+
+(defun TeX-arg-physics-exp (_optional)
+ "Query and insert (), [] or {}."
+ (TeX-physics--arg-any-braces t t nil t))
+
+(defun TeX-arg-physics-dd (_optional)
+ "Query and insert () or {}."
+ (TeX-physics--arg-any-braces t nil nil t))
+
+(defun TeX-arg-physics-mqty (_optional)
+ "Query and insert (), [] or ||.
+When the user declined, supplement {} instead."
+ (TeX-physics--arg-any-braces t t t nil))
+
+(defun TeX-physics--arg-single-brace (open close &optional force)
+ "Template to query and insert single flavor of braces.
+If optional argument FORCE is non-nil, don't ask and always insert."
+ (when (or force
+ (y-or-n-p (format "Use \"%s%s\"? " open close)))
+ (setq TeX-arg-opening-brace open
+ TeX-arg-closing-brace close)
+ (let ((content (if (TeX-active-mark)
+ (prog1
+ (buffer-substring-no-properties (point) (mark))
+ (delete-region (point) (mark)))
+ "")))
+ (TeX-argument-insert content nil))))
+
+(defun TeX-arg-physics-trig (_optional)
+ "Query and insert ().
+First query optional argument for power. If that is non-empty,
+use () unconditionally."
+ ;; XXX: Should we respect `TeX-insert-macro-default-style'?
+ (let ((power (TeX-read-string "(Optional) Power: ")))
+ (let ((TeX-arg-opening-brace LaTeX-optop)
+ (TeX-arg-closing-brace LaTeX-optcl))
+ (TeX-argument-insert power t))
+ (TeX-physics--arg-single-brace "(" ")" (< 0 (length power)))))
+
+(defun TeX-arg-physics-ReIm (_optional)
+ "Query and insert {}."
+ (TeX-physics--arg-single-brace TeX-grop TeX-grcl))
+
+(defun TeX-arg-physics-mqty* (_optional)
+ "Insert ()."
+ (TeX-physics--arg-single-brace "(" ")" t))
+
+(defun TeX-physics--arg-1-or-2-arg (prompt1 prompt2)
+ "Template to query and insert one or two arguments."
+ (let* ((arg1 (TeX-read-string (concat prompt1 ": ")))
+ (arg2 (TeX-read-string (concat prompt2 " (RET to omit): "))))
+ (TeX-argument-insert arg1 nil)
+ (if (< 0 (length arg2))
+ (TeX-argument-insert arg2 nil))))
+
+(defun TeX-arg-physics-braket (_optional)
+ (TeX-physics--arg-1-or-2-arg "Bra content" "Ket content"))
+
+(defun TeX-arg-physics-ketbra (_optional)
+ (TeX-physics--arg-1-or-2-arg "Ket content" "Bra content"))
+
+(defun TeX-arg-physics-expval (_optional)
+ (TeX-physics--arg-1-or-2-arg "Observable" "State"))
+
+(defun TeX-arg-physics-derivative (_optional &optional partial)
+ "Query and insert one or two arguments for derivative.
+The user can choose whether to wrap the function to derive with ().
+In addition, query and insert optional power argument.
+
+If optional argument PARTIAL is non-nil, three arguments are also
+supported for partial derivative.
+When three arguments are specified, don't ask optional power argument."
+ (let* ((func (TeX-read-string
+ "\
+Function to derive (RET to omit, SPC RET to have empty placeholder): "))
+ (paren (and (< 0 (length func))
+ (y-or-n-p "Use \"()\" to wrap the function? ")))
+ (var1 (TeX-read-string "Derivative variable: "))
+ (var2 (and partial (not paren) (< 0 (length func))
+ (TeX-read-string
+ "Derivative variable 2nd (RET to omit): "))))
+ (unless var2
+ ;; XXX: Should we respect `TeX-insert-macro-default-style'?
+ (TeX-arg-string t "Power" nil nil nil LaTeX-optop LaTeX-optcl))
+ (when (and (< 0 (length func))
+ (not paren))
+ (if (equal func " ")
+ (setq func ""))
+ (TeX-argument-insert func nil))
+ (TeX-argument-insert var1 nil)
+ (if (< 0 (length var2))
+ (TeX-argument-insert var2 nil))
+ (when paren
+ (setq TeX-arg-opening-brace "("
+ TeX-arg-closing-brace ")")
+ (if (equal func " ")
+ (setq func ""))
+ (TeX-argument-insert func nil))))
+
+(TeX-add-style-hook
+ "physics"
+ (lambda ()
+ ;; physics requires amsmath and xparse.
+ (TeX-run-style-hooks "amsmath" "xparse")
+
+ (TeX-add-symbols
+ ;; 2.1 Automatic bracing
+ '("quantity" [TeX-arg-physics-big] TeX-arg-physics-qty)
+ '("qty" [TeX-arg-physics-big] TeX-arg-physics-qty)
+ '("pqty" [TeX-arg-physics-big] t) '("bqty" [TeX-arg-physics-big] t)
+ '("vqtry" [TeX-arg-physics-big] t) '("Bqty" [TeX-arg-physics-big] t)
+ '("absolutevalue" [TeX-arg-physics-big] t)
+ '("absolutevalue*" t)
+ '("abs" [TeX-arg-physics-big] t) '("abs*" t)
+ '("norm" [TeX-arg-physics-big] t)
+ '("norm*" t)
+ '("evaluated" TeX-arg-physics-eval)
+ '("evaluated*" TeX-arg-physics-eval)
+ '("eval" TeX-arg-physics-eval) '("eval*" TeX-arg-physics-eval)
+ '("order" [TeX-arg-physics-big] t)
+ '("order*" t)
+ '("commutator" [TeX-arg-physics-big] 2)
+ '("commutator*" 2)
+ '("comm" [TeX-arg-physics-big] 2) '("comm*" 2)
+ '("anticommutator" [TeX-arg-physics-big] 2)
+ '("anticommutator*" 2)
+ '("acomm" [TeX-arg-physics-big] 2) '("acomm*" 2)
+ '("poissonbracket" [TeX-arg-physics-big] 2)
+ '("poissonbracket*" 2)
+ '("pb" [TeX-arg-physics-big] 2) '("pb*" 2)
+ ;; 2.2 Vector notation
+ '("vectorbold" t) '("vectorbold*" t)
+ '("vb" t) '("vb*" t)
+ '("vectorarrow" t) '("vectorarrow*" t)
+ '("va" t) '("va*" t)
+ '("vectorunit" t) '("vectorunit*" t)
+ '("vu" t) '("vu*" t)
+ "dotproduct" "vdot"
+ "crossproduct" "cross"
+ "cp"
+ '("gradient" TeX-arg-physics-grad)
+ '("grad" TeX-arg-physics-grad)
+ '("divergence" TeX-arg-physics-grad)
+ '("div" TeX-arg-physics-grad)
+ "divisionsymbol"
+ '("curl" TeX-arg-physics-grad)
+ '("laplacian" TeX-arg-physics-grad)
+ ;; 2.3 Operators
+ '("sin" TeX-arg-physics-trig)
+ '("sinh" TeX-arg-physics-trig)
+ '("arcsin" TeX-arg-physics-trig)
+ '("asin" TeX-arg-physics-trig)
+ '("cos" TeX-arg-physics-trig)
+ '("cosh" TeX-arg-physics-trig)
+ '("arccos" TeX-arg-physics-trig)
+ '("acos" TeX-arg-physics-trig)
+ '("tan" TeX-arg-physics-trig)
+ '("tanh" TeX-arg-physics-trig)
+ '("arctan" TeX-arg-physics-trig)
+ '("atan" TeX-arg-physics-trig)
+ '("csc" TeX-arg-physics-trig)
+ '("csch" TeX-arg-physics-trig)
+ '("arccsc" TeX-arg-physics-trig)
+ '("acsc" TeX-arg-physics-trig)
+ "sine" "hypsine" "arcsine" "asine"
+ "cosine" "hypcosine" "arccosine" "acosine"
+ "tangent" "hyptangent" "arctangent" "atangent"
+ "cosecant" "hypcosecant" "arccosecant" "acosecant"
+ "secant" "hypsecant" "arcsecant" "asecant"
+ "cotangent" "hypcotangent" "arccotangent" "acotangent"
+ '("exp" TeX-arg-physics-exp)
+ '("log" TeX-arg-physics-exp)
+ '("ln" TeX-arg-physics-exp)
+ '("det" TeX-arg-physics-exp)
+ '("Pr" TeX-arg-physics-exp)
+ "exponential" "logarithm" "naturallogarithm" "determinant" "Probability"
+ '("tr" TeX-arg-physics-exp)
+ '("Tr" TeX-arg-physics-exp)
+ "rank" "erf"
+ '("Res" TeX-arg-physics-exp)
+ '("principalvalue" t)
+ '("pv" t) '("PV" t)
+ '("Re" TeX-arg-physics-ReIm)
+ '("Im" TeX-arg-physics-ReIm)
+ "real" "imaginary"
+ ;; 2.4 Quick quad text
+ '("qqtext" t)
+ '("qqtext*" t)
+ '("qq" t) '("qq*" t)
+ "qcomma" "qcomma*" "qc" "qc*" "qcc" "qcc*"
+ "qif" "qif*" "qthen" "qthen*" "qelse" "qelse*" "qotherwise" "qotherwise*"
+ "qunless" "qunless*" "qgiven" "qgiven*" "qusing" "qusing*"
+ "qassume" "qassume*" "qsince" "qsince*" "qlet" "qlet*" "qfor" "qfor*"
+ "qall" "qall*" "qeven" "qeven*" "qodd" "qodd*" "qinteger" "qinteger*"
+ "qand" "qand*" "qor" "qor*" "qas" "qas*" "qin" "qin*"
+ ;; 2.5 Derivatives
+ '("differential" ["Power"] TeX-arg-physics-dd)
+ '("dd" ["Power"] TeX-arg-physics-dd)
+ '("derivative" TeX-arg-physics-derivative)
+ '("derivative*" TeX-arg-physics-derivative)
+ '("dv" TeX-arg-physics-derivative)
+ '("dv*" TeX-arg-physics-derivative)
+ '("partialderivative" (TeX-arg-physics-derivative t))
+ '("partialderivative*" (TeX-arg-physics-derivative t))
+ '("pderivative" (TeX-arg-physics-derivative t))
+ '("pderivative*" (TeX-arg-physics-derivative t))
+ '("pdv" (TeX-arg-physics-derivative t))
+ '("pdv*" (TeX-arg-physics-derivative t))
+ '("variation" ["Power"] TeX-arg-physics-dd)
+ '("var" ["Power"] TeX-arg-physics-dd)
+ '("functionalderivative" TeX-arg-physics-derivative)
+ '("fdv" TeX-arg-physics-derivative)
+ ;; 2.6 Dirac bra-ket notation
+ '("bra" t)
+ '("bra*" t)
+ '("ket" t)
+ '("ket*" t)
+ '("innerproduct" TeX-arg-physics-braket)
+ '("innerproduct*" TeX-arg-physics-braket)
+ '("braket" TeX-arg-physics-braket)
+ '("braket*" TeX-arg-physics-braket)
+ '("ip" TeX-arg-physics-braket)
+ '("outerproduct" TeX-arg-physics-ketbra)
+ '("outerproduct*" TeX-arg-physics-ketbra)
+ '("dyad" TeX-arg-physics-ketbra)
+ '("dyad*" TeX-arg-physics-ketbra)
+ '("ketbra" TeX-arg-physics-ketbra)
+ '("ketbra*" TeX-arg-physics-ketbra)
+ '("op" TeX-arg-physics-ketbra)
+ '("op*" TeX-arg-physics-ketbra)
+ '("expectationvalue" TeX-arg-physics-expval)
+ '("expectationvalue*" TeX-arg-physics-expval)
+ '("expval" TeX-arg-physics-expval)
+ '("expval*" TeX-arg-physics-expval)
+ '("ev" TeX-arg-physics-expval)
+ '("ev*" TeX-arg-physics-expval)
+ '("matrixelement" 3)
+ '("matrixelement*" 3)
+ '("matrixelement**" 3)
+ '("matrixel" 3) '("matrixel*" 3) '("matrixel**" 3)
+ '("mel" 3) '("mel*" 3) '("mel**" 3)
+ ;; 2.7 Matrix macros
+ '("matrixquantity" TeX-arg-physics-mqty)
+ '("matrixquantity*" TeX-arg-physics-mqty*)
+ '("mqty" TeX-arg-physics-mqty)
+ '("mqty*" TeX-arg-physics-mqty*)
+ '("pmqty" t) '("Pmqty" t) '("bmqty" t) '("vmqty" t)
+ '("smallmatrixquantity" TeX-arg-physics-mqty)
+ '("smallmatrixquantity*" TeX-arg-physics-mqty*)
+ '("smqty" TeX-arg-physics-mqty)
+ '("smqty*" TeX-arg-physics-mqty*)
+ '("spmqty" t) '("sPmqty" t) '("sbmqty" t) '("svmqty" t)
+ '("matrixdeterminant" t)
+ '("mdet" t) '("smdet" t)
+ '("identitymatrix" "Size")
+ '("imat" "Size")
+ '("xmatrix" "Element" "Rows" "Cols")
+ '("xmatrix*" "Element" "Rows" "Cols")
+ '("xmat" "Element" "Rows" "Cols") '("xmat*" "Element" "Rows" "Cols")
+ '("zeromatrix" "Rows" "Cols")
+ '("zmat" "Rows" "Cols")
+ '("paulimatrix" "0,1,2,3 or x,y,z")
+ '("pmat" "0,1,2,3 or x,y,z")
+ '("diagonalmatrix" ["Filler"] t)
+ '("dmat" ["Filler"] t)
+ '("antidiagonalmatrix" ["Filler"] t)
+ '("admatrix" ["Filler"] t)))
+ TeX-dialect)
+
+(defvar LaTeX-physics-package-options
+ '("bolddel" "arrowdel" "trig" "notrig" "uprightdiff" "italicdiff")
+ "Package options for the physics package.")
+
+;;; physics.el ends here
diff --git a/style/pstricks.el b/style/pstricks.el
index 6a6707f3..b5b93df6 100644
--- a/style/pstricks.el
+++ b/style/pstricks.el
@@ -136,6 +136,8 @@ available through package name PNAME and return
\"param=value\"."
((string-match bregexp param)
'LaTeX-pst-boolean-list)))
val compl)
+ ;; See FIXME below: The next form is just to silence the compiler:
+ (setq compl nil)
;; ask for value
(setq val (TeX-arg-compl-list
(symbol-value parlist)
diff --git a/style/theorem.el b/style/theorem.el
index 6657c3c0..52aea651 100644
--- a/style/theorem.el
+++ b/style/theorem.el
@@ -107,7 +107,7 @@ make them available as new environments."
`("theorembodyfont"
(TeX-arg-completing-read-multiple
,(lambda () (append LaTeX-font-family
- LaTeX-font-shape
+ LaTeX-font-series
LaTeX-font-shape
LaTeX-font-size))
"Body font" nil nil ,(regexp-quote TeX-esc) ,TeX-esc
@@ -116,7 +116,7 @@ make them available as new environments."
`("theoremheaderfont"
(TeX-arg-completing-read-multiple
,(lambda () (append LaTeX-font-family
- LaTeX-font-shape
+ LaTeX-font-series
LaTeX-font-shape
LaTeX-font-size))
"Header font" nil nil ,(regexp-quote TeX-esc) ,TeX-esc
diff --git a/style/tikz.el b/style/tikz.el
index a0edfd46..e0cb0413 100644
--- a/style/tikz.el
+++ b/style/tikz.el
@@ -37,16 +37,6 @@
(declare-function ConTeXt-add-environments "context"
(&rest environments))
-(defgroup AUCTeX-TikZ nil
- "AUCTeX TikZ support"
- :group 'AUCTeX)
-
-(defcustom TeX-TikZ-point-name-regexp
- "(\\([A-Za-z0-9]+\\))"
- "A regexp that matches TikZ names."
- :type 'regexp
- :group 'AUCTeX-TikZ)
-
(defconst TeX-TikZ-point-function-map
'(("Rect Point" TeX-TikZ-arg-rect-point)
("Polar Point" TeX-TikZ-arg-polar-point)
@@ -85,8 +75,8 @@
(defun TeX-TikZ-get-opt-arg-string (arg &optional open close)
"Return a string for optional arguments.
If ARG is nil or \"\", return \"\". Otherwise return \"OPEN ARG
-CLOSE\". If OPEN or CLOSE are nil, set them to `LaTeX-optop' and
-`LaTeX-optcl' respectively."
+CLOSE\". If OPEN and CLOSE are nil, set them to `LaTeX-optop'
+and `LaTeX-optcl' respectively."
(unless (or open close)
(setq open LaTeX-optop)
(setq close LaTeX-optcl))
@@ -284,6 +274,16 @@ return \"\"."
(label (TeX-TikZ-arg-label nil)))
(insert options " " name " at" point label ";")))
+;; TODO: Add similar support for plain TeX.
+(defun TeX-TikZ-env-scope (_ignored)
+ "Ask the user for TikZ option and insert it with surrounding \"[]\".
+If the user provides empty input, insert \"[]\" anyway and put the
+point inside it."
+ (let ((option (TeX-TikZ-arg-options nil)))
+ (insert option)
+ (if (string= option "[]")
+ (set-marker TeX-exit-mark (1- (point))))))
+
(TeX-add-style-hook
"tikz"
(lambda ()
@@ -311,7 +311,7 @@ return \"\"."
(lambda ()
(LaTeX-add-environments
'("tikzpicture" ["TikZ option"])
- '("scope" ["TikZ option"]))
+ '("scope" LaTeX-env-args TeX-TikZ-env-scope))
;; tikz.sty loads pgfcore.sty, which loads packages graphicx,
;; keyval and xcolor, too.
(TeX-run-style-hooks "pgf" "graphicx" "keyval" "xcolor"))
@@ -323,7 +323,7 @@ return \"\"."
(lambda ()
(ConTeXt-add-environments
'("tikzpicture" ["TikZ option"])
- '("scope" ["TikZ option"])))
+ '("scope" ConTeXt-env-args TeX-TikZ-env-scope)))
:context)
;; plain TeX specific stuff
diff --git a/style/xcolor.el b/style/xcolor.el
index 001f4086..b0bc74fb 100644
--- a/style/xcolor.el
+++ b/style/xcolor.el
@@ -1,6 +1,6 @@
;; xcolor.el --- AUCTeX style for `xcolor.sty' (v2.12) -*- lexical-binding:
t; -*-
-;; Copyright (C) 2016--2022 Free Software Foundation, Inc.
+;; Copyright (C) 2016--2023 Free Software Foundation, Inc.
;; Author: Arash Esbati <arash@gnu.org>
;; Maintainer: auctex-devel@gnu.org
@@ -416,15 +416,16 @@ xcolor package.")
'("providecolor" TeX-arg-xcolor-definecolor)
;; \colorlet[<type>]{<name>}[<num model>]{<color>}
- '("colorlet"
+ `("colorlet"
[TeX-arg-completing-read LaTeX-xcolor-type-color-models "Type"]
- (TeX-arg-eval
- (lambda ()
+ ,(lambda (optional)
(let ((xcolor (TeX-read-string
- (TeX-argument-prompt nil nil "Color"))))
+ (TeX-argument-prompt optional nil "Color"))))
(LaTeX-add-xcolor-definecolors xcolor)
- (format "%s" xcolor))))
- [TeX-arg-completing-read (LaTeX-xcolor-color-models t) "Model"]
+ (TeX-argument-insert xcolor optional)))
+ [TeX-arg-completing-read ,(lambda ()
+ (LaTeX-xcolor-color-models t))
+ "Model"]
(TeX-arg-completing-read (LaTeX-xcolor-definecolor-list) "Color"))
;; 2.5.3 Defining sets of colors
@@ -539,15 +540,15 @@ xcolor package.")
;; \rowcolors[<commands>]{<row>}{<odd-row color>}{<even-row color>}
'("rowcolors"
(TeX-arg-conditional (y-or-n-p "With optional commands? ")
- ( [ t ] )
- (ignore))
+ ( [ t ] )
+ (ignore))
"Row"
(TeX-arg-completing-read (LaTeX-xcolor-definecolor-list) "Odd-row
color")
(TeX-arg-completing-read (LaTeX-xcolor-definecolor-list) "Even-row
color"))
'("rowcolors*"
(TeX-arg-conditional (y-or-n-p "With optional commands? ")
- ( [ t ] )
- (ignore))
+ ( [ t ] )
+ (ignore))
"Row"
(TeX-arg-completing-read (LaTeX-xcolor-definecolor-list) "Odd-row
color")
(TeX-arg-completing-read (LaTeX-xcolor-definecolor-list) "Even-row
color"))
diff --git a/tests/tex/navigation.el b/tests/tex/navigation.el
index 4debb44f..45071bf2 100644
--- a/tests/tex/navigation.el
+++ b/tests/tex/navigation.el
@@ -1,6 +1,6 @@
;;; navigation.el --- tests for navigation function in TeX buffer -*-
lexical-binding: t; -*-
-;; Copyright (C) 2019-2021 Free Software Foundation, Inc.
+;; Copyright (C) 2019-2023 Free Software Foundation, Inc.
;; This file is part of AUCTeX.
@@ -26,29 +26,66 @@
(defun TeX-check-f-m-e-h (string &optional position)
"Check whether `TeX-find-macro-end-helper' works for exceptional case."
+ (erase-buffer)
+ (insert string)
+ (should (= (or position (point-max))
+ (TeX-find-macro-end-helper (point-min)))))
+
+(ert-deftest TeX-find-macro-end-helper ()
(with-temp-buffer
- (insert string)
- (should (= (or position (point-max))
- (TeX-find-macro-end-helper (point-min))))))
+ (LaTeX-mode)
+
+ ;; single macro ending at EOB
+ (TeX-check-f-m-e-h "\\foo")
+
+ ;; curly braces ending at EOB
+ (TeX-check-f-m-e-h "\\foo{bar}")
+
+ ;; curly brace failing to close at EOB
+ (TeX-check-f-m-e-h "\\foo{bar")
+
+ ;; square brackets ending at EOB
+ (TeX-check-f-m-e-h "\\foo{bar}[baz]")
+
+ ;; square bracket failing to close at EOB
+ (TeX-check-f-m-e-h "\\foo{bar}[baz" (1+ (length "\\foo{bar}")))))
+
+(defun TeX-check-f-m-b (string &optional chars)
+ "Check whether `TeX-find-macro-boundaries' works for exceptional case."
+ (erase-buffer)
+ (insert string)
+ (if chars (backward-char chars))
+ (let ((result (TeX-find-macro-boundaries)))
+ (should (= (point-min)
+ (car result)))
+ (should (= (point-max)
+ (cdr result)))))
+
+(ert-deftest TeX-find-macro-boundaries-detached-arg ()
+ (with-temp-buffer
+ ;; necessary to set comment syntax properly
+ (LaTeX-mode)
+
+ ;; argument separated by newline
+ (TeX-check-f-m-e-h "\\foo{bar}
+{baz}")
+
+ (TeX-check-f-m-e-h "\\foo{bar}
+ {baz}")
-(ert-deftest TeX-find-macro-end-helper-single ()
- ;; single macro ending at EOB
- (TeX-check-f-m-e-h "\\foo"))
+ (TeX-check-f-m-e-h "\\foo{bar} % comment
+ {baz}")
-(ert-deftest TeX-find-macro-end-helper-curly ()
- ;; curly braces ending at EOB
- (TeX-check-f-m-e-h "\\foo{bar}"))
+ (TeX-check-f-m-b "\\foo{bar}
+{baz}" 2)
-(ert-deftest TeX-find-macro-end-helper-curly-fail ()
- ;; curly brace failing to close at EOB
- (TeX-check-f-m-e-h "\\foo{bar"))
+ (TeX-check-f-m-b "\\foo{bar}
+ {baz}" 2)
-(ert-deftest TeX-find-macro-end-helper-square ()
- ;; square brackets ending at EOB
- (TeX-check-f-m-e-h "\\foo{bar}[baz]"))
+ (TeX-check-f-m-b "\\foo{bar} % comment
+ {baz}" 2)
-(ert-deftest TeX-find-macro-end-helper-square-fail ()
- ;; square bracket failing to close at EOB
- (TeX-check-f-m-e-h "\\foo{bar}[baz" (1+ (length "\\foo{bar}"))))
+ (TeX-check-f-m-b "\\foo{bar}% comment
+ {baz}" 2)))
;;; navigation.el ends here
diff --git a/tex-info.el b/tex-info.el
index 2ee3d7ac..dd0ff433 100644
--- a/tex-info.el
+++ b/tex-info.el
@@ -164,7 +164,7 @@ there are unbalanced begin-end pairs in comments and
verbatim
environments."
;; TODO:
;; This is identical to the LaTeX counterpart but for the find begin/end
- ;; functions. So some day the implemenation should be factorized.
+ ;; functions. So some day the implemenation should be factorized.
(interactive "p")
(setq count (if count (abs count) 1))
(let ((cur (point)) beg end)
@@ -290,7 +290,7 @@ beginning of keyword `@node' or `@bye'."
(defun Texinfo-nodename-de-escape (node-name)
"In NODE-NAME, convert `@comma{}' commands to the corresponding `,'
-character. Return the resulting string."
+character. Return the resulting string."
(let ((pos 0) (map '(("comma" . ","))))
(while (and (< pos (length
node-name))
@@ -304,7 +304,7 @@ character. Return the resulting string."
(defun Texinfo-nodename-escape (node-name)
"Convert in NODE-NAME the `,' characters to `@comma{}'
-commands. Return the resulting string."
+commands. Return the resulting string."
(let* ((pos 0)
(map '(("," . "comma")))
(re (regexp-opt (mapcar #'car map))) )
@@ -466,7 +466,7 @@ is assumed by default."
(literal (buffer-substring-no-properties
(1- (match-beginning 3))
(min (point-max) (+ (match-end 0) (length text1) 1))))
- ;; Literal can be too short since text1 too short. No big problem.
+ ;; Literal can be too short since text1 too short. No big problem.
(text (reftex-nicify-text text1)))
;; Add section number and indentation
@@ -728,7 +728,7 @@ value of `Texinfo-mode-hook'."
'("bye")
'("c" (TeX-arg-literal " ") (TeX-arg-free "Comment"))
'("caption" "Caption"
- ;; TODO: caption is meaningful only inside float env. Maybe some checking
+ ;; TODO: caption is meaningful only inside float env. Maybe some checking
;; and warning would be good.
)
'("center" (TeX-arg-literal " ") (TeX-arg-free "Line of text"))
diff --git a/tex-style.el b/tex-style.el
index b880bfcc..d273ea08 100644
--- a/tex-style.el
+++ b/tex-style.el
@@ -411,6 +411,13 @@ must be unique. It is initialized to ?s when added to
`reftex-index-macros'."
:type 'character)
+;; style/tikz.el
+
+(defcustom TeX-TikZ-point-name-regexp
+ "(\\([A-Za-z0-9]+\\))"
+ "A regexp that matches TikZ names."
+ :type 'regexp)
+
;; Don't look for file-local variables before this line, so that the
;; example in the docstring of `LaTeX-shortvrb-chars' isn't picked up.
diff --git a/tex.el b/tex.el
index d74d10d0..456c0310 100644
--- a/tex.el
+++ b/tex.el
@@ -1,6 +1,6 @@
;;; tex.el --- Support for TeX documents. -*- lexical-binding: t; -*-
-;; Copyright (C) 1985-2022 Free Software Foundation, Inc.
+;; Copyright (C) 1985-2023 Free Software Foundation, Inc.
;; Maintainer: auctex-devel@gnu.org
;; Keywords: tex
@@ -56,6 +56,7 @@
(bus service path interface signal handler &rest args))
(declare-function LaTeX-environment-list "latex" nil)
(declare-function LaTeX-bibliography-list "latex" nil)
+(declare-function LaTeX-section-name "latex" (level))
(declare-function comint-exec "ext:comint"
(buffer name command startfile switches))
(declare-function comint-mode "ext:comint" nil)
@@ -91,7 +92,6 @@
(defvar LaTeX-optcl)
(defvar LaTeX-optop)
(defvar LaTeX-largest-level)
-(defvar LaTeX-section-list)
;; tex-ispell.el
(defvar TeX-ispell-verb-delimiters)
;; Others:
@@ -270,41 +270,41 @@ expanded. The expansion is done using the information
found in
The third element is the function which actually start the process.
Several such hooks have been defined:
-TeX-run-command: Start up the process and show the output in a
+`TeX-run-command': Start up the process and show the output in a
separate buffer. Check that there is not two commands running for the
same file. Return the process object.
-TeX-run-format: As `TeX-run-command', but assume the output is created
+`TeX-run-format': As `TeX-run-command', but assume the output is created
by a TeX macro package. Return the process object.
-TeX-run-TeX: For TeX output.
+`TeX-run-TeX': For TeX output.
-TeX-run-interactive: Run TeX or LaTeX interactively.
+`TeX-run-interactive': Run TeX or LaTeX interactively.
-TeX-run-BibTeX: For BibTeX output.
+`TeX-run-BibTeX': For BibTeX output.
-TeX-run-Biber: For Biber output.
+`TeX-run-Biber': For Biber output.
-TeX-run-compile: Use `compile' to run the process.
+`TeX-run-compile': Use `compile' to run the process.
-TeX-run-shell: Use `shell-command' to run the process.
+`TeX-run-shell': Use `shell-command' to run the process.
-TeX-run-discard: Start the process in the background, discarding its
+`TeX-run-discard': Start the process in the background, discarding its
output.
-TeX-run-background: Start the process in the background, show output
+`TeX-run-background': Start the process in the background, show output
in other window.
-TeX-run-silent: Start the process in the background.
+`TeX-run-silent': Start the process in the background.
-TeX-run-discard-foreground: Start the process in the foreground,
+`TeX-run-discard-foreground': Start the process in the foreground,
discarding its output.
-TeX-run-function: Execute the Lisp function or function call
+`TeX-run-function': Execute the Lisp function or function call
specified by the string in the second element. Consequently,
this hook does not start a process.
-TeX-run-discard-or-function: If the command is a Lisp function,
+`TeX-run-discard-or-function': If the command is a Lisp function,
execute it as such, otherwise start the command as a process,
discarding its output.
@@ -701,11 +701,6 @@ sure \"%p\" is the first entry."
TeX-expand-list
TeX-expand-list-builtin))
-;; This variable used to be defined in tex-buf.el. It is used in
-;; `TeX-mode-specific-command-menu-entries' in this file. It is now
-;; (June 2021) moved into this file to avoid `void-variable' errors
-;; with the "Command" menu if tex-buf.el is not loaded yet for reasons
-;; mentioned above.
(defcustom TeX-parse-all-errors t
"Whether to automatically collect all warning and errors after running TeX.
@@ -1106,24 +1101,32 @@ DE is the name of the desktop environment, APP is the
name of viewer."
(and (featurep 'dbusbind)
(require 'dbus nil :no-error)
(dbus-ignore-errors (dbus-get-unique-name :session))
- (dbus-ping :session (format "org.%s.%s.Daemon" de app))
+ ;; Apparently, `dbus-ping' can signal errors in certain
+ ;; situations. If so, fail gracefully (bug#59380).
+ (ignore-errors
+ (dbus-ping :session (format "org.%s.%s.Daemon" de app)
+ ;; Don't block for up to 25 secs if something
+ ;; is wonky.
+ 2000))
(or (not (memq :forward options))
(let ((spec (dbus-introspect-get-method
:session (format "org.%s.%s.Daemon" de app)
(format "/org/%s/%s/Daemon" de app)
(format "org.%s.%s.Daemon" de app)
"FindDocument")))
- ;; FindDocument must exist, and its signature must be (String,
- ;; Boolean, String). Evince versions between 2.30 and 2.91.x
- ;; didn't have the Boolean spawn argument we need to start
evince
- ;; initially.
- (and spec
- (equal '("s" "b" "s")
- (delq nil (mapcar (lambda (elem)
- (when (and (listp elem)
- (eq (car elem) 'arg))
- (cdr (caar (cdr elem)))))
- spec)))))))))
+ ;; FindDocument must exist, and its signature must be
+ ;; (String, Boolean, String). Evince versions between
+ ;; 2.30 and 2.91.x didn't have the Boolean spawn
+ ;; argument we need to start evince initially.
+ (and
+ spec
+ (equal '("s" "b" "s")
+ (delq nil (mapcar
+ (lambda (elem)
+ (when (and (listp elem)
+ (eq (car elem) 'arg))
+ (cdr (caar (cdr elem)))))
+ spec)))))))))
(defun TeX-pdf-tools-sync-view ()
"Focus the focused page/paragraph in `pdf-view-mode'.
@@ -3257,7 +3260,7 @@ See `completion-at-point-functions'."
(make-variable-buffer-local 'TeX-default-macro)
(defcustom TeX-insert-braces t
- "If non-nil, append a empty pair of braces after inserting a macro.
+ "If non-nil, append an empty pair of braces after inserting a macro.
See also `TeX-insert-braces-alist'."
:group 'TeX-macro
@@ -3941,7 +3944,8 @@ Generated by `TeX-auto-add-type'."))
(make-variable-buffer-local ',change)
(defun ,add (&rest ,(intern names))
,(concat "Add information about " (upcase names)
- " to the current buffer.
+ ".
+Information is added to the current buffer.
Generated by `TeX-auto-add-type'.")
(TeX-auto-add-information ,unique-key ,(intern names)))
(defun ,local ()
@@ -5569,10 +5573,18 @@ in the buffer."
(TeX-find-balanced-brace -1 depth limit))
(defun TeX-find-macro-boundaries (&optional lower-bound)
- "Return a list containing the start and end of a macro.
+ "Return a cons containing the start and end of a macro.
If LOWER-BOUND is given, do not search backward further than this
point in buffer. Arguments enclosed in brackets or braces are
considered part of the macro."
+ ;; FIXME: Pay attention to `texmathp-allow-detached-args' and
+ ;; `reftex-allow-detached-macro-args'.
+ ;; Should we handle cases like \"{o} and \\[3mm] (that is, a macro
+ ;; whose name is a symbol and takes some arguments) as well? Note
+ ;; that amsmath package arranges the macro \\ so that white spaces
+ ;; between \\ and [something] prevents the latter to be interpreted
+ ;; as an optional argument. mathtools package arranges some
+ ;; environments including gathered similarly.
(save-restriction
(when lower-bound
(narrow-to-region lower-bound (point-max)))
@@ -5599,6 +5611,7 @@ considered part of the macro."
(condition-case nil (backward-sexp)
(error (throw 'abort nil)))
(forward-comment -1)
+ (skip-chars-backward " \t")
(and (memq (char-before) '(?\] ?\}))
(not (TeX-escaped-p (1- (point)))))))
(skip-chars-backward "A-Za-z@*")
@@ -5628,7 +5641,7 @@ those will be considered part of it."
(while (not (eobp))
(cond
;; Skip over pairs of square brackets
- ((or (looking-at "[ \t]*\n?\\(\\[\\)") ; Be conservative: Consider
+ ((or (looking-at "[ \t]*\n?[ \t]*\\(\\[\\)") ; Be conservative:
Consider
; only consecutive lines.
(and (looking-at (concat "[ \t]*" TeX-comment-start-regexp))
(save-excursion
@@ -5639,7 +5652,7 @@ those will be considered part of it."
(forward-sexp)
(scan-error (throw 'found (point)))))
;; Skip over pairs of curly braces
- ((or (looking-at "[ \t]*\n?{") ; Be conservative: Consider
+ ((or (looking-at "[ \t]*\n?[ \t]*{") ; Be conservative: Consider
; only consecutive lines.
(and (looking-at (concat "[ \t]*" TeX-comment-start-regexp))
(save-excursion
@@ -5714,8 +5727,8 @@ throwing an error.
A pattern is escaped, if it is preceded by an odd number of escape
characters."
(let ((search-fun (if (eq direction 'backward)
- (if regexp-flag 're-search-backward 'search-backward)
- (if regexp-flag 're-search-forward 'search-forward))))
+ (if regexp-flag #'re-search-backward #'search-backward)
+ (if regexp-flag #'re-search-forward #'search-forward))))
(catch 'found
(while (funcall search-fun pattern bound noerror)
(when (not (TeX-escaped-p (match-beginning 0)))
@@ -6278,7 +6291,7 @@ between.
If there is an active region, ARG will be ignored, braces will be
inserted around the region, and point will be left after the
closing brace."
- (interactive "P")
+ (interactive "*P")
(if (TeX-active-mark)
(progn
(if (< (point) (mark))
@@ -9074,8 +9087,7 @@ Initialize it to `LaTeX-largest-level' if needed."
determine the current section by `LaTeX-command-section'.
The levels are defined by `LaTeX-section-list'."
(interactive "p")
- (let ((old-level (car (rassoc (list (LaTeX-command-section-level))
- LaTeX-section-list))))
+ (let ((old-level (LaTeX-section-name (LaTeX-command-section-level))))
(setq LaTeX-command-section-level (+ LaTeX-command-section-level arg))
(cond
((> LaTeX-command-section-level 6)
@@ -9085,8 +9097,8 @@ The levels are defined by `LaTeX-section-list'."
(setq LaTeX-command-section-level 0)
(message "Cannot enlarge LaTeX-command-section-level above part."))
(t (message "Changed level from %s to %s."
- old-level (car (rassoc (list LaTeX-command-section-level)
- LaTeX-section-list)))))))
+ old-level (LaTeX-section-name
+ LaTeX-command-section-level))))))
(defun LaTeX-command-section-boundaries ()
"Return the boundaries of the current section as (start . end).
@@ -9094,13 +9106,10 @@ The section is determined by
`LaTeX-command-section-level'."
(let* ((case-fold-search nil)
(rx (concat "\\\\" (regexp-opt
(mapcar
- (lambda (level)
- (car (rassoc (list level) LaTeX-section-list)))
- (let (r)
- (dotimes (i (1+ (LaTeX-command-section-level)))
- (push i r))
- r)))
- "{")))
+ #'LaTeX-section-name
+ (number-sequence
+ 0 (LaTeX-command-section-level))))
+ "\\*?{")))
(cons (save-excursion
(re-search-backward rx nil t)
(point))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- main 358b4d07 220/257: Merge remote-tracking branch 'origin/master' into externals/auctex,
Tassilo Horn <=