branch: main commit 800064f6c123dbd5dc6899a821b0cf7c2fe508b0 Merge: c576c01d b2571b60 Author: Tassilo Horn <t...@gnu.org> Commit: Tassilo Horn <t...@gnu.org>
Merge branch 'master' into externals/auctex --- Makefile.in | 3 +- context-en.el | 3 +- context-nl.el | 2 +- context.el | 17 +- doc/auctex.texi | 21 +++ doc/changes.texi | 25 +++ doc/install.texi | 11 +- doc/tex-ref.tex | 4 +- font-latex.el | 3 +- latex.el | 8 +- plain-tex.el | 6 +- preview.el | 43 +++-- prv-xemacs.el | 2 +- style/XCharter.el | 26 ++- style/amsthm.el | 2 +- style/arabxetex.el | 113 ++++++++++++ style/biblatex.el | 4 +- style/bidi.el | 0 style/epigraph.el | 62 +++++-- style/fontspec.el | 3 +- style/graphicx.el | 32 ++-- style/longtable.el | 73 ++++---- style/minted.el | 4 +- style/relsize.el | 4 +- style/xltabular.el | 64 +++++++ tests/japanese/parse-timing-test.tex | 2 + tests/japanese/parse-timing.el | 63 +++++++ tests/latex/latex-test.el | 16 ++ tests/tex/path-expansion.el | 59 +++++++ tests/tex/utility.el | 32 ++++ tex-bar.el | 2 +- tex-buf.el | 2 +- tex-fold.el | 2 +- tex-info.el | 57 ++++-- tex-jp.el | 55 +++--- tex-site.el.in | 2 +- tex-style.el | 2 +- tex.el | 329 +++++++++++++++++------------------ 38 files changed, 834 insertions(+), 324 deletions(-) diff --git a/Makefile.in b/Makefile.in index 4114d0e3..abe2b2e7 100644 --- a/Makefile.in +++ b/Makefile.in @@ -167,7 +167,8 @@ STYLESRC = style/prosper.el \ style/preview.el style/fvextra.el style/jurabib.el \ style/csquotes.el style/babel.el style/dk-bib.el \ style/floatrow.el style/moodle.el style/canadian.el \ - style/australian.el style/newzealand.el + style/arabxetex.el style/australian.el style/newzealand.el \ + style/xltabular.el STYLEELC = $(STYLESRC:.el=.elc) diff --git a/context-en.el b/context-en.el index 865ca717..7e6db6f0 100644 --- a/context-en.el +++ b/context-en.el @@ -1,6 +1,7 @@ ;;; context-en.el --- Support for the ConTeXt english interface. -;; Copyright (C) 2003, 2004 Free Software Foundation, Inc. +;; Copyright (C) 2003-2004, 2006, 2008, 2010, 2014 +;; Free Software Foundation, Inc. ;; Maintainer: Berend de Boer <ber...@pobox.com> ;; Keywords: tex diff --git a/context-nl.el b/context-nl.el index 6d69b3b9..b08dadc0 100644 --- a/context-nl.el +++ b/context-nl.el @@ -1,6 +1,6 @@ ;;; context-nl.el --- Support for the ConTeXt dutch interface. -;; Copyright (C) 2003, 2004 Free Software Foundation, Inc. +;; Copyright (C) 2003, 2004, 2006, 2010, 2015 Free Software Foundation, Inc. ;; Maintainer: Berend de Boer <ber...@pobox.com> ;; Keywords: tex diff --git a/context.el b/context.el index d322afce..e42423bd 100644 --- a/context.el +++ b/context.el @@ -508,7 +508,7 @@ in your .emacs file." Insert this hook into `ConTeXt-numbered-section-hook' to allow the user to change the name of the sectioning command inserted with `\\[ConTeXt-section]'." (let ((string (completing-read - (concat "Select level: (default " name ") ") + (concat "Select level (default " name "): ") ConTeXt-numbered-section-list nil nil nil))) ;; Update name @@ -520,7 +520,7 @@ the name of the sectioning command inserted with `\\[ConTeXt-section]'." Insert this hook into `ConTeXt-unnumbered-section-hook' to allow the user to change the name of the sectioning command inserted with `\\[ConTeXt-section]'." (let ((string (completing-read - (concat "Select level: (default " name ") ") + (concat "Select level (default " name "): ") ConTeXt-unnumbered-section-list nil nil nil))) ;; Update name @@ -670,7 +670,7 @@ With optional ARG, modify current environment." ((TeX-near-bobp) "text") (t ConTeXt-default-environment))) (environment - (completing-read (concat "Environment type: (default " default ") ") + (completing-read (concat "Environment type (default " default "): ") ConTeXt-environment-list nil nil nil 'ConTeXt-environment-history default))) ;; Use `environment' as default for the next time only if it is different @@ -1545,46 +1545,55 @@ else. There might be text before point." (setq ConTeXt-menu-changed nil) (message "Updating section menu...") (mapc #'ConTeXt-section-enable ConTeXt-section-list) + (message "Updating section menu...done") (message "Updating environment menu...") (easy-menu-change '("ConTeXt") ConTeXt-environment-menu-name (LaTeX-split-long-menu (mapcar #'ConTeXt-environment-menu-entry (ConTeXt-environment-list)))) + (message "Updating environment menu...done") (message "Updating modify environment menu...") (easy-menu-change '("ConTeXt") ConTeXt-environment-modify-menu-name (LaTeX-split-long-menu (mapcar #'ConTeXt-environment-modify-menu-entry (ConTeXt-environment-list)))) + (message "Updating modify environment menu...done") (message "Updating define menu...") (easy-menu-change '("ConTeXt") ConTeXt-define-menu-name (LaTeX-split-long-menu (mapcar #'ConTeXt-define-menu-entry ConTeXt-define-list))) + (message "Updating define menu...done") (message "Updating setup menu...") (easy-menu-change '("ConTeXt") ConTeXt-setup-menu-name (LaTeX-split-long-menu (mapcar #'ConTeXt-setup-menu-entry ConTeXt-setup-list))) + (message "Updating setup menu...done") (message "Updating referencing menu...") (easy-menu-change '("ConTeXt") ConTeXt-referencing-menu-name (LaTeX-split-long-menu (mapcar #'ConTeXt-referencing-menu-entry ConTeXt-referencing-list))) + (message "Updating referencing menu...done") (message "Updating other macro's menu...") (easy-menu-change '("ConTeXt") ConTeXt-other-macro-menu-name (LaTeX-split-long-menu (mapcar #'ConTeXt-other-macro-menu-entry ConTeXt-other-macro-list))) + (message "Updating other macro's menu...done") (message "Updating project structure menu...") (easy-menu-change '("ConTeXt") ConTeXt-project-structure-menu-name (LaTeX-split-long-menu (mapcar #'ConTeXt-project-structure-menu-entry ConTeXt-project-structure-list))) + (message "Updating project structure menu...done") (message "Updating section block menu...") (easy-menu-change '("ConTeXt") ConTeXt-section-block-menu-name (LaTeX-split-long-menu (mapcar #'ConTeXt-section-block-menu-entry ConTeXt-section-block-list))) + (message "Updating section block menu...done") (message "Updating section menu...") (easy-menu-change '("ConTeXt") ConTeXt-numbered-section-menu-name (LaTeX-split-long-menu @@ -1594,7 +1603,7 @@ else. There might be text before point." (LaTeX-split-long-menu (mapcar #'ConTeXt-unnumbered-section-menu-entry ConTeXt-unnumbered-section-list))) - (message "Updating...done") + (message "Updating section menu...done") (and menu (easy-menu-return-item ConTeXt-mode-menu menu)) ))) diff --git a/doc/auctex.texi b/doc/auctex.texi index 0335b6cd..72599321 100644 --- a/doc/auctex.texi +++ b/doc/auctex.texi @@ -1206,6 +1206,15 @@ In order to enable this feature, set the variable If non-nil, insert braces after typing @key{^} and @key{_} in math mode. @end defopt +You can automatically turn off input methods, used to input non-ascii +characters, when you begin to enter math constructs. + +@defopt TeX-math-input-method-off-regexp +Input method matching this regular expression is turned off when @kbd{$} +is typed to begin math mode or a math environment is inserted by +@kbd{C-c C-e} (@code{LaTeX-environment}). +@end defopt + @node Completion @section Completion @cindex Completion @@ -3473,6 +3482,18 @@ A built-in viewer spec from @code{TeX-view-program-list-builtin} can be overwritten by defining a new viewer spec with the same name. @end defopt +After the viewer is called via either the View command or the key stroke +@kbd{C-c C-v}, the window system focus goes and stays on the viewer. If +you prefer that the focus is pulled back to Emacs immediately after that +and you are using evince-compatible viewer, customize the option +@code{TeX-view-enince-keep-focus}. + +@defopt TeX-view-evince-keep-focus +When this option is non-nil and the viewer is compatible with evince, +the focus is pulled back to Emacs immediately after the viewer is +invoked or refreshed from within @AUCTeX{}. +@end defopt + Note that the viewer selection and invocation as described above will only work if certain default settings in @AUCTeX{} are intact. For one, the whole viewer selection machinery will only be triggered if there is diff --git a/doc/changes.texi b/doc/changes.texi index ab38cdfa..bf34e225 100644 --- a/doc/changes.texi +++ b/doc/changes.texi @@ -8,6 +8,31 @@ @end ifset +@heading News in 11.92 + +@itemize @bullet +@item +@previewlatex{} is compatible with Ghostscript 9.22 where the operator +@samp{.runandhide} is removed. All occurrences of @samp{.runandhide} in +@previewlatex{} are replaced by alternative code making it work with +Ghostscript 9.22 again. + +@item +@AUCTeX{} has a new customize option +@code{TeX-math-input-method-off-regexp}. When you begin to input a math +formula, the current input method is turned off if its name matches this +regular expression. + +In fact this variable was introduced long before, but has not been +documented in info files nor turned into a customize option with +@code{defcustom} until this release. + +@item +The window system focus is pulled back to Emacs when viewing with +evince-compatible viewers if a new customize option +@code{TeX-view-evince-keep-focus} is non-nil. +@end itemize + @heading News in 11.91 @itemize @bullet diff --git a/doc/install.texi b/doc/install.texi index 184be7cd..bf3390d9 100644 --- a/doc/install.texi +++ b/doc/install.texi @@ -1,5 +1,6 @@ @c This is part of the AUCTeX Manual. -@c Copyright (C) 1994, 1996, 2003-2007, 2012 Free Software Foundation, Inc. +@c Copyright (C) 1994, 1996, 2003-2007, 2012-2013, +@c 2015, 2017 Free Software Foundation, Inc. @c See the file auctex.texi for copying conditions. @ifset rawfile @include macros.texi @@ -135,6 +136,14 @@ This is needed for operation of @previewlatex{} in both @acronym{DVI} and @acronym{PDF} mode. Most versions of Ghostscript nowadays in use should work fine (version 7.0 and newer). +@item GNU make + +Recent @AUCTeX{} uses GNU make specific capabilities in the Makefiles. +If your OS's default @command{make} command is not GNU make, you have to +obtain it in order to build @AUCTeX{} by yourself. GNU make is +sometimes provided under the name @command{gmake} in your OS's binary +package system. + @item The @code{texinfo} package Strictly speaking, you can get away without it if you are building diff --git a/doc/tex-ref.tex b/doc/tex-ref.tex index 80c82031..b86a221e 100644 --- a/doc/tex-ref.tex +++ b/doc/tex-ref.tex @@ -53,7 +53,7 @@ \def\copyrightnotice{% \vskip 1ex plus 2 fill\begingroup\small \centerline{Copyright \copyright\ 1987, 1992-1994, 2004-2006, 2008, 2010,} -\centerline{2012, 2014, 2015 Free Software Foundation, Inc.} +\centerline{2012, 2014-2017 Free Software Foundation, Inc.} \centerline{for AUC\TeX\ version \versionnumber} Permission is granted to make and distribute copies of @@ -579,7 +579,7 @@ AUCTeX, insert the following lines in .emacs. \vskip-3mm \beginexample (add-hook 'LaTeX-mode-hook 'turn-on-reftex) -(setq reftex-plug-into-auctex t) +(setq reftex-plug-into-AUCTeX t) \endexample \section{Table of Contents} diff --git a/font-latex.el b/font-latex.el index 9296a1c2..c3dda00d 100644 --- a/font-latex.el +++ b/font-latex.el @@ -1241,7 +1241,6 @@ The entries are added to `font-latex-syntax-alist' and eventually end up in `font-lock-defaults'. Each entry in LIST should be a cons pair as expected by `font-lock-defaults'. The function also triggers Font Lock to recognize the change." - (make-local-variable 'font-latex-syntax-alist) (set (make-local-variable 'font-latex-syntax-alist) (append font-latex-syntax-alist list)) ;; Tell font-lock about the update. @@ -1813,7 +1812,7 @@ Each character is a string.") "Match math pattern up to LIMIT. Used for patterns like: \\( F = ma \\) -\\[ F = ma \\] but not \\\\ [len]" +\\=\\[ F = ma \\] but not \\\\=\\[len]" (catch 'match (while (re-search-forward "\\(\\\\(\\)\\|\\(\\\\\\[\\)" limit t) (unless (save-excursion diff --git a/latex.el b/latex.el index 8dc9fa35..fa2ae349 100644 --- a/latex.el +++ b/latex.el @@ -1,6 +1,6 @@ ;;; latex.el --- Support for LaTeX documents. -;; Copyright (C) 1991, 1993-2016 Free Software Foundation, Inc. +;; Copyright (C) 1991, 1993-2017 Free Software Foundation, Inc. ;; Maintainer: auctex-devel@gnu.org ;; Keywords: tex @@ -835,7 +835,7 @@ work analogously." (defvar LaTeX-document-style-hook nil "List of hooks to run when inserting a document environment. -To insert a hook here, you must insert it in the appropiate style file.") +To insert a hook here, you must insert it in the appropriate style file.") (defun LaTeX-env-document (&optional _ignore) "Create new LaTeX document. @@ -1530,14 +1530,14 @@ This is necessary since index entries may contain commands and stuff.") (defvar LaTeX-auto-class-regexp-list '(;; \RequirePackage[<options>]{<package>}[<date>] - ("\\\\Require\\(Package\\)\\(\\[\\([^#\\.%]*?\\)\\]\\)?\ + ("\\\\Require\\(Package\\)\\(\\[\\([^\]\\]*\\)\\]\\)?\ {\\([^#\\.\n\r]+?\\)}" (3 4 1) LaTeX-auto-style) ;; \RequirePackageWithOptions{<package>}[<date>], ("\\\\Require\\(Package\\)WithOptions\\(\\){\\([^#\\.\n\r]+?\\)}" (2 3 1) LaTeX-auto-style) ;; \LoadClass[<options>]{<package>}[<date>] - ("\\\\Load\\(Class\\)\\(\\[\\([^#\\.%]*?\\)\\]\\)?{\\([^#\\.\n\r]+?\\)}" + ("\\\\Load\\(Class\\)\\(\\[\\([^\]\\]*\\)\\]\\)?{\\([^#\\.\n\r]+?\\)}" (3 4 1) LaTeX-auto-style) ;; \LoadClassWithOptions{<package>}[<date>] ("\\\\Load\\(Class\\)WithOptions\\(\\){\\([^#\\.\n\r]+?\\)}" diff --git a/plain-tex.el b/plain-tex.el index 4960196d..9b561ac8 100644 --- a/plain-tex.el +++ b/plain-tex.el @@ -1,6 +1,6 @@ ;;; plain-tex.el --- Support for plain TeX documents. -;; Copyright (C) 2010, 2013, 2016 Free Software Foundation, Inc. +;; Copyright (C) 2010, 2013, 2016-2017 Free Software Foundation, Inc. ;; Maintainer: auctex-devel@gnu.org ;; Keywords: tex @@ -126,7 +126,7 @@ Special commands: Entering `plain-tex-mode' calls the value of `text-mode-hook', then the value of `TeX-mode-hook', and then the value -of plain-TeX-mode-hook." +of `plain-TeX-mode-hook'." (interactive) (plain-TeX-common-initialization) (setq major-mode 'plain-tex-mode) @@ -298,7 +298,7 @@ See info under AUCTeX for documentation. Special commands: \\{AmSTeX-mode-map} -Entering AmS-tex-mode calls the value of `text-mode-hook', +Entering `ams-tex-mode' calls the value of `text-mode-hook', then the value of `TeX-mode-hook', and then the value of `AmS-TeX-mode-hook'." (interactive) diff --git a/preview.el b/preview.el index abeaebb7..f9382214 100644 --- a/preview.el +++ b/preview.el @@ -1,6 +1,6 @@ ;;; preview.el --- embed preview LaTeX images in source buffer -;; Copyright (C) 2001-2006, 2010-2015 Free Software Foundation, Inc. +;; Copyright (C) 2001-2006, 2010-2015, 2017 Free Software Foundation, Inc. ;; Author: David Kastrup ;; Keywords: tex, wp, convenience @@ -738,10 +738,10 @@ SETUP may contain a parser setup function." null eq{pop{pop}bind}if def\ <</BeginPage{currentpagedevice/PageSize get dup 0 get 1 ne exch 1 get 1 ne or\ {.preview-BP %s}{pop}ifelse}bind/PageSize[1 1]>>setpagedevice\ -/preview-do{[count 3 roll save]3 1 roll dup length 0 eq\ -{pop}{setpagedevice}{ifelse .runandhide}\ +/preview-do{/.preview-ST[count 4 roll save]def dup length 0 eq\ +{pop}{setpagedevice}{ifelse exec}\ stopped{handleerror quit}if \ -aload pop restore}bind def " +.preview-ST aload pop restore}bind def " (preview-gs-color-string preview-colors))) (preview-gs-queue-empty) (preview-parse-messages (or setup #'preview-gs-dvips-process-setup)))) @@ -1090,7 +1090,7 @@ NONREL is not NIL." .locksafe} stopped pop " (mapconcat 'preview-ps-quote-filename all-files "")) preview-gs-init-string - (format "[%s(r)file]aload exch %s .runandhide aload pop " + (format " %s(r)file /.preview-ST 1 index def %s exec .preview-ST " (preview-ps-quote-filename file) (preview-gs-dsc-cvx 0 preview-gs-dsc)))))) @@ -3537,19 +3537,28 @@ internal parameters, STR may be a log to insert into the current log." ((preview-format-name (shell-quote-argument (preview-dump-file-name (file-name-nondirectory master)))) + (process-environment process-environment) (process - (TeX-run-command - "Preview-LaTeX" - (if (consp (cdr dumped-cons)) - (preview-do-replacements - command - (append preview-undump-replacements - ;; Since the command options provided in - ;; (TeX-engine-alist) are dropped, give them - ;; back. - (list (list "\\`\\([^ ]+\\)" - (TeX-command-expand "%(latex)" nil))))) - command) file))) + (progn + ;; Fix Bug#20773, Bug#27088. + ;; Make LaTeX not to insert newline in lines necessary to + ;; identify Bounding Boxes. + (setenv "max_print_line" "1000") + (TeX-run-command + "Preview-LaTeX" + (if (consp (cdr dumped-cons)) + (preview-do-replacements + command + (append preview-undump-replacements + ;; Since the command options provided in + ;; (TeX-engine-alist) are dropped, give them + ;; back. + (list (list "\\`\\([^ ]+\\)" + (TeX-command-expand "%(PDF)%(latex)" + (if TeX-current-process-region-p + #'TeX-region-file + #'TeX-master-file)))))) + command) file)))) (condition-case err (progn (when str diff --git a/prv-xemacs.el b/prv-xemacs.el index 32949d18..ae204024 100644 --- a/prv-xemacs.el +++ b/prv-xemacs.el @@ -1,6 +1,6 @@ ;;; prv-xemacs.el --- XEmacs support for preview-latex -;; Copyright (C) 2001-2006 Free Software Foundation, Inc. +;; Copyright (C) 2001-2006, 2017 Free Software Foundation, Inc. ;; Author: David Kastrup ;; Keywords: convenience, tex, wp diff --git a/style/XCharter.el b/style/XCharter.el index 5ff866d9..d1e71a94 100644 --- a/style/XCharter.el +++ b/style/XCharter.el @@ -1,6 +1,6 @@ -;;; XCharter.el --- AUCTeX style for `XCharter.sty' (v1.05) +;;; XCharter.el --- AUCTeX style for `XCharter.sty' (v1.094) -;; Copyright (C) 2014 Free Software Foundation, Inc. +;; Copyright (C) 2014, 2017 Free Software Foundation, Inc. ;; Author: Arash Esbati <ar...@gnu.org> ;; Maintainer: auctex-devel@gnu.org @@ -26,7 +26,7 @@ ;;; Commentary: -;; This file adds support for `XCharter.sty' (v1.05) from 2014/07/03. +;; This file adds support for `XCharter.sty' (v1.094) from 2017/08/08. ;; `XCharter.sty' is part of TeXLive. ;;; Code: @@ -48,21 +48,35 @@ ;; Text commands '("textsu" t) ; superior figures '("sustyle" -1) ; + '("textin" t) ; inferior figures + '("instyle" -1) ; '("textlf" t) ; lining figures '("lfstyle" -1) ; '("textosf" t) ; oldstyle figures '("textosfI" t) ; oldstyle figures alternate - '("osfstyle" -1)) ; whatever oldstyle option is in force + '("osfstyle" -1) ; whatever oldstyle option is in force + '("textnumerator" t) ; numerators + '("textnu" t) ; + '("textdenominator" t) ; denominators + '("textde" t) ; + '("textfrac" 2)) ;; Fontification (when (and (featurep 'font-latex) (eq TeX-install-font-lock 'font-latex-setup)) (font-latex-add-keywords '(("textsu" "{") + ("textin" "{") ("textlf" "{") ("textosf" "{") - ("textosfI" "{")) + ("textosfI" "{") + ("textnumerator" "{") + ("textnu" "{") + ("textdenominator" "{") + ("textde" "{") + ("textfrac" "{{")) 'type-command) (font-latex-add-keywords '(("sustyle" "") + ("instyle" "") ("lfstyle" "") ("osfstyle" "")) 'type-declaration))) @@ -70,7 +84,7 @@ (defvar LaTeX-XCharter-package-options '("lining" "lf" "oldstyle" "osf" "oldstyleI" "osfI" - "scaled" "sups") + "scaled" "sups" "scosf") "Package options for the XCharter package.") ;;; XCharter.el ends here diff --git a/style/amsthm.el b/style/amsthm.el index fee2843b..a8cd995a 100644 --- a/style/amsthm.el +++ b/style/amsthm.el @@ -135,7 +135,7 @@ make them available as new environments. Update (let ((nthm (TeX-read-string (TeX-argument-prompt nil nil "Environment")))) (LaTeX-add-amsthm-newtheorems nthm) - (LaTeX-add-environments (list nthm 'LaTeX-theorem-env-label)) + (LaTeX-add-environments (list nthm 'LaTeX-amsthm-env-label)) (format "%s" nthm)))) [ TeX-arg-environment "Numbered like" ] t [ (TeX-arg-eval progn (if (eq (save-excursion diff --git a/style/arabxetex.el b/style/arabxetex.el new file mode 100644 index 00000000..cdd8a642 --- /dev/null +++ b/style/arabxetex.el @@ -0,0 +1,113 @@ +;;; arabxetex.el --- AUCTeX style for `arabxetex.sty' (v1.2.1) + +;; Copyright (C) 2017 Free Software Foundation, Inc. + +;; Author: Arash Esbati <ar...@gnu.org> +;; Maintainer: auctex-devel@gnu.org +;; Created: 2017-08-12 +;; 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 `arabxetex.sty' (v1.2.1) from 2015/09/04. +;; `arabxetex.sty' is part of TeXLive. + +;;; Code: + +(TeX-add-style-hook + "arabxetex" + (lambda () + + ;; Run the style hooks for packages required by arabxetex: + (TeX-run-style-hooks "amsmath" "fontspec" "bidi") + + ;; We need xelatex, so check for the engine here: + (TeX-check-engine-add-engines 'xetex) + + ;; New macros & environments: + (let ((langs '("arab" + "farsi" "persian" + "urdu" + "sindhi" + "pashto" + "ottoman" "turk" + "kurdisch" + "kashmiri" + "malay" "jawi" + "uighur"))) + ;; Add \text<language>[option]{...} + (mapc #'TeX-add-symbols + (mapcar + (lambda (symbol) + (list symbol + [ TeX-arg-eval completing-read + (TeX-argument-prompt optional nil "Mode") + LaTeX-arabxetex-package-options ] + t)) + (mapcar (lambda (lang) (concat "text" lang)) langs))) + ;; + ;; Add \begin{<language>}[option] ... \end{<language>} + (mapc #'LaTeX-add-environments + (mapcar + (lambda (environment) + (list environment + #'LaTeX-env-args + [ TeX-arg-eval completing-read + (TeX-argument-prompt optional nil "Mode") + LaTeX-arabxetex-package-options ])) + langs)) + ;; + ;; Fontification + (when (and (featurep 'font-latex) + (eq TeX-install-font-lock 'font-latex-setup)) + (font-latex-add-keywords (mapcar (lambda (lang) + (list (concat "text" lang) "[{")) + langs) + 'textual))) + + ;; Other macros: + (TeX-add-symbols + '("textLR" t) + '("aemph" t) + + ;; 3.3 Transliteration + '("SetTranslitConvention" + (TeX-arg-eval completing-read + (TeX-argument-prompt optional nil "Mapping") + '("dmg" "loc"))) + '("SetTranslitStyle" "Style")) + + ;; Fontification + (when (and (featurep 'font-latex) + (eq TeX-install-font-lock 'font-latex-setup)) + (font-latex-add-keywords '(("textLR" "{")) + 'textual) + (font-latex-add-keywords '(("aemph" "{")) + 'italic-command) + (font-latex-add-keywords '(("SetTranslitConvention" "{") + ("SetTranslitStyle" "{")) + 'function))) + LaTeX-dialect) + +(defvar LaTeX-arabxetex-package-options + '("novoc" "voc" "fullvoc" "trans" "utf") + "Package options for the arabxetex package.") + +;;; arabxetex.el ends here diff --git a/style/biblatex.el b/style/biblatex.el index 66626956..4c47295e 100644 --- a/style/biblatex.el +++ b/style/biblatex.el @@ -161,6 +161,7 @@ string." (or (symbol-value files) (set files (mapcar 'list (TeX-search-files-by-type 'biberinputs 'global t nil)))) + (message "Searching for BibLaTeX files...done") (setq database (completing-read (TeX-argument-prompt optional prompt "BibLaTeX files") (append (mapcar 'list (TeX-search-files-by-type @@ -618,7 +619,8 @@ for citation keys." (progn (message "Searching for BibLaTeX styles...") (setq BibLaTeX-global-style-files - (TeX-search-files-by-type 'bbxinputs 'global t t))) + (TeX-search-files-by-type 'bbxinputs 'global t t)) + (message "Searching for BibLaTeX styles...done")) ;; ...else, use for completion only standard BibLaTeX styles (see §3.3 of ;; Biblatex reference manual). (setq BibLaTeX-global-style-files diff --git a/style/bidi.el b/style/bidi.el old mode 100755 new mode 100644 diff --git a/style/epigraph.el b/style/epigraph.el index c25b1481..1d10c6ae 100644 --- a/style/epigraph.el +++ b/style/epigraph.el @@ -1,6 +1,6 @@ -;;; epigraph.el --- AUCTeX style for `epigraph.sty' +;;; epigraph.el --- AUCTeX style for `epigraph.sty' v1.5c -;; Copyright (C) 2012 Free Software Foundation, Inc. +;; Copyright (C) 2012, 2017 Free Software Foundation, Inc. ;; Author: Mads Jensen <m...@inducks.org> ;; Maintainer: auctex-devel@gnu.org @@ -26,7 +26,7 @@ ;;; Commentary: -;; This file adds support for `epigraph.sty'. +;; This file adds support for `epigraph.sty' v1.5c from 2009/09/02. ;;; Code: @@ -34,33 +34,57 @@ "epigraph" (lambda () (TeX-add-symbols - '("epigraph" t t) - '("qitem" t t) - '("epigraphhead" [ "Distance (a number)" ] t) - '("dropchapter" TeX-arg-size) - "epigraphwidth" + ;; 2.1 The epigraph command + '("epigraph" 2) + ;; 2.2 The epigraphs environment + '("qitem" 2) + ;; 2.3 General "textflush" "epigraphflush" "sourceflush" "epigraphsize" - "epigraphrule" - "beforeepigraphskip" - "afterepigraphskip" + ;; 2.4 Epigraphs before chapter headings + '("epigraphhead" [ "Distance (a number)" ] t) + '("dropchapter" TeX-arg-length) "undodrop" - "cleartoevenpage") + ;; \cleartoevenpage takes an optional argument. Don't query for + ;; it, just insert the macro and leave the rest to the user + '("cleartoevenpage" 0)) + ;; 2.2 The epigraphs environment (LaTeX-add-environments '("epigraphs" LaTeX-env-item)) - (add-to-list 'LaTeX-item-list '("epigraphs" . LaTeX-epigraph-qitem)) - + ;; The value of these lengths can be changed with \setlength + (LaTeX-add-lengths "epigraphwidth" "epigraphrule" + "beforeepigraphskip" + "afterepigraphskip") + + ;; Append epigraphs to `LaTeX-item-list': + (add-to-list 'LaTeX-item-list + '("epigraphs" . LaTeX-epigraph-qitem) t) + + ;; Append qitem to `LaTeX-item-regexp': + (unless (string-match "qitem" LaTeX-item-regexp) + (set (make-local-variable 'LaTeX-item-regexp) + (concat + LaTeX-item-regexp + "\\|" + "qitem\\b")) + (LaTeX-set-paragraph-start)) + + ;; Fontification: (when (and (featurep 'font-latex) (eq TeX-install-font-lock 'font-latex-setup)) - (font-latex-add-keywords '(("epigraph" "{{") - ("qitem" "{{") - ("dropchapter" "{") - ("epigraphhead" "{")) 'function) - (font-latex-add-keywords '("cleartoevenpage") 'warning))) + (font-latex-add-keywords '(("epigraph" "{{") + ("qitem" "{{") + ("epigraphhead" "[{")) + 'textual) + (font-latex-add-keywords '(("dropchapter" "{") + ("undodrop" "")) + 'variable) + (font-latex-add-keywords '("cleartoevenpage") + 'warning))) LaTeX-dialect) (defvar LaTeX-epigraph-package-options nil diff --git a/style/fontspec.el b/style/fontspec.el index 58f4e485..9446b722 100644 --- a/style/fontspec.el +++ b/style/fontspec.el @@ -189,7 +189,8 @@ to retrieve the list of fonts." (re-search-forward "^\\([^\n\r\t]*\\)\t\\([^\n\r\t]*\\)\t.*$" nil t) (add-to-list 'LaTeX-fontspec-font-list (match-string-no-properties 1)) (add-to-list 'LaTeX-fontspec-font-list - (match-string-no-properties 2)))))) + (match-string-no-properties 2)))) + (message "Searching for fonts...done"))) (TeX-argument-insert (completing-read (TeX-argument-prompt optional prompt "Font name") diff --git a/style/graphicx.el b/style/graphicx.el index 4fcdc174..6ba58e4d 100644 --- a/style/graphicx.el +++ b/style/graphicx.el @@ -23,7 +23,7 @@ ;;; Commentary: -;; This package supports the includegraphcics macro in graphicx style. +;; This package supports the includegraphics macro in graphicx style. ;; Acknowledgements ;; Dr. Thomas Baumann <thomas.baum...@ch.tum.de> @@ -110,22 +110,22 @@ key-val's." (let* ((temp (copy-sequence LaTeX-includegraphics-extensions)) (LaTeX-includegraphics-extensions (cond (;; 'default TeX-engine: - (if (and (eq TeX-engine 'default) - ;; we want to produce a pdf - (if TeX-PDF-mode - ;; Return t if default compiler produces PDF, - ;; nil for "Dvips" or "Dvipdfmx" - (not (TeX-PDF-from-DVI)) - ;; t if pdftex is used in dvi-mode - TeX-DVI-via-PDFTeX)) + (eq TeX-engine 'default) + (if ;; we want to produce a pdf + (if TeX-PDF-mode + ;; Return t if default compiler produces PDF, + ;; nil for "Dvips" or "Dvipdfmx" + (not (TeX-PDF-from-DVI)) + ;; t if pdftex is used in dvi-mode + TeX-DVI-via-PDFTeX) ;; We're using pdflatex in pdf-mode (delete-dups (append LaTeX-includegraphics-pdftex-extensions - LaTeX-includegraphics-extensions)) + temp)) ;; We're generating a .dvi to process with dvips or dvipdfmx (progn (dolist (x '("jpe?g" "pdf" "png")) - (setq temp (remove x temp))) + (setq temp (delete x temp))) (delete-dups (append LaTeX-includegraphics-dvips-extensions temp))))) @@ -134,20 +134,20 @@ key-val's." (if TeX-PDF-mode (delete-dups (append LaTeX-includegraphics-pdftex-extensions - LaTeX-includegraphics-extensions)) + temp)) (progn (dolist (x '("jpe?g" "pdf" "png")) - (setq temp (remove x temp))) + (setq temp (delete x temp))) (delete-dups (append LaTeX-includegraphics-dvips-extensions temp))))) ;; Running xetex in any mode: ((eq TeX-engine 'xetex) (delete-dups (append LaTeX-includegraphics-xetex-extensions - LaTeX-includegraphics-extensions))) + temp))) ;; For anything else (t - LaTeX-includegraphics-extensions)))) + temp)))) (concat "\\." (mapconcat 'identity (or list LaTeX-includegraphics-extensions) @@ -175,7 +175,7 @@ doesn't works with Emacs 21.3 or XEmacs. See (file-relative-name (read-file-name "Image file: " nil nil nil nil - ;; FIXME: Emacs 21.3 and XEmacs 21.4.15 dont have PREDICATE as the sixth + ;; FIXME: Emacs 21.3 and XEmacs 21.4.15 don't have PREDICATE as the sixth ;; argument (Emacs 21.3: five args; XEmacs 21.4.15: sixth is HISTORY). (lambda (fname) (or (file-directory-p fname) diff --git a/style/longtable.el b/style/longtable.el index aeb275e5..b57833bf 100644 --- a/style/longtable.el +++ b/style/longtable.el @@ -1,6 +1,6 @@ ;;; longtable.el --- AUCTeX style for `longtable.sty'. -;; Copyright (C) 2013--2016 Free Software Foundation, Inc. +;; Copyright (C) 2013--2017 Free Software Foundation, Inc. ;; Maintainer: auctex-devel@gnu.org ;; Author: Mosè Giordano <m...@gnu.org> @@ -46,44 +46,47 @@ insert line break macro." (LaTeX-insert-ampersands LaTeX-longtable-skipping-regexp #'LaTeX-array-count-columns)) +(defun LaTeX-env-longtable (environment) + "Insert a longtable-like ENVIRONMENT with caption and label." + (let* ((pos (completing-read (TeX-argument-prompt t nil "Position") + '(("l") ("r") ("c")))) + (fmt (TeX-read-string "Format: " LaTeX-default-format)) + (caption (TeX-read-string "Caption: ")) + (short-caption (when (>= (length caption) LaTeX-short-caption-prompt-length) + (TeX-read-string "(Optional) Short caption: ")))) + (setq LaTeX-default-format fmt) + (LaTeX-insert-environment environment + (concat + (unless (zerop (length pos)) + (concat LaTeX-optop pos LaTeX-optcl)) + (concat TeX-grop fmt TeX-grcl))) + ;; top caption -- do nothing if user skips caption + (unless (zerop (length caption)) + ;; insert `\caption[short-caption]{caption': + (insert TeX-esc "caption") + (when (and short-caption (not (string= short-caption ""))) + (insert LaTeX-optop short-caption LaTeX-optcl)) + (insert TeX-grop caption) + ;; ask for a label and insert it + (LaTeX-label environment 'environment) + ;; the longtable `\caption' is equivalent to a + ;; `\multicolumn', so it needs a `\\' at the + ;; end of the line. Prior to that, add } to + ;; close `\caption{' + (insert TeX-grcl "\\\\") + ;; fill the caption + (LaTeX-fill-paragraph) + ;; Insert a new line and indent + (LaTeX-newline) + (indent-according-to-mode)) + ;; Insert suitable number of &'s, suppress line break + (LaTeX-item-longtable t))) + (TeX-add-style-hook "longtable" (lambda () (LaTeX-add-environments - '("longtable" (lambda (environment) - (let* ((pos (completing-read (TeX-argument-prompt t nil "Position") - '(("l") ("r") ("c")))) - (fmt (TeX-read-string "Format: " LaTeX-default-format)) - (caption (TeX-read-string "Caption: ")) - (short-caption (when (>= (length caption) LaTeX-short-caption-prompt-length) - (TeX-read-string "(Optional) Short caption: ")))) - (setq LaTeX-default-format fmt) - (LaTeX-insert-environment environment - (concat - (unless (zerop (length pos)) - (concat LaTeX-optop pos LaTeX-optcl)) - (concat TeX-grop fmt TeX-grcl))) - ;; top caption -- do nothing if user skips caption - (unless (zerop (length caption)) - ;; insert `\caption[short-caption]{caption': - (insert TeX-esc "caption") - (when (and short-caption (not (string= short-caption ""))) - (insert LaTeX-optop short-caption LaTeX-optcl)) - (insert TeX-grop caption) - ;; ask for a label and insert it - (LaTeX-label environment 'environment) - ;; the longtable `\caption' is equivalent to a - ;; `\multicolumn', so it needs a `\\' at the - ;; end of the line. Prior to that, add } to - ;; close `\caption{' - (insert TeX-grcl "\\\\") - ;; fill the caption - (LaTeX-fill-paragraph) - ;; Insert a new line and indent - (LaTeX-newline) - (indent-according-to-mode)) - ;; Insert suitable number of &'s, suppress line break - (LaTeX-item-longtable t))))) + '("longtable" LaTeX-env-longtable)) (TeX-add-symbols ;; Commands to end table rows diff --git a/style/minted.el b/style/minted.el index 3ae3b480..4e4ccd28 100644 --- a/style/minted.el +++ b/style/minted.el @@ -1,4 +1,4 @@ -;;; minted.el --- AUCTeX style for `minted.sty' (v2.4.1) +;;; minted.el --- AUCTeX style for `minted.sty' (v2.5) ;; Copyright (C) 2014-2017 Free Software Foundation, Inc. @@ -26,7 +26,7 @@ ;;; Commentary: -;; This file adds support for `minted.sty' (v2.4.1) from 2016/10/31. +;; This file adds support for `minted.sty' (v2.5) from 2017/07/19. ;;; Code: diff --git a/style/relsize.el b/style/relsize.el index ceaabf56..0a47b01a 100644 --- a/style/relsize.el +++ b/style/relsize.el @@ -38,8 +38,8 @@ ;; Declarations and commands '("relsize" "Steps" ) '("relscale" "Scale factor" ) - '("larger" [ "Steps (default: 1)" ] -1) - '("smaller" [ "Steps (default: 1)" ] -1) + '("larger" [ "Steps (default 1)" ] -1) + '("smaller" [ "Steps (default 1)" ] -1) '("textlarger" [ "Steps" ] t) '("textsmaller" [ "Steps" ] t) '("textscale" "Scale factor" t) diff --git a/style/xltabular.el b/style/xltabular.el new file mode 100644 index 00000000..e78b4e92 --- /dev/null +++ b/style/xltabular.el @@ -0,0 +1,64 @@ +;;; xltabular.el --- AUCTeX style for `xltabular.sty' (v0.05) + +;; Copyright (C) 2017 Free Software Foundation, Inc. + +;; Author: Arash Esbati <ar...@gnu.org> +;; Maintainer: auctex-devel@gnu.org +;; Created: 2017-11-03 +;; 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 `xltabular.sty' (v0.05) from 2017/10/26. +;; `xltabular.sty' is part of TeXLive. + +(TeX-add-style-hook + "xltabular" + (lambda () + ;; ltablex loads both tabularx and longtable + (TeX-run-style-hooks "ltablex") + + ;; `LaTeX-env-longtable' is provided by `longtable.el': + (LaTeX-add-environments + '("xltabular" LaTeX-env-longtable)) + + ;; Use the enhanced table formatting. Append to + ;; `LaTeX-indent-environment-list' in order not to override custom settings. + (add-to-list (make-variable-buffer-local 'LaTeX-indent-environment-list) + '("xltabular" LaTeX-indent-tabular) t) + + ;; Append xltabular to `LaTeX-label-alist', in order not to + ;; override possible custome values. + (add-to-list 'LaTeX-label-alist '("xltabular" . LaTeX-table-label) t) + + ;; Append xltabular to `LaTeX-item-list' with `LaTeX-item-longtable' + (add-to-list 'LaTeX-item-list '("xltabular" . LaTeX-item-longtable) t) + + ;; Tell RefTeX -- This is the same entry as for "longtable" in + ;; `reftex-label-alist-builtin': + (when (fboundp 'reftex-add-label-environments) + (reftex-add-label-environments + '(("xltabular" ?t nil nil caption))))) + LaTeX-dialect) + +(defvar LaTeX-xltabular-package-options nil + "Package options for the xltabular package.") + +;;; xltabular.el ends here diff --git a/tests/japanese/parse-timing-test.tex b/tests/japanese/parse-timing-test.tex new file mode 100644 index 00000000..c995cf54 --- /dev/null +++ b/tests/japanese/parse-timing-test.tex @@ -0,0 +1,2 @@ +\documentclass{jarticle} +\usepackage{amsmath} diff --git a/tests/japanese/parse-timing.el b/tests/japanese/parse-timing.el new file mode 100644 index 00000000..c9f52434 --- /dev/null +++ b/tests/japanese/parse-timing.el @@ -0,0 +1,63 @@ +;;; parse-timing.el --- tests for parse timing + +;; Copyright (C) 2017 Free Software Foundation, Inc. + +;; This file is part of AUCTeX. + +;; AUCTeX is free software; you can redistribute it and/or modify it +;; under the terms of the GNU General Public License as published by +;; the Free Software Foundation; either version 3, or (at your option) +;; any later version. + +;; AUCTeX is distributed in the hope that it will be useful, but +;; WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;; General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with AUCTeX; see the file COPYING. If not, write to the Free +;; Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA +;; 02110-1301, USA. + +;;; Commentary: +;; In AUCTeX, style hooks must not be executed too early. In +;; particular, they should not be called within the major mode hook +;; because the required settings are sometimes not ready at that +;; timing. A difficult point is that many AUCTeX functions implicitly +;; call `TeX-update-style', which eventually calls style hooks. Thus +;; a complicated hook sometimes triggers style hooks unintentionally. +;; Such cases suits for detection via regression tests. + +;;; Code: + +(require 'ert) +(require 'tex-jp) + +(defun AUCTeX-set-ert-path (&rest sym-val) + "Set first element of SYM-VAL to the next one, and so on. + +The value is the path to the test file, make sure it is expanded +in the right directory even when the ERT test from the command +line and from another directory." + (while sym-val + (set (pop sym-val) + (expand-file-name (pop sym-val) + (when load-file-name + (file-name-directory load-file-name)))))) +(AUCTeX-set-ert-path + 'parse-timing + "parse-timing-test.tex") + +(ert-deftest japanese-TeX-style-hook-timing () + "Test style hooks are not called too early." + (let ((TeX-parse-self t) + (TeX-master t) + (LaTeX-mode-hook '(japanese-latex-mode-initialization + turn-on-reftex))) + (find-file parse-timing) + (should (memq 'AMSTeX + (get reftex-docstruct-symbol + 'reftex-label-alist-style))) + (kill-buffer))) + +;;; parse-timing.el ends here diff --git a/tests/latex/latex-test.el b/tests/latex/latex-test.el index 05ca2c83..a53d48e7 100644 --- a/tests/latex/latex-test.el +++ b/tests/latex/latex-test.el @@ -165,4 +165,20 @@ last extension is stripped." (LaTeX-bibliography-list)) '(("../foo-1.bar_2.qux3"))))) +(ert-deftest LaTeX-auto-class-regexp () + "Check parsing optional argument with comment correctly. + +Test against RequirePackage." + (with-temp-buffer + (insert "\\RequirePackage[ +backend=biber % here is a comment +]{biblatex} +") + (latex-mode) + (let ((TeX-parse-self t)) + (TeX-update-style t)) + (should (member "biblatex" (TeX-style-list))) + (should (LaTeX-provided-package-options-member + "biblatex" "backend=biber")))) + ;;; latex-test.el ends here diff --git a/tests/tex/path-expansion.el b/tests/tex/path-expansion.el new file mode 100644 index 00000000..149cbab9 --- /dev/null +++ b/tests/tex/path-expansion.el @@ -0,0 +1,59 @@ +;;; path-expansion.el --- tests for path expansion + +;; Copyright (C) 2017 Free Software Foundation, Inc. + +;; This file is part of AUCTeX. + +;; AUCTeX is free software; you can redistribute it and/or modify it +;; under the terms of the GNU General Public License as published by +;; the Free Software Foundation; either version 3, or (at your option) +;; any later version. + +;; AUCTeX is distributed in the hope that it will be useful, but +;; WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;; General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with AUCTeX; see the file COPYING. If not, write to the Free +;; Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA +;; 02110-1301, USA. + +;;; Code: + +(require 'ert) +(require 'tex) + +(ert-deftest TeX-variable-truncation () + "Check whether list variable is not truncated as side effect." + (let ((var '("str1" "str2")) + (TeX-kpathsea-path-delimiter nil) + (TeX-search-files-type-alist + '((abc "${dummy}" ("str2" var) TeX-file-extensions)))) + (TeX-search-files-by-type 'abc 'global) + (should (equal var '("str1" "str2"))))) + +(ert-deftest TeX-kpathsea-delimiter-w32 () + "Check whether `TeX-kpathsea-path-delimiter' is set to \";\" on w32 platform." + ;; This test is meaningful only on w32 platform. + (skip-unless (eq system-type 'windows-nt)) + ;; Provide `TeX-tree-expand' with output which doesn't begin with + ;; dos drive letter. + (let ((TeX-kpathsea-path-delimiter + (eval (car (get 'TeX-kpathsea-path-delimiter 'standard-value))))) + (TeX-tree-expand '(".") nil) + (should (equal TeX-kpathsea-path-delimiter ";"))) + ;; Provide `TeX-search-files-kpathsea' with output of only one + ;; component (thus without a separator ";".) + (let ((TeX-kpathsea-path-delimiter + (eval (car (get 'TeX-kpathsea-path-delimiter 'standard-value)))) + ;; Let's hope that no other files in the temp directory have + ;; such a bizarre extension. + (temp-file (make-temp-file "TeX-path-expansion" nil ".xxyyzz"))) + (unwind-protect + (TeX-search-files-kpathsea (file-name-directory temp-file) + '("xxyyzz") nil nil nil) + (delete-file temp-file)) + (should (equal TeX-kpathsea-path-delimiter ";")))) + +;;; command-expansion.el ends here diff --git a/tests/tex/utility.el b/tests/tex/utility.el new file mode 100644 index 00000000..843bd57b --- /dev/null +++ b/tests/tex/utility.el @@ -0,0 +1,32 @@ +;;; utility.el --- tests for AUCTeX utility functions + +;; Copyright (C) 2017 Free Software Foundation, Inc. + +;; This file is part of AUCTeX. + +;; AUCTeX is free software; you can redistribute it and/or modify it +;; under the terms of the GNU General Public License as published by +;; the Free Software Foundation; either version 3, or (at your option) +;; any later version. + +;; AUCTeX is distributed in the hope that it will be useful, but +;; WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;; General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with AUCTeX; see the file COPYING. If not, write to the Free +;; Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA +;; 02110-1301, USA. + +;;; Code: + +(require 'ert) +(require 'tex) + +(ert-deftest TeX-infinite-loop () + "Check whether functions don't fall into infinite loop." + (should (TeX-delete-duplicate-strings '("nil"))) + (should (TeX-delete-dups-by-car '(("nil" . 1))))) + +;;; utility.el ends here diff --git a/tex-bar.el b/tex-bar.el index 59b91588..0124f55c 100644 --- a/tex-bar.el +++ b/tex-bar.el @@ -1,6 +1,6 @@ ;;; tex-bar.el --- toolbar icons on AUCTeX in GNU emacs and XEmacs -;; Copyright (C) 2004-2008, 2012-2014 Free Software Foundation, Inc. +;; Copyright (C) 2004-2008, 2012-2014, 2016 Free Software Foundation, Inc. ;; This program is free software; you can redistribute it and/or ;; modify it under the terms of the GNU General Public License as diff --git a/tex-buf.el b/tex-buf.el index f64fa2d6..f458651c 100644 --- a/tex-buf.el +++ b/tex-buf.el @@ -1,6 +1,6 @@ ;;; tex-buf.el --- External commands for AUCTeX. -;; Copyright (C) 1991-1999, 2001-2016 Free Software Foundation, Inc. +;; Copyright (C) 1991-1999, 2001-2017 Free Software Foundation, Inc. ;; Maintainer: auctex-devel@gnu.org ;; Keywords: tex, wp diff --git a/tex-fold.el b/tex-fold.el index 6188147f..356c2687 100644 --- a/tex-fold.el +++ b/tex-fold.el @@ -28,7 +28,7 @@ ;;; Commentary: ;; This file provides support for hiding and unhiding TeX, LaTeX, -;; ContTeXt, Texinfo and similar macros and environments inside of +;; ConTeXt, Texinfo and similar macros and environments inside of ;; AUCTeX. ;; ;; Caveats: diff --git a/tex-info.el b/tex-info.el index 7eb7970c..4a96e11c 100644 --- a/tex-info.el +++ b/tex-info.el @@ -1,7 +1,7 @@ ;;; tex-info.el --- Support for editing Texinfo source. -;; Copyright (C) 1993, 1994, 1997, 2000, 2001, 2004, 2005, 2006, 2011-2015 -;; Free Software Foundation, Inc. +;; Copyright (C) 1993, 1994, 1997, 2000, 2001, 2004, 2005, 2006, +;; 2011-2015, 2017 Free Software Foundation, Inc. ;; Maintainer: auctex-devel@gnu.org ;; Keywords: tex @@ -403,10 +403,38 @@ If DEFINITION is non-nil, then chosen node name is a node name to be added to the list of defined node names. Current implementation ignored DEFINITION as the full document is scanned for node names at each invocation." - (let ((node-name (completing-read (TeX-argument-prompt optional prompt "Key") + (let ((node-name (completing-read (TeX-argument-prompt optional prompt "Node") (Texinfo-make-node-list)))) (insert "{" (Texinfo-nodename-escape node-name) "}" ))) +(defun Texinfo-arg-lrc (optional &rest args) + (let ((l (read-from-minibuffer "Enter left part: ")) + (c (read-from-minibuffer "Enter center part: ")) + (r (read-from-minibuffer "Enter right part: "))) + (insert " " l " @| " c " @| " r))) + +(defun Texinfo-arg-next-line (optional &rest args) + "Go to the beginning of next line if we are at the end of line. Otherwise insert an end-of-line." + (if (eolp) (forward-line) (insert "\n"))) + +(defun Texinfo-arg-on|off (optional &optional prompt style) + "Prompt for a boolean input. +OPTIONAL is ignored. +Use PROMPT as the prompt string. +STYLE may be one of `:on|off' or `:true|false', if omitted `:on|off' +is assumed by default." +(let ((collection (cdr (assq style + '((nil . #1=("on" "off")) + (:on|off . #1#) + (:true|false "true" "false")))))) + (insert (if (y-or-n-p (TeX-argument-prompt optional prompt (concat (car collection) ", not " (cadr collection)))) + (car collection) + (cadr collection))))) + +(defun Texinfo-arg-choice (optional &optional prompt collection) + (insert (completing-read (TeX-argument-prompt optional prompt "Key") + collection))) + ;; Silence the byte-compiler from warnings for variables and functions declared ;; in reftex. (defvar reftex-section-levels-all) @@ -682,12 +710,14 @@ value of `Texinfo-mode-hook'." (TeX-add-symbols '("acronym" "Acronym") + '("allowcodebreaks" (TeX-arg-literal " ") (Texinfo-arg-on|off nil :true|false) (Texinfo-arg-next-line)) '("appendix" (TeX-arg-literal " ") (TeX-arg-free "Title")) '("appendixsec" (TeX-arg-literal " ") (TeX-arg-free "Title")) '("appendixsection" (TeX-arg-literal " ") (TeX-arg-free "Title")) '("appendixsubsec" (TeX-arg-literal " ") (TeX-arg-free "Title")) '("appendixsubsubsec" (TeX-arg-literal " ") (TeX-arg-free "Title")) '("asis") + '("atchar" nil) '("author" (TeX-arg-literal " ") (TeX-arg-free "Author")) '("b" "Text") '("bullet") @@ -704,6 +734,8 @@ value of `Texinfo-mode-hook'." '("cite" "Reference") '("clear" (TeX-arg-literal " ") (TeX-arg-free "Flag")) '("code" "Sample code") + '("codequotebacktick" (TeX-arg-literal " ") (Texinfo-arg-on|off) (Texinfo-arg-next-line)) + '("codequoteundirected" (TeX-arg-literal " ") (Texinfo-arg-on|off) (Texinfo-arg-next-line)) '("command" "Command") '("comment" (TeX-arg-literal " ") (TeX-arg-free "Comment")) '("contents") @@ -712,15 +744,17 @@ value of `Texinfo-mode-hook'." '("defindex" (TeX-arg-literal " ") (TeX-arg-free "Index name")) '("dfn" "Term") '("dmn" "Dimension") + '("documentlanguage" (TeX-arg-literal " ") (Texinfo-arg-choice "Language" ("ca" "cs" "de" "en" "es" "fr" "hu" "is" "it" "ja" "nb" "nl" "nn" "pl" "pt" "ru" "sr" "tr" "uk")) (Texinfo-arg-next-line)) + '("documentencoding" (TeX-arg-literal " ") (Texinfo-arg-choice "Encoding" ("US-ASCII" "UTF-8" "ISO-8859-1" "ISO-8859-15" "ISO-8859-2" "koi8-r" "koi8-u")) (Texinfo-arg-next-line)) '("dots" nil) '("emph" "Text") '("email" "Email address") '("equiv" nil) '("error") - '("evenfooting" Texinfo-lrc-argument-hook) - '("evenheading" Texinfo-lrc-argument-hook) - '("everyfooting" Texinfo-lrc-argument-hook) - '("everyheading" Texinfo-lrc-argument-hook) + '("evenfooting" Texinfo-arg-lrc) + '("evenheading" Texinfo-arg-lrc) + '("everyfooting" Texinfo-arg-lrc) + '("everyheading" Texinfo-arg-lrc) '("exdent" (TeX-arg-literal " ") (TeX-arg-free "Line of text")) '("expansion" nil) '("file" "Filename") @@ -744,6 +778,7 @@ value of `Texinfo-mode-hook'." '("kbd" "Keyboard characters") '("key" "Key name") '("kindex" (TeX-arg-literal " ") (TeX-arg-free "Entry")) + '("LaTeX" nil) '("lowersections" 0) '("majorheading" (TeX-arg-literal " ") (TeX-arg-free "Title")) '("menu") @@ -754,8 +789,8 @@ value of `Texinfo-mode-hook'." (TeX-arg-literal ", ") (TeX-arg-free "Previous") (TeX-arg-literal ", ") (TeX-arg-free "Up")) '("noindent") - '("oddfooting" Texinfo-lrc-argument-hook) - '("oddheading" Texinfo-lrc-argument-hook) + '("oddfooting" Texinfo-arg-lrc) + '("oddheading" Texinfo-arg-lrc) '("page") '("paragraphindent" (TeX-arg-literal " ") (TeX-arg-free "Indent")) '("pindex" "Entry") @@ -774,8 +809,7 @@ value of `Texinfo-mode-hook'." '("sc" "Text") '("section" (TeX-arg-literal " ") (TeX-arg-free "Title")) '("set" (TeX-arg-literal " ") (TeX-arg-free "Flag")) - ;; XXX: Would be nice with completion. - '("setchapternewpage" (TeX-arg-literal " ") (TeX-arg-free "On off odd")) + '("setchapternewpage" (TeX-arg-literal " ") (Texinfo-arg-choice "On off odd" ("on" "off" "odd")) (Texinfo-arg-next-line)) '("setfilename" (TeX-arg-literal " ") (TeX-arg-free "Info file name")) '("settitle" (TeX-arg-literal " ") (TeX-arg-free "Title")) '("shortcontents") @@ -809,6 +843,7 @@ value of `Texinfo-mode-hook'." '("unnumberedsec" (TeX-arg-literal " ") (TeX-arg-free "Title")) '("unnumberedsubsec" (TeX-arg-literal " ") (TeX-arg-free "Title")) '("unnumberedsubsubsec" (TeX-arg-literal " ") (TeX-arg-free "Title")) + '("url" "Link") '("value" "Flag") '("var" "Metasyntactic variable") '("vindex" (TeX-arg-literal " ") (TeX-arg-free "Entry")) diff --git a/tex-jp.el b/tex-jp.el index 09909ba0..81125ae8 100644 --- a/tex-jp.el +++ b/tex-jp.el @@ -526,17 +526,16 @@ Set `japanese-TeX-mode' to t, and enter `TeX-plain-tex-mode'." (defun japanese-plain-tex-mode-initialization () "Japanese plain-TeX specific initializations." (when japanese-TeX-mode -; (setq TeX-command-default japanese-TeX-command-default) (TeX-engine-set japanese-TeX-engine-default) ;; For the intent of the following lines, see the comments below ;; in `japanese-latex-mode-initialization'. (when enable-local-variables (setq major-mode 'japanese-plain-tex-mode) - (add-hook 'hack-local-variables-hook 'japanese-TeX-reset-mode-name + (add-hook 'hack-local-variables-hook #'japanese-TeX-reset-mode-name nil t)))) -(add-hook 'plain-TeX-mode-hook 'japanese-plain-tex-mode-initialization) +(add-hook 'plain-TeX-mode-hook #'japanese-plain-tex-mode-initialization) ;;;###autoload (defun japanese-latex-mode () @@ -549,21 +548,16 @@ Set `japanese-TeX-mode' to t, and enter `TeX-latex-mode'." (defun japanese-latex-mode-initialization () "Japanese LaTeX specific initializations." (when japanese-TeX-mode -; (setq TeX-command-default japanese-LaTeX-command-default) - (TeX-engine-set - (cond - ((TeX-match-style "\\`u[jt]\\(article\\|report\\|book\\)\\'") - 'uptex) - ((TeX-match-style "\\`[jt]s?\\(article\\|report\\|book\\)\\'") - (if (LaTeX-match-class-option "\\`uplatex\\'") - 'uptex 'ptex)) - ((TeX-match-style "\\`j-\\(article\\|report\\|book\\)\\'") - 'jtex) - (t japanese-TeX-engine-default))) + ;; `TeX-match-style' $B$r;H$&$N$O(B `TeX-update-style' $B$N8e$KCY$i$;$k!#(B + ;; $B$3$NCJ3,$G;H$&$H!"$=$NCf$G8F$V(B `TeX-style-list' $B$NCf$G(B + ;; `TeX-update-style' $B$,8F$P$l$F$7$^$$!"(Blocal variable $BEy$N=`Hw$,(B + ;; $B@0$C$F$J$$CJ3,$G(B style hook $B$,<B9T$5$l$FITE,$J7k2L$K$J$k$3$H$,(B + ;; $B$"$k!#$^$?!"(B`TeX-update-style' $B$O8e$+$i(B `find-file-hook' $BCf$G$b(B + ;; $B$&0lEY8F$P$l$k$N$G!"(B`TeX-parse-self' $B$,(B t $B$@$H(B parse $B=hM}$bL5BL(B + ;; $B$K(B 2 $B2s9T$o$l$F$7$^$&!#(B + (add-hook 'TeX-update-style-hook + #'japanese-LaTeX-guess-engine nil t) (setq LaTeX-default-style japanese-LaTeX-default-style) -; (setq TeX-command-BibTeX -; (if (and (eq TeX-engine 'ptex) (executable-find "pbibtex")) -; "pBibTeX" "jBibTeX")) (when (and (fboundp 'font-latex-add-keywords) (eq TeX-install-font-lock 'font-latex-setup)) @@ -590,10 +584,10 @@ Set `japanese-TeX-mode' to t, and enter `TeX-latex-mode'." ;; `hack-local-variables' is done. (when enable-local-variables (setq major-mode 'japanese-latex-mode) - (add-hook 'hack-local-variables-hook 'japanese-TeX-reset-mode-name + (add-hook 'hack-local-variables-hook #'japanese-TeX-reset-mode-name nil t)))) -(add-hook 'LaTeX-mode-hook 'japanese-latex-mode-initialization) +(add-hook 'LaTeX-mode-hook #'japanese-latex-mode-initialization) ;; This function is useful only within `hack-local-variables-hook'. (defun japanese-TeX-reset-mode-name () @@ -601,7 +595,7 @@ Set `japanese-TeX-mode' to t, and enter `TeX-latex-mode'." (setq major-mode 'latex-mode)) ((eq major-mode 'japanese-plain-tex-mode) (setq major-mode 'plain-tex-mode))) - (remove-hook 'hack-local-variables-hook 'japanese-TeX-reset-mode-name t)) + (remove-hook 'hack-local-variables-hook #'japanese-TeX-reset-mode-name t)) ;; Make `hack-dir-local-variables' to regard `latex-mode' as parent ;; of `japanese-latex-mode', and `plain-tex-mode' as parent of @@ -609,6 +603,25 @@ Set `japanese-TeX-mode' to t, and enter `TeX-latex-mode'." (put 'japanese-plain-tex-mode 'derived-mode-parent 'plain-tex-mode) (put 'japanese-latex-mode 'derived-mode-parent 'latex-mode) +(defun japanese-LaTeX-guess-engine () + "Guess Japanese TeX engine and set it to `TeX-engine'. +Document class and its option is considered in the guess. Do not +overwrite the value already set locally." + ;; `TeX-engine' may be set by the file local variable or by the menu + ;; Command->TeXing Options manually. Don't override the user + ;; preference set in such ways. + (unless (local-variable-p 'TeX-engine (current-buffer)) + (TeX-engine-set + (cond + ((TeX-match-style "\\`u[jt]\\(?:article\\|report\\|book\\)\\'") + 'uptex) + ((TeX-match-style "\\`[jt]s?\\(?:article\\|report\\|book\\)\\'") + (if (LaTeX-match-class-option "\\`uplatex\\'") + 'uptex 'ptex)) + ((TeX-match-style "\\`j-\\(?:article\\|report\\|book\\)\\'") + 'jtex) + (t japanese-TeX-engine-default))))) + ;;; Support for various self-insert-command (fset 'japanese-TeX-self-insert-command @@ -627,7 +640,7 @@ Set `japanese-TeX-mode' to t, and enter `TeX-latex-mode'." (expand-abbrev) (if (TeX-looking-at-backward "\\\\/\\(}+\\)" 50) (replace-match "\\1" t)) - (call-interactively 'japanese-TeX-self-insert-command)) + (call-interactively #'japanese-TeX-self-insert-command)) ;;; Error Messages diff --git a/tex-site.el.in b/tex-site.el.in index 7ceb64ef..ecbf1134 100644 --- a/tex-site.el.in +++ b/tex-site.el.in @@ -1,6 +1,6 @@ ;;; tex-site.el - Site specific variables. Don't edit. -;; Copyright (C) 2005, 2013, 2016 Free Software Foundation, Inc. +;; Copyright (C) 2005, 2013, 2016-2017 Free Software Foundation, Inc. ;; ;; completely rewritten. diff --git a/tex-style.el b/tex-style.el index 223c3647..b523d8c0 100644 --- a/tex-style.el +++ b/tex-style.el @@ -1,6 +1,6 @@ ;;; tex-style.el --- Customizable variables for AUCTeX style files -;; Copyright (C) 2005, 2007, 2009, 2012-2015 +;; Copyright (C) 2005, 2007, 2009, 2012-2017 ;; Free Software Foundation, Inc. ;; Author: Reiner Steib <reiner.st...@gmx.de> diff --git a/tex.el b/tex.el index 972110b3..8eab9bc7 100644 --- a/tex.el +++ b/tex.el @@ -1,6 +1,6 @@ ;;; tex.el --- Support for TeX documents. -;; Copyright (C) 1985-1987, 1991, 1993-2016 Free Software Foundation, Inc. +;; Copyright (C) 1985-1987, 1991, 1993-2017 Free Software Foundation, Inc. ;; Maintainer: auctex-devel@gnu.org ;; Keywords: tex @@ -914,12 +914,11 @@ overlays." "Return a list of all elements in ALIST, but each car only once. Elements of KEEP-LIST are not removed even if duplicate." ;; Copy of `reftex-uniquify-by-car' (written by David Kastrup). - (setq keep-list (sort (copy-sequence keep-list) #'string<)) + (setq keep-list (TeX-sort-strings keep-list)) (setq alist (sort (copy-sequence alist) - (lambda (a b) - (string< (car a) (car b))))) + #'TeX-car-string-lessp)) (let ((new alist) elt) - (while new + (while (cdr new) (setq elt (caar new)) (while (and keep-list (string< (car keep-list) elt)) (setq keep-list (cdr keep-list))) @@ -933,7 +932,7 @@ Elements of KEEP-LIST are not removed even if duplicate." "Return a list of all strings in LIST, but each only once." (setq list (TeX-sort-strings list)) (let ((new list) elt) - (while new + (while (cdr new) (setq elt (car new)) (while (string= elt (cadr new)) (setcdr new (cddr new))) @@ -944,6 +943,11 @@ Elements of KEEP-LIST are not removed even if duplicate." "Return sorted list of all strings in LIST." (sort (copy-sequence list) #'string<)) +(defun TeX-car-string-lessp (s1 s2) + "Compare the cars of S1 and S2 in lexicographic order. +Return t if first is less than second in lexicographic order." + (string-lessp (car s1) (car s2))) + ;;; Buffer (defgroup TeX-output nil @@ -1301,6 +1305,15 @@ entry in `TeX-view-program-list-builtin'." (pop-to-buffer (or (find-buffer-visiting pdf) (find-file-noselect pdf)))))) +(defcustom TeX-view-evince-keep-focus nil + "Whether Emacs retains the focus when viewing PDF files with Evince. + +When calling `TeX-evince-sync-view', Evince normally captures the +focus. If this option is set to non-nil, Emacs will retain the +focus." + :group 'TeX-view + :type 'boolean) + (defvar url-unreserved-chars) (defun TeX-evince-sync-view-1 (de app) @@ -1340,7 +1353,14 @@ viewer." ;; line. What is the right number to specify here? ;; number of letters? bytes in UTF8? or other? :int32 (1+ (current-column))) - :uint32 0)) + :uint32 0) + (when TeX-view-evince-keep-focus + (cond ((fboundp #'select-frame-set-input-focus) + (select-frame-set-input-focus (selected-frame))) + ((fboundp #'x-focus-frame) + (x-focus-frame (selected-frame))) + ((fboundp #'focus-frame) + (focus-frame (selected-frame)))))) (error "Couldn't find the %s instance for %s" (capitalize app) uri)))) (defun TeX-atril-sync-view () @@ -2246,7 +2266,7 @@ Programs should not use this variable directly but the function "Return the value of variable `TeX-PDF-from-DVI'. If `TeX-PDF-from-DVI' is not set and obsolete option -`TeX-PDF-via-dvips-ps2pdf' is non-nil, return \"dvips-ps2pdf\" +`TeX-PDF-via-dvips-ps2pdf' is non-nil, return \"Dvips\" for backward compatibility." (cond (TeX-PDF-from-DVI) @@ -2676,45 +2696,62 @@ If REGEXP is nil, or \"\", an error will occur." (setq answers (cons entry answers)))) answers)) +(defcustom TeX-kpathsea-path-delimiter path-separator + "Path delimiter for kpathsea output. +nil means kpathsea is disabled." + :group 'TeX-file + :type '(choice (const ":") + (const ";") + (const :tag "Off" nil))) +;; backward compatibility +(when (eq TeX-kpathsea-path-delimiter t) + (setq TeX-kpathsea-path-delimiter path-separator)) + (defun TeX-tree-expand (vars program &optional subdirs) "Return directories corresponding to the kpathsea variables VARS. This is done calling `kpsewhich --expand-path' for the variables. -PROGRAM is passed as the parameter for --progname. SUBDIRS are -subdirectories which are appended to the directories of the TeX -trees. Only existing directories are returned." +PROGRAM if non-nil is passed as the parameter for --progname. +Optional argument SUBDIRS are subdirectories which are appended +to the directories of the TeX trees. Only existing directories +are returned." ;; FIXME: The GNU convention only uses "path" to mean "list of directories" ;; and uses "filename" for the name of a file even if it contains possibly ;; several elements separated by "/". - (let* ((exit-status 1) - (path-list (ignore-errors - (with-output-to-string - (setq exit-status - (call-process - "kpsewhich" nil - (list standard-output nil) nil - "--progname" program - "--expand-path" - (mapconcat #'identity vars - (if (eq system-type 'windows-nt) - ";" ":")))))))) - (when (zerop exit-status) - (let ((separators (if (string-match "^[A-Za-z]:" path-list) - "[\n\r;]" - "[\n\r:]")) - path input-dir-list) - (dolist (item (condition-case nil - (split-string path-list separators t) - ;; COMPATIBILITY for XEmacs <= 21.4.15 - (error (delete "" (split-string path-list separators))))) - (if subdirs - (dolist (subdir subdirs) - (setq path (file-name-as-directory (concat item subdir))) - (when (file-exists-p path) - (pushnew path input-dir-list :test #'equal))) - (setq path (file-name-as-directory item)) - (when (file-exists-p path) - (pushnew path input-dir-list :test #'equal)))) - (nreverse input-dir-list))))) + (when TeX-kpathsea-path-delimiter + (let* ((exit-status 1) + (args `(,@(if program `("--progname" ,program)) + "--expand-path" + ,(mapconcat #'identity vars + TeX-kpathsea-path-delimiter))) + (path-list (ignore-errors + (with-output-to-string + (setq exit-status + (apply #'call-process + "kpsewhich" nil + (list standard-output nil) nil + args)))))) + (if (not (zerop exit-status)) + ;; kpsewhich is not available. Disable subsequent usage. + (setq TeX-kpathsea-path-delimiter nil) + (let ((separators (format "[\n\r%s]" TeX-kpathsea-path-delimiter)) + path input-dir-list) + (dolist (item (condition-case nil + (split-string path-list separators t) + ;; COMPATIBILITY for XEmacs <= 21.4.15 + (error (delete "" (split-string path-list separators))))) + (if subdirs + (dolist (subdir subdirs) + (setq path (file-name-as-directory (concat item subdir))) + (when (file-exists-p path) + (pushnew path input-dir-list :test #'equal))) + (setq path (file-name-as-directory item)) + (when (file-exists-p path) + (pushnew path input-dir-list :test #'equal)))) + ;; No duplication in result is assured since `pushnew' is + ;; used above. Should we introduce an option for speed just + ;; to accumulate all the results without care for + ;; duplicates? + (nreverse input-dir-list)))))) (defun TeX-macro-global () "Return directories containing the site's TeX macro and style files." @@ -3297,7 +3334,7 @@ CDR is non-nil or nil, depending on whether a pair of braces should be, respectively, appended or not to the macro. If a macro has an element in this variable, `TeX-parse-macro' -will use its value to decided what to do, whatever the value of +will use its value to decide what to do, whatever the value of the variable `TeX-insert-braces'." :group 'TeX-macro :type '(repeat (cons (string :tag "Macro name") @@ -3623,7 +3660,7 @@ Unless optional argument COMPLETE is non-nil, ``: '' will be appended." (defun TeX-arg-literal (optional &rest args) "Insert its arguments ARGS into the buffer. Used for specifying extra syntax for a macro. The compatibility -argument OPTION is ignored." +argument OPTIONAL is ignored." (apply 'insert args)) @@ -3806,14 +3843,7 @@ The algorithm is as follows: ;; Standard Emacs completion-at-point support (when (boundp 'completion-at-point-functions) (add-hook 'completion-at-point-functions - #'TeX--completion-at-point nil t) - - ;; Support for company-mode - (when (fboundp 'company-mode) - ;; By default, company completions kick in after a prefix of 3 chars has - ;; been typed. Since we don't have too many completions, that's too - ;; much. - (set (make-local-variable 'company-minimum-prefix-length) 1))) + #'TeX--completion-at-point nil t)) ;; Let `TeX-master-file' be called after a new file was opened and ;; call `TeX-update-style' on any file opened. (The addition to the @@ -3923,7 +3953,7 @@ The algorithm is as follows: (defmacro TeX-auto-add-type (name prefix &optional plural) "Add information about NAME to the parser using PREFIX. -Optional third argument PLURAL is the plural form of TYPE. +Optional third argument PLURAL is the plural form of NAME. By default just add an `s'. This macro creates a set of variables and functions to maintain a @@ -4310,56 +4340,55 @@ you should not use something like `[\\(]' for a character range." "Parse TeX information according to REGEXP-LIST between BEG and END." (if (symbolp regexp-list) (setq regexp-list (and (boundp regexp-list) (symbol-value regexp-list)))) - (if regexp-list - ;; Extract the information. - (let* (groups - (count 1) - (regexp (concat "\\(" - (mapconcat - (lambda(x) - (push (cons count x) groups) - (setq count - (+ 1 count - (TeX-regexp-group-count (car x)))) - (car x)) - regexp-list "\\)\\|\\(") - "\\)")) - syms - lst) - (setq count 0) - (goto-char (if end (min end (point-max)) (point-max))) - (while (re-search-backward regexp beg t) - (let* ((entry (cdr (TeX-member nil groups - (lambda (a b) - (match-beginning (car b)))))) - (symbol (nth 2 entry)) - (match (nth 1 entry))) - (unless (TeX-in-comment) - (looking-at (nth 0 entry)) - (if (fboundp symbol) - (funcall symbol match) - (puthash (if (listp match) - (mapcar #'TeX-match-buffer match) - (TeX-match-buffer match)) - (setq count (1- count)) - (cdr (or (assq symbol syms) - (car (push - (cons symbol - (make-hash-table :test 'equal)) - syms))))))))) - (setq count 0) - (dolist (symbol syms) - (setq lst (symbol-value (car symbol))) - (while lst - (puthash (pop lst) - (setq count (1+ count)) - (cdr symbol))) - (maphash (lambda (key value) - (push (cons value key) lst)) - (cdr symbol)) - (clrhash (cdr symbol)) - (set (car symbol) (mapcar #'cdr (sort lst #'car-less-than-car))))))) - + (if regexp-list + ;; Extract the information. + (let* (groups + (count 1) + (regexp (concat "\\(" + (mapconcat + (lambda(x) + (push (cons count x) groups) + (setq count + (+ 1 count + (TeX-regexp-group-count (car x)))) + (car x)) + regexp-list "\\)\\|\\(") + "\\)")) + syms + lst) + (setq count 0) + (goto-char (if end (min end (point-max)) (point-max))) + (while (re-search-backward regexp beg t) + (let* ((entry (cdr (TeX-member nil groups + (lambda (a b) + (match-beginning (car b)))))) + (symbol (nth 2 entry)) + (match (nth 1 entry))) + (unless (TeX-in-comment) + (looking-at (nth 0 entry)) + (if (fboundp symbol) + (funcall symbol match) + (puthash (if (listp match) + (mapcar #'TeX-match-buffer match) + (TeX-match-buffer match)) + (setq count (1- count)) + (cdr (or (assq symbol syms) + (car (push + (cons symbol + (make-hash-table :test 'equal)) + syms))))))))) + (setq count 0) + (dolist (symbol syms) + (setq lst (symbol-value (car symbol))) + (while lst + (puthash (pop lst) + (setq count (1+ count)) + (cdr symbol))) + (maphash (lambda (key value) + (push (cons value key) lst)) + (cdr symbol)) + (clrhash (cdr symbol)) + (set (car symbol) (mapcar #'cdr (sort lst #'car-less-than-car))))))) (defun TeX-auto-parse () "Parse TeX information in current buffer. @@ -4538,15 +4567,6 @@ EXTENSIONS defaults to `TeX-file-extensions'." :group 'TeX-file :type '(repeat directory)) -(defcustom TeX-kpathsea-path-delimiter t - "Path delimiter for kpathsea output. -t means autodetect, nil means kpathsea is disabled." - :group 'TeX-file - :type '(choice (const ":") - (const ";") - (const :tag "Autodetect" t) - (const :tag "Off" nil))) - ;; We keep this function in addition to `TeX-search-files' because it ;; is faster. Since it does not look further into subdirectories, ;; this comes at the price of finding a smaller number of files. @@ -4556,45 +4576,26 @@ Only files which match EXTENSIONS are returned. SCOPE defines the scope for the search and can be `local' or `global' besides nil. If NODIR is non-nil, remove directory part. If STRIP is non-nil, remove file extension." - (and TeX-kpathsea-path-delimiter - (catch 'no-kpathsea - (let* ((dirs (if (eq scope 'local) - "." - (with-output-to-string - (unless (zerop (call-process - "kpsewhich" nil - (list standard-output nil) nil - (concat "-expand-path=" var))) - (if (eq TeX-kpathsea-path-delimiter t) - (throw 'no-kpathsea - (setq TeX-kpathsea-path-delimiter nil)) - (error "kpsewhich error")))))) - result) - (when (eq TeX-kpathsea-path-delimiter t) - (setq TeX-kpathsea-path-delimiter - (if (string-match ";" dirs) ";" ":"))) - (unless TeX-kpathsea-path-delimiter - (throw 'no-kpathsea nil)) - (setq dirs (TeX-delete-duplicate-strings - (delete "" (split-string - dirs (concat "[\n\r" - TeX-kpathsea-path-delimiter - "]+"))))) - (if (eq scope 'global) - (delete "." dirs)) - (setq extensions (concat "\\." (regexp-opt extensions t) "\\'") - result (apply #'append (mapcar (lambda (x) - (when (file-readable-p x) - (directory-files - x (not nodir) extensions))) - dirs))) - (if strip - (mapcar (lambda(x) - (if (string-match extensions x) - (substring x 0 (match-beginning 0)) - x)) - result) - result))))) + (when TeX-kpathsea-path-delimiter + (let ((dirs (if (eq scope 'local) + '("./") + (TeX-tree-expand (list var) nil))) + result) + (if (eq scope 'global) + (setq dirs (delete "./" dirs))) + (setq extensions (concat "\\." (regexp-opt extensions t) "\\'") + result (apply #'append (mapcar (lambda (x) + (when (file-readable-p x) + (directory-files + x (not nodir) extensions t))) + dirs))) + (if strip + (mapcar (lambda (x) + (if (string-match extensions x) + (substring x 0 (match-beginning 0)) + x)) + result) + result)))) (defun TeX-search-files (&optional directories extensions nodir strip) "Return a list of all reachable files in DIRECTORIES ending with EXTENSIONS. @@ -4696,7 +4697,12 @@ If optional argument STRIP is non-nil, remove file extension." (error "No TeX trees available; configure `TeX-tree-roots'") ;; Expand variables. (setq expdirs - (delete-dups + ;; Don't use `delete-dups' instead of + ;; `TeX-delete-duplicate-strings' here. + ;; Otherwise, when the last element of `rawdirs' + ;; is a variable, its value might be truncated as + ;; side effect. + (TeX-delete-duplicate-strings (apply #'append (mapcar (lambda (rawdir) (if (symbolp rawdir) @@ -4738,11 +4744,6 @@ If optional argument STRIP is non-nil, remove file extension." ;; Some of these functions has little to do with TeX, but nonetheless we ;; should use the "TeX-" prefix to avoid name clashes. -(defun TeX-car-string-lessp (s1 s2) - "Compare the cars of S1 and S2 in lexicographic order. -Return t if first is less than second in lexicographic order." - (string-lessp (car s1) (car s2))) - (defun TeX-listify (elt) "Return a newly created list with element ELT. If ELT already is a list, return ELT." @@ -6113,9 +6114,11 @@ sign. With optional ARG, insert that many dollar signs." ((insert "$"))))) (TeX-math-input-method-off)) -(defvar TeX-math-input-method-off-regexp +(defcustom TeX-math-input-method-off-regexp (concat "^" (regexp-opt '("chinese" "japanese" "korean" "bulgarian" "russian") t)) - "Regexp matching input methods to be deactivated when entering math mode.") + "Regexp matching input methods to be deactivated when entering math mode." + :group 'TeX-misc + :type 'regexp) (defun TeX-math-input-method-off () "Toggle off input method when entering math mode." @@ -6446,15 +6449,7 @@ the number of the file to view, anything else to skip: ") list))) '((texdoc (plain-tex-mode latex-mode doctex-mode ams-tex-mode context-mode) (lambda () (when (executable-find "texdoc") - (TeX-search-files - ;; Explicitely supply doc directory for - ;; non-kpathsea-based TeX systems. - (unless (stringp TeX-kpathsea-path-delimiter) - (or (TeX-tree-expand - '("$SYSTEXMF" "$TEXMFLOCAL" "$TEXMFMAIN" "$TEXMFDIST") - "latex" '("/doc/")) - `(,@TeX-macro-global ,@TeX-macro-private))) - '("dvi" "pdf" "ps" "txt" "html") t t))) + (TeX-search-files-by-type 'docs 'global t t))) (lambda (doc) ;; texdoc in MiKTeX requires --view in order to start ;; the viewer instead of an intermediate web page.