branch: main commit 17f588897feb284a072a4c2be929f6adadbd3490 Merge: 8c89edf0 ca40c6a9 Author: Tassilo Horn <t...@gnu.org> Commit: Tassilo Horn <t...@gnu.org>
Merge branch 'master' into elpa --- ChangeLog | 199 +++++++++++++++++++++++ Makefile.in | 26 ++- doc/Makefile.in | 14 +- doc/auctex.texi | 34 ++++ doc/install.texi | 26 ++- doc/wininstall.texi | 2 +- font-latex.el | 5 +- latex.el | 87 +++++++--- latex/Makefile.in | 14 +- style/bidibeamer.el | 40 +++++ style/caption.el | 311 ++++++++++++++++++++++++++++++++++++ style/color.el | 308 ++++++++++++++++++++++++++++++++++++ style/currvita.el | 94 +++++++++++ style/enumitem.el | 447 ++++++++++++++++++++++++++++++++++++++++++++++++++++ style/expl3.el | 51 ++++++ style/geometry.el | 150 ++++++++++++++++++ style/ltablex.el | 49 ++++++ style/ltxtable.el | 51 ++++++ style/mn2e.el | 175 ++++++++++++++++++++ style/tcolorbox.el | 82 ++++++++++ tex-buf.el | 87 +++++----- tex.el | 129 ++++++++------- 22 files changed, 2248 insertions(+), 133 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7d47bcdf..4b64c907 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,202 @@ +2015-03-17 Mos� Giordano <m...@gnu.org> + + * doc/wininstall.texi: Fix a broken link. + + * style/mn2e.el: New style file. + + * Makefile.in (STYLESRC): Activate new style. + +2015-03-15 Arash Esbati <esb...@gmx.de> + + * Makefile.in (STYLESRC): Add new style. + + * style/ltxtable.el: New file. + +2015-03-15 Arash Esbati <esb...@gmx.de> + + * Makefile.in (STYLESRC): Add new style. + + * style/ltablex.el: New file. + +2015-03-15 Arash Esbati <esb...@gmx.de> + + * style/enumitem.el (LaTeX-enumitem-SetEnumitemKey-regexp): Delete + match for the second argument. + (LaTeX-enumitem-SetEnumitemValue-regexp): Delete match for the + third argument. + (LaTeX-arg-SetEnumitemValue): Replace the randomly generated + number with something human-readable. + + * style/caption.el (LaTeX-caption-DeclareCaption-regexp): Delete + match for the second argument. + (LaTeX-arg-caption-DeclareCaption): Replace the randomly generated + number with something human-readable. + +2015-03-10 Tassilo Horn <t...@gnu.org> + + * tex.el (TeX-style-path): Replace `pushnew' with equivalent code + since defcustom init-forms don't seem to get compiled. + + * doc/auctex.texi (Modes and Hooks): Document + TeX-after-TeX-LaTeX-command-finished-hook. + + * tex-buf.el (TeX-after-TeX-LaTeX-command-finished-hook): New + hook. + (TeX-LaTeX-sentinel): Call it. + +2015-03-09 Mos� Giordano <m...@gnu.org> + + * tex-buf.el (TeX-find-display-help): Display the help also when + the file cannot be determined. + + * latex.el (LaTeX-end-regexp): Add "\]". + (LaTeX-indent-calculate): Indent "\[...\]" display math as a + regular environment. + +2015-03-08 Arash Esbati <esb...@gmx.de> + + * Makefile.in (STYLESRC): Add new style. + + * style/geometry.el: New file. + +2015-03-08 Arash Esbati <esb...@gmx.de> + + * Makefile.in (STYLESRC): Add new style. + + * style/caption.el: New file. + +2015-03-08 Arash Esbati <esb...@gmx.de> + + * Makefile.in (STYLESRC): Add new style. + + * style/enumitem.el: New file. + +2015-03-08 Tassilo Horn <t...@gnu.org> + + * tex.el (TeX-style-path): Replace add-to-list on local with + pushnew. + + * style/bidibeamer.el: New style. + + * Makefile.in (STYLESRC): Activate new bidibeamer style. + +2015-03-07 Mos� Giordano <m...@gnu.org> + + * doc/install.texi: Mention uninstallation in menus. + (Build/install and uninstall): Add "Uninstallation" index entry. + Document uninstallation process. + + * Makefile.in: Update copyright years. + (.PHONY): Add uninstall rule. + (uninstall): New rule. + + * doc/Makefile.in: Update copyright years. + (.PHONY): Add uninstall rule. + (uninstall): New rule. + + * latex/Makefile.in: Update copyright years. + (.PHONY): Declare phony targets. + (install-texmf-doc): Do not ignore errors in this rule. + (uninstall): New rule. + +2015-03-03 Tassilo Horn <t...@gnu.org> + + * doc/auctex.texi (Filling): Document LaTeX-fill-excluded-macros. + + * latex.el (LaTeX-fill-excluded-macros): New defcustom for + excluding macro arguments from filling. + (LaTeX-fill-region-as-paragraph): Use it. + +2015-03-02 Tassilo Horn <t...@gnu.org> + + * font-latex.el (font-latex-match-command-with-arguments): Fix + error introduced in the last change. + +2015-02-24 Tassilo Horn <t...@gnu.org> + + * style/expl3.el: New style for the wrapper package for + experimental LaTeX 3. + + * Makefile.in (STYLESRC): Activate new style. + + * font-latex.el (font-latex-match-simple-command) + (font-latex-match-command-with-arguments): Use \s_ and \sw regexp + classes instead of hard-coding [A-Za-z@] as LaTeX macro chars. + +2015-02-17 Tassilo Horn <t...@gnu.org> + + * latex.el (LaTeX-after-insert-env-hook): Rename from + `LaTeX-after-insert-env-hooks' which is now an obsolete variable + alias. + (LaTeX-after-modify-env-hook): New hook. + (LaTeX-modify-environment): Run `LaTeX-after-modify-env-hook'. + +2015-02-13 Tassilo Horn <t...@gnu.org> + + * tex.el (TeX-pdf-tools-sync-view, TeX-PDF-mode): Move addition of + `TeX-source-correlate-handle-TeX-region' to + `pdf-sync-backward-redirect-functions' from `TeX-PDF-mode' to + `TeX-pdf-tools-sync-view'. + +2015-02-09 Tassilo Horn <t...@gnu.org> + + * tex.el (TeX-pdf-tools-sync-view): Make it work with + `TeX-command-region'. + +2015-02-09 Tassilo Horn <t...@gnu.org> + + * tex.el (TeX-pdf-tools-sync-view): Simplify function. + +2015-02-09 Arash Esbati <esb...@gmx.de> + + * Makefile.in (STYLESRC): Add new style. + + * style/color.el: New style. + +2015-02-08 Tassilo Horn <t...@gnu.org> + + * tex.el (TeX-source-correlate-handle-TeX-region): Fix + void-variable error. + +2015-02-07 Tassilo Horn <t...@gnu.org> + + * tex.el (TeX-pdf-tools-sync-view) + (TeX-source-correlate-handle-TeX-region) + (TeX-source-correlate-sync-source, TeX-PDF-mode): Adapt PDF Tools + forward/backward search to latest PDF Tools changes. + +2015-02-06 Mos� Giordano <m...@gnu.org> + + * tex.el (TeX-source-correlate-handle-TeX-region): Replace + `file-name-base', introduced in GNU Emacs 24, with + `file-name-sans-extension'+`file-name-nondirectory'. + +2015-02-06 Tassilo Horn <t...@gnu.org> + + * tex.el (TeX-source-correlate-handle-TeX-region): New function. + (TeX-source-correlate-sync-source): Use it. + (TeX-PDF-mode): Set `pdf-sync-correlate-tex-refine-function' to + `TeX-source-correlate-sync-source'. + +2015-02-05 Tassilo Horn <t...@gnu.org> + + * tex.el (TeX-pdf-tools-sync-view): New function to use PDF Tools + `pdf-view-mode' as a viewer. + (TeX-view-program-list-builtin): Add PDF Tools entry calling + `TeX-pdf-tools-sync-view'. + +2015-02-04 Tassilo Horn <t...@gnu.org> + + * Makefile.in (STYLESRC): Add new style. + + * style/tcolorbox.el: New style. + +2015-01-31 Arash Esbati <esb...@gmx.de> + + * Makefile.in (STYLESRC): Add new style. + + * style/currvita.el: New file. + 2015-01-27 Tassilo Horn <t...@gnu.org> * Version 11.88.2 released. diff --git a/Makefile.in b/Makefile.in index 39402e78..08c50a09 100644 --- a/Makefile.in +++ b/Makefile.in @@ -2,7 +2,7 @@ # Maintainer: auctex-devel@gnu.org -# Copyright (C) 2003-2008, 2010, 2013, 2014 Free Software +# Copyright (C) 2003-2008, 2010, 2013-2015 Free Software # Foundation, Inc. # This file is part of AUCTeX. @@ -143,7 +143,12 @@ STYLESRC = style/prosper.el \ style/luatextra.el style/erewhon.el style/baskervaldx.el \ style/fbb.el style/newtxmath.el style/newtxsf.el \ style/newtxtext.el style/newtxttt.el style/minted.el \ - style/wrapfig.el style/relsize.el + style/wrapfig.el style/relsize.el style/currvita.el \ + style/tcolorbox.el style/color.el style/expl3.el \ + style/bidibeamer.el style/enumitem.el style/caption.el \ + style/geometry.el style/ltablex.el style/ltxtable.el \ + style/mn2e.el + STYLEELC = $(STYLESRC:.el=.elc) ifeq (@preview_enabled@,yes) @@ -183,7 +188,7 @@ all: texmf lisp docs install-man clean distclean maintainer-clean extraclean \ tar-ball-clean check-tag check release-commit dist snapshot \ patch tar-ball rpm-packages wc xemacs-package windows-package \ - release-sign release-upload preview-ball + release-sign release-upload preview-ball uninstall texmf: latex/Makefile $(TEXMF) @@ -351,6 +356,21 @@ install-metadata: echo "pkginfo/MANIFEST.$(PACKAGE)" >> "pkginfo/MANIFEST.$(PACKAGE)" ; \ } +uninstall: + rm -rf $(DESTDIR)$(packagelispdir) $(DESTDIR)$(packagedatadir) \ + $(DESTDIR)$(autodir) + if test X$(packagedir) = Xno ; then \ + rm -f $(DESTDIR)$(lispdir)/tex-site.el \ + $(DESTDIR)$(auctexstartfile) ; \ + else \ + rm -f $(DESTDIR)$(packagedir)/man/auctex/RELEASE \ + $(DESTDIR)$(packagedir)/pkginfo/MANIFEST.$(PACKAGE); \ + fi + cd doc ; $(MAKE) DESTDIR=$(DESTDIR) uninstall + rm -f $(DESTDIR)$(previewstartfile) + rm -rf $(DESTDIR)$(packagelispdir) + (cd latex ; $(MAKE) DESTDIR=$(DESTDIR) uninstall) + .el.elc: $(ELCC) -f batch-byte-compile $< diff --git a/doc/Makefile.in b/doc/Makefile.in index 0855186d..01e7e2af 100644 --- a/doc/Makefile.in +++ b/doc/Makefile.in @@ -2,7 +2,7 @@ # Maintainer: auctex-devel@gnu.org -# Copyright (C) 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc. +# Copyright (C) 2003-2008, 2013-2015 Free Software Foundation, Inc. # This file is part of AUCTeX. @@ -90,7 +90,8 @@ dist: $(DISTTEXTS) preview-latex.info auctex.info tex-ref.pdf extradist: html/$(TEXI2HTML_TOC) auctex.ps auctex.pdf tex-ref.ps tex-ref.pdf .PHONY: all info dvi dist install-auctex disttexts clean distclean \ - maintainer-clean install-preview install-man html-docs extradist + maintainer-clean install-preview install-man uninstall html-docs \ + extradist # AUCTeX @@ -200,6 +201,15 @@ install-preview: preview-latex.info # clean +uninstall: + for info in $(DESTDIR)$(infodir)/{auctex.info,preview-latex.info}; do \ + test ! -f $${info} || \ + $(INSTALL_INFO) --delete --info-dir=$(DESTDIR)$(infodir) $${info}; \ + done + rm -f $(DESTDIR)$(infodir)/auctex.info $(DESTDIR)$(infodir)/auctex.info-* \ + $(DESTDIR)$(infodir)/preview-latex.info* + test X$(packagedir) != Xno || rm -rf -f $(DESTDIR)$(docdir) + clean: rm -f *.dvi *.ps *.pdf *.aux *.cp *.fn *.ky *.log *~ \#*\# \ *.tp *.vr *.pg *.toc *.tp *.bak *.cps *.kys *.tps \ diff --git a/doc/auctex.texi b/doc/auctex.texi index 8fb997cc..6fb6d713 100644 --- a/doc/auctex.texi +++ b/doc/auctex.texi @@ -1741,6 +1741,26 @@ be inserted before the last non-comment word to minimize the chance that the line becomes overfull. @end defopt +@defopt LaTeX-fill-excluded-macros +A list of macro names (without leading backslash) for whose arguments +filling should be disabled. Typically, you will want to add macros here +which have long, multi-line arguments. An example is +@code{\pgfplotstabletypeset} from the pgfplotstable package which is +used as shown in the following listing: + +@verbatim +\pgfplotstabletypeset[skip first n=4]{% + XYZ Format, + Version 1.234 + Date 2010-09-01 + @author Mustermann + A B C + 1 2 3 + 4 5 6 +} +@end verbatim +@end defopt + @node Display @chapter Controlling Screen Display @@ -3468,6 +3488,20 @@ if it is relevant for any @AUCTeX{} mode, add it to @code{TeX-mode-hook} and if it is relevant for all text modes, append it to @code{text-mode-hook}. +Other useful hooks are listed below. + +@defvr Variable TeX-after-TeX-LaTeX-command-finished-hook +Hook which is run after the @TeX{}/@LaTeX{} processor has successfully +finished compiling your document. (@xref{Processing}, for finding out +how to compile your document). Each function in the hook is run with +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. +@end defvr +@vindex TeX-after-TeX-LaTeX-command-finished-hook + @node Multifile @section Multifile Documents @cindex Multifile Documents diff --git a/doc/install.texi b/doc/install.texi index 24fda968..d814ccaa 100644 --- a/doc/install.texi +++ b/doc/install.texi @@ -43,7 +43,7 @@ the file @file{INSTALL.windows}. @menu * Prerequisites:: * Configure:: -* Build/install:: +* Build/install and uninstall:: * Loading the package:: * Advice for package providers:: * Advice for non-privileged users:: @@ -56,7 +56,7 @@ the file @file{INSTALL.windows}. @menu * Prerequisites:: * Configure:: -* Build/install:: +* Build/install and uninstall:: * Loading the package:: * Advice for package providers:: * Advice for non-privileged users:: @@ -270,11 +270,12 @@ It is to be used when you are using @code{--with-tex-dir=@var{/dir}}, but is normally not necessary otherwise. @end table -@node Build/install -@section Build/install +@node Build/install and uninstall +@section Build/install and uninstall @cindex Installation @cindex Make +@cindex Uninstallation Once @command{configure} has been run, simply enter @@ -291,9 +292,21 @@ locations chosen earlier, type make install @end example +@noindent You may need special privileges to install, e.g., if you are installing into system directories. +Should you want to completely remove the installed package, in the same +directory you built @AUCTeX{} run + +@example +make uninstall +@end example + +@noindent +You will need administration privileges if you installed the package +into system directories. + @node Loading the package @section Loading the package @cindex @file{.emacs} @@ -575,3 +588,8 @@ directories will be searched recursively, so there is no reason to list subdirectories explicitly. Automatic configuration will already have set the variable for you if it could use the program @samp{kpsewhich}. In this case you normally don't have to alter anything. + +@c Local Variables: +@c mode: texinfo +@c TeX-master: "auctex" +@c End: diff --git a/doc/wininstall.texi b/doc/wininstall.texi index f3961849..e71809e0 100644 --- a/doc/wininstall.texi +++ b/doc/wininstall.texi @@ -362,7 +362,7 @@ choose another image format to be used by @previewlatex{}. Adding support for an image format usually involves the installation of a library, e.g. from @uref{http://gnuwin32.sf.net/}. If you got your -Emacs from @uref{gnu.org} you might want to check its +Emacs from @uref{http://www.gnu.org} you might want to check its @uref{ftp://ftp.gnu.org/gnu/emacs/windows/README,README file} for details. diff --git a/font-latex.el b/font-latex.el index 0a1b8ade..ed953d38 100644 --- a/font-latex.el +++ b/font-latex.el @@ -1494,7 +1494,7 @@ Returns nil if none of KEYWORDS is found." (list (point) (progn (forward-char) - (if (zerop (skip-chars-forward "A-Za-z@")) + (if (zerop (skip-syntax-forward "_w")) (forward-char) ; Single-char macro. (skip-chars-forward "*")) (point)))) @@ -1634,7 +1634,8 @@ marks boundaries for searching for group ends." (defun font-latex-match-simple-command (limit) "Search for command like \\foo before LIMIT." - (TeX-re-search-forward-unescaped "\\\\[@A-Za-z]+" limit t)) + ;; \s_ matches chars with symbol syntax, \sw chars with word syntax + (TeX-re-search-forward-unescaped "\\\\\\(?:\\s_\\|\\sw\\)+" limit t)) (defun font-latex-match-math-env (limit) "Match math pattern up to LIMIT. diff --git a/latex.el b/latex.el index 84096902..c232c24b 100644 --- a/latex.el +++ b/latex.el @@ -644,7 +644,11 @@ With prefix-argument, reopen environment afterwards." marker)) (move-marker marker nil))))) -(defvar LaTeX-after-insert-env-hooks nil +(if (featurep 'xemacs) + (define-obsolete-variable-alias 'LaTeX-after-insert-env-hooks 'LaTeX-after-insert-env-hook) + (define-obsolete-variable-alias 'LaTeX-after-insert-env-hooks 'LaTeX-after-insert-env-hook "11.89")) + +(defvar LaTeX-after-insert-env-hook nil "List of functions to be run at the end of `LaTeX-insert-environment'. Each function is called with three arguments: the name of the environment just inserted, the buffer position just before @@ -738,26 +742,48 @@ allowing one level of TeX group braces." (regexp-quote TeX-grop) "]*" (regexp-quote TeX-grcl) "\\)*[^" (regexp-quote TeX-grcl) (regexp-quote TeX-grop) "]*\\)")) +(defvar LaTeX-after-modify-env-hook nil + "List of functions to be run at the end of `LaTeX-modify-environment'. +Each function is called with four arguments: the new name of the +environment, the former name of the environment, the buffer +position just before \\begin and the position just before +\\end.") + (defun LaTeX-modify-environment (environment) "Modify current ENVIRONMENT." - (save-excursion - (LaTeX-find-matching-end) - (re-search-backward (concat (regexp-quote TeX-esc) - "end" - (regexp-quote TeX-grop) - (LaTeX-environment-name-regexp) - (regexp-quote TeX-grcl)) - (save-excursion (beginning-of-line 1) (point))) - (replace-match (concat TeX-esc "end" TeX-grop environment TeX-grcl) t t) - (beginning-of-line 1) - (LaTeX-find-matching-begin) - (re-search-forward (concat (regexp-quote TeX-esc) - "begin" - (regexp-quote TeX-grop) - (LaTeX-environment-name-regexp) - (regexp-quote TeX-grcl)) - (save-excursion (end-of-line 1) (point))) - (replace-match (concat TeX-esc "begin" TeX-grop environment TeX-grcl) t t))) + (let ((goto-end (lambda () + (LaTeX-find-matching-end) + (re-search-backward (concat (regexp-quote TeX-esc) + "end" + (regexp-quote TeX-grop) + "\\(" + (LaTeX-environment-name-regexp) + "\\)" + (regexp-quote TeX-grcl)) + (save-excursion (beginning-of-line 1) (point))))) + (goto-begin (lambda () + (LaTeX-find-matching-begin) + (prog1 (point) + (re-search-forward (concat (regexp-quote TeX-esc) + "begin" + (regexp-quote TeX-grop) + "\\(" + (LaTeX-environment-name-regexp) + "\\)" + (regexp-quote TeX-grcl)) + (save-excursion (end-of-line 1) (point))))))) + (save-excursion + (funcall goto-end) + (let ((old-env (match-string 1))) + (replace-match environment t t nil 1) + (beginning-of-line 1) + (funcall goto-begin) + (replace-match environment t t nil 1) + (end-of-line 1) + (run-hook-with-args 'LaTeX-after-modify-env-hook + environment old-env + (save-excursion (funcall goto-begin)) + (progn (funcall goto-end) (point))))))) (defun LaTeX-current-environment (&optional arg) "Return the name (a string) of the enclosing LaTeX environment. @@ -2922,7 +2948,7 @@ indentation level in columns." :group 'LaTeX-indentation :type 'regexp) -(defcustom LaTeX-end-regexp "end\\b" +(defcustom LaTeX-end-regexp "end\\b\\|\\]" "*Regexp matching macros considered ends." :group 'LaTeX-indentation :type 'regexp) @@ -3115,6 +3141,10 @@ outer indentation in case of a commented line. The symbols ;; End brace in the start of the line. (- (LaTeX-indent-calculate-last force-type) TeX-brace-indent-level)) + ((and (texmathp) + ;; Display math \[...\], treat as a generic environment. + (equal "\\[" (car texmathp-why))) + LaTeX-indent-level) (t (LaTeX-indent-calculate-last force-type)))))) (defun LaTeX-indent-level-count () @@ -3327,6 +3357,12 @@ does not fit into the line." :group 'LaTeX :type 'boolean) +(defcustom LaTeX-fill-excluded-macros nil + "List of macro names (without leading \\) whose arguments must +not be subject to filling." + :group 'LaTeX + :type '(repeat string)) + (defvar LaTeX-nospace-between-char-regexp (if (featurep 'xemacs) (if (and (boundp 'word-across-newline) word-across-newline) @@ -3353,6 +3389,7 @@ pass args FROM, TO and JUSTIFY-FLAG." (interactive "*r\nP") (let ((end-marker (save-excursion (goto-char to) (point-marker)))) (if (or (assoc (LaTeX-current-environment) LaTeX-indent-environment-list) + (member (TeX-current-macro) LaTeX-fill-excluded-macros) ;; This could be generalized, if there are more cases where ;; a special string at the start of a region to fill should ;; inhibit filling. @@ -5847,7 +5884,7 @@ i.e. you do _not_ have to cater for this yourself by adding \\\\' or $." LaTeX-section-list))) (set (make-local-variable 'TeX-auto-full-regexp-list) - (append LaTeX-auto-regexp-list plain-TeX-auto-regexp-list)) + (append LaTeX-auto-regexp-list plain-TeX-auto-regexp-list)) (LaTeX-set-paragraph-start) (setq paragraph-separate @@ -5863,10 +5900,10 @@ i.e. you do _not_ have to cater for this yourself by adding \\\\' or $." LaTeX-search-files-type-alist) (set (make-local-variable 'LaTeX-item-list) '(("description" . LaTeX-item-argument) - ("thebibliography" . LaTeX-item-bib) - ("array" . LaTeX-item-array) - ("tabular" . LaTeX-item-array) - ("tabular*" . LaTeX-item-tabular*))) + ("thebibliography" . LaTeX-item-bib) + ("array" . LaTeX-item-array) + ("tabular" . LaTeX-item-array) + ("tabular*" . LaTeX-item-tabular*))) (setq TeX-complete-list (append '(("\\\\cite\\[[^]\n\r\\%]*\\]{\\([^{}\n\r\\%,]*\\)" diff --git a/latex/Makefile.in b/latex/Makefile.in index 8a40ca0b..afb0a62a 100644 --- a/latex/Makefile.in +++ b/latex/Makefile.in @@ -2,7 +2,8 @@ # Maintainer: auctex-devel@gnu.org -# Copyright (C) 2002, 2003, 2005, 2006 Free Software Foundation, Inc. +# Copyright (C) 2002-2006, 2008, 2014, 2015 Free Software Foundation, +# Inc. # This file is part of AUCTeX. @@ -41,6 +42,8 @@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ MKINSTALLDIRS = ../mkinstalldirs +.PHONY: all install install-texmf install-texmf-doc uninstall clean + all: $(TEXMFGEN) preview.drv preview-mk.ins preview.dvi preview.pdf install: install-texmf install-texmf-doc @@ -61,9 +64,12 @@ install-texmf: $(TEXMFGEN) fi install-texmf-doc: preview.dvi - -$(MKINSTALLDIRS) $(DESTDIR)$(previewdocdir) + $(MKINSTALLDIRS) $(DESTDIR)$(previewdocdir) $(INSTALL_DATA) preview.dvi $(DESTDIR)$(previewdocdir) +uninstall: + rm -rf $(DESTDIR)$(previewdocdir)/preview.dvi $(DESTDIR)$(previewtexmfdir) + preview-mk.ins: preview.dtx bootstrap.ins $(TEX) '\nonstopmode \input bootstrap.ins' @@ -87,5 +93,5 @@ preview.pdf: preview.drv preview.dtx preview.sty $(PDFLATEX) '\nonstopmode \AtBeginDocument{\OnlyDescription}\input{preview.drv}' clean: - rm -f *~ *.aux *.dvi *.drv *.log - rm -f $(TEXMFGEN) preview.ins preview-mk.ins + rm -f *~ *.aux *.dvi *.drv *.log + rm -f $(TEXMFGEN) preview.ins preview-mk.ins diff --git a/style/bidibeamer.el b/style/bidibeamer.el new file mode 100644 index 00000000..767a6470 --- /dev/null +++ b/style/bidibeamer.el @@ -0,0 +1,40 @@ +;;; bidibeamer.el --- AUCTeX style for the bidibeamer class + +;; Copyright (C) 2015 Free Software Foundation + +;; Author: Tassilo Horn <t...@gnu.org> +;; Created: 2015-03-08 +;; Keywords: tex + +;; This file is part of AUCTeX. + +;; AUCTeX is free software; you can redistribute it and/or modify it +;; under the terms of the GNU General Public License as published by +;; the Free Software Foundation; either version 3, or (at your option) +;; any later version. + +;; AUCTeX is distributed in the hope that it will be useful, but +;; WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;; General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with AUCTeX; see the file COPYING. If not, write to the Free +;; Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA +;; 02110-1301, USA. + +;;; Commentary: + +;; This file adds support for the bidibeamer class which offers the same +;; functionality and interface as latex-beamer, so we simply call the style +;; hook of the latter. + +;;; Code: + +(TeX-add-style-hook + "bidibeamer" + (lambda () + (TeX-run-style-hooks "beamer")) + LaTeX-dialect) + +;;; bidibeamer.el ends here diff --git a/style/caption.el b/style/caption.el new file mode 100644 index 00000000..c79f5626 --- /dev/null +++ b/style/caption.el @@ -0,0 +1,311 @@ +;;; caption.el --- AUCTeX style for `caption.sty' (v3.3-89) + +;; Copyright (C) 2015 Free Software Foundation, Inc. + +;; Author: Arash Esbati <esbati'at'gmx.de> +;; Maintainer: auctex-devel@gnu.org +;; Created: 2015-02-21 +;; 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 `caption.sty' (v3.3-89) from 2013/05/02. +;; `caption.sty' is part of TeXLive. + +;; If things do not work or when in doubt, press `C-c C-n'. Comments +;; for improvement are welcome. + +;;; Code: + +;; Needed for compiling `pushnew': +(eval-when-compile (require 'cl)) + +;; Needed for auto-parsing. +(require 'tex) + +(defvar LaTeX-caption-key-val-options + '(("aboveskip") + ("belowskip") + ("font" ("scriptsize" "footnotesize" "small" "normalsize" "large" + "Large" "normalfont" "up" "it" "sl" "sc" "md" "bf" "rm" + "sf" "tt" "singlespacing" "onehalfspacing" "doublespacing" + "stretch" "normalcolor" "color" "normal")) + ("font+" ("scriptsize" "footnotesize" "small" "normalsize" "large" + "Large" "normalfont" "up" "it" "sl" "sc" "md" "bf" "rm" + "sf" "tt" "singlespacing" "onehalfspacing" "doublespacing" + "stretch" "normalcolor" "color" "normal")) + ("format" ("plain" "hang")) + ("hangindent") + ("hypcap") + ("hypcapspace") + ("indention") + ("justification" ("justified" "centering" "centerlast" "centerfirst" + "raggedright" "RaggedRight" "raggedleft")) + ("labelfont" ("scriptsize" "footnotesize" "small" "normalsize" "large" + "Large" "normalfont" "up" "it" "sl" "sc" "md" "bf" "rm" + "sf" "tt" "singlespacing" "onehalfspacing" "doublespacing" + "stretch" "normalcolor" "color" "normal")) + ("labelfont+" ("scriptsize" "footnotesize" "small" "normalsize" "large" + "Large" "normalfont" "up" "it" "sl" "sc" "md" "bf" "rm" + "sf" "tt" "singlespacing" "onehalfspacing" "doublespacing" + "stretch" "normalcolor" "color" "normal")) + ("labelformat" ("default" "empty" "simple" "brace" "parens")) + ("labelsep" ("none" "colon" "period" "space" "quad" "newline" "endash")) + ("list" ("false" "no" "off" "0" "true" "yes" "on" "1")) + ("listformat" ("empty" "simple" "paren" "subsimple" "subparens")) + ("margin" ("type*" "width")) + ("margin*") + ("maxmargin") + ("minmargin") + ("name") + ("oneside") + ("parindent") + ("parskip") + ("position" ("top" "above" "bottom" "below" "auto")) + ("singlelinecheck" ("false" "no" "off" "0" "true" "yes" "on" "1")) + ("skip") + ("strut" ("false" "no" "off" "0" "true" "yes" "on" "1")) + ("style" ("base" "default")) + ("textfont" ("scriptsize" "footnotesize" "small" "normalsize" "large" + "Large" "normalfont" "up" "it" "sl" "sc" "md" "bf" "rm" + "sf" "tt" "singlespacing" "onehalfspacing" "doublespacing" + "stretch" "normalcolor" "color" "normal")) + ("textfont+" ("scriptsize" "footnotesize" "small" "normalsize" "large" + "Large" "normalfont" "up" "it" "sl" "sc" "md" "bf" "rm" + "sf" "tt" "singlespacing" "onehalfspacing" "doublespacing" + "stretch" "normalcolor" "color" "normal")) + ("textformat" ("empty" "simple" "period")) + ("twoside") + ("type" ("figure" "table" "ContinuedFloat")) + ("type*" ("figure" "table" "ContinuedFloat")) + ("width")) + "Key=value options for caption macros.") + +(defvar LaTeX-caption-key-val-options-local nil + "Buffer-local key=value options for caption macros.") +(make-variable-buffer-local 'LaTeX-caption-key-val-options-local) + +(defvar LaTeX-caption-supported-float-types + '("figure" "table" "ContinuedFloat" ; Standard caption.sty + "sub" "subtable" "subfigure" ; subcaption.sty + "ruled" "boxed" ; float.sty + "floatingfigure" "floatingtable" ; floatflt.sty + "lstlisting" ; listings.sty + "longtable" ; longtable.sty + "figwindow" "tabwindow" ; picinpar.sty + "parpic" ; picins.sty + "SCfigure" "SCtable" ; sidecap.sty + "supertabular" "xtabular" ; supertabular.sty & xtab.sty + "threeparttable" "measuredfigure" ; threeparttable.sty + "wrapfigure" "wraptable") ; wrapfigure + "List of float types provided by other LaTeX packages and +supported by `caption.sty'.") + +;; Setup for various \DeclareCaption's: +(TeX-auto-add-type "caption-DeclareCaption" "LaTeX") + +;; The 2. argument to `DeclareCaption[A-Za-z]' contains (La)TeX code. +;; We deliberately ignore that argument in our regex since it is not +;; needed for this style and would pollute the auto generated +;; `docname.el' file. +(defvar LaTeX-caption-DeclareCaption-regexp + `(,(concat "\\\\DeclareCaption\\(Font\\|Format\\|Justification" + "\\|LabelFormat\\|LabelSeparator\\|ListFormat" + "\\|Option\\|Style\\|TextFormat\\)" + "\\*?" + "[ \t\n\r%]*" + "{\\([^}]+\\)}") + (0 1 2) LaTeX-auto-caption-DeclareCaption) + "Matches the arguments of different `\\DeclareCaption*' from +`caption.sty'.") + +(defun LaTeX-caption-auto-prepare () + "Clear `LaTeX-auto-caption-DeclareCaption' before parsing." + (setq LaTeX-auto-caption-DeclareCaption nil)) + +(add-hook 'TeX-auto-prepare-hook #'LaTeX-caption-auto-prepare t) + +(defun LaTeX-caption-update-key-val-options () + "Update the buffer-local key-val options before offering them +in `caption'-completions." + (dolist (keyvals (LaTeX-caption-DeclareCaption-list)) + (let* ((key (cond ((string-equal (nth 1 keyvals) "LabelSeparator") + (downcase (substring (nth 1 keyvals) 0 8))) + (t (downcase (nth 1 keyvals))))) + (val (nth 2 keyvals)) + ;; (key-match (car (assoc key LaTeX-caption-key-val-options-local))) + (val-match (cdr (assoc key LaTeX-caption-key-val-options-local))) + (temp (copy-alist LaTeX-caption-key-val-options-local)) + (opts (assq-delete-all (car (assoc key temp)) temp))) + ;; For `\DeclareCaptionOption', only add the value + ;; (remember: key=^^^^^^, val="defined key") + (if (string-equal key "option") + (pushnew (list val) opts :test #'equal) + ;; For anything but `\DeclareCaptionOption', do the standard procedure + (if val-match + (pushnew (list key (delete-dups (apply 'append (list val) val-match))) + opts :test #'equal) + (pushnew (list key (list val)) opts :test #'equal))) + (setq LaTeX-caption-key-val-options-local (copy-alist opts))))) + +(defun LaTeX-arg-caption-command (&optional optional prompt) + "Insert caption-commands from `caption.sty'. If OPTIONAL is non-nil, +indicate `(Optional)' while reading key=val. PROMPT replaces the +standard one." + (LaTeX-caption-update-key-val-options) + (let ((opts (TeX-read-key-val optional + LaTeX-caption-key-val-options-local + prompt))) + (format "%s" opts))) + +;; In `LaTeX-caption-DeclareCaption-regexp', we match (0 1 2). When +;; adding a new `Name', we need something unique for `0'-match until +;; the next `C-c C-n'. We mimic that regex-match bei concat'ing the +;; elements. It will vanish upon next `C-c C-n'. +(defun LaTeX-arg-caption-DeclareCaption (format) + "Insert various `\\DeclareCaptionFORMAT' commands. FORMAT is +the suffix of the command." + (let ((name (TeX-read-string "Name: "))) + (LaTeX-add-caption-DeclareCaptions + (list (concat "\\DeclareCaption" format "{" name "}") + format name)) + (format "%s" name))) + +(TeX-add-style-hook + "caption" + (lambda () + + ;; Add caption to the parser. + (TeX-auto-add-regexp LaTeX-caption-DeclareCaption-regexp) + + ;; Activate the buffer-local version of key-vals. + (setq LaTeX-caption-key-val-options-local + (copy-alist LaTeX-caption-key-val-options)) + + ;; Caption commands: + (TeX-add-symbols + '("caption*" t) + + '("captionlistentry" + [TeX-arg-eval completing-read (TeX-argument-prompt t nil "Float type") + LaTeX-caption-supported-float-types] + t) + + '("captionof" + (TeX-arg-eval completing-read (TeX-argument-prompt nil nil "Float type") + LaTeX-caption-supported-float-types) + ["List entry"] t) + + '("captionof*" + (TeX-arg-eval completing-read (TeX-argument-prompt nil nil "Float type") + LaTeX-caption-supported-float-types) + ["List entry"] t) + + '("captionsetup" + [TeX-arg-eval completing-read (TeX-argument-prompt t nil "Float type") + LaTeX-caption-supported-float-types] + (TeX-arg-eval LaTeX-arg-caption-command)) + + '("captionsetup*" + [TeX-arg-eval completing-read (TeX-argument-prompt t nil "Float type") + LaTeX-caption-supported-float-types] + (TeX-arg-eval LaTeX-arg-caption-command)) + + '("clearcaptionsetup" + [TeX-arg-eval LaTeX-arg-caption-command t "Single key"] + (TeX-arg-eval completing-read (TeX-argument-prompt nil nil "Float type") + LaTeX-caption-supported-float-types)) + + '("clearcaptionsetup*" + [TeX-arg-eval LaTeX-arg-caption-command t "Single key"] + (TeX-arg-eval completing-read (TeX-argument-prompt nil nil "Float type") + LaTeX-caption-supported-float-types)) + + '("ContinuedFloat" 0) + + '("DeclareCaptionFont" + (TeX-arg-eval LaTeX-arg-caption-DeclareCaption "Font") t) + + '("DeclareCaptionFormat" + (TeX-arg-eval LaTeX-arg-caption-DeclareCaption "Format") t) + + '("DeclareCaptionFormat*" + (TeX-arg-eval LaTeX-arg-caption-DeclareCaption "Format") t) + + '("DeclareCaptionJustification" + (TeX-arg-eval LaTeX-arg-caption-DeclareCaption "Justification") t) + + '("DeclareCaptionLabelFormat" + (TeX-arg-eval LaTeX-arg-caption-DeclareCaption "LabelFormat") t) + + '("DeclareCaptionLabelSeparator" + (TeX-arg-eval LaTeX-arg-caption-DeclareCaption "LabelSeparator") t) + + '("DeclareCaptionLabelSeparator*" + (TeX-arg-eval LaTeX-arg-caption-DeclareCaption "LabelSeparator") t) + + '("DeclareCaptionListFormat" + (TeX-arg-eval LaTeX-arg-caption-DeclareCaption "ListFormat") t) + + '("DeclareCaptionOption" + (TeX-arg-eval LaTeX-arg-caption-DeclareCaption "Option") t) + + '("DeclareCaptionStyle" + (TeX-arg-eval LaTeX-arg-caption-DeclareCaption "Style") + [TeX-arg-eval LaTeX-arg-caption-command t "Additional options"] + (TeX-arg-eval LaTeX-arg-caption-command nil "Options")) + + '("DeclareCaptionTextFormat" + (TeX-arg-eval LaTeX-arg-caption-DeclareCaption "TextFormat") t) + + '("bothIfFirst" 2) + + '("bothIfSecond" 2)) + + ;; Fontification + (when (and (featurep 'font-latex) + (eq TeX-install-font-lock 'font-latex-setup)) + (font-latex-add-keywords '(("caption" "*[{") + ("captionlistentry" "[{") + ("captionof" "*[{")) + 'textual) + (font-latex-add-keywords '(("captionsetup" "*[{") + ("clearcaptionsetup" "*[{") + ("DeclareCaptionFont" "{{") + ("DeclareCaptionFormat" "*{{") + ("DeclareCaptionJustification" "{{") + ("DeclareCaptionLabelFormat" "{{") + ("DeclareCaptionLabelSeparator" "*{{") + ("DeclareCaptionListFormat" "{{") + ("DeclareCaptionOption" "{{") + ("DeclareCaptionStyle" "{[{") + ("DeclareCaptionTextFormat" "{{")) + 'function)) ) + LaTeX-dialect) + +(defun LaTeX-caption-package-options () + "Prompt for package options for the caption package." + (TeX-read-key-val t + (append '(("compatibility" ("true" "false"))) + '(("figureposition" ("top" "above" "bottom" "below"))) + '(("tableposition" ("top" "above" "bottom" "below"))) + LaTeX-caption-key-val-options))) + +;;; caption.el ends here diff --git a/style/color.el b/style/color.el new file mode 100644 index 00000000..de0f50c9 --- /dev/null +++ b/style/color.el @@ -0,0 +1,308 @@ +;;; color.el --- AUCTeX style for `color.sty' (v1.1a) + +;; Copyright (C) 2015 Free Software Foundation, Inc. + +;; Author: Arash Esbati <esbati'at'gmx.de> +;; Maintainer: auctex-devel@gnu.org +;; Created: 2015-01-16 +;; 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 `color.sty' (v1.1a) from 2014/10/28. +;; `color.sty' is part of TeXLive. + +;; Many thanks to Tassilo Horn for his percetive comments on +;; implementation of this style and testing. + +;;; Code: + +(defvar LaTeX-color-colour-models + '("cmyk" "gray" "named" "rgb") + "List of color models provided by `color.sty'.") + +(defvar LaTeX-color-dvipsnames-colors + '("Apricot" "Aquamarine" "Bittersweet" "Black" + "Blue" "BlueGreen" "BlueViolet" "BrickRed" + "Brown" "BurntOrange" "CadetBlue" "CarnationPink" + "Cerulean" "CornflowerBlue" "Cyan" "Dandelion" + "DarkOrchid" "Emerald" "ForestGreen" "Fuchsia" + "Goldenrod" "Gray" "Green" "GreenYellow" + "JungleGreen" "Lavender" "LimeGreen" "Magenta" + "Mahogany" "Maroon" "Melon" "MidnightBlue" + "Mulberry" "NavyBlue" "OliveGreen" "Orange" + "OrangeRed" "Orchid" "Peach" "Periwinkle" + "PineGreen" "Plum" "ProcessBlue" "Purple" + "RawSienna" "Red" "RedOrange" "RedViolet" + "Rhodamine" "RoyalBlue" "RoyalPurple" "RubineRed" + "Salmon" "SeaGreen" "Sepia" "SkyBlue" + "SpringGreen" "Tan" "TealBlue" "Thistle" + "Turquoise" "Violet" "VioletRed" "White" + "WildStrawberry" "Yellow" "YellowGreen" "YellowOrange") + "List of colors defined by package option `dvipsnames' from `color.sty'.") + +;; Needed for auto-parsing. +(require 'tex) + +;; Plug color into the parser -- after that we have the following: +;; 1. LaTeX-auto-color-definecolor: Name of temporary variable used +;; when parsing. +;; 2. LaTeX-add-color-definecolors: Name of function to add +;; information to add to #3. +;; 3. LaTeX-color-definecolor-list: Name of variable holding buffer +;; local information. +;; 4. LaTeX-color-definecolors-changed: Name of variable indicating +;; that #3 has changed. +(TeX-auto-add-type "color-definecolor" "LaTeX") + +(defvar LaTeX-color-definecolor-regexp + '("\\\\definecolor{\\([^}]+\\)}{\\([^}]+\\)}{\\([^}]+\\)}" + 1 LaTeX-auto-color-definecolor) + "Matches the arguments of `\\definecolor' from `color' +package.") + +(defun LaTeX-color-auto-prepare () + "Clear `LaTeX-auto-color-definecolor' before parsing." + (setq LaTeX-auto-color-definecolor nil)) + +(defun LaTeX-color-auto-cleanup () + "Move parsed colors from `LaTeX-auto-color-definecolor' to +`LaTeX-color-definecolor-list'." + ;; \definecolor{<name>}{<model>}{<colour-spec>} + ;; color=<name>, ignored=<model>, ignored=<colour-spec> + (dolist (color LaTeX-auto-color-definecolor) + (add-to-list 'LaTeX-color-definecolor-list (list color)))) + +(add-hook 'TeX-auto-prepare-hook #'LaTeX-color-auto-prepare t) +(add-hook 'TeX-auto-cleanup-hook #'LaTeX-color-auto-cleanup t) + +(defun TeX-arg-color-definecolor (optional &optional prompt) + "Insert arguments of `\\definecolor' from `color.sty'." + ;; \definecolor{<name>}{<model>}{<color spec>} + ;; Ask for <name>, add to our list and insert it + (let ((colorname (read-string "Color name: "))) + (LaTeX-add-color-definecolors colorname) + (TeX-argument-insert colorname optional)) + ;; Ask and insert <model> + (let ((model (completing-read + (TeX-argument-prompt optional prompt "Color model") + (if (not (or (LaTeX-provided-package-options-member "color" "dvips") + (LaTeX-provided-package-options-member "color" "dvipsnames"))) + (remove "named" LaTeX-color-colour-models) + LaTeX-color-colour-models)))) + (TeX-argument-insert model optional) + ;; Depending on <model>, ask for <color spec> and insert it + (cond (;; <cmyk> model + (string-equal model "cmyk") + (let ((cyan (read-string "Value Cyan (between 0,1): ")) + (magenta (read-string "Value Magenta (between 0,1): ")) + (yellow (read-string "Value Yellow (between 0,1): ")) + (black (read-string "Value Black (between 0,1): "))) + (TeX-argument-insert + (concat cyan "," magenta "," yellow "," black) optional))) + ;; <rgb> model + ((string-equal model "rgb") + (let ((red (read-string "Value Red (between 0,1): ")) + (green (read-string "Value Green (between 0,1): ")) + (blue (read-string "Value Blue (between 0,1): "))) + (TeX-argument-insert + (concat red "," green "," blue) optional))) + ;; <gray> model + ((string-equal model "gray") + (let ((grayness (read-string "Value Gray (between 0,1): "))) + (TeX-argument-insert grayness optional))) + ;; <named> model takes the dvipsnames + ((string-equal model "named") + (let ((color (completing-read "Named Color: " + LaTeX-color-dvipsnames-colors))) + (TeX-argument-insert color optional)))))) + +(defun TeX-arg-color (optional &optional prompt) + "Insert arguments of various color commands from `color.sty'." + ;; \color{<name>} or \color[<model>]{<color spec>} + ;; First, ask for <model>. `named' is removed here from completion + ;; if package option is not given + (let ((model (completing-read + (TeX-argument-prompt t prompt "Color model") + (if (not (or (LaTeX-provided-package-options-member "color" "dvips") + (LaTeX-provided-package-options-member "color" "dvipsnames"))) + (remove "named" LaTeX-color-colour-models) + LaTeX-color-colour-models)))) + (if (string-equal model "") + ;; if empty, ask for <name> with completion + (let ((color (completing-read + (TeX-argument-prompt optional prompt "Color name") + (LaTeX-color-definecolor-list)))) + (TeX-argument-insert color optional)) + ;; if not empty, insert [<model>] and proceed + (insert (concat LaTeX-optop model LaTeX-optcl)) + (cond (;; <cmyk> model + (string-equal model "cmyk") + (let ((cyan (read-string "Value Cyan (between 0,1): ")) + (magenta (read-string "Value Magenta (between 0,1): ")) + (yellow (read-string "Value Yellow (between 0,1): ")) + (black (read-string "Value Black (between 0,1): "))) + (TeX-argument-insert + (concat cyan "," magenta "," yellow "," black) optional))) + ;; <rgb> model + ((string-equal model "rgb") + (let ((red (read-string "Value Red (between 0,1): ")) + (green (read-string "Value Green (between 0,1): ")) + (blue (read-string "Value Blue (between 0,1): "))) + (TeX-argument-insert + (concat red "," green "," blue) optional))) + ;; <gray> model + ((string-equal model "gray") + (let ((grayness (read-string "Value Gray (between 0,1): "))) + (TeX-argument-insert grayness optional))) + ;; <named> model; allowed are dvipsnames. + ((string-equal model "named") + (let ((color (completing-read "Named Color: " + LaTeX-color-dvipsnames-colors))) + (TeX-argument-insert color optional))))))) + +(defun TeX-arg-color-fcolorbox (optional &optional prompt) + "Insert arguments of `\\fcolorbox' from `color.sty'. " + ;; \fcolorbox{<frame color name>}{<box color name>}{<text>} or + ;; \fcolorbox[<model>]{<frame color spec>}{<box color spec>}{<text>} + ;; First, ask for <model>; remove `named' again + (let ((model (completing-read + (TeX-argument-prompt t prompt "Color model") + (if (not (or (LaTeX-provided-package-options-member "color" "dvips") + (LaTeX-provided-package-options-member "color" "dvipsnames"))) + (remove "named" LaTeX-color-colour-models) + LaTeX-color-colour-models)))) + (if (string-equal model "") + ;; if empty, ask for <frame color spce> with completion + (let ((frame-color (completing-read + (TeX-argument-prompt optional prompt "Frame color name") + (LaTeX-color-definecolor-list))) + (box-color (completing-read + (TeX-argument-prompt optional prompt "Box color name") + (LaTeX-color-definecolor-list)))) + (TeX-argument-insert frame-color optional) + (TeX-argument-insert box-color optional)) + ;; if not empty, insert [<model>] and cater for 2 mandatory args. + (insert (concat LaTeX-optop model LaTeX-optcl)) + (cond (;; <cmyk> model + (string-equal model "cmyk") + (let ((cyan (read-string "Frame value Cyan (between 0,1): ")) + (magenta (read-string "Frame value Magenta (between 0,1): ")) + (yellow (read-string "Frame value Yellow (between 0,1): ")) + (black (read-string "Frame value Black (between 0,1): "))) + (TeX-argument-insert + (concat cyan "," magenta "," yellow "," black) optional)) + (let ((cyan (read-string "Box value Cyan (between 0,1): ")) + (magenta (read-string "Box value Magenta (between 0,1): ")) + (yellow (read-string "Box value Yellow (between 0,1): ")) + (black (read-string "Box value Black (between 0,1): "))) + (TeX-argument-insert + (concat cyan "," magenta "," yellow "," black) optional))) + ;; <rgb> model + ((string-equal model "rgb") + (let ((red (read-string "Frame value Red (between 0,1): ")) + (green (read-string "Frame value Green (between 0,1): ")) + (blue (read-string "Frame value Blue (between 0,1): "))) + (TeX-argument-insert + (concat red "," green "," blue) optional)) + (let ((red (read-string "Box value Red (between 0,1): ")) + (green (read-string "Box value Green (between 0,1): ")) + (blue (read-string "box value Blue (between 0,1): "))) + (TeX-argument-insert + (concat red "," green "," blue) optional))) + ;; <gray> model + ((string-equal model "gray") + (let ((grayness (read-string "Frame value Gray (between 0,1): "))) + (TeX-argument-insert grayness optional)) + (let ((grayness (read-string "Box value Gray (between 0,1): "))) + (TeX-argument-insert grayness optional))) + ;; <named> model; allowed are dvipsnames. + ((string-equal model "named") + (let ((color (completing-read "Frame named Color: " + LaTeX-color-dvipsnames-colors))) + (TeX-argument-insert color optional)) + (let ((color (completing-read "Box named Color: " + LaTeX-color-dvipsnames-colors))) + (TeX-argument-insert color optional))))))) + +(TeX-add-style-hook + "color" + (lambda () + ;; Add color to the parser. + (TeX-auto-add-regexp LaTeX-color-definecolor-regexp) + + ;; Add list of colors which are always available. + (LaTeX-add-color-definecolors + "black" "blue" "cyan" "green" "magenta" "red" "white" "yellow") + + ;; Add dvips colors in conjunction with `usenames'. + (when (and (LaTeX-provided-package-options-member "color" "usenames") + (or (LaTeX-provided-package-options-member "color" "dvips") + (LaTeX-provided-package-options-member "color" "dvipsnames"))) + (apply #'LaTeX-add-color-definecolors LaTeX-color-dvipsnames-colors)) + + (TeX-add-symbols + ;; \definecolor{<name>}{<model>}{<color spec>} + '("definecolor" TeX-arg-color-definecolor) + + ;; \color{<name>} or \color[<model>]{<color spec>} + '("color" TeX-arg-color) + + ;; \textcolor{<name>}{<text>} or + ;; \textcolor[<model>]{<color spec>}{<text>} + '("textcolor" TeX-arg-color "Text") + + ;; \pagecolor{<name>} or + ;; \pagecolor[<model>]{<color spec>} + '("pagecolor" TeX-arg-color) + + ;; \nopagecolor + '("nopagecolor" 0) + + ;; \colorbox{<name>}{<text>} or + ;; \colorbox[<model>]{<color spec>}{<text>} + '("colorbox" TeX-arg-color "Text") + + ;; \fcolorbox{<frame color name>}{<box color name>}{<text>} or + ;; \fcolorbox[<model>]{<frame color spec>}{<box color spec>}{<text>} + '("fcolorbox" TeX-arg-color-fcolorbox "Text")) + + ;; Fontification + (when (and (featurep 'font-latex) + (eq TeX-install-font-lock 'font-latex-setup)) + (font-latex-add-keywords '(("color" "[{") + ("pagecolor" "[{")) + 'type-declaration) + (font-latex-add-keywords '(("textcolor" "[{{") + ("colorbox" "[{{" ) + ("fcolorbox" "[{{{")) + 'type-command) + (font-latex-add-keywords '(("definecolor" "{{{")) + 'function))) + LaTeX-dialect) + +(defvar LaTeX-color-package-options + '("debugshow" "dvipdf" "dvipdfm" "dvipdfmx" "dvips" "dvipsnames" + "dvipsone" "dviwin" "dviwindo" "emtex" "monochrome" "nodvipsnames" + "oztex" "pctex32" "pctexhp" "pctexps" "pctexwin" "pdftex" "tcidvi" + "textures" "truetex" "usenames" "vtex" "xdvi" "xetex") + "Package options for the color package.") + +;;; color.el ends here diff --git a/style/currvita.el b/style/currvita.el new file mode 100644 index 00000000..f2a1d551 --- /dev/null +++ b/style/currvita.el @@ -0,0 +1,94 @@ +;;; currvita.el --- AUCTeX style for `currvita.sty' (v0.9i) + +;; Copyright (C) 2015 Free Software Foundation, Inc. + +;; Author: Arash Esbati <esbati'at'gmx.de> +;; Maintainer: auctex-devel@gnu.org +;; Created: 2015-01-05 +;; 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 `currvita.sty' (v0.9i) from 1999/09/13. +;; `currvita.sty' is part of TeXLive. + +;;; Code: + +;; This is a modified version of `LaTeX-env-item'. +(defun LaTeX-currvita-env-with-label (env) + "Insert ENV, a mandatory label and the first item." + (LaTeX-insert-environment + env + (let ((heading (read-string "Heading of list: "))) + (format "{%s}" heading))) + (if (TeX-active-mark) + (progn + (LaTeX-find-matching-begin) + (end-of-line 1)) + (end-of-line 0)) + (delete-char 1) + (when (looking-at (concat "^[ \t]+$\\|" + "^[ \t]*" TeX-comment-start-regexp "+[ \t]*$")) + (delete-region (point) (line-end-position))) + (delete-horizontal-space) + ;; Deactivate the mark here in order to prevent `TeX-parse-macro' + ;; from swapping point and mark and the \item ending up right after + ;; \begin{...}. + (TeX-deactivate-mark) + (LaTeX-insert-item) + ;; The inserted \item may have outdented the first line to the + ;; right. Fill it, if appropriate. + (when (and (not (looking-at "$")) + (not (assoc environment LaTeX-indent-environment-list)) + (> (- (line-end-position) (line-beginning-position)) + (current-fill-column))) + (LaTeX-fill-paragraph nil))) + + +(TeX-add-style-hook + "currvita" + (lambda () + + ;; env's defined by currvita.sty + (LaTeX-add-environments + '("cv" "Heading of CV") + '("cvlist" LaTeX-currvita-env-with-label)) + + ;; Add "cvlist" to the list of environments which have an optional + ;; argument for each item + (add-to-list 'LaTeX-item-list '("cvlist" . LaTeX-item-argument)) + + ;; General commands: "\date" is already provided by AUCTeX + (TeX-add-symbols + '("cvplace" t) + '("cvheadingfont" 0) + '("cvlistheadingfont" 0) + '("cvlabelfont" 0) + '("cvbibname" 0)) + + ;; Add new lengths defined by currvita.sty + (LaTeX-add-lengths "cvlabelwidth" "cvlabelskip" "cvlabelsep")) + LaTeX-dialect) + +(defvar LaTeX-currvita-package-options + '("LabelsAligned" "TextAligned" "openbib" "ManyBibs" "NoDate") + "Package options for the currvita package.") + +;;; currvita.el ends here diff --git a/style/enumitem.el b/style/enumitem.el new file mode 100644 index 00000000..e2fce50b --- /dev/null +++ b/style/enumitem.el @@ -0,0 +1,447 @@ +;;; enumitem.el --- AUCTeX style for `enumitem.sty' (v3.5.2) + +;; Copyright (C) 2015 Free Software Foundation, Inc. + +;; Author: Arash Esbati <esbati'at'gmx.de> +;; Maintainer: auctex-devel@gnu.org +;; Created: 2014-10-20 +;; Keywords: tex + +;; This file is part of AUCTeX. + +;; AUCTeX is free software; you can redistribute it and/or modify it +;; under the terms of the GNU General Public License as published by +;; the Free Software Foundation; either version 3, or (at your option) +;; any later version. + +;; AUCTeX is distributed in the hope that it will be useful, but +;; WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;; General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with AUCTeX; see the file COPYING. If not, write to the Free +;; Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA +;; 02110-1301, USA. + +;;; Commentary: + +;; This file adds support for `enumitem.sty' (v3.5.2) from 2011/09/28. +;; `enumitem.sty' is part of TeXLive. + +;; Tassilo Horn's `minted.el' was a major source of inspiration for +;; this style, many thanks to him (also for patiently answering my +;; many other questions, incl. the stupid ones.) + +;; If things do not work or when in doubt, press `C-c C-n'. Comments +;; for improvement are welcome. + +;;; Code: + +;; Needed for compiling `pushnew': +(eval-when-compile (require 'cl)) + +;; Needed for auto-parsing. +(require 'tex) + +(defvar LaTeX-enumitem-key-val-options + '(;; Vertical Spacing + ("topsep") + ("partopsep") + ("parsep") + ("itemsep") + ;; Horizontal Spacing + ("leftmargin" ("*" "!")) + ("itemindent" ("*" "!")) + ("labelsep" ("*" "!")) + ("labelwidth" ("*" "!")) + ("labelindent" ("*" "!")) + ("labelsep*") + ("labelindent*") + ("widest") + ("widest*") + ("rightmargin") + ;; Labels and cross reference format + ("label") + ("label*") + ("ref") + ("font") + ("format") + ("align" ("left" "right" "parleft")) + ;; Numbering, stopping, resuming + ("start") + ("resume") + ("resume*") + ;; Series + ("series") + ;; Penalties + ("beginpenalty") + ("midpenalty") + ("endpenalty") + ("before") + ("before*") + ("after") + ("after*") + ;; Description styles + ("style" ("standard" "multiline" "nextline" "sameline" "unboxed")) + ;; Compact lists + ("noitemsep") + ("nosep") + ;; Wide lists + ("wide") + ;; Inline lists + ("itemjoin") + ("itemjoin*") + ("afterlabel") + ("mode" ("boxed" "unboxed"))) + "Key=value options for enumitem macros and environments.") + +(defvar LaTeX-enumitem-key-val-options-local nil + "Buffer-local key=value options for enumitem macros and environments.") +(make-variable-buffer-local 'LaTeX-enumitem-key-val-options-local) + +;; Variables needed for \newlist: This command is not hooked into +;; the parser via `TeX-auto-add-type', we mimic that behaviour. + +(defvar LaTeX-enumitem-newlist-list nil + "List of environments defined by command `\\newlist' from +`enumitem' package.") + +(defvar LaTeX-enumitem-newlist-list-local nil + "Local list of all environments definded with `\\newlist' +plus available through `enumitem' package.") +(make-variable-buffer-local 'LaTeX-enumitem-newlist-list-local) + +(defvar LaTeX-enumitem-newlist-list-item-arg nil + "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.") + +(defvar LaTeX-enumitem-newlist-regexp + '("\\\\newlist{\\([^}]+\\)}{\\([^}]+\\)}" + (1 2) LaTeX-auto-enumitem-newlist) + "Matches the arguments of `\\newlist' from `enumitem' +package.") + + +;; Setup for \SetEnumitemKey: + +(TeX-auto-add-type "enumitem-SetEnumitemKey" "LaTeX") + +(defvar LaTeX-enumitem-SetEnumitemKey-regexp + '("\\\\SetEnumitemKey{\\([^}]+\\)}" + 1 LaTeX-auto-enumitem-SetEnumitemKey) + "Matches the arguments of `\\SetEnumitemKey' from `enumitem' +package.") + + +;; Setup for \SetEnumitemValue: + +(TeX-auto-add-type "enumitem-SetEnumitemValue" "LaTeX") + +;; Upon Tassilo's recommendation, we include also `0' so that we can +;; use the function `LaTeX-enumitem-SetEnumitemValue-list' while we +;; make sure that `TeX-auto-list-information' doesn't remove multiple +;; defined values to a specific key. For this reason, we also ignore +;; the 3. argument to the `\SetEnumitemValue' macro (i.e., a third +;; {\\([^}]+\\)} in regex) so that we don't pollute the generated +;; `docname.el' with unnecessary (La)TeX code. +(defvar LaTeX-enumitem-SetEnumitemValue-regexp + '("\\\\SetEnumitemValue{\\([^}]+\\)}{\\([^}]+\\)}" + (0 1 2) LaTeX-auto-enumitem-SetEnumitemValue) + "Matches the arguments of `\\SetEnumitemValue' from `enumitem' +package.") + +;; Plug them into the machinery. +(defun LaTeX-enumitem-auto-prepare () + "Clear various `LaTeX-enumitem-*' before parsing." + (setq LaTeX-auto-enumitem-newlist nil + LaTeX-enumitem-newlist-list nil + LaTeX-enumitem-newlist-list-item-arg nil + LaTeX-auto-enumitem-SetEnumitemKey nil + LaTeX-auto-enumitem-SetEnumitemValue nil)) + +(defun LaTeX-enumitem-auto-cleanup () + "Move parsing results into right places for further usage." + ;; \newlist{<name>}{<type>}{<max-depth>} + ;; env=<name>, type=<type>, ignored=<max-depth> + (dolist (env-type LaTeX-auto-enumitem-newlist) + (let* ((env (car env-type)) + (type (cadr env-type))) + (add-to-list 'LaTeX-auto-environment + (list env 'LaTeX-enumitem-env-with-opts)) + (add-to-list 'LaTeX-enumitem-newlist-list + (list env)) + (when (or (string-equal type "description") + (string-equal type "description*")) + (add-to-list 'LaTeX-enumitem-newlist-list-item-arg + (list env)))))) + +(add-hook 'TeX-auto-prepare-hook #'LaTeX-enumitem-auto-prepare t) +(add-hook 'TeX-auto-cleanup-hook #'LaTeX-enumitem-auto-cleanup t) + +(defun LaTeX-enumitem-env-with-opts (env) + "Update available key-val options, then insert ENV and optional +key-val and the first item." + (LaTeX-enumitem-update-key-val-options) + (LaTeX-insert-environment + env + (let ((opts (TeX-read-key-val t LaTeX-enumitem-key-val-options-local))) + (when (and opts (not (string-equal opts ""))) + (format "[%s]" opts)))) + (if (TeX-active-mark) + (progn + (LaTeX-find-matching-begin) + (end-of-line 1)) + (end-of-line 0)) + (delete-char 1) + (when (looking-at (concat "^[ \t]+$\\|" + "^[ \t]*" TeX-comment-start-regexp "+[ \t]*$")) + (delete-region (point) (line-end-position))) + (delete-horizontal-space) + ;; Deactivate the mark here in order to prevent `TeX-parse-macro' + ;; from swapping point and mark and the \item ending up right after + ;; \begin{...}. + (TeX-deactivate-mark) + (LaTeX-insert-item) + ;; The inserted \item may have outdented the first line to the + ;; right. Fill it, if appropriate. + (when (and (not (looking-at "$")) + (not (assoc environment LaTeX-indent-environment-list)) + (> (- (line-end-position) (line-beginning-position)) + (current-fill-column))) + (LaTeX-fill-paragraph nil))) + +(defun LaTeX-arg-SetEnumitemKey (optional &optional prompt) + "Ask for a new key to be defined and add it to +`LaTeX-enumitem-key-val-options-local'." + (LaTeX-enumitem-update-key-val-options) + (let ((key (TeX-read-string "New Key: ")) + (replace (TeX-read-key-val optional + LaTeX-enumitem-key-val-options-local "Replacement"))) + (TeX-argument-insert key optional) + (TeX-argument-insert replace optional) + (add-to-list 'LaTeX-enumitem-key-val-options-local (list key)) + (LaTeX-add-enumitem-SetEnumitemKeys key))) + +;; In `LaTeX-enumitem-SetEnumitemValue-regexp', we match (0 1 2). +;; When adding a new `key=val', we need something unique for `0'-match +;; until the next `C-c C-n'. We mimic that regex-match bei concat'ing +;; the elements and pass the result to +;; `LaTeX-add-enumitem-SetEnumitemValues'. It will vanish upon next +;; invocation of `C-c C-n'. +(defun LaTeX-arg-SetEnumitemValue (optional &optional prompt) + "Ask for a new value added to an existing key incl. the final +replacement of the value." + (LaTeX-enumitem-update-key-val-options) + (let* ((key (TeX-read-key-val optional LaTeX-enumitem-key-val-options-local "Key")) + (val (TeX-read-string "String value: ")) + ;; (key-match (car (assoc key LaTeX-enumitem-key-val-options-local))) + (val-match (cdr (assoc key LaTeX-enumitem-key-val-options-local))) + (temp (copy-alist LaTeX-enumitem-key-val-options-local)) + (opts (assq-delete-all (car (assoc key temp)) temp))) + (if val-match + (pushnew (list key (delete-dups (apply 'append (list val) val-match))) + opts :test #'equal) + (pushnew (list key (list val)) opts :test #'equal)) + (setq LaTeX-enumitem-key-val-options-local (copy-alist opts)) + (TeX-argument-insert key optional) + (TeX-argument-insert val optional) + (LaTeX-add-enumitem-SetEnumitemValues + (list (concat "\\SetEnumitemValue{" key "}{" val "}") + key val)))) + +(defun LaTeX-enumitem-update-key-val-options () + "Update the buffer-local key-val options before offering them +in `enumitem'-completions." + (dolist (key (LaTeX-enumitem-SetEnumitemKey-list)) + (add-to-list 'LaTeX-enumitem-key-val-options-local key)) + (dolist (keyvals (LaTeX-enumitem-SetEnumitemValue-list)) + (let* ((key (nth 1 keyvals)) + (val (nth 2 keyvals)) + ;; (key-match (car (assoc key LaTeX-enumitem-key-val-options-local))) + (val-match (cdr (assoc key LaTeX-enumitem-key-val-options-local))) + (temp (copy-alist LaTeX-enumitem-key-val-options-local)) + (opts (assq-delete-all (car (assoc key temp)) temp))) + (if val-match + (pushnew (list key (delete-dups (apply 'append (list val) val-match))) + opts :test #'equal) + (pushnew (list key (list val)) opts :test #'equal)) + (setq LaTeX-enumitem-key-val-options-local (copy-alist opts))))) + + +(TeX-add-style-hook + "enumitem" + (lambda () + + ;; Add enumitem to the parser. + (TeX-auto-add-regexp LaTeX-enumitem-newlist-regexp) + (TeX-auto-add-regexp LaTeX-enumitem-SetEnumitemKey-regexp) + (TeX-auto-add-regexp LaTeX-enumitem-SetEnumitemValue-regexp) + + ;; Activate the buffer-local version of key-vals. + (setq LaTeX-enumitem-key-val-options-local + (copy-alist LaTeX-enumitem-key-val-options)) + + ;; Set the standard env's to the local list. + (setq LaTeX-enumitem-newlist-list-local + '(("itemize") ("enumerate") ("description"))) + + ;; Add the starred versions to the local list. + (when (LaTeX-provided-package-options-member "enumitem" "inline") + (setq LaTeX-enumitem-newlist-list-local + (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) + '("enumerate" LaTeX-enumitem-env-with-opts) + '("description" LaTeX-enumitem-env-with-opts)) + + ;; Make inline env's available with package option "inline" + (when (LaTeX-provided-package-options-member "enumitem" "inline") + (LaTeX-add-environments + '("itemize*" LaTeX-enumitem-env-with-opts) + '("enumerate*" LaTeX-enumitem-env-with-opts) + '("description*" LaTeX-enumitem-env-with-opts)) + (add-to-list 'LaTeX-item-list '("description*" . LaTeX-item-argument))) + + ;; Cloning lists + (TeX-add-symbols + ;; The easy way would be: + ;; '("newlist" + ;; "Name" (TeX-arg-eval + ;; completing-read "Type: " + ;; '(("itemize") ("enumerate") ("description") + ;; ("itemize*") ("enumerate*") ("description*"))) + ;; "Max-depth") + ;; But we go the extra mile to improve the user experience and add + ;; the arguments directly to appropriate lists. + ;; \newlist{<name>}{<type>}{<max-depth>} + '("newlist" + (TeX-arg-eval + (lambda () + (let ((name (TeX-read-string "Name: ")) + (type (completing-read + "Type: " + '(("itemize") ("enumerate") ("description") + ("itemize*") ("enumerate*") ("description*")))) + (depth (TeX-read-string "Max-depth: "))) + (setq LaTeX-enumitem-newlist-list-local + (append `(,(list name)) LaTeX-enumitem-newlist-list-local)) + (when (or (string-equal type "description") + (string-equal type "description*")) + (add-to-list 'LaTeX-item-list `(,name . LaTeX-item-argument))) + (LaTeX-add-environments `(,name LaTeX-enumitem-env-with-opts)) + (insert (format "{%s}" name) + (format "{%s}" type)) + (format "%s" depth))))) + + ;; \renewlist{<name>}{<type>}{<max-depth>} + '("renewlist" + (TeX-arg-eval completing-read "Name: " + LaTeX-enumitem-newlist-list-local) + (TeX-arg-eval completing-read "Type: " + '(("itemize") ("enumerate") ("description") + ("itemize*") ("enumerate*") ("description*"))) + "Max-depth") + + ;; \setlist{<names,levels>}{<key-vals>} + '("setlist" + [TeX-arg-eval mapconcat 'identity + (TeX-completing-read-multiple + "Environment(s), level(s): " + `(,@LaTeX-enumitem-newlist-list-local + ("1") ("2") ("3") ("4"))) ","] + (TeX-arg-eval + (lambda () + (LaTeX-enumitem-update-key-val-options) + (let ((opts (TeX-read-key-val nil LaTeX-enumitem-key-val-options-local))) + (format "%s" opts))))) + + ;; \setlist*{<names,levels>}{<key-vals>} + '("setlist*" + [TeX-arg-eval mapconcat 'identity + (TeX-completing-read-multiple + "Environment, level: " + `(,@LaTeX-enumitem-newlist-list-local + ("1") ("2") ("3") ("4"))) ","] + (TeX-arg-eval + (lambda () + (LaTeX-enumitem-update-key-val-options) + (let ((opts (TeX-read-key-val nil LaTeX-enumitem-key-val-options-local))) + (format "%s" opts))))) ) + + ;; General commands: + (TeX-add-symbols + + ;; Ask for an Integer and insert it. + '("setlistdepth" "Integer") + + ;; Just add the braces and let the user do the rest. + '("AddEnumerateCounter" 3) + + ;; This command only makes sense for enumerate type environments. + ;; Currently, we offer all defined env's -- to be improved + ;; sometimes. + '("restartlist" + (TeX-arg-eval completing-read "List name: " + LaTeX-enumitem-newlist-list-local)) + + ;; "Key" will be parsed and added to key-val list. + '("SetEnumitemKey" LaTeX-arg-SetEnumitemKey) + + ;; "Key" and "Value" are added to our key-val list + '("SetEnumitemValue" LaTeX-arg-SetEnumitemValue "Replacement")) + + ;; Setting enumerate short label + (when (LaTeX-provided-package-options-member "enumitem" "shortlabels") + (TeX-add-symbols + '("SetEnumerateShortLabel" + (TeX-arg-eval completing-read "Key: " + '(("A") ("a") ("I") ("i") ("1"))) + "Replacement"))) + + ;; Fontification + (when (and (featurep 'font-latex) + (eq TeX-install-font-lock 'font-latex-setup)) + (font-latex-add-keywords '(("newlist" "{{{") + ("renewlist" "{{{") + ("setlist" "*[{") + ("AddEnumerateCounter" "{{{") + ("SetEnumitemKey" "{{" ) + ("SetEnumitemValue" "{{{")) + 'function) + (font-latex-add-keywords '(("restartlist" "{" ) + ("setlistdepth" "{" ) + ("SetEnumerateShortLabel" "{{")) + 'variable))) + LaTeX-dialect) + +(defvar LaTeX-enumitem-package-options + '("inline" "ignoredisplayed" "shortlabels" "loadonly") + "Package options for the enumitem package.") + +;;; enumitem.el ends here diff --git a/style/expl3.el b/style/expl3.el new file mode 100644 index 00000000..6293b875 --- /dev/null +++ b/style/expl3.el @@ -0,0 +1,51 @@ +;;; expl3.el --- AUCTeX style for `expl3.sty' + +;; Copyright (C) 2015 Free Software Foundation, Inc. + +;; Author: Tassilo Horn <t...@gnu.org> +;; Maintainer: auctex-devel@gnu.org +;; Created: 2015-02-22 +;; 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 `expl3.sty'. + +;;; Code: + +(defvar LaTeX-expl3-syntax-table + (let ((st (copy-syntax-table LaTeX-mode-syntax-table))) + ;; Make _ and : symbol chars + (modify-syntax-entry ?\_ "_" st) + (modify-syntax-entry ?\: "_" st) + st)) + +(TeX-add-style-hook + "expl3" + (lambda () + (set-syntax-table LaTeX-expl3-syntax-table) + (when (and (featurep 'font-latex) + (eq TeX-install-font-lock 'font-latex-setup)) + ;; For syntactic fontification, e.g. verbatim constructs. + (font-latex-set-syntactic-keywords) + ;; Tell font-lock about the update. + (setq font-lock-set-defaults nil) + (font-lock-set-defaults))) + LaTeX-dialect) diff --git a/style/geometry.el b/style/geometry.el new file mode 100644 index 00000000..d2631836 --- /dev/null +++ b/style/geometry.el @@ -0,0 +1,150 @@ +;;; geometry.el --- AUCTeX style for `geometry.sty' (v5.6) + +;; Copyright (C) 2015 Free Software Foundation, Inc. + +;; Author: Arash Esbati <esbati'at'gmx.de> +;; Maintainer: auctex-devel@gnu.org +;; Created: 2015-02-21 +;; 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 `geometry.sty' (v5.6) from 2010/09/12. +;; `geometry.sty' is part of TeXLive. + +;;; Code: + +(defvar LaTeX-geometry-always-key-val-options + '(("layout") ("layoutwidth") ("layoutheight") ("layoutsize") + ("layouthoffset") ("layoutvoffset") ("layoutoffset") ("hscale") + ("vscale") ("scale") ("width") ("totalwidth") ("height") ("totalheight") + ("total") ("textwidth") ("textheight") ("text") ("body") ("lines") + ("includehead") ("includefoot") ("includeheadfoot") ("includemp") + ("includeall") ("ignorehead") ("ignorefoot") ("ignoreheadfoot") + ("ignoremp") ("ignoreall") ("heightrounded") ("hdivide") ("vdivide") + ("divide") ("left") ("lmargin") ("inner") ("right") ("rmargin") + ("outer") ("top") ("tmargin") ("bottom") ("bmargin") ("hmargin") + ("vmargin") ("margin") ("hmarginratio") ("vmarginratio") ("marginratio") + ("ratio") ("hcentering") ("vcentering") ("centering") ("twoside") + ("asymmetric") ("bindingoffset") ("hdivide") ("vdivide") ("divide") + ("headheight") ("head") ("headsep") ("footskip") ("foot") ("nohead") + ("nofoot") ("noheadfoot") ("footnotesep") ("marginparwidth") ("marginpar") + ("marginparsep") ("nomarginpar") ("columnsep") ("hoffset") ("voffset") + ("offset") ("twocolumn") ("onecolumn") ("twoside") ("textwidth") + ("textheight") ("reversemp") ("reversemarginpar")) + "Key=value options always available for geometry macros.") + +(defvar LaTeX-geometry-preamble-key-val-options + '(("paper" ("a0paper" "a1paper" "a2paper" "a3paper" "a4paper" + "a5paper" "a6paper" "b0paper" "b1paper" "b2paper" + "b3paper" "b4paper" "b5paper" "b6paper" "c0paper" + "c1paper" "c2paper" "c3paper" "c4paper" "c5paper" + "c6paper" "b0j" "b1j" "b2j" "b3j" "b4j" "b5j" "b6j" + "ansiapaper" "ansibpaper" "ansicpaper" "ansidpaper" + "ansiepaper" "ansiapaper" "ansibpaper" "ansicpaper" + "ansidpaper" "ansiepaper")) + ("papername" ("a0paper" "a1paper" "a2paper" "a3paper" "a4paper" + "a5paper" "a6paper" "b0paper" "b1paper" "b2paper" + "b3paper" "b4paper" "b5paper" "b6paper" "c0paper" + "c1paper" "c2paper" "c3paper" "c4paper" "c5paper" + "c6paper" "b0j" "b1j" "b2j" "b3j" "b4j" "b5j" "b6j" + "ansiapaper" "ansibpaper" "ansicpaper" "ansidpaper" + "ansiepaper" "ansiapaper" "ansibpaper" "ansicpaper" + "ansidpaper" "ansiepaper")) + ("a0paper") ("a1paper") ("a2paper") ("a3paper") ("a4paper") ("a5paper") + ("a6paper") ("b0paper") ("b1paper") ("b2paper") ("b3paper") ("b4paper") + ("b5paper") ("b6paper") ("c0paper") ("c1paper") ("c2paper") ("c3paper") + ("c4paper") ("c5paper") ("c6paper") ("b0j") ("b1j") ("b2j") ("b3j") + ("b4j") ("b5j") ("b6j") ("ansiapaper") ("ansibpaper") ("ansicpaper") + ("ansidpaper") ("ansiepaper") ("ansiapaper") ("ansibpaper") ("ansicpaper") + ("ansidpaper") ("ansiepaper") ("screen") ("paperwidth") ("paperheight") + ("papersize") ("landscape") ("portrait") + ("driver" ("dvips" "dvipdfm" "pdftex" "vtex" "xetex" "auto" "none")) + ("dvips") ("dvipdfm") ("pdftex") ("xetex") ("vtex") ("verbose") + ("reset") ("mag") ("truedimen") ("pass") ("showframe") ("showcrop")) + "Key=value options allowed only in the preamble for geometry macros.") + + +;; Needed for auto-parsing. +(require 'tex) + +;; Setup for \savegeometry: +(TeX-auto-add-type "geometry-savegeometry" "LaTeX" "geometry-savegeometries") + +(defvar LaTeX-geometry-savegeometry-regexp + '("\\\\savegeometry{\\([^}]+\\)}" + 1 LaTeX-auto-geometry-savegeometry) + "Matches the argument of `\\savegeometry' from `geometry' +package.") + +(defun LaTeX-geometry-auto-prepare () + "Clear `LaTeX-auto-geometry-savegeometry' before parsing." + (setq LaTeX-auto-geometry-savegeometry nil)) + +(add-hook 'TeX-auto-prepare-hook #'LaTeX-geometry-auto-prepare t) + +(TeX-add-style-hook + "geometry" + (lambda () + + ;; Add geometry to the parser. + (TeX-auto-add-regexp LaTeX-geometry-savegeometry-regexp) + + ;; geometry commands: + (TeX-add-symbols + '("geometry" + (TeX-arg-eval TeX-read-key-val nil + (append LaTeX-geometry-preamble-key-val-options + LaTeX-geometry-always-key-val-options))) + '("newgeometry" + (TeX-arg-key-val LaTeX-geometry-always-key-val-options)) + + '("restoregeometry" 0) + + '("savegeometry" + (TeX-arg-eval + (lambda () + (let ((name (TeX-read-string "Name: "))) + (LaTeX-add-geometry-savegeometries name) + (format "%s" name))))) + + '("loadgeometry" + (TeX-arg-eval + (lambda () + (completing-read "Name: " + (LaTeX-geometry-savegeometry-list)))))) + + ;; Fontification + (when (and (featurep 'font-latex) + (eq TeX-install-font-lock 'font-latex-setup)) + (font-latex-add-keywords '(("geometry" "{") + ("newgeometry" "{") + ("savegeometry" "{") + ("loadgeometry" "{")) + 'function))) + LaTeX-dialect) + +(defun LaTeX-geometry-package-options () + "Prompt for package options for the geometry package." + (TeX-read-key-val t + (append LaTeX-geometry-preamble-key-val-options + LaTeX-geometry-always-key-val-options))) + +;;; geometry.el ends here diff --git a/style/ltablex.el b/style/ltablex.el new file mode 100644 index 00000000..5e0fad53 --- /dev/null +++ b/style/ltablex.el @@ -0,0 +1,49 @@ +;;; ltablex.el --- AUCTeX style for `ltablex.sty' (v1.1) + +;; Copyright (C) 2015 Free Software Foundation, Inc. + +;; Author: Arash Esbati <esbati'at'gmx.de> +;; Maintainer: auctex-devel@gnu.org +;; Created: 2015-03-14 +;; 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 `ltablex.sty' (v1.1) from 2014/08/13. +;; `ltablex.sty' is part of TeXLive. `ltablex.sty' modifies the +;; tabularx environment to combine the features of the tabularx +;; package with those of the longtable package. All we need is to +;; call those styles and add two macros. + +;;; Code: + +(TeX-add-style-hook + "ltablex" + (lambda () + (TeX-run-style-hooks "tabularx" "longtable") + (TeX-add-symbols + '("keepXColumns" 0) + '("convertXColumns" 0))) + LaTeX-dialect) + +(defvar LaTeX-ltablex-package-options nil + "Package options for the ltablex package.") + +;;; ltablex.el ends here diff --git a/style/ltxtable.el b/style/ltxtable.el new file mode 100644 index 00000000..ddc7c89d --- /dev/null +++ b/style/ltxtable.el @@ -0,0 +1,51 @@ +;;; ltxtable.el --- AUCTeX style for `ltxtable.sty' (v0.2) + +;; Copyright (C) 2015 Free Software Foundation, Inc. + +;; Author: Arash Esbati <esbati'at'gmx.de> +;; Maintainer: auctex-devel@gnu.org +;; Created: 2015-03-14 +;; 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 `ltxtable.sty' (v0.2) from 1995/12/11. +;; `ltxtable.sty' is part of TeXLive. + +;;; Code: + +(TeX-add-style-hook + "ltxtable" + (lambda () + (TeX-run-style-hooks "tabularx" "longtable") + (TeX-add-symbols + '("LTXtable" + (TeX-arg-length) + (TeX-arg-eval + (lambda () + (let ((longtable (file-relative-name + (read-file-name "File with longtable: ")))) + (format "%s" longtable))))))) + LaTeX-dialect) + +(defvar LaTeX-ltxtable-package-options nil + "Package options for the ltxtable package.") + +;;; ltxtable.el ends here diff --git a/style/mn2e.el b/style/mn2e.el new file mode 100644 index 00000000..0c6d9f6e --- /dev/null +++ b/style/mn2e.el @@ -0,0 +1,175 @@ +;;; mn2e.el --- AUCTeX style for `mn2e.cls' version 2.2. + +;; Copyright (C) 2015 Free Software Foundation, Inc. + +;; Maintainer: auctex-devel@gnu.org +;; Author: Mosè Giordano <m...@gnu.org> +;; 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 `mn2e.cls' version 2.2. + +;;; Code: + +(TeX-add-style-hook + "mn2e" + (lambda () + (if (LaTeX-provided-class-options-member "mn2e" "usegraphicx") + (TeX-run-style-hooks "graphicx")) + (if (LaTeX-provided-class-options-member "mn2e" "usenatbib") + (TeX-run-style-hooks "natbib")) + (if (LaTeX-provided-class-options-member "mn2e" "usedcolumn") + (TeX-run-style-hooks "dcolumn")) + (TeX-add-symbols + ;; 4.5.3 Bold Greek + "balpha" + "bbeta" + "bgamma" + "bdelta" + "bepsilon" + "bzeta" + "boldeta" + "btheta" + "biota" + "bkappa" + "blambda" + "bmu" + "bnu" + "bxi" + "bpi" + "brho" + "bsigma" + "btau" + "bupsilon" + "bphi" + "bchi" + "bpsi" + "bomega" + "bvarepsilon" + "bvartheta" + "bvarpi" + "bvarrho" + "bvarsigma" + "bvarphi" + ;; 4.5.5 Special symbols + "getsto" + "cor" + "lid" + "gid" + "sol" + "sog" + "lse" + "gse" + "grole" + "leogr" + "loa" + "goa" + "sun" + "earth" + "degr" + "diameter" + "sq" + "squareforqed" + "fd" + "fh" + "fm" + "fs" + "fdg" + "farcm" + "farcs" + "fp" + "arcmin" + "arcsec" + "micron" + ;; Authors' notes + '("title" ["Short title"] "Long title") + '("author" ["Short author(s)"] (LaTeX-arg-author "Long author(s)")) + "newauthor" + "nokeywords" + "plate" + "contcaption" + '("bmath" "Math text") + '("mathbfss" "Text") + '("textbfss" "Text") + '("mathbfit" "Text") + '("textbfit" "Text") + ;; Editors' notes + "pagerange" + "volume" + "pubyear" + "journal" + "bsp") + (if (LaTeX-provided-class-options-member "mn2e" "useAMS") + (TeX-add-symbols + ;; 4.5.4 Upright Greek characters + "upi" + "umu" + "upartial" + "leqslant" + "geqslant" + "la" + "ga")) + (LaTeX-add-environments + "keywords" + "abstract" + "proof") + (LaTeX-add-pagestyles + "headings" + "myheadings" + "titlepage" + "plate") + (LaTeX-add-counters + "part" + "section" + "subsection" + "subsubsection" + "paragraph" + "subparagraph" + "dummy" + "table" + "figure") + (LaTeX-add-lengths + "realparindent" + "bibhang") + + ;; Fontification + (when (and (featurep 'font-latex) + (eq TeX-install-font-lock 'font-latex-setup)) + (font-latex-add-keywords '(("author" "[{") + ("title" "[{") + ("newauthor") + ("nokeywords" "{") + ("plate" "{") + ("contcaption" "{") + ("pagerange" "{") + ("volume" "{") + ("pubyear" "{") + ("journal") + ("bsp")) + 'function))) + LaTeX-dialect) + +(defvar LaTeX-mn2e-class-options + '("useAMS" "usegraphicx" "usenatbib" "usedcolumn" + "doublespacing" "galley" "landscape" "letters" "onecolumn" "referee") + "Package options for the mn2e package.") + +;; mn2e.el ends here diff --git a/style/tcolorbox.el b/style/tcolorbox.el new file mode 100644 index 00000000..73c85556 --- /dev/null +++ b/style/tcolorbox.el @@ -0,0 +1,82 @@ +;;; tcolorbox.el --- AUCTeX style for `tcolorbox.sty' + +;; Copyright (C) 2015 Free Software Foundation, Inc. + +;; Author: Tassilo Horn <t...@gnu.org> +;; Maintainer: auctex-devel@gnu.org +;; Created: 2015-01-04 +;; 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 `tcolorbox.sty'. + +;;; Code: + +;; TODO: There are tons of more options... +(defvar LaTeX-tcolorbox-keyval-options + '(("title") + ("notitle") + ("adjusted title") + ("adjust text") + ("squeezed title") + ("squeezed title*") + ("detach title") + ("attach title") + ("attach title to upper") + ("upperbox" ("visible" "invisible")) + ("visible") + ("invisible") + ("lowerbox" ("visible" "invisible" "ignored")) + ("savelowerto") + ("lower separated" ("true" "false")) + ("savedelimiter") + ("colframe") + ("colback") + ("title filled" ("true" "false")) + ("colbacktitle") + ("colupper") + ("collower") + ("coltext") + ("coltitle") + ("fontupper") + ("fontlower") + ("fonttitle") + ("width") + ("height") + ("after") + ("before"))) + +(TeX-add-style-hook + "tcolorbox" + (lambda () + ;; TODO: There are many more macros + (TeX-add-symbols + "tcblower" + '("tcbset" + (TeX-arg-key-val LaTeX-tcolorbox-keyval-options)) + '("tcbsetforeverylayer" + (TeX-arg-key-val LaTeX-tcolorbox-keyval-options))) + (LaTeX-add-environments + '("tcolorbox" LaTeX-env-args + [TeX-arg-key-val LaTeX-tcolorbox-keyval-options]))) + LaTeX-dialect) + +;;; tcolorbox.el ends here diff --git a/tex-buf.el b/tex-buf.el index 26230234..c61ffafe 100644 --- a/tex-buf.el +++ b/tex-buf.el @@ -557,8 +557,8 @@ QUEUE is non-nil when we are checking for the printer queue." (if (listp TeX-output-extension) (car TeX-output-extension) (or (TeX-process-get-variable (TeX-active-master) - 'TeX-output-extension - TeX-output-extension) + 'TeX-output-extension + TeX-output-extension) TeX-output-extension))) (defun TeX-view-mouse (event) @@ -603,6 +603,12 @@ the current style options." ;;; Command Hooks +(defvar TeX-after-TeX-LaTeX-command-finished-hook nil + "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.") + (defvar TeX-after-start-process-function nil "Hooks to run after starting an asynchronous process. Used by Japanese TeX to set the coding system.") @@ -1110,7 +1116,12 @@ changed\\. Rerun LaTeX\\." nil t) (setq TeX-command-next TeX-command-Show)) (t (message "%s%s%s" name ": problems after " (TeX-current-pages)) - (setq TeX-command-next TeX-command-default)))) + (setq TeX-command-next TeX-command-default))) + (unless TeX-error-list + (run-hook-with-args 'TeX-after-TeX-LaTeX-command-finished-hook + (with-current-buffer TeX-command-buffer + (expand-file-name + (TeX-active-master (TeX-output-extension))))))) ;; should go into latex.el? --pg (defun TeX-BibTeX-sentinel (process name) @@ -1820,14 +1831,6 @@ Return non-nil if an error or warning is found." (defun TeX-find-display-help (type file line error offset context string line-end bad-box error-point) "Find the error and display the help." - (unless file - (cond - ;; XXX: error messages have to be different? - ((equal type 'error) - (error "Error occurred after last TeX file closed")) - (t - (error "Could not determine file for warning")))) - ;; Go back to TeX-buffer (let ((runbuf (TeX-active-buffer)) (master (with-current-buffer TeX-command-buffer @@ -1835,33 +1838,41 @@ Return non-nil if an error or warning is found." (command-buffer TeX-command-buffer) error-file-buffer start) (run-hooks 'TeX-translate-location-hook) - (setq error-file-buffer - (find-file - (expand-file-name file (file-name-directory master)))) - ;; Set the value of `TeX-command-buffer' in the next file with an - ;; error to be displayed to the value it has in the current buffer. - (with-current-buffer error-file-buffer - (set (make-local-variable 'TeX-command-buffer) command-buffer)) - - ;; Find the location of the error or warning. - (when line - (goto-char (point-min)) - (forward-line (+ offset line -1)) - (cond - ;; Error. - ((equal type 'error) - (if (not (string= string " ")) - (search-forward string nil t))) - ;; Warning or bad box. - (t - (beginning-of-line 0) - (setq start (point)) - (goto-char (point-min)) - (forward-line (+ offset line-end -1)) - (end-of-line) - (when string - (search-backward string start t) - (search-forward string nil t))))) + + (if file + (progn + (setq error-file-buffer + (find-file + (expand-file-name file (file-name-directory master)))) + ;; Set the value of `TeX-command-buffer' in the next file with an + ;; error to be displayed to the value it has in the current buffer. + (with-current-buffer error-file-buffer + (set (make-local-variable 'TeX-command-buffer) command-buffer)) + + ;; Find the location of the error or warning. + (when line + (goto-char (point-min)) + (forward-line (+ offset line -1)) + (cond + ;; Error. + ((equal type 'error) + (if (not (string= string " ")) + (search-forward string nil t))) + ;; Warning or bad box. + (t + (beginning-of-line 0) + (setq start (point)) + (goto-char (point-min)) + (forward-line (+ offset line-end -1)) + (end-of-line) + (when string + (search-backward string start t) + (search-forward string nil t)))))) + ;; When the file cannot be determined stay here but issue a warning. + (message (concat "Could not determine file for " + (cond ((equal type 'error) "error") + (t "warning")))) + (beep)) ;; Display the help. (cond ((eq TeX-display-help 'expert) diff --git a/tex.el b/tex.el index a17b8b40..88e2336b 100644 --- a/tex.el +++ b/tex.el @@ -1096,6 +1096,27 @@ search are checked, too." (cdr (caar (cdr elem))))) spec)))))))) +(defun TeX-pdf-tools-sync-view () + "Focus the focused page/paragraph in `pdf-view-mode'. +If `TeX-source-correlate-mode' is disabled, only find and pop to +the output PDF file. Used by default for the PDF Tools viewer +entry in `TeX-view-program-list-builtin'." + (unless (featurep 'pdf-tools) + (error "PDF Tools are not installed")) + (unless TeX-PDF-mode + (error "PDF Tools only work with PDF output")) + (add-hook 'pdf-sync-backward-redirect-functions + #'TeX-source-correlate-handle-TeX-region) + (if (and TeX-source-correlate-mode + (fboundp 'pdf-sync-forward-search)) + (with-current-buffer (or (find-buffer-visiting + (concat file "." TeX-default-extension)) + (current-buffer)) + (pdf-sync-forward-search)) + (let ((pdf (concat file "." (TeX-output-extension)))) + (pop-to-buffer (or (find-buffer-visiting pdf) + (find-file-noselect pdf)))))) + (defvar url-unreserved-chars) (defun TeX-evince-sync-view () @@ -1164,7 +1185,8 @@ the requirements are met." " -i %(outpage)" " -p %(outpage)")) " %o")) "evince") ("Okular" ("okular --unique %o" (mode-io-correlate "#src:%n%a")) "okular") - ("xdg-open" "xdg-open %o" "xdg-open")))) + ("xdg-open" "xdg-open %o" "xdg-open") + ("PDF Tools" TeX-pdf-tools-sync-view)))) "Alist of built-in viewer specifications. This variable should not be changed by the user who can use `TeX-view-program-list' to add new viewers or overwrite the @@ -1301,8 +1323,8 @@ are evaluated positively is chosen." (mapc (lambda (spec) (add-to-list 'list `(const ,(car spec)))) - (append TeX-view-program-list - TeX-view-program-list-builtin)) + (append TeX-view-program-list + TeX-view-program-list-builtin)) (sort list (lambda (a b) (string< (downcase (cadr a)) @@ -1601,6 +1623,21 @@ If this is nil, an empty string will be returned." "Keymap for `TeX-source-correlate-mode'. You could use this for unusual mouse bindings.") +(defun TeX-source-correlate-handle-TeX-region (file line col) + "Translate backward search info with respect to `TeX-region'. +That is, if FILE is `TeX-region', update FILE to the real tex +file and LINE to (+ LINE offset-of-region). Else, return nil." + (when (string-equal TeX-region (file-name-sans-extension + (file-name-nondirectory file))) + (with-current-buffer (or (find-buffer-visiting file) + (find-file-noselect file)) + (goto-char 0) + (when (re-search-forward "!offset(\\([[:digit:]]+\\))" nil t) + (let ((offset (string-to-int (match-string-no-properties 1)))) + (when TeX-region-orig-buffer + (list (expand-file-name (buffer-file-name TeX-region-orig-buffer)) + (+ line offset) col))))))) + (defun TeX-source-correlate-sync-source (file linecol &rest ignored) "Show TeX FILE with point at LINECOL. This function is called when emacs receives a SyncSource signal @@ -1610,55 +1647,37 @@ or newer." ;; FILE may be given as relative path to the TeX-master root document or as ;; absolute file:// URL. In the former case, the tex file has to be already ;; opened. - (let* ((line (car linecol)) - (col (cadr linecol)) - (region (string= TeX-region (file-name-sans-extension - (file-name-nondirectory file)))) - (region-search-string nil) - (buf (let ((f (condition-case nil - (progn - (require 'url-parse) - (require 'url-util) - (url-unhex-string (aref (url-generic-parse-url file) 6))) - ;; For Emacs 21 compatibility, which doesn't have the - ;; url package. - (file-error (replace-regexp-in-string "^file://" "" file))))) - (cond - ;; Copy the text referenced by syntex relative in the region - ;; file so that we can search it in the original file. - (region (let ((region-buf (get-buffer (file-name-nondirectory file)))) - (when region-buf - (with-current-buffer region-buf - (goto-char (point-min)) - (forward-line (1- line)) - (let* ((p (point)) - (bound (save-excursion - (re-search-backward "\\\\message{[^}]+}" nil t) - (end-of-line) - (point))) - (start (save-excursion - (while (< (- p (point)) 250) - (backward-paragraph)) - (point)))) - (setq region-search-string (buffer-substring-no-properties - (if (< start bound) bound start) - (point)))) - ;; TeX-region-create stores the original buffer - ;; locally as TeX-region-orig-buffer. - (get-buffer TeX-region-orig-buffer))))) - ((file-name-absolute-p f) (find-file f)) - (t (get-buffer (file-name-nondirectory file))))))) - (if (null buf) - (message "No buffer for %s." file) - (switch-to-buffer buf) - (push-mark (point) 'nomsg) - (goto-char (point-min)) - (if region - (search-forward region-search-string nil t) - (forward-line (1- line))) - (unless (= col -1) - (move-to-column col)) - (raise-frame)))) + (let* ((file (condition-case nil + (progn + (require 'url-parse) + (require 'url-util) + (url-unhex-string (aref (url-generic-parse-url file) 6))) + ;; For Emacs 21 compatibility, which doesn't have the + ;; url package. + (file-error (replace-regexp-in-string "^file://" "" file)))) + (flc (or (apply #'TeX-source-correlate-handle-TeX-region file linecol) + (apply #'list file linecol))) + (file (car flc)) + (line (cadr flc)) + (col (nth 2 flc))) + (pop-to-buffer (or (find-buffer-visiting file) + (find-file-noselect file))) + (push-mark nil 'nomsg) + (let ((pos + (when (> line 0) + (save-excursion + (save-restriction + (widen) + (goto-char 1) + (forward-line (1- line)) + (when (> col 0) + (forward-char (1- col))) + (point)))))) + (when pos + (when (or (< pos (point-min)) + (> pos (point-max))) + (widen)) + (goto-char pos))))) (define-minor-mode TeX-source-correlate-mode "Minor mode for forward and inverse search. @@ -2421,11 +2440,13 @@ These correspond to the personal TeX macros." (let ((path)) ;; Put directories in an order where the more local files can ;; override the more global ones. - (mapc (lambda (file) (when file (add-to-list 'path file t))) + (mapc (lambda (file) + (when (and file (not (member file path))) + (setq path (cons file path)))) (append (list TeX-auto-global TeX-style-global) TeX-auto-private TeX-style-private (list TeX-auto-local TeX-style-local))) - path) + (nreverse path)) "List of directories to search for AUCTeX style files. Per default the list is built from the values of the variables `TeX-auto-global', `TeX-style-global', `TeX-auto-private',