branch: externals/auctex commit 590651fcb6d5c6dac8132a75c72780fba42735ce Merge: 35a4cfc 7427d62 Author: Tassilo Horn <t...@gnu.org> Commit: Tassilo Horn <t...@gnu.org>
Merge branch 'master' into elpa --- .gitignore | 3 +- ChangeLog-preview | 4 + ChangeLog => ChangeLog.1 | 170 +++++++++++++ Makefile.in | 21 ++- RELEASE | 129 ++++------- build-aux/gitlog-to-changelog | 492 +++++++++++++++++++++++++++++++++++++ configure.ac | 2 +- doc/auctex.texi | 34 +++- doc/changes.texi | 31 ++- doc/tex-ref.tex | 8 +- latex.el | 22 +- latex/preview.dtx | 2 +- style/Alegreya.el | 6 +- style/AlegreyaSans.el | 6 +- style/amsthm.el | 144 +++++++++-- style/caption.el | 2 +- style/enumitem.el | 29 +-- style/hologo.el | 233 ++++++++++++++++++ style/subcaption.el | 4 +- tests/latex/latex-filling-in.tex | 1 + tests/latex/latex-filling-out.tex | 5 + tests/latex/latex-test.el | 80 ++++++- tests/latex/math-indent-in.tex | 17 ++ tests/latex/math-indent-out.tex | 17 ++ tex-buf.el | 36 +++- tex-info.el | 135 ++++++++--- tex.el | 19 +- 27 files changed, 1433 insertions(+), 219 deletions(-) diff --git a/.gitignore b/.gitignore index 24160a8..62fffdb 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ *.log *~ CHANGES +ChangeLog FAQ INSTALL INSTALL.windows @@ -38,7 +39,7 @@ latex/prtracingall.def preview-latex.el preview.el PROBLEMS.preview - # Files generated when installing/compiling the package in place. auctex-pkg.el auctex-autoloads.el +tests/*/auto/* diff --git a/ChangeLog-preview b/ChangeLog-preview index d86946d..1c3cd32 100644 --- a/ChangeLog-preview +++ b/ChangeLog-preview @@ -1,3 +1,7 @@ +2015-11-13 Mos� Giordano <m...@gnu.org> + + * Version 11.89 released. + 2014-11-28 Stefan Monnier <monn...@iro.umontreal.ca> * preview.el.in: Cleanup compiler warnings. Mark unused arguments. diff --git a/ChangeLog b/ChangeLog.1 similarity index 99% rename from ChangeLog rename to ChangeLog.1 index 2c59fef..dd1f90c 100644 --- a/ChangeLog +++ b/ChangeLog.1 @@ -1,3 +1,173 @@ +2015-11-13 Mos� Giordano <m...@gnu.org> + + * Version 11.89 released. + +2015-11-12 Mos� Giordano <m...@gnu.org> + + * RELEASE: Update AUCTeX version, the new features section, and + the list of contributors. + + * configure.ac: Update AUCTeX version. + + * doc/changes.texi: Mention PDF Tools and generic features for + 11.89 release. + + * doc/tex-ref.tex: Update AUCTeX version and copyright years + across the file. + + * latex.el: Update copyright year. + + * latex/preview.dtx: Manually update release version. + + * Makefile.in (WEMACSPACKAGE): Update for Emacs 24.5 + (www-doc): Download gendocs.sh patch from AUCTeX repository. + + * tex.el (TeX-view-predicate-list-bultin): For + `has-no-display-manager' predicate, use the current test only for + old Emacsen, otherwise employ `display-graphic-p'. Suggested by + Santiago Saavedra. + +2015-11-11 Mos� Giordano <m...@gnu.org> + + * tests/latex/latex-test.el (LaTeX-math-indent) + (LaTeX-change-environment-with-esc): New tests. + + * tests/latex/math-indent-in.tex: New test file. + + * tests/latex/math-indent-out.tex: Ditto. + +2015-11-10 Mos� Giordano <m...@gnu.org> + + * latex.el (LaTeX-fill-break-at-separators): Change default value + to opening only inline and display math switches. + + * tests/latex/latex-filling-in.tex: New test file. + + * tests/latex/latex-filling-out.tex: Ditto. + + * tests/latex/latex-test.el (LaTeX-indent-tabular-test/in) + (LaTeX-indent-tabular-test/out): Remove variables defined with + `defvar'. + (AUCTeX-set-ert-path): New function for setting the path of the + ERT test files. + (LaTeX-filling): New ERT test. + +2015-11-10 Tassilo Horn <t...@gnu.org> + + * tex-buf.el (TeX-revert-document-buffer): New function. + (TeX-after-TeX-LaTeX-command-finished-hook): Mention it in docstring. + * doc/auctex.texi (Modes and Hooks): Mention it in manual. + +2015-11-10 Santiago Saavedra <ssaave...@gpul.org> (tiny change) + + * tex.el (TeX-command-list, TeX-view-program-list-builtin) + (TeX-view-program-selection): Add dvi2tty as a first-class + command, removing it from a load-time quasiquotation so that the + strategy for selecting it or evince goes down to the frame + performing the View command. Fixes bug#21873. + +2015-11-09 Mos� Giordano <m...@gnu.org> + + * tex-info.el: Update copyright years. + (Texinfo-nodename-de-escape, Texinfo-nodename-escape): Use + `TeX-assoc-string' in place of `assoc-string'. + +2015-11-08 Mos� Giordano <m...@gnu.org> + + * tex-info.el (TeX-texinfo-mode): Set `TeX-output-extension'. + Remove compatibility code with old Emacsen. + +2015-11-06 Mos� Giordano <m...@gnu.org> + + * tex-buf.el (TeX-check-TeX, TeX-check-TeX-command-not-found): New + customizable options. + (TeX-command): Do a better check for the presence of a TeX + distribution. Run `call-process' instead of `executable-find', + like `TeX-run-command' actually does. The point is that + `call-process' and `start-process' use `PATH' environment + variable, `executable-find' uses `exec-path' variable and they do + not need to match, but we should check what `TeX-run-command' will + really do. + + * doc/auctex.texi (Processor Options): Document `TeX-check-TeX'. + + * doc/changes.texi: Mention `TeX-check-TeX'. + +2015-11-03 Mos� Giordano <m...@gnu.org> + + * doc/auctex.texi (Processor Options): Document + `ConTeXt-Mark-version'. + (Multifile): Mention `dwim' value for `TeX-master'. + + * doc/changes.texi: Mention `ConTeXt-Mark-version'. + +2015-11-02 Mos� Giordano <m...@gnu.org> + + * latex.el (TeX-arg-document): When `TeX-arg-input-file-search' is + nil, use `LaTeX-style-list' to complete document classes. Fixes + bug#21814. + +2015-10-31 Arash Esbati <esb...@gmx.de> + + * Makefile.in (STYLESRC): Add new style. + + * style/hologo.el: New file. + +2015-10-28 Tassilo Horn <t...@gnu.org> + + * latex.el (LaTeX-fill-break-at-separators): Default to nil + because many users don't like that special filling. + + * tex-info.el (Texinfo-make-node-list): Warn about duplicate + nodes. Return nodes in order instead of reversed. + +2015-10-25 Vincent Bela�che <vincent....@hotmail.fr> + + * tex-info.el (Texinfo-nodename-de-escape): New defun. + (Texinfo-nodename-escape): New defun. + (Texinfo-make-node-list): New defun, code taken from + Texinfo-insert-node into this function for the sake of code + factorization. In addition, (1) allow node name not to be + followed by a comma --- i.e. next node etc. unspecified --- (2) + trim trailing blanks after node name, and (3) de-escape @comma{} + before insertion of node name into the list. + (Texinfo-insert-node): (1) Use new function + `Texinfo-make-node-list', and (2) escape node names for commas. + (Texinfo-arg-nodename): New defun. + (TeX-texinfo-mode): (1) Remove `group' from list of commands, + `group' is an environment, not a command. (2) Add + `guillemetleft', `guillemetright', `guilsinglleft', + `guilsinglright', `quotedblbase' and `quotesinglbase' to the list + of commands. (3) For commands `pxref', `ref' and `xref', use new + function `Texinfo-arg-nodename' to read node name with completion. + +2015-10-24 Arash Esbati <esb...@gmx.de> + + * style/enumitem.el (LaTeX-enumitem-auto-cleanup): Move some + operations from style hook into this function. + (LaTeX-enumitem-newlist-list-item-arg-local): Delete now unused + variable. + + * style/amsthm.el (LaTeX-amsthm-theoremstyle-list): New variable + replacing the deleted function + `LaTeX-amsthm-complete-theoremstyle'. + (LaTeX-amsthm-env-label): New function to insert user defined + environments. + ("amsthm"): Improve handling of "newtheorem*" and + "newtheoremstyle". + + * style/AlegreyaSans.el ("AlegreyaSans"): Remove SmallCaps + font declaration command. + + * style/Alegreya.el ("Alegreya"): Remove SmallCaps + font declaration command. + + * style/caption.el (LaTeX-arg-caption-captionbox): Fix doctring. + + * style/subcaption.el (LaTeX-arg-subcaption-subcaption): Fix + doctring. + (LaTeX-arg-subcaption-subcaptionbox): ditto. + 2015-10-19 Tassilo Horn <t...@gnu.org> * Version 11.88.9 released. diff --git a/Makefile.in b/Makefile.in index ba31c43..1b33ce6 100644 --- a/Makefile.in +++ b/Makefile.in @@ -60,7 +60,7 @@ AUTOLOAD=--eval '(let ((generated-autoload-file (expand-file-name "$@"))) \ PREVIEW_AUTOLOAD=--eval '(let ((generated-autoload-file (expand-file-name "$@"))) \ (update-file-autoloads "preview.el")(save-buffers-kill-emacs t))' -EXCLUDEDFILES=autogen.sh .cvsignore .gitignore doc/.gitignore README.GIT tests +EXCLUDEDFILES=autogen.sh .cvsignore .gitignore doc/.gitignore README.GIT tests build-aux .SUFFIXES: .el .elc .texi @@ -152,7 +152,8 @@ STYLESRC = style/prosper.el \ style/mnras.el style/environ.el style/polyglossia.el \ style/vwcol.el style/textpos.el style/transparent.el \ style/fontenc.el style/Alegreya.el style/gloss-italian.el \ - style/newfloat.el style/subcaption.el style/AlegreyaSans.el + style/newfloat.el style/subcaption.el style/AlegreyaSans.el \ + style/hologo.el STYLEELC = $(STYLESRC:.el=.elc) @@ -429,7 +430,7 @@ wc: # 6) release-upload # Upload files to GNU FTP server. # -# 7) www-doc TAG=<tag> GENDOCSPATCH=<patch-file> +# 7) www-doc TAG=<tag> # Create documentation for AUCTeX home page. # # 8) preview-ball TAG=<tag> @@ -521,7 +522,16 @@ ifeq ($(shell echo "$(WEMACSVER)" | grep '\(2[2-3].[1-4]\|24.[1-3]\)' -),$(WEMAC else WEMACSDATAROOTDIR="share/" WEMACSEXTRACTDIR="emacs-$(WEMACSVER)" - WEMACSPACKAGE="emacs-$(WEMACSVER)-bin-i686-pc-mingw32.zip" +# And just to add more complexity, the package name changed again with Emacs +# 24.5. Actually, we don't really need to keep track of all these changes as we +# should support only the latest Emacs version, but unless something else +# changes again again in the near future we can keep them (and it's useful to +# reproduce old AUCTeX packages!). + ifeq (24.4,$(WEMACSVER)) + WEMACSPACKAGE="emacs-$(WEMACSVER)-bin-i686-pc-mingw32.zip" + else + WEMACSPACKAGE="emacs-$(WEMACSVER)-bin-i686-mingw32.zip" + endif WEMACSSITELISP="$(WEMACSDATAROOTDIR)/emacs/site-lisp" endif WPACKAGEFILES=$(WEMACSSITELISP)/auctex $(WEMACSSITELISP)/site-start.d \ @@ -604,7 +614,8 @@ www-doc: check-tag $(CP) auctex-$(TAG)/doc/*.texi $(WWWDIR)/manual cd $(WWWDIR)/manual \ && wget -O gendocs.sh 'http://cvs.savannah.gnu.org/viewvc/%2acheckout%2a/texinfo/texinfo/util/gendocs.sh' \ - && patch <$(GENDOCSPATCH) \ + && wget -O gendocs.sh.patch 'http://git.savannah.gnu.org/gitweb/?p=auctex.git;a=blob_plain;f=gendocs.sh.patch;hb=gendocspatch' \ + && patch <gendocs.sh.patch \ && chmod u+x gendocs.sh \ && wget -O gendocs_template 'http://cvs.savannah.gnu.org/viewvc/%2acheckout%2a/texinfo/texinfo/util/gendocs_template' \ && sed -i -e 's/html_node\/index\.html/%%PACKAGE%%\/index.html/' gendocs_template \ diff --git a/RELEASE b/RELEASE index 6517532..15eb656 100644 --- a/RELEASE +++ b/RELEASE @@ -1,4 +1,4 @@ -Release notes for AUCTeX 11.88 with preview-latex +Release notes for AUCTeX 11.89 with preview-latex ================================================= AUCTeX provides by far the most wide-spread and sophisticated @@ -25,91 +25,54 @@ sleuth work, testing. New features and fixed bugs in this release ------------------------------------------- -'TeX-PDF-mode' is now enabled by default. +You can now run all commands needed to compile a document and then +open the viewer with a single command: 'TeX-command-run-all', bound +to 'C-c C-a'. -Now 'TeX-previous-error' works with TeX commands if the new option -'TeX-parse-all-errors' is non-nil, which is the default. When this -option is non-nil, an overview of errors and warnings reported by the -TeX compiler can be opened with 'M-x TeX-error-overview <RET>'. +Commands such as LaTeX and View can now be executed conveniently on +the current section (or part, chapter, subsection, etc). See +'LaTeX-command-section' and 'LaTeX-command-section-change-level'. -Style file authors are encouraged to distinguish common from expert -macros and environments, and mark the latter using -'TeX-declare-expert-macros' and 'LaTeX-declare-expert-environments'. -Users can then restrict completion using -'TeX-complete-expert-commands'. +Forward and backward search with Evince now also work when only a +region of the document is compiled/viewed. -Management of LaTeX package options in the parser was improved. You -might need to reparse your documents, especially if you loaded the -'babel' package with language options. +To open the PDF output file you can now use also PDF Tools, a +document viewer for Emacs. With it, as a plus, forward and +backward search is accurate at word level. -Now you can insert '$...$' or '\(...\)' by typing a single '$'. To do -this, customize the new option 'TeX-electric-math'. -'TeX-math-close-double-dollar' was removed. +With new option 'TeX-PDF-via-dvips-ps2pdf' it is possible to +compile a document to DVI and then convert it to PDF using +'dvips'-'ps2pdf' before viewing it. -'C-c <RET> documentclass <RET>' completes with all available LaTeX -classes, if the 'TeX-arg-input-file-search' variable is non-nil. -Completion for class options of the standard LaTeX classes is provided -as well. +New option 'TeX-file-line-error' allows to select file:line:error +style for error messages. -New user options 'LaTeX-default-author', -'LaTeX-fontspec-arg-font-search', 'LaTeX-fontspec-font-list-default', -'TeX-date-format', and 'TeX-insert-braces-alist'. A new possible value -('show-all-optional-args') for 'TeX-insert-macro-default-style' was -added. The default value of 'TeX-source-correlate-method' has been -changed. +Indent '\[...\]' math mode as a regular environment by default. -'biblatex' support was greatly expanded. If parsing is enabled, AUCTeX -looks at 'backend' option to decide whether to use Biber or BibTeX. The -'LaTeX-biblatex-use-Biber' variable was changed to be file local only -and is no more customizable. +Now AUCTeX suggests to run 'makeindex' when appropriate. -With some LaTeX classes, the default environment suggested by -'LaTeX-environment' ('C-c C-e') when the current environment is -'document' was changed. With 'beamer' class the default environment is -'frame', with 'letter' it is 'letter', with 'slides' it is 'slide'. +'TeX-view-program-list' can contain, as third optional element of +each item, the name of the executable(s) needed to open the viewer. -Brace pairing feature was enhanced in LaTeX documents. Support for -'\bigl', '\Bigl', '\biggl' and '\Biggl', the same as the one for -'\left', was added to 'TeX-insert-macro'. For example, 'C-c <RET> bigl -<RET> ( <RET>' inserts '\bigl(\bigr)'. +'TeX-expand-list' variable has been split into 'TeX-expand-list' +and 'TeX-expand-list-builtin'. Only the former is intended to be +customized by the user, the latter contains built-in expanders. +You might want to keep in 'TeX-expand-list' only new expansion +strings. -You can insert brace pair '()', '{}' and '[]' by typing a single left -brace if the new user option 'LaTeX-electric-left-right-brace' is -enabled. +When new option 'TeX-check-engine' is non-nil, before running LaTeX +commands AUCTeX will check whether the correct engine has been set, +based upon known restrictions posed by LaTeX packages. -Macros '\langle', '\lfloor' and '\lceil', which produce the left part -of the paired braces, are treated similarly as '(', '{' and '[' during -the course of 'TeX-insert-macro'. +Basic support to ConTeXt Mark IV has been added. Users can now +select the Mark version to be used with new option +'ConTeXt-Mark-version', and AUCTeX is able to catch error messages +in the output log of a Mark IV document. -Support for dozens of LaTeX packages was added. +Support for tons of LaTeX packages has been addedd. -Tabular-like environments (tabular, tabular*, tabularx, tabulary, -array, align, ...) are indented in a nicer and more informative way -when the column values of a table line are written across multiple -lines in the tex file. - -The suitable number of ampersands are inserted when you insert array, -tabular and tabular* environments with 'C-c C-e'. Similar experience -is obtained if you terminate rows in these environments with 'C-c -<LFD>'. It supplies line break macro '\\' and inserts the suitable -number of ampersands on the next line. Similar supports are provided -for various amsmath environments. - -Commands for narrowing to a group ('TeX-narrow-to-group') and to LaTeX -environments ('LaTeX-narrow-to-environment') were added. - -Now arbitrary options can be passed to the TeX processor on a per file -basis using the 'TeX-command-extra-options' option. - -Now 'C-c C-e document <RET>', in an empty document, prompts for -'\usepackage' macros in addition to '\documentclass'. - -'TeX-add-style-hook' has now a third argument to tell AUCTeX for which -dialect (LaTeX, Texinfo or BibTeX) the style hook is registers. -Labelling style hook by dialect will avoid applying them not in the -right context. - -There have been lots of bug fixes and feature additions. +Numbers of bugs have been fixed, many minor features have been +addedd. Requirements ------------ @@ -179,16 +142,16 @@ remains the most effective way of helping AUCTeX development. The following people contributed to this release series (in alphabetical order): Ivan Andrus, Ralf Angeli, Masayuki Ataka, Fabrice Ben Hamouda, Thomas Baumann, Vincent Bela�che, Berend de Boer, Ken -Brown, Joshua Buhl, Patrice Dumas, Werner Fink, Miguel Frasson, Peter -S. Galbraith, Mos� Giordano, Patrick Gundlach, Jobst Hoffmann, Tassilo -Horn, Yvon Hevel, Mads Jensen, Arne J�rgensen, David Kastrup, Ikumi -Keita, Philip Kime, Oleh Krehel, Joost Kremers, Frank K�ster, Jan-�ke -Larsson, Matthew Leach, Antoine Levitt, Leo Liu, Vladimir Lomov, Stefan -Monnier, Dan Nicolaescu, Piet van Oostrum, Nicolas Richard, Augusto -Ritter Stoffel, Florent Rougon, Davide G. M. Salvetti, R�diger -Sonderfeld, Holger Sparr, Mike Sperber, Reiner Steib, Christian -Schlauer, Shiro Takeda, Mark Trettin (Please accept our apologies if we -forgot somebody.) +Brown, Joshua Buhl, Patrice Dumas, Arash Esbati, Werner Fink, Miguel +Frasson, Peter S. Galbraith, Mos� Giordano, Patrick Gundlach, Jobst +Hoffmann, Tassilo Horn, Yvon Hevel, Orlando Iovino, Mads Jensen, Arne +J�rgensen, David Kastrup, Ikumi Keita, Philip Kime, Oleh Krehel, Joost +Kremers, Frank K�ster, Jan-�ke Larsson, Matthew Leach, Antoine Levitt, +Leo Liu, Vladimir Lomov, Stefan Monnier, Dan Nicolaescu, Piet van +Oostrum, Nicolas Richard, Augusto Ritter Stoffel, Florent Rougon, +Santiago Saavedra, Davide G. M. Salvetti, R�diger Sonderfeld, Holger +Sparr, Mike Sperber, Reiner Steib, Christian Schlauer, Shiro Takeda, +Mark Trettin (Please accept our apologies if we forgot somebody.) Footnotes: diff --git a/build-aux/gitlog-to-changelog b/build-aux/gitlog-to-changelog new file mode 100755 index 0000000..a0e0a05 --- /dev/null +++ b/build-aux/gitlog-to-changelog @@ -0,0 +1,492 @@ +eval '(exit $?0)' && eval 'exec perl -wS "$0" ${1+"$@"}' + & eval 'exec perl -wS "$0" $argv:q' + if 0; +# Convert git log output to ChangeLog format. + +my $VERSION = '2015-06-11 01:03'; # UTC +# The definition above must lie within the first 8 lines in order +# for the Emacs time-stamp write hook (at end) to update it. +# If you change this file with Emacs, please let the write hook +# do its job. Otherwise, update this string manually. + +# Copyright (C) 2008-2015 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 published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +# Written by Jim Meyering + +use strict; +use warnings; +use Getopt::Long; +use POSIX qw(strftime); + +(my $ME = $0) =~ s|.*/||; + +# use File::Coda; # http://meyering.net/code/Coda/ +END { + defined fileno STDOUT or return; + close STDOUT and return; + warn "$ME: failed to close standard output: $!\n"; + $? ||= 1; +} + +sub usage ($) +{ + my ($exit_code) = @_; + my $STREAM = ($exit_code == 0 ? *STDOUT : *STDERR); + if ($exit_code != 0) + { + print $STREAM "Try '$ME --help' for more information.\n"; + } + else + { + print $STREAM <<EOF; +Usage: $ME [OPTIONS] [ARGS] + +Convert git log output to ChangeLog format. If present, any ARGS +are passed to "git log". To avoid ARGS being parsed as options to +$ME, they may be preceded by '--'. + +OPTIONS: + + --amend=FILE FILE maps from an SHA1 to perl code (i.e., s/old/new/) that + makes a change to SHA1's commit log text or metadata. + --append-dot append a dot to the first line of each commit message if + there is no other punctuation or blank at the end. + --no-cluster never cluster commit messages under the same date/author + header; the default is to cluster adjacent commit messages + if their headers are the same and neither commit message + contains multiple paragraphs. + --srcdir=DIR the root of the source tree, from which the .git/ + directory can be derived. + --since=DATE convert only the logs since DATE; + the default is to convert all log entries. + --until=DATE convert only the logs older than DATE. + --ignore-matching=PAT ignore commit messages whose first lines match PAT. + --ignore-line=PAT ignore lines of commit messages that match PAT. + --format=FMT set format string for commit subject and body; + see 'man git-log' for the list of format metacharacters; + the default is '%s%n%b%n' + --strip-tab remove one additional leading TAB from commit message lines. + --strip-cherry-pick remove data inserted by "git cherry-pick"; + this includes the "cherry picked from commit ..." line, + and the possible final "Conflicts:" paragraph. + --help display this help and exit + --version output version information and exit + +EXAMPLE: + + $ME --since=2008-01-01 > ChangeLog + $ME -- -n 5 foo > last-5-commits-to-branch-foo + +SPECIAL SYNTAX: + +The following types of strings are interpreted specially when they appear +at the beginning of a log message line. They are not copied to the output. + + Copyright-paperwork-exempt: Yes + Append the "(tiny change)" notation to the usual "date name email" + ChangeLog header to mark a change that does not require a copyright + assignment. + Co-authored-by: Joe User <user\@example.com> + List the specified name and email address on a second + ChangeLog header, denoting a co-author. + Signed-off-by: Joe User <user\@example.com> + These lines are simply elided. + +In a FILE specified via --amend, comment lines (starting with "#") are ignored. +FILE must consist of <SHA,CODE+> pairs where SHA is a 40-byte SHA1 (alone on +a line) referring to a commit in the current project, and CODE refers to one +or more consecutive lines of Perl code. Pairs must be separated by one or +more blank line. + +Here is sample input for use with --amend=FILE, from coreutils: + +3a169f4c5d9159283548178668d2fae6fced3030 +# fix typo in title: +s/all tile types/all file types/ + +1379ed974f1fa39b12e2ffab18b3f7a607082202 +# Due to a bug in vc-dwim, I mis-attributed a patch by Paul to myself. +# Change the author to be Paul. Note the escaped "@": +s,Jim .*>,Paul Eggert <eggert\\\@cs.ucla.edu>, + +EOF + } + exit $exit_code; +} + +# If the string $S is a well-behaved file name, simply return it. +# If it contains white space, quotes, etc., quote it, and return the new string. +sub shell_quote($) +{ + my ($s) = @_; + if ($s =~ m![^\w+/.,-]!) + { + # Convert each single quote to '\'' + $s =~ s/\'/\'\\\'\'/g; + # Then single quote the string. + $s = "'$s'"; + } + return $s; +} + +sub quoted_cmd(@) +{ + return join (' ', map {shell_quote $_} @_); +} + +# Parse file F. +# Comment lines (starting with "#") are ignored. +# F must consist of <SHA,CODE+> pairs where SHA is a 40-byte SHA1 +# (alone on a line) referring to a commit in the current project, and +# CODE refers to one or more consecutive lines of Perl code. +# Pairs must be separated by one or more blank line. +sub parse_amend_file($) +{ + my ($f) = @_; + + open F, '<', $f + or die "$ME: $f: failed to open for reading: $!\n"; + + my $fail; + my $h = {}; + my $in_code = 0; + my $sha; + while (defined (my $line = <F>)) + { + $line =~ /^\#/ + and next; + chomp $line; + $line eq '' + and $in_code = 0, next; + + if (!$in_code) + { + $line =~ /^([0-9a-fA-F]{40})$/ + or (warn "$ME: $f:$.: invalid line; expected an SHA1\n"), + $fail = 1, next; + $sha = lc $1; + $in_code = 1; + exists $h->{$sha} + and (warn "$ME: $f:$.: duplicate SHA1\n"), + $fail = 1, next; + } + else + { + $h->{$sha} ||= ''; + $h->{$sha} .= "$line\n"; + } + } + close F; + + $fail + and exit 1; + + return $h; +} + +# git_dir_option $SRCDIR +# +# From $SRCDIR, the --git-dir option to pass to git (none if $SRCDIR +# is undef). Return as a list (0 or 1 element). +sub git_dir_option($) +{ + my ($srcdir) = @_; + my @res = (); + if (defined $srcdir) + { + my $qdir = shell_quote $srcdir; + my $cmd = "cd $qdir && git rev-parse --show-toplevel"; + my $qcmd = shell_quote $cmd; + my $git_dir = qx($cmd); + defined $git_dir + or die "$ME: cannot run $qcmd: $!\n"; + $? == 0 + or die "$ME: $qcmd had unexpected exit code or signal ($?)\n"; + chomp $git_dir; + push @res, "--git-dir=$git_dir/.git"; + } + @res; +} + +{ + my $since_date; + my $until_date; + my $format_string = '%s%n%b%n'; + my $amend_file; + my $append_dot = 0; + my $cluster = 1; + my $ignore_matching; + my $ignore_line; + my $strip_tab = 0; + my $strip_cherry_pick = 0; + my $srcdir; + GetOptions + ( + help => sub { usage 0 }, + version => sub { print "$ME version $VERSION\n"; exit }, + 'since=s' => \$since_date, + 'until=s' => \$until_date, + 'format=s' => \$format_string, + 'amend=s' => \$amend_file, + 'append-dot' => \$append_dot, + 'cluster!' => \$cluster, + 'ignore-matching=s' => \$ignore_matching, + 'ignore-line=s' => \$ignore_line, + 'strip-tab' => \$strip_tab, + 'strip-cherry-pick' => \$strip_cherry_pick, + 'srcdir=s' => \$srcdir, + ) or usage 1; + + defined $since_date + and unshift @ARGV, "--since=$since_date"; + defined $until_date + and unshift @ARGV, "--until=$until_date"; + + # This is a hash that maps an SHA1 to perl code (i.e., s/old/new/) + # that makes a correction in the log or attribution of that commit. + my $amend_code = defined $amend_file ? parse_amend_file $amend_file : {}; + + my @cmd = ('git', + git_dir_option $srcdir, + qw(log --log-size), + '--pretty=format:%H:%ct %an <%ae>%n%n'.$format_string, @ARGV); + open PIPE, '-|', @cmd + or die ("$ME: failed to run '". quoted_cmd (@cmd) ."': $!\n" + . "(Is your Git too old? Version 1.5.1 or later is required.)\n"); + + my $prev_multi_paragraph; + my $prev_date_line = ''; + my @prev_coauthors = (); + my @skipshas = (); + while (1) + { + defined (my $in = <PIPE>) + or last; + $in =~ /^log size (\d+)$/ + or die "$ME:$.: Invalid line (expected log size):\n$in"; + my $log_nbytes = $1; + + my $log; + my $n_read = read PIPE, $log, $log_nbytes; + $n_read == $log_nbytes + or die "$ME:$.: unexpected EOF\n"; + + # Extract leading hash. + my ($sha, $rest) = split ':', $log, 2; + defined $sha + or die "$ME:$.: malformed log entry\n"; + $sha =~ /^[0-9a-fA-F]{40}$/ + or die "$ME:$.: invalid SHA1: $sha\n"; + + my $skipflag = 0; + if (@skipshas) + { + foreach(@skipshas) + { + if ($sha =~ /^$_/) + { + $skipflag = 1; + ## Perhaps only warn if a pattern matches more than once? + warn "$ME: warning: skipping $sha due to $_\n"; + last; + } + } + } + + # If this commit's log requires any transformation, do it now. + my $code = $amend_code->{$sha}; + if (defined $code) + { + eval 'use Safe'; + my $s = new Safe; + # Put the unpreprocessed entry into "$_". + $_ = $rest; + + # Let $code operate on it, safely. + my $r = $s->reval("$code") + or die "$ME:$.:$sha: failed to eval \"$code\":\n$@\n"; + + # Note that we've used this entry. + delete $amend_code->{$sha}; + + # Update $rest upon success. + $rest = $_; + } + + # Remove lines inserted by "git cherry-pick". + if ($strip_cherry_pick) + { + $rest =~ s/^\s*Conflicts:\n.*//sm; + $rest =~ s/^\s*\(cherry picked from commit [\da-f]+\)\n//m; + } + + my @line = split /[ \t]*\n/, $rest; + my $author_line = shift @line; + defined $author_line + or die "$ME:$.: unexpected EOF\n"; + $author_line =~ /^(\d+) (.*>)$/ + or die "$ME:$.: Invalid line " + . "(expected date/author/email):\n$author_line\n"; + + # Format 'Copyright-paperwork-exempt: Yes' as a standard ChangeLog + # `(tiny change)' annotation. + my $tiny = (grep (/^(?:Copyright-paperwork-exempt|Tiny-change):\s+[Yy]es$/, @line) + ? ' (tiny change)' : ''); + + my $date_line = sprintf "%s %s$tiny\n", + strftime ("%Y-%m-%d", localtime ($1)), $2; + + my @coauthors = grep /^Co-authored-by:.*$/, @line; + # Omit meta-data lines we've already interpreted. + @line = grep !/^(?:Signed-off-by:[ ].*>$ + |Co-authored-by:[ ] + |Copyright-paperwork-exempt:[ ] + |Tiny-change:[ ] + )/x, @line; + + # Remove leading and trailing blank lines. + if (@line) + { + while ($line[0] =~ /^\s*$/) { shift @line; } + while ($line[$#line] =~ /^\s*$/) { pop @line; } + } + + # Handle Emacs gitmerge.el "skipped" commits. + # Yes, this should be controlled by an option. So sue me. + if ( grep /^(; )?Merge from /, @line ) + { + my $found = 0; + foreach (@line) + { + if (grep /^The following commit.*skipped:$/, $_) + { + $found = 1; + ## Reset at each merge to reduce chance of false matches. + @skipshas = (); + next; + } + if ($found && $_ =~ /^([0-9a-fA-F]{7,}) [^ ]/) + { + push ( @skipshas, $1 ); + } + } + } + + # Ignore commits that match the --ignore-matching pattern, if specified. + if (! ($skipflag || (defined $ignore_matching + && @line && $line[0] =~ /$ignore_matching/))) + { + if (defined $ignore_line && @line) + { + @line = grep ! /$ignore_line/, @line; + while ($line[$#line] =~ /^\s*$/) { pop @line; } + } + + # Record whether there are two or more paragraphs. + my $multi_paragraph = grep /^\s*$/, @line; + + # Format 'Co-authored-by: A U Thor <em...@example.com>' lines in + # standard multi-author ChangeLog format. + for (@coauthors) + { + s/^Co-authored-by:\s*/\t /; + s/\s*</ </; + + /<.*?@.*\..*>/ + or warn "$ME: warning: missing email address for " + . substr ($_, 5) . "\n"; + } + + # If clustering of commit messages has been disabled, if this header + # would be different from the previous date/name/etc. header, + # or if this or the previous entry consists of two or more paragraphs, + # then print the header. + if ( ! $cluster + || $date_line ne $prev_date_line + || "@coauthors" ne "@prev_coauthors" + || $multi_paragraph + || $prev_multi_paragraph) + { + $prev_date_line eq '' + or print "\n"; + print $date_line; + @coauthors + and print join ("\n", @coauthors), "\n"; + } + $prev_date_line = $date_line; + @prev_coauthors = @coauthors; + $prev_multi_paragraph = $multi_paragraph; + + # If there were any lines + if (@line == 0) + { + warn "$ME: warning: empty commit message:\n $date_line\n"; + } + else + { + if ($append_dot) + { + # If the first line of the message has enough room, then + if (length $line[0] < 72) + { + # append a dot if there is no other punctuation or blank + # at the end. + $line[0] =~ /[[:punct:]\s]$/ + or $line[0] .= '.'; + } + } + + # Remove one additional leading TAB from each line. + $strip_tab + and map { s/^\t// } @line; + + # Prefix each non-empty line with a TAB. + @line = map { length $_ ? "\t$_" : '' } @line; + + print "\n", join ("\n", @line), "\n"; + } + } + + defined ($in = <PIPE>) + or last; + $in ne "\n" + and die "$ME:$.: unexpected line:\n$in"; + } + + close PIPE + or die "$ME: error closing pipe from " . quoted_cmd (@cmd) . "\n"; + # FIXME-someday: include $PROCESS_STATUS in the diagnostic + + # Complain about any unused entry in the --amend=F specified file. + my $fail = 0; + foreach my $sha (keys %$amend_code) + { + warn "$ME:$amend_file: unused entry: $sha\n"; + $fail = 1; + } + + exit $fail; +} + +# Local Variables: +# mode: perl +# indent-tabs-mode: nil +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "my $VERSION = '" +# time-stamp-format: "%:y-%02m-%02d %02H:%02M" +# time-stamp-time-zone: "UTC" +# time-stamp-end: "'; # UTC" +# End: diff --git a/configure.ac b/configure.ac index 43a229d..fd250db 100644 --- a/configure.ac +++ b/configure.ac @@ -21,7 +21,7 @@ dnl along with AUCTeX; see the file COPYING. If not, write to the Free dnl Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, dnl MA 02110-1301, USA. -AC_INIT(auctex,11.88,bug-auc...@gnu.org) +AC_INIT(auctex,11.89,bug-auc...@gnu.org) AC_CHECK_PROGS_REQUIRED(MAKECMD, make, [make not found, aborting!]) AC_PROG_MAKE_SET diff --git a/doc/auctex.texi b/doc/auctex.texi index a7ac3ae..8c02499 100644 --- a/doc/auctex.texi +++ b/doc/auctex.texi @@ -2989,6 +2989,23 @@ command can either be a variable or a string. An empty string or nil means there is no command available. @end defopt +In some systems, Emacs cannot inherit the PATH environment variable from +the shell and thus @AUCTeX{} may not be able to run @TeX{} commands. +Before running them, @AUCTeX{} checks if it able to find those commands +and will warn you in case it fails. You can skip this test by changing +the option @code{TeX-check-TeX}. + +@defopt TeX-check-TeX +@vindex TeX-command +@vindex TeX-check-TeX-command-not-found +If non-nil, @AUCTeX{} will check if it is able to find a working @TeX{} +distribution before running @TeX{}, @LaTeX{}, @ConTeXt{}, etc. It +actually checks if can run @code{TeX-command} command or the shell +returns a command not found error. The error code returned by the shell +in this case can be set in @code{TeX-check-TeX-command-not-found} +option. +@end defopt + Some @LaTeX{} packages requires the document to be compiled with a specific engine. Notable examples are fontspec and polyglossia packages, which require Lua@TeX{} and Xe@TeX{} engines. If you try to @@ -3034,6 +3051,16 @@ file:line:error which is similar to the way many compilers format them. If non-nil, @TeX{} will produce file:line:error style error messages. @end defopt +@ConTeXt{} users can choose between Mark II and Mark IV versions. This +is controlled by @code{ConTeXt-Mark-version} option. + +@defopt ConTeXt-Mark-version +This variables specifies which version of Mark should be used. Values +currently supported are @code{"II"}, the default, and @code{"IV"}. It +can be set globally using customization interface or on a per-file +basis, by specifying it as a file variable. +@end defopt + @node Viewing @section Viewing the Formatted Output @cindex Viewing @@ -3572,9 +3599,11 @@ the compiled output document as its argument. This is useful for automatically refreshing the viewer after re-compilation especially when using Emacs viewers such as DocView or -PDF Tools. +PDF Tools. The function @code{TeX-revert-document-buffer} can be added +to the hook for this purpose. @end defvr @vindex TeX-after-TeX-LaTeX-command-finished-hook +@findex TeX-revert-document-buffer @node Multifile @section Multifile Documents @@ -3645,6 +3674,9 @@ file itself. If the variable is @code{shared}, then @AUCTeX{} will query for the name, but will not change the file. + +If the variable is @code{dwim}, @AUCTeX{} will try to avoid querying by +attempting to ``do what I mean''; and then change the file. @end defopt @defopt TeX-one-master diff --git a/doc/changes.texi b/doc/changes.texi index 0ed617e..a48e7ab 100644 --- a/doc/changes.texi +++ b/doc/changes.texi @@ -8,7 +8,7 @@ @end ifset -@heading News since 11.88 +@heading News in 11.89 @itemize @bullet @item @@ -30,6 +30,11 @@ Forward and backward search with Evince now also work when only a region of the document is compiled/viewed. @item +To open the PDF output file you can now use also PDF Tools, a document +viewer for Emacs. With it, as a plus, forward and backward search is +accurate at word level. + +@item With new option @code{TeX-PDF-via-dvips-ps2pdf} it is possible to compile a document to @acronym{DVI} and then convert it to @acronym{PDF} using @command{dvips}--@command{ps2pdf} before viewing it. @@ -56,9 +61,25 @@ built-in expanders. You might want to keep in @code{TeX-expand-list} only new expansion strings. @item -When new option @code{TeX-check-engine} is non-nil, before running -@LaTeX{} commands @AUCTeX{} will check whether the correct engine has -been set, based upon known restrictions posed by @LaTeX{} packages. +Before running commands like @TeX{} and @LaTeX{}, now @AUCTeX{} performs +some checks. If @code{TeX-check-TeX} is non-nil, it will test whether a +working @TeX{} distribution is actually present in the system and +available to Emacs. Instead, when @code{TeX-check-engine} is non-nil, +before running @LaTeX{} commands @AUCTeX{} will check whether the +correct engine has been set, based upon known restrictions posed by +@LaTeX{} packages. + +@item +Basic support to @ConTeXt{} Mark IV has been added. Users can now +select the Mark version to be used with new option +@code{ConTeXt-Mark-version}, and @AUCTeX{} is able to catch error +messages in the output log of a Mark IV document. + +@item +Support for tons of @LaTeX{} packages has been addedd. + +@item +Numbers of bugs have been fixed, many minor features have been addedd. @end itemize @heading News in 11.88 @@ -192,7 +213,7 @@ in the right context. There have been lots of bug fixes and feature additions. @end itemize -@heading News since 11.87 +@heading News in 11.87 @itemize @bullet @item diff --git a/doc/tex-ref.tex b/doc/tex-ref.tex index de7edb8..5151a3d 100644 --- a/doc/tex-ref.tex +++ b/doc/tex-ref.tex @@ -1,4 +1,4 @@ -% Reference Card for AUCTeX version 11.88 +% Reference Card for AUCTeX version 11.89 %**start of header \newcount\columnsperpage @@ -42,9 +42,9 @@ % Paul Rubin, Bob Chassell, Len Tower, and Richard Mlynarik % for creating the GNU Emacs Reference Card from which this was mutated -\def\versionnumber{11.88} -\def\year{2014} -\def\version{October \year\ v\versionnumber} +\def\versionnumber{11.89} +\def\year{2015} +\def\version{November \year\ v\versionnumber} \def\shortcopyrightnotice{\vskip 1ex plus 2 fill \centerline{\small \copyright\ \year\ Free Software Foundation, Inc. diff --git a/latex.el b/latex.el index ade8c6c..69cbf04 100644 --- a/latex.el +++ b/latex.el @@ -1,6 +1,6 @@ ;;; latex.el --- Support for LaTeX documents. -;; Copyright (C) 1991, 1993-2014 Free Software Foundation, Inc. +;; Copyright (C) 1991, 1993-2015 Free Software Foundation, Inc. ;; Maintainer: auctex-de...@gnu.org ;; Keywords: tex @@ -2052,14 +2052,14 @@ OPTIONAL and IGNORE are ignored." (crm-separator ",") style var options) (unless LaTeX-global-class-files - (if (if (eq TeX-arg-input-file-search 'ask) - (not (y-or-n-p "Find class yourself? ")) - TeX-arg-input-file-search) - (progn - (message "Searching for LaTeX classes...") - (setq LaTeX-global-class-files - (mapcar 'identity (TeX-search-files-by-type 'texinputs 'global t t)))) - LaTeX-style-list)) + (setq LaTeX-global-class-files + (if (if (eq TeX-arg-input-file-search 'ask) + (not (y-or-n-p "Find class yourself? ")) + TeX-arg-input-file-search) + (progn + (message "Searching for LaTeX classes...") + (mapcar 'identity (TeX-search-files-by-type 'texinputs 'global t t))) + LaTeX-style-list))) (setq style (completing-read (concat "Document class: (default " LaTeX-default-style ") ") LaTeX-global-class-files nil nil nil nil LaTeX-default-style)) @@ -3357,7 +3357,9 @@ recognized." ;;; Filling -(defcustom LaTeX-fill-break-at-separators '(\\\( \\\) \\\[ \\\]) +;; The default value should try not to break formulae across lines (this is +;; useful for preview-latex) and give a meaningful filling. +(defcustom LaTeX-fill-break-at-separators '(\\\( \\\[) "List of separators before or after which respectively a line break will be inserted if they do not fit into one line." :group 'LaTeX diff --git a/latex/preview.dtx b/latex/preview.dtx index 0675c27..0e220cd 100644 --- a/latex/preview.dtx +++ b/latex/preview.dtx @@ -439,7 +439,7 @@ \NeedsTeXFormat{LaTeX2e} \def\reserved@a #1#2$#3: #4${\xdef#1{\reserved@c #2#4 $}} \def\reserved@c #1 #2${#1} \begingroup \catcode`\_=12 -\reserved@a\pr@version $Name: release_11_88 $ \ifx\pr@version\@empty +\reserved@a\pr@version $Name: release_11_89 $ \ifx\pr@version\@empty \reserved@a\pr@version CVS-$Revision: 1.126 $ \endgroup \else \def\next release_{} \lccode`\_=`. \edef\next{\lowercase{\endgroup diff --git a/style/Alegreya.el b/style/Alegreya.el index e2a444f..70e69e0 100644 --- a/style/Alegreya.el +++ b/style/Alegreya.el @@ -1,4 +1,4 @@ -;;; Alegreya.el --- AUCTeX style for `Alegreya.sty' (v2015/09/02) +;;; Alegreya.el --- AUCTeX style for `Alegreya.sty' (v2015/10/22) ;; Copyright (C) 2015 Free Software Foundation, Inc. @@ -26,7 +26,7 @@ ;;; Commentary: -;; This file adds support for `Alegreya.sty' (v2015/09/02). +;; This file adds support for `Alegreya.sty' (v2015/10/22). ;; `Alegreya.sty' is part of TeXLive. ;;; Code: @@ -49,7 +49,6 @@ '("useosf") ;; Text commands '("Alegreya" -1) - '("AlegreyaSC" -1) '("AlegreyaBlack" -1) '("AlegreyaLF" -1) '("AlegreyaOsF" -1) @@ -67,7 +66,6 @@ ("textin" "{")) 'type-command) (font-latex-add-keywords '(("Alegreya" "") - ("AlegreyaSC" "") ("AlegreyaBlack" "") ("AlegreyaLF" "") ("AlegreyaOsF" "") diff --git a/style/AlegreyaSans.el b/style/AlegreyaSans.el index 4d9b497..494890d 100644 --- a/style/AlegreyaSans.el +++ b/style/AlegreyaSans.el @@ -1,4 +1,4 @@ -;;; AlegreyaSans.el --- AUCTeX style for `AlegreyaSans.sty' (v2015/09/02) +;;; AlegreyaSans.el --- AUCTeX style for `AlegreyaSans.sty' (v2015/10/22) ;; Copyright (C) 2015 Free Software Foundation, Inc. @@ -26,7 +26,7 @@ ;;; Commentary: -;; This file adds support for `AlegreyaSans.sty' (v2015/09/02). +;; This file adds support for `AlegreyaSans.sty' (v2015/10/22). ;; `AlegreyaSans.sty' is part of TeXLive. ;;; Code: @@ -58,7 +58,6 @@ '("AlegreyaSansMedium" -1) '("AlegreyaSansExtraBold" -1) '("AlegreyaSansBlack" -1) - '("AlegreyaSansSC" -1) '("textsu" t) ; superior figures '("sufigures" -1) ; '("textin" t) ; inferior figures @@ -79,7 +78,6 @@ ("AlegreyaSansMedium" "") ("AlegreyaSansExtraBold" "") ("AlegreyaSansBlack" "") - ("AlegreyaSansSC" "") ("sufigures" "") ("infigures" "")) 'type-declaration))) diff --git a/style/amsthm.el b/style/amsthm.el index 57f2315..8bc33d4 100644 --- a/style/amsthm.el +++ b/style/amsthm.el @@ -1,6 +1,6 @@ ;;; amsthm.el --- Style hook for the AMS-LaTeX amsthm package. -;; Copyright (C) 1997, 2013, 2014 Free Software Foundation, Inc. +;; Copyright (C) 1997, 2013--2015 Free Software Foundation, Inc. ;; Author: Carsten Dominik <domi...@strw.leidenuniv.nl> ;; Maintainer: auctex-de...@gnu.org @@ -22,51 +22,143 @@ ;; Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA ;; 02110-1301, USA. +;;; 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. + ;;; Code: (defvar LaTeX-amsthm-package-options nil "Package options for the amsthm package.") +(defvar LaTeX-amsthm-theoremstyle-list + '(("plain") ("definition") ("remark")) + "List of theorem styles provided by `amsthm.el' and new ones +defined with \"\\newtheoremstyle\".") + +(defvar LaTeX-amsthm-fontdecl + (mapcar (lambda (elt) (concat TeX-esc elt)) + '("itshape" "bfseries" "scshape" + "ttfamily" "upshape" "mdseries" + "rmfamily" "sffamily" "slshape")) + "List of font declaration commands for \"\\newtheoremstyle\".") + +(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', e.g. + + (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))) + +;; Needed for auto-parsing +(require 'tex) + +;; Setup parsing for \newtheorem +(TeX-auto-add-type "amsthm-newtheorem" "LaTeX") + +;; Setup parsing for \newtheoremstyle +(TeX-auto-add-type "amsthm-newtheoremstyle" "LaTeX") + +(defun LaTeX-amsthm-auto-prepare () + "Clear `LaTeX-auto-amsthm-newtheorem' and +`LaTeX-auto-amsthm-newtheoremstyle' before parsing." + (setq LaTeX-auto-amsthm-newtheorem nil) + (setq LaTeX-auto-amsthm-newtheoremstyle nil)) + +(defun LaTeX-amsthm-auto-cleanup () + "Move parsed results from `LaTeX-auto-amsthm-newtheorem' and +make them available as new environments. Update +`LaTeX-amsthm-theoremstyle-list' with styles defined with +\"\\newtheoremstyle\"." + (dolist (newthm (mapcar 'car (LaTeX-amsthm-newtheorem-list))) + (LaTeX-add-environments (list newthm 'LaTeX-amsthm-env-label))) + (dolist (newthmstyle (LaTeX-amsthm-newtheoremstyle-list)) + (add-to-list (make-local-variable 'LaTeX-amsthm-theoremstyle-list) + newthmstyle))) + +(add-hook 'TeX-auto-prepare-hook #'LaTeX-amsthm-auto-prepare t) +(add-hook 'TeX-auto-prepare-hook #'LaTeX-amsthm-auto-cleanup t) +(add-hook 'TeX-update-style-hook #'TeX-auto-parse t) + (TeX-add-style-hook "amsthm" (lambda () (LaTeX-add-environments - '("proof" (lambda (env &rest ignore) - (LaTeX-insert-environment - env - (let ((heading (TeX-read-string "(optional) Heading: "))) - (if (string= heading "") - "" - (format "[%s]" heading)))))) - ) + '("proof" LaTeX-amsthm-env-label)) (TeX-add-symbols - '("newtheorem*" TeX-arg-define-environment "Heading") - '("theoremstyle" LaTeX-amsthm-complete-theoremstyle) + '("newtheorem*" + (TeX-arg-eval + (lambda () + (let ((nthm (TeX-read-string + (TeX-argument-prompt nil nil "Environment"))) + (heading (TeX-read-string + (TeX-argument-prompt nil nil "Heading")))) + (LaTeX-add-amsthm-newtheorems nthm) + (LaTeX-add-environments (list nthm 'LaTeX-amsthm-env-label)) + (insert (concat TeX-grop nthm TeX-grcl)) + (format "%s" heading))))) + + '("theoremstyle" + (TeX-arg-eval completing-read + "Style: " + LaTeX-amsthm-theoremstyle-list)) "qedhere" "swapnumbers" - '("newtheoremstyle" "Style name" (TeX-arg-length nil "Space above") - (TeX-arg-length nil "Space below") "Body font" "Indent amount" - "Theorem head font" "Punctuation after head" - (TeX-arg-length nil "Space after head") "Theorem head spec")) + + '("newtheoremstyle" + (TeX-arg-eval + (lambda () + (let ((nthmstyle (TeX-read-string + (TeX-argument-prompt nil nil "Style name")))) + (LaTeX-add-amsthm-newtheoremstyles nthmstyle) + (add-to-list (make-local-variable 'LaTeX-amsthm-theoremstyle-list) + (list nthmstyle)) + (format "%s" nthmstyle)))) + (TeX-arg-length "Space above") + (TeX-arg-length "Space below") + (TeX-arg-eval completing-read + "Body font: " LaTeX-amsthm-fontdecl) + "Indent amount" + (TeX-arg-eval completing-read + "Theorem head font: " LaTeX-amsthm-fontdecl) + "Punctuation after head" + (TeX-arg-length "Space after head") + "Theorem head spec")) (TeX-auto-add-regexp - `(,(concat "\\\\newtheorem\\*{\\(" TeX-token-char "+\\)}") - 1 LaTeX-auto-environment)) + `(,(concat "\\\\newtheorem\\*?{\\(" TeX-token-char "+\\)}") + 1 LaTeX-auto-amsthm-newtheorem)) + (TeX-auto-add-regexp + `(,(concat "\\\\newtheoremstyle{\\(" TeX-token-char "+\\)}") + 1 LaTeX-auto-amsthm-newtheoremstyle)) ;; Fontification (when (and (featurep 'font-latex) (eq TeX-install-font-lock 'font-latex-setup)) - (font-latex-add-keywords '(("newtheorem" "*{[{[") - ("theoremstyle" "{") + (font-latex-add-keywords '(("newtheorem" "*{[{[") + ("theoremstyle" "{") ("newtheoremstyle" "{{{{{{{{{")) 'function))) LaTeX-dialect) -(defun LaTeX-amsthm-complete-theoremstyle (&rest ignore) - (insert TeX-grop - (completing-read "Style: " '(("plain" . nil) - ("definition" . nil) - ("remark" . nil))) - TeX-grcl)) - ;;; amsthm.el ends here diff --git a/style/caption.el b/style/caption.el index 4412443..4e394f0 100644 --- a/style/caption.el +++ b/style/caption.el @@ -221,7 +221,7 @@ suffix of the command." (defun LaTeX-arg-caption-captionbox (optional &optional star prompt) "Query for the arguments of `\\captionbox' incl. a label and -insert them. If STAR is t, then do not query for a `\\label' and +insert them. If STAR is non-nil, then do not query for a `\\label' and insert only a caption." (let ((caption (TeX-read-string (TeX-argument-prompt optional prompt "Caption")))) diff --git a/style/enumitem.el b/style/enumitem.el index dff94aa..a527c86 100644 --- a/style/enumitem.el +++ b/style/enumitem.el @@ -116,11 +116,6 @@ plus available through `enumitem' package.") "List of description like environments defined by command `\\newlist' from `enumitem' package.") -(defvar LaTeX-enumitem-newlist-list-item-arg-local nil - "Local list of all description like environments defined by command -`\\newlist' plus available through `enumitem' package.") -(make-variable-buffer-local 'LaTeX-enumitem-newlist-list-item-arg-local) - (defvar LaTeX-auto-enumitem-newlist nil "Temporary for parsing the arguments of `\\newlist' from `enumitem' package.") @@ -183,7 +178,16 @@ package.") (when (or (string-equal type "description") (string-equal type "description*")) (add-to-list 'LaTeX-enumitem-newlist-list-item-arg - (list env)))))) + (list env))))) + ;; Now add the parsed env's to the local list. + (when LaTeX-enumitem-newlist-list + (setq LaTeX-enumitem-newlist-list-local + (append LaTeX-enumitem-newlist-list + LaTeX-enumitem-newlist-list-local))) + ;; Tell AUCTeX about parsed description like environments. + (when LaTeX-enumitem-newlist-list-item-arg + (dolist (env LaTeX-enumitem-newlist-list-item-arg) + (add-to-list 'LaTeX-item-list `(,(car env) . LaTeX-item-argument))))) (add-hook 'TeX-auto-prepare-hook #'LaTeX-enumitem-auto-prepare t) (add-hook 'TeX-auto-cleanup-hook #'LaTeX-enumitem-auto-cleanup t) @@ -302,19 +306,6 @@ in `enumitem'-completions." (append '(("itemize*") ("enumerate*") ("description*")) LaTeX-enumitem-newlist-list-local))) - ;; Now add the parsed env's to the local list. - (setq LaTeX-enumitem-newlist-list-local - (append LaTeX-enumitem-newlist-list - LaTeX-enumitem-newlist-list-local)) - - ;; Move parsed description like env's into a local variable. - (setq LaTeX-enumitem-newlist-list-item-arg-local - LaTeX-enumitem-newlist-list-item-arg) - - ;; Tell AUCTeX about special items parsed - (dolist (env LaTeX-enumitem-newlist-list-item-arg-local) - (add-to-list 'LaTeX-item-list `(,(car env) . LaTeX-item-argument))) - ;; Standard env's take key-val as optional argument. (LaTeX-add-environments '("itemize" LaTeX-enumitem-env-with-opts) diff --git a/style/hologo.el b/style/hologo.el new file mode 100644 index 0000000..1795870 --- /dev/null +++ b/style/hologo.el @@ -0,0 +1,233 @@ +;;; holog.el --- AUCTeX style for `hologo.sty' (v1.10) + +;; Copyright (C) 2015 Free Software Foundation, Inc. + +;; Author: Arash Esbati <esbati'at'gmx.de> +;; Maintainer: auctex-de...@gnu.org +;; Created: 2015-10-31 +;; 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 `hologo.sty' (v1.10) from 2012/04/26. +;; `hologo.sty' is part of TeXLive. + +;;; Code: + +(defvar LaTeX-hologo-logo-names + '("(La)TeX" + "AmSLaTeX" + "AmSTeX" + "biber" + "BibTeX" + "BibTeX8" + "ConTeXt" + "emTeX" + "eTeX" + "ExTeX" + "HanTheThanh" + "iniTeX" + "KOMAScript" + "La" + "LaTeX" + "LaTeX2e" + "LaTeX3" + "LaTeXe" + "LaTeXML" + "LaTeXTeX" + "LuaLaTeX" + "LuaTeX" + "LyX" + "METAFONT" + "MetaFun" + "METAPOST" + "MetaPost" + "MiKTeX" + "NTS" + "OzMF" + "OzMP" + "OzTeX" + "OzTtH" + "PCTeX" + "pdfTeX" + "pdfLaTeX" + "PiC" + "PiCTeX" + "plainTeX" + "SageTeX" + "SLiTeX" + "SliTeX" + "teTeX" + "TeX" + "TeX4ht" + "TTH" + "virTeX" + "VTeX" + "Xe" + "XeLaTeX" + "XeTeX") + "List of logos provided by \"hologo.sty\".") + +(defvar LaTeX-hologo-key-val-options-global + '(("break" ("true" "false")) + ("hyphenbreak" ("true" "false")) + ("spacebreak" ("true" "false")) + ("discretionarybreak" ("true" "false"))) + "Global key=value options for hologo macros.") + +(defvar LaTeX-hologo-key-val-options-local + '(("variant" ("sf" "sc" ; BibTeX + "lift" ; SliTeX + "narrow" "simple" ; SliTeX, ConTeXt + "space" "hyphen" "runtogether"))) ; plainTeX + "Local key=value options for hologo macros.") + +(TeX-add-style-hook + "hologo" + (lambda () + (TeX-add-symbols + + ;; Insert logo macros + '("hologo" (TeX-arg-eval completing-read + "Logo name: " LaTeX-hologo-logo-names)) + + '("Hologo" (TeX-arg-eval completing-read + "Logo name: " LaTeX-hologo-logo-names)) + + ;; 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 optional) + (format "%s" keyval))))) + + '("hologoDriverSetup" (TeX-arg-eval completing-read + "Driver: " + '("pdftex" "luatex" + "dvipdfm" "dvipdfmx" + "dvips" "dvipsone" "xdvi" + "xetex" "vtex" "driverfallback"))) + + '("hologoFontSetup" + (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 optional) + (format "%s" keyval))))) + + ;; Additional user macros + '("hologoVariant" + (TeX-arg-eval completing-read + "Logo name: " LaTeX-hologo-logo-names) + (TeX-arg-eval + (lambda () + (let ((setup (TeX-read-key-val + nil + (append LaTeX-hologo-key-val-options-local + LaTeX-hologo-key-val-options-global)))) + (format "%s" setup))))) + + '("HologoVariant" + (TeX-arg-eval completing-read + "Logo name: " LaTeX-hologo-logo-names) + (TeX-arg-eval + (lambda () + (let ((setup (TeX-read-key-val + nil + (append LaTeX-hologo-key-val-options-local + LaTeX-hologo-key-val-options-global)))) + (format "%s" setup))))) + + '("hologoList" 0) + + '("hologoEntry" "Logo name" "Variant" "Since")) + + ;; Fontification + (when (and (featurep 'font-latex) + (eq TeX-install-font-lock 'font-latex-setup)) + (font-latex-add-keywords '(("hologo" "{") + ("Hologo" "{")) + 'textual) + (font-latex-add-keywords '(("hologoSetup" "{") + ("hologoLogoSetup" "{{") + ("hologoDriverSetup" "{") + ("hologoFontSetup" "{") + ("hologoLogoFontSetup" "{{") + ("hologoVariant" "{{") + ("HologoVariant" "{{") + ("hologoList" "") + ("hologoEntry" "{{{")) + 'function))) + LaTeX-dialect) + +(defvar LaTeX-hologo-package-options nil + "Package options for the hologo package.") + +;;; hologo.el ends here diff --git a/style/subcaption.el b/style/subcaption.el index 83b20a0..6205366 100644 --- a/style/subcaption.el +++ b/style/subcaption.el @@ -38,7 +38,7 @@ same values as \"labelformat\" from caption package.") (defun LaTeX-arg-subcaption-subcaption (optional &optional star prompt) "Query for the arguments of \\subcaption incl. a label and -insert them. If STAR is t, then do not query for the lof entry +insert them. If STAR is non-nil, then do not query for the lof entry and \\label and insert only a caption." (let ((lof (unless star (TeX-read-string @@ -56,7 +56,7 @@ and \\label and insert only a caption." (defun LaTeX-arg-subcaption-subcaptionbox (optional &optional star prompt) "Query for the arguments of \\subcaptionbox incl. a label and -insert them. If STAR is t, then do not query for a \\label and +insert them. If STAR is non-nil, then do not query for a \\label and insert only a caption." (let ((caption (TeX-read-string (TeX-argument-prompt optional prompt "Sub-caption")))) diff --git a/tests/latex/latex-filling-in.tex b/tests/latex/latex-filling-in.tex new file mode 100644 index 0000000..4cc184b --- /dev/null +++ b/tests/latex/latex-filling-in.tex @@ -0,0 +1 @@ +Lorem ipsum dolor sit amet, consectetur adipisci elit, sed eiusmod \(0 = 1\) tempor incidunt ut $a^{2} + b^{2} = c^{2}$ labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur. diff --git a/tests/latex/latex-filling-out.tex b/tests/latex/latex-filling-out.tex new file mode 100644 index 0000000..cdb767a --- /dev/null +++ b/tests/latex/latex-filling-out.tex @@ -0,0 +1,5 @@ +Lorem ipsum dolor sit amet, consectetur adipisci elit, sed eiusmod +\(0 = 1\) tempor incidunt ut $a^{2} + b^{2} = c^{2}$ labore et dolore +magna aliqua. Ut enim ad minim veniam, quis nostrum exercitationem +ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi +consequatur. diff --git a/tests/latex/latex-test.el b/tests/latex/latex-test.el index ac662db..cc23caf 100644 --- a/tests/latex/latex-test.el +++ b/tests/latex/latex-test.el @@ -1,6 +1,6 @@ ;;; latex-test.el --- tests for LaTeX mode -;; Copyright (C) 2014 Free Software Foundation, Inc. +;; Copyright (C) 2014, 2015 Free Software Foundation, Inc. ;; This file is part of AUCTeX. @@ -24,14 +24,31 @@ (require 'ert) (require 'latex) -(defvar LaTeX-indent-tabular-test/in - (expand-file-name "tabular-in.tex" - (when load-file-name - (file-name-directory load-file-name)))) -(defvar LaTeX-indent-tabular-test/out - (expand-file-name "tabular-out.tex" - (when load-file-name - (file-name-directory load-file-name)))) +(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 + 'LaTeX-indent-tabular-test/in + "tabular-in.tex" + 'LaTeX-indent-tabular-test/out + "tabular-out.tex" + 'LaTeX-filling/in + "latex-filling-in.tex" + 'LaTeX-filling/out + "latex-filling-out.tex" + 'LaTeX-math-indent/in + "math-indent-in.tex" + 'LaTeX-math-indent/out + "math-indent-out.tex") (ert-deftest LaTeX-indent-tabular () (should (string= @@ -44,4 +61,49 @@ (insert-file-contents LaTeX-indent-tabular-test/out) (buffer-string))))) +;; Another test for indentation, but for math mode, see +;; https://debbugs.gnu.org/cgi/bugreport.cgi?bug=20227 Let's keep those tests +;; separated so it would be easier to find the culprit of a future failure. +(ert-deftest LaTeX-math-indent () + (should (string= + (with-temp-buffer + (insert-file-contents LaTeX-math-indent/in) + (LaTeX-mode) + (indent-region (point-min) (point-max)) + (buffer-string)) + (with-temp-buffer + (insert-file-contents LaTeX-math-indent/out) + (buffer-string))))) + +;; Test LaTeX code with math modes is indented as expected. This has mostly to +;; do with the value of `LaTeX-fill-break-at-separators' and how +;; `LaTeX-fill-move-to-break-point' handles it. If the test fails, try to look +;; there. +(ert-deftest LaTeX-filling () + (should (string= + (with-temp-buffer + (insert-file-contents LaTeX-filling/in) + (LaTeX-mode) + (let ((fill-column 70)) + (fill-paragraph)) + (buffer-string)) + (with-temp-buffer + (insert-file-contents LaTeX-filling/out) + (buffer-string))))) + +;; Test for bug#19281 (https://debbugs.gnu.org/cgi/bugreport.cgi?bug=19281): +;; make sure AUCTeX is able to insert and modify an environment containing a +;; TeX-esc and braces in its name. +(ert-deftest LaTeX-change-environment-with-esc () + (should (string= + (with-temp-buffer + (LaTeX-mode) + (LaTeX-insert-environment (concat TeX-esc "foo{bar}")) + (LaTeX-modify-environment "foobar") + (buffer-string)) + (with-temp-buffer + (LaTeX-mode) + (LaTeX-insert-environment "foobar") + (buffer-string))))) + ;;; latex-test.el ends here diff --git a/tests/latex/math-indent-in.tex b/tests/latex/math-indent-in.tex new file mode 100644 index 0000000..16acac6 --- /dev/null +++ b/tests/latex/math-indent-in.tex @@ -0,0 +1,17 @@ +\[ +x +\] + +\[ +\begin{split} +x &= y \\ +y &= z +\end{split} +\] + +\begin{itemize} +\item Some text here +\[ +x +\] +\end{itemize} diff --git a/tests/latex/math-indent-out.tex b/tests/latex/math-indent-out.tex new file mode 100644 index 0000000..e895be2 --- /dev/null +++ b/tests/latex/math-indent-out.tex @@ -0,0 +1,17 @@ +\[ + x +\] + +\[ + \begin{split} + x &= y \\ + y &= z + \end{split} +\] + +\begin{itemize} +\item Some text here + \[ + x + \] +\end{itemize} diff --git a/tex-buf.el b/tex-buf.el index ec3653c..bc19f7d 100644 --- a/tex-buf.el +++ b/tex-buf.el @@ -437,6 +437,16 @@ Do you want to select one of these engines?" (add-file-local-variable 'TeX-engine engine) (save-buffer)))))) +(defcustom TeX-check-TeX t + "Whether AUCTeX should check if a working TeX distribution is present." + :group 'TeX-command + :type 'boolean) + +(defcustom TeX-check-TeX-command-not-found 127 + "Numerical code returned by shell for a command not found error." + :group 'TeX-command + :type 'integer) + (defun TeX-command (name file &optional override-confirm) "Run command NAME on the file returned by calling FILE. @@ -481,8 +491,11 @@ been set." ;; Before running some commands, check that AUCTeX is able to find "tex" ;; program. - (and (member name '("TeX" "LaTeX" "AmSTeX" "ConTeXt" "ConTeXt Full")) - (not (executable-find TeX-command)) + (and TeX-check-TeX + (member name '("TeX" "LaTeX" "AmSTeX" "ConTeXt" "ConTeXt Full")) + (= TeX-check-TeX-command-not-found + (call-process TeX-shell nil nil nil + TeX-shell-command-option TeX-command)) (error (format "ERROR: AUCTeX cannot find a working TeX distribution. Make sure you have one and that TeX binaries are in PATH environment variable%s" (if (eq system-type 'darwin) @@ -876,7 +889,24 @@ the current style options." "Hook being run after TeX/LaTeX finished successfully. The functions in this hook are run with the DVI/PDF output file given as argument. Using this hook can be useful for updating -the viewer automatically after re-compilation of the document.") +the viewer automatically after re-compilation of the document. + +If you use an emacs-internal viewer such as `doc-view-mode' or +`pdf-view-mode', add `TeX-revert-document-buffer' to this hook.") + +(defun TeX-revert-document-buffer (file) + "Revert the buffer visiting FILE. +This function is intended to be used in +`TeX-after-TeX-LaTeX-command-finished-hook' for users that view +their compiled document with an emacs viewer such as +`doc-view-mode' or `pdf-view-mode'. (Note that this function +just calls `revert-buffer' in the respective buffer and thus +requires that the corresponding mode defines a sensible +`revert-buffer-function'.)" + (let ((buf (find-buffer-visiting file))) + (when buf + (with-current-buffer buf + (revert-buffer nil t t))))) (defvar TeX-after-start-process-function nil "Hooks to run after starting an asynchronous process. diff --git a/tex-info.el b/tex-info.el index 40b0391..0433b0a 100644 --- a/tex-info.el +++ b/tex-info.el @@ -1,6 +1,6 @@ ;;; tex-info.el --- Support for editing Texinfo source. -;; Copyright (C) 1993, 1994, 1997, 2000, 2001, 2004, 2005, 2006, 2011, 2014 +;; Copyright (C) 1993, 1994, 1997, 2000, 2001, 2004, 2005, 2006, 2011-2015 ;; Free Software Foundation, Inc. ;; Maintainer: auctex-de...@gnu.org @@ -290,6 +290,63 @@ beginning of keyword `@node' or `@bye'." (goto-char beg) (TeX-activate-region) ))) +(defun Texinfo-nodename-de-escape (node-name) + "In NODE-NAME, convert `@comma{}' commands to the corresponding `,' +character. Return the resulting string." + (let ((pos 0) (map '(("comma" . ",")))) + (while (and (< pos (length + node-name)) (string-match "@\\(comma\\)[[:blank:]]*{}" node-name pos)) + (setq node-name (concat (substring node-name 0 (match-beginning 0)) + (cdr (TeX-assoc-string (match-string 1 node-name) map)) + (substring node-name (match-end 0))) + pos (1+ (match-beginning 0))))) + node-name) + + +(defun Texinfo-nodename-escape (node-name) + "Convert in NODE-NAME the `,' characters to `@comma{}' +commands. Return the resulting string." + (let* ((pos 0) + (map '(("," . "comma"))) + (re (regexp-opt (mapcar 'car map))) ) + (while (and (< pos (length node-name)) (string-match re node-name pos)) + (setq node-name (concat (substring node-name 0 (match-beginning 0)) + "@" (cdr (TeX-assoc-string (match-string 0 node-name) map)) + "{}" + (substring node-name (match-end 0))) + pos (1+ (match-beginning 0))))) + node-name) + + +(defun Texinfo-make-node-list () + ;; Build list of nodes in current buffer. + ;; (What about using `imenu--index-alist'?) + ;; FIXME: Support multi-file documents. + (save-excursion + (goto-char (point-min)) + (let (nodes dups) + (while (re-search-forward "^@node\\b" nil t) + (skip-chars-forward "[:blank:]") + (pushnew (list (Texinfo-nodename-de-escape + (buffer-substring-no-properties + (point) (progn (skip-chars-forward "^\r\n,") + (skip-chars-backward "[:blank:]") + (point))))) + nodes + :test (lambda (a b) + (when (equal a b) + (push (cons a (line-number-at-pos (point))) dups) + t)))) + (when dups + (display-warning + 'AUCTeX + (format "There are duplicate nodes:\n%s" + (mapconcat (lambda (dup) + (format " %s on line %d" (car dup) (cdr dup))) + (nreverse dups) + "\n")))) + (nreverse nodes)))) + (defun Texinfo-insert-node () "Insert a Texinfo node in the current buffer. That means, insert the string `@node' and prompt for current, @@ -299,26 +356,20 @@ a comment on the following line indicating the order of arguments for @node." (interactive) (let ((active-mark (and (TeX-active-mark) (not (eq (mark) (point))))) - nodes node-name next-node previous-node up-node) - ;; Build list of nodes in current buffer. - ;; (What about using `imenu--index-alist'?) - ;; FIXME: Support multi-file documents. - (save-excursion - (goto-char (point-min)) - (while (re-search-forward "^@node\\b" nil t) - (skip-chars-forward " \t") - (pushnew (list (buffer-substring-no-properties - (point) (progn (skip-chars-forward "^,") - (point)))) - nodes :test #'equal))) + (nodes (Texinfo-make-node-list)) + node-name next-node previous-node up-node) (unless active-mark - (setq node-name (TeX-read-string "Node name: "))) + (setq node-name (Texinfo-nodename-escape + (TeX-read-string "Node name: ")))) ;; FIXME: What if key binding for `minibuffer-complete' was changed? ;; `substitute-command-keys' doesn't return the correct value. - (setq next-node (completing-read "Next node (TAB completes): " nodes)) + (setq next-node (Texinfo-nodename-escape + (completing-read "Next node (TAB completes): " nodes))) (setq previous-node - (completing-read "Previous node (TAB completes): " nodes)) - (setq up-node (completing-read "Upper node (TAB completes): " nodes)) + (Texinfo-nodename-escape + (completing-read "Previous node (TAB completes): " nodes))) + (setq up-node (Texinfo-nodename-escape + (completing-read "Upper node (TAB completes): " nodes))) (when (and active-mark (< (mark) (point))) (exchange-point-and-mark)) @@ -344,6 +395,18 @@ for @node." (progn (skip-chars-forward "^,") (forward-char 2)) (throw 'break nil))))))) +(defun Texinfo-arg-nodename (optional &optional prompt definition) + "Prompt for a node name completing with known node names. +OPTIONAL is ignored. +Use PROMPT as the prompt string. +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") + (Texinfo-make-node-list)))) + (insert "{" (Texinfo-nodename-escape node-name) "}" ))) + ;; Silence the byte-compiler from warnings for variables and functions declared ;; in reftex. (defvar reftex-section-levels-all) @@ -539,6 +602,7 @@ value of `Texinfo-mode-hook'." (interactive) (kill-all-local-variables) (setq TeX-mode-p t) + (setq TeX-output-extension (if TeX-PDF-mode "pdf" "dvi")) (setq TeX-sentinel-default-function 'TeX-TeX-sentinel) ;; Mostly stolen from texinfo.el (setq TeX-base-mode-name "Texinfo") @@ -562,9 +626,8 @@ value of `Texinfo-mode-hook'." (set (make-local-variable 'comment-start-skip) "@c +\\|@comment +") (set (make-local-variable 'comment-use-syntax) nil) (set (make-local-variable 'words-include-escapes) t) - (if (boundp 'texinfo-imenu-generic-expression) - ;; This was introduced in 19.30. - (set (make-local-variable 'imenu-generic-expression) texinfo-imenu-generic-expression)) + (set (make-local-variable 'imenu-generic-expression) + texinfo-imenu-generic-expression) (set (make-local-variable 'font-lock-defaults) ;; COMPATIBILITY for Emacs 20 @@ -573,15 +636,16 @@ value of `Texinfo-mode-hook'." nil nil nil backward-paragraph (font-lock-syntactic-keywords . texinfo-font-lock-syntactic-keywords)) - '(texinfo-font-lock-keywords t))) - (if (not (boundp 'texinfo-section-list)) - ;; This was included in 19.31. - () - (set (make-local-variable 'outline-regexp) - (concat "@\\(" - (mapconcat 'car texinfo-section-list "\\>\\|") - "\\>\\)")) - (set (make-local-variable 'outline-level) 'texinfo-outline-level)) + ;; This is for Emacs >= 23.3, when + ;; `texinfo-font-lock-syntactic-keywords' was removed. + '(texinfo-font-lock-keywords nil nil nil backward-paragraph))) + + ;; Outline settings. + (set (make-local-variable 'outline-regexp) + (concat "@\\(" + (mapconcat 'car texinfo-section-list "\\>\\|") + "\\>\\)")) + (set (make-local-variable 'outline-level) 'texinfo-outline-level) ;; Mostly AUCTeX stuff (easy-menu-add Texinfo-mode-menu Texinfo-mode-map) @@ -664,7 +728,10 @@ value of `Texinfo-mode-hook'." '("findex" (TeX-arg-literal " ") (TeX-arg-free "Entry")) '("footnote" "Text of footnote") '("footnotestyle" (TeX-arg-literal " ") (TeX-arg-free "Style")) - '("group") + '("guillemetleft") + '("guillemetright") + '("guilsinglleft") + '("guilsinglright") '("heading" (TeX-arg-literal " ") (TeX-arg-free "Title")) ;; XXX: Would be nice with completion. '("headings" (TeX-arg-literal " ") (TeX-arg-free "On off single double")) @@ -695,10 +762,12 @@ value of `Texinfo-mode-hook'." '("point" nil) '("print") '("printindex" (TeX-arg-literal " ") (TeX-arg-free "Index name")) - '("pxref" "Node name") + '("pxref" (Texinfo-arg-nodename "Node name")) + '("quotedblbase") + '("quotesinglbase") '("r" "Text") '("raisesections" 0) - '("ref" "Node name") + '("ref" (Texinfo-arg-nodename "Node name")) '("refill") '("result") '("samp" "Text") @@ -745,7 +814,7 @@ value of `Texinfo-mode-hook'." '("vindex" (TeX-arg-literal " ") (TeX-arg-free "Entry")) '("vskip" (TeX-arg-literal " ") (TeX-arg-free "Amount")) '("w" "Text") - '("xref" "Node name")) + '("xref" (Texinfo-arg-nodename "Node name"))) ;; RefTeX plugging (add-hook 'reftex-mode-hook 'Texinfo-reftex-hook) diff --git a/tex.el b/tex.el index 6bd7a95..ce0c344 100644 --- a/tex.el +++ b/tex.el @@ -121,7 +121,7 @@ If nil, none is specified." ;; `TeX-expand-list-builtin' for a description of the % escapes (defcustom TeX-command-list - `(("TeX" "%(PDF)%(tex) %(file-line-error) %(extraopts) %`%S%(PDFout)%(mode)%' %t" + '(("TeX" "%(PDF)%(tex) %(file-line-error) %(extraopts) %`%S%(PDFout)%(mode)%' %t" TeX-run-TeX nil (plain-tex-mode ams-tex-mode texinfo-mode) :help "Run plain TeX") ("LaTeX" "%`%l%(mode)%' %t" @@ -143,10 +143,7 @@ If nil, none is specified." (context-mode) :help "Run ConTeXt until completion") ("BibTeX" "bibtex %s" TeX-run-BibTeX nil t :help "Run BibTeX") ("Biber" "biber %s" TeX-run-Biber nil t :help "Run Biber") - ,(if (or window-system (getenv "DISPLAY")) - '("View" "%V" TeX-run-discard-or-function t t :help "Run Viewer") - '("View" "dvi2tty -q -w 132 %s" TeX-run-command t t - :help "Run Text viewer")) + ("View" "%V" TeX-run-discard-or-function t t :help "Run Viewer") ("Print" "%p" TeX-run-command t t :help "Print the file") ("Queue" "%q" TeX-run-background nil t :help "View the printer queue" :visible TeX-queue-command) @@ -1119,6 +1116,12 @@ all the regular expressions must match for the element to apply." (string-match "pdf" (TeX-output-extension))) (output-html (string-match "html" (TeX-output-extension))) + (has-no-display-manager + ;; Compatibility for Emacs <= 22: older Emacsen don't have FRAME argument + ;; to `getenv', later versions have the `display-graphic-p' function. + (not (if (< emacs-major-version 23) + (or window-system (getenv "DISPLAY")) + (display-graphic-p)))) (style-pstricks (TeX-match-style "^pstricks$\\|^pst-\\|^psfrag$")) (engine-omega @@ -1275,7 +1278,8 @@ the requirements are met." ("displayline" "displayline %n %o %b" "displayline") ("open" "open %o" "open"))) (t - `(("xdvi" ("%(o?)xdvi" + `(("dvi2tty" ("dvi2tty -q -w 132 %o")) + ("xdvi" ("%(o?)xdvi" (mode-io-correlate " -sourceposition \"%n %b\" -editor \"%cS\"") ((paper-a4 paper-portrait) " -paper a4") ((paper-a4 paper-landscape) " -paper a4r") @@ -1389,7 +1393,8 @@ restarting Emacs." (output-pdf "open") (output-html "open"))) (t - '(((output-dvi style-pstricks) "dvips and gv") + '(((output-dvi has-no-display-manager) "dvi2tty") + ((output-dvi style-pstricks) "dvips and gv") (output-dvi "xdvi") (output-pdf "Evince") (output-html "xdg-open"))))