branch: main commit 1bb965fe2f8cf36bd6386a441c3966127493a554 Merge: 7363de19 d9f61d55 Author: Tassilo Horn <t...@gnu.org> Commit: Tassilo Horn <t...@gnu.org>
Merge branch 'master' into elpa --- Makefile.in | 4 +- aclocal.m4 | 36 +++-- autogen.sh | 23 ++- configure.ac | 2 +- context.el | 55 ++++--- doc/Makefile.in | 2 +- doc/auctex.texi | 4 +- latex.el | 8 +- plain-tex.el | 9 +- preview.el | 4 +- style/amsthm.el | 56 +++++-- style/biblatex.el | 4 +- style/cleveref.el | 9 +- style/enumitem.el | 69 ++++----- style/fancyref.el | 9 +- style/hologo.el | 2 +- style/hyperref.el | 14 +- style/ntheorem.el | 426 +++++++++++++++++++++++++++++++++++++++++++++++++++++ style/subfigure.el | 4 +- style/theorem.el | 174 ++++++++++++++++++++++ style/varioref.el | 9 +- tex-buf.el | 32 ++-- tex-font.el | 2 +- tex-style.el | 9 +- tex.el | 32 ++-- texmathp.el | 2 +- 26 files changed, 852 insertions(+), 148 deletions(-) diff --git a/Makefile.in b/Makefile.in index 1b33ce64..ee9c122f 100644 --- a/Makefile.in +++ b/Makefile.in @@ -153,7 +153,7 @@ STYLESRC = style/prosper.el \ style/vwcol.el style/textpos.el style/transparent.el \ style/fontenc.el style/Alegreya.el style/gloss-italian.el \ style/newfloat.el style/subcaption.el style/AlegreyaSans.el \ - style/hologo.el + style/hologo.el style/theorem.el style/ntheorem.el STYLEELC = $(STYLESRC:.el=.elc) @@ -242,7 +242,7 @@ configure: configure.ac aclocal.m4 Makefile: Makefile.in config.status ./config.status -doc/Makefile: doc/Makefile.in config.status ChangeLog +doc/Makefile: doc/Makefile.in config.status ChangeLog.1 ./config.status config.status: configure diff --git a/aclocal.m4 b/aclocal.m4 index 9b29ec03..b7016537 100644 --- a/aclocal.m4 +++ b/aclocal.m4 @@ -93,21 +93,39 @@ fi ]) AC_DEFUN(AC_DATE_VERSION_FROM_CHANGELOG, [ -AC_MSG_CHECKING([for date in ChangeLog]) -$1=[`sed -n '1s/^\([-0-9][-0-9]*\).*/\1/p' "$3"`] +AC_MSG_CHECKING([for date with git]) +$1=[`git log -1 --date=short --format=%ad 2> /dev/null`] if test "X${$1}" = X then - AC_MSG_ERROR([[not found]]) + AC_MSG_RESULT([git not found, checking for date in ChangeLog:]) + $1=[`sed -n '1s/^\([-0-9][-0-9]*\).*/\1/p' "$3"`] + if test "X${$1}" = X + then + AC_MSG_ERROR([[not found]]) + fi fi AC_MSG_RESULT(${$1}) -AC_MSG_CHECKING([for release in ChangeLog]) -$2=[`sed -n '2,/^[0-9]/s/.*Version \(.*\) released\..*/\1/p' "$3"`] -if test "X${$2}" = X + +AC_MSG_CHECKING([for release with git]) +if git describe --tags > /dev/null 2> /dev/null then - $2=${$1} - AC_MSG_RESULT([not found, using ${$2} instead]) + if test "X`git describe --tags | sed 's/release_.._..//'`" = X + then + $2=[`git describe --tags`] + else + $2=${$1} + AC_MSG_RESULT([not found, using ${$2} instead]) + fi else - AC_MSG_RESULT([${$2}]) + AC_MSG_RESULT([git not found, checking for release in ChangeLog:]) + $2=[`sed -n '2,/^[0-9]/s/.*Version \(.*\) released\..*/\1/p' "$3"`] + if test "X${$2}" = X + then + $2=${$1} + AC_MSG_RESULT([not found, using ${$2} instead]) + else + AC_MSG_RESULT([${$2}]) + fi fi ]) diff --git a/autogen.sh b/autogen.sh index c61b5345..1bed156a 100755 --- a/autogen.sh +++ b/autogen.sh @@ -32,14 +32,29 @@ ${AUTOCONF} || { echo "Error running ${AUTOCONF} in ." >&2 ; exit 1; } rm -rf autom4te.cache if test "x${AUCTEXDATE}" = x then - AUCTEXDATE=`LC_ALL=C sed -n '1s/^\([-0-9][-0-9]*\).*/\1/p' ChangeLog` - test "X${AUCTEXDATE}" != X || { echo "Can't find date in ChangeLog" >&2 ; exit 1; } + AUCTEXDATE=`git log -1 --date=short --format=%ad 2> /dev/null` + if test "X${AUCTEXDATE}" = X + then + echo "Can't find date with git, trying with ChangeLog.1..." >&2 + AUCTEXDATE=`LC_ALL=C sed -n '1s/^\([-0-9][-0-9]*\).*/\1/p' ChangeLog.1` + test "X${AUCTEXDATE}" != X || { echo "Can't find date in ChangeLog.1" >&2 ; exit 1; } + fi fi if test "x${AUCTEXVERSION}" = x then - AUCTEXVERSION=`sed -n '2,/^[0-9]/s/.*Version \(.*\) released\..*/\1/p' ChangeLog` - test "X${AUCTEXVERSION}" != X || AUCTEXVERSION=${AUCTEXDATE} + if git describe --tags >/dev/null 2> /dev/null + then + if test "X`git describe --tags | sed 's/release_.._..//'`" = X + then + AUCTEXVERSION=`git describe --tags` + else + AUCTEXVERSION=${AUCTEXDATE} + fi + else + AUCTEXVERSION=`sed -n '2,/^[0-9]/s/.*Version \(.*\) released\..*/\1/p' ChangeLog.1` + test "X${AUCTEXVERSION}" != X || AUCTEXVERSION=${AUCTEXDATE} + fi fi cd doc diff --git a/configure.ac b/configure.ac index fd250dba..c61f4c73 100644 --- a/configure.ac +++ b/configure.ac @@ -27,7 +27,7 @@ AC_CHECK_PROGS_REQUIRED(MAKECMD, make, [make not found, aborting!]) AC_PROG_MAKE_SET AC_PROG_INSTALL -AC_DATE_VERSION_FROM_CHANGELOG(AUCTEXDATE,AUCTEXVERSION,ChangeLog) +AC_DATE_VERSION_FROM_CHANGELOG(AUCTEXDATE,AUCTEXVERSION,ChangeLog.1) AC_SUBST(AUCTEXDATE) AC_SUBST(AUCTEXVERSION) diff --git a/context.el b/context.el index 62d7b3a6..b962e0d2 100644 --- a/context.el +++ b/context.el @@ -1,6 +1,6 @@ ;;; context.el --- Support for ConTeXt documents. -;; Copyright (C) 2003-2006, 2008, 2010, 2012, 2014, 2015 +;; Copyright (C) 2003-2006, 2008, 2010, 2012, 2014-2016 ;; Free Software Foundation, Inc. ;; Maintainer: Berend de Boer <ber...@pobox.com> @@ -600,7 +600,12 @@ inserted after the sectioning command." (t (message (concat 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-compilation-finished-functions + (with-current-buffer TeX-command-buffer + (expand-file-name + (TeX-active-master (TeX-output-extension))))))) ;;; Environments @@ -649,33 +654,26 @@ inserted after the sectioning command." ;; this should not happen (error "Unknown interface: %s" ConTeXt-current-interface)))) - (defun ConTeXt-environment (arg) "Make ConTeXt environment (\\start...-\\stop... pair). With optional ARG, modify current environment." (interactive "*P") - (let ((environment ( - completing-read (concat "Environment type: (default " - (if (TeX-near-bobp) - "text" - ConTeXt-default-environment) - ") ") - ConTeXt-environment-list - nil nil nil - 'ConTeXt-environment-history) - )) - ;; Get default - (cond ((and (zerop (length environment)) - (TeX-near-bobp)) - (setq environment "text")) - ((zerop (length environment)) - (setq environment ConTeXt-default-environment)) - (t - (setq ConTeXt-default-environment environment))) + (let* ((default (cond + ((TeX-near-bobp) "text") + (t ConTeXt-default-environment))) + (environment + (completing-read (concat "Environment type: (default " default ") ") + ConTeXt-environment-list nil nil nil + 'ConTeXt-environment-history default))) + ;; Use `environment' as default for the next time only if it is different + ;; from the current default. + (unless (equal environment default) + (setq ConTeXt-default-environment environment)) (let ((entry (assoc environment ConTeXt-environment-list))) - (when (null entry) - (ConTeXt-add-environments (list environment))) + (if (null entry) + (ConTeXt-add-environments (list environment))) + (if arg (ConTeXt-modify-environment environment) (ConTeXt-environment-menu environment))))) @@ -1654,7 +1652,15 @@ Use `ConTeXt-Mark-version' to choose the command." ConTeXt-section-list ConTeXt-text ConTeXt-item-list - ConTeXt-extra-paragraph-commands)) + ConTeXt-extra-paragraph-commands + ConTeXt-environment-list) + "List of variables to be set from languages specific ones.") + +(defconst ConTeXt-dialect :context + "Default dialect for use with function `TeX-add-style-hook' for +argument DIALECT-EXPR when the hook is to be run only on ConTeXt +file, or any mode derived thereof. See variable +`TeX-style-hook-dialect'." ) (defcustom ConTeXt-clean-intermediate-suffixes ;; See *suffixes in texutil.pl. @@ -1690,6 +1696,7 @@ i.e. you do _not_ have to cater for this yourself by adding \\\\' or $." (setq major-mode 'context-mode) (setq local-abbrev-table context-mode-abbrev-table) + (set (make-local-variable 'TeX-style-hook-dialect) ConTeXt-dialect) ;; Make language specific variables buffer local (dolist (symbol ConTeXt-language-variable-list) diff --git a/doc/Makefile.in b/doc/Makefile.in index 01e7e2af..6a375411 100644 --- a/doc/Makefile.in +++ b/doc/Makefile.in @@ -110,7 +110,7 @@ tex-ref.ps: tex-ref.dvi tex-ref.pdf: tex-ref.tex $(PDFTEX) tex-ref.tex -version.texi: ../ChangeLog +version.texi: ../ChangeLog.1 echo @set VERSION $(AUCTEXVERSION) >version.texi echo @set UPDATED $(AUCTEXDATE) >>version.texi diff --git a/doc/auctex.texi b/doc/auctex.texi index 8c02499b..39125c9f 100644 --- a/doc/auctex.texi +++ b/doc/auctex.texi @@ -3591,7 +3591,7 @@ and if it is relevant for all text modes, append it to Other useful hooks are listed below. -@defvr Variable TeX-after-TeX-LaTeX-command-finished-hook +@defvr Variable TeX-after-compilation-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 @@ -3602,7 +3602,7 @@ re-compilation especially when using Emacs viewers such as DocView or PDF Tools. The function @code{TeX-revert-document-buffer} can be added to the hook for this purpose. @end defvr -@vindex TeX-after-TeX-LaTeX-command-finished-hook +@vindex TeX-after-compilation-finished-hook @findex TeX-revert-document-buffer @node Multifile diff --git a/latex.el b/latex.el index 69cbf04a..d6841203 100644 --- a/latex.el +++ b/latex.el @@ -1,6 +1,6 @@ ;;; latex.el --- Support for LaTeX documents. -;; Copyright (C) 1991, 1993-2015 Free Software Foundation, Inc. +;; Copyright (C) 1991, 1993-2016 Free Software Foundation, Inc. ;; Maintainer: auctex-devel@gnu.org ;; Keywords: tex @@ -1745,6 +1745,7 @@ It will setup BibTeX to store keys in an auto file." (if (boundp 'local-write-file-hooks) (add-hook 'local-write-file-hooks 'TeX-safe-auto-write) (add-hook 'write-file-hooks 'TeX-safe-auto-write)) + (TeX-bibtex-set-BibTeX-dialect) (set (make-local-variable 'TeX-auto-update) 'BibTeX) (set (make-local-variable 'TeX-auto-untabify) nil) (set (make-local-variable 'TeX-auto-parse-length) 999999) @@ -2058,7 +2059,7 @@ OPTIONAL and IGNORE are ignored." TeX-arg-input-file-search) (progn (message "Searching for LaTeX classes...") - (mapcar 'identity (TeX-search-files-by-type 'texinputs 'global t t))) + (TeX-search-files-by-type 'texinputs 'global t t)) LaTeX-style-list))) (setq style (completing-read (concat "Document class: (default " LaTeX-default-style ") ") @@ -4776,6 +4777,7 @@ file, or any mode derived thereof. See variable (nil "Longrightarrow" "Arrows" 10233) ;; #X27F9 (nil "longleftrightarrow" "Arrows" 10231) ;; #X27F7 (nil "Longleftrightarrow" "Arrows" 10234) ;; #X27FA + (nil "iff" "Arrows" 10234) ;; #X27FA (nil "longmapsto" "Arrows" 10236) ;; #X27FC (nil "hookrightarrow" "Arrows" 8618) ;; #X21AA (nil "rightharpoonup" "Arrows" 8640) ;; #X21C0 @@ -4929,6 +4931,8 @@ file, or any mode derived thereof. See variable ("v W" "varOmega" ("AMS" "Greek Uppercase") 120570) ;; #X1D6FA (nil "dashrightarrow" ("AMS" "Arrows")) (nil "dashleftarrow" ("AMS" "Arrows")) + (nil "impliedby" ("AMS" "Arrows") 10232) ;; #X27F8 + (nil "implies" ("AMS" "Arrows") 10233) ;; #X27F9 (nil "leftleftarrows" ("AMS" "Arrows") 8647) ;; #X21C7 (nil "leftrightarrows" ("AMS" "Arrows") 8646) ;; #X21C6 (nil "Lleftarrow" ("AMS" "Arrows") 8666) ;; #X21DA diff --git a/plain-tex.el b/plain-tex.el index 3df61969..dfdc423d 100644 --- a/plain-tex.el +++ b/plain-tex.el @@ -1,6 +1,6 @@ ;;; plain-tex.el --- Support for plain TeX documents. -;; Copyright (C) 2010 Free Software Foundation, Inc. +;; Copyright (C) 2010, 2013, 2016 Free Software Foundation, Inc. ;; Maintainer: auctex-devel@gnu.org ;; Keywords: tex @@ -103,6 +103,12 @@ Install tool bar if `plain-TeX-enable-toolbar' is non-nil." ;;; The mode +(defconst plain-TeX-dialect :plain-tex + "Default dialect for use with function `TeX-add-style-hook' for +argument DIALECT-EXPR when the hook is to be run only on +plain-TeX file, or any mode derived thereof. See variable +`TeX-style-hook-dialect'." ) + (defcustom plain-TeX-mode-hook nil "A hook run in plain TeX mode buffers." :type 'hook @@ -143,6 +149,7 @@ of plain-TeX-mode-hook." (VirTeX-common-initialization) (set-syntax-table TeX-mode-syntax-table) (setq local-abbrev-table plain-tex-mode-abbrev-table) + (set (make-local-variable 'TeX-style-hook-dialect) plain-TeX-dialect) (setq paragraph-start (concat "\\(^[ \t]*$" diff --git a/preview.el b/preview.el index d78682c7..b10f91a1 100644 --- a/preview.el +++ b/preview.el @@ -3207,8 +3207,8 @@ and strings get evaluated as replacement strings." (defconst preview-LaTeX-disable-pdfoutput '(("\\`\\(pdf[^ ]*\\)\ -\\(\\( [-&]\\([^ \"]\\|\"[^\"]*\"\\)*\\|\ - \"[-&][^\"]*\"\\)*\\)\\(.*\\)\\'" +\\(\\( +[-&]\\([^ \"]\\|\"[^\"]*\"\\)*\\|\ + +\"[-&][^\"]*\"\\)*\\)\\(.*\\)\\'" . ("\\1\\2 \"\\\\pdfoutput=0 \" \\5"))) "This replacement places `\"\\pdfoutput=0 \"' after the options of any command starting with `pdf'.") diff --git a/style/amsthm.el b/style/amsthm.el index 8bc33d4a..5c837240 100644 --- a/style/amsthm.el +++ b/style/amsthm.el @@ -40,12 +40,34 @@ defined with \"\\newtheoremstyle\".") (defvar LaTeX-amsthm-fontdecl - (mapcar (lambda (elt) (concat TeX-esc elt)) - '("itshape" "bfseries" "scshape" - "ttfamily" "upshape" "mdseries" - "rmfamily" "sffamily" "slshape")) + '(;; family + "rmfamily" "sffamily" "ttfamily" + ;; series + "mdseries" "bfseries" + ;; shape + "upshape" "itshape" "slshape" "scshape" + ;; size + "tiny" "scriptsize" "footnotesize" + "small" "normalsize" "large" + "Large" "LARGE" "huge" "Huge" + ;; reset macro + "normalfont") "List of font declaration commands for \"\\newtheoremstyle\".") +(defun LaTeX-arg-amsthm-fontdecl (optional &optional prompt) + "Prompt for font declaration commands in \"\\newtheoremstyle\". +If OPTIONAL is non-nil, insert the resulting value as an optional +argument. Use PROMPT as the prompt string." + ;; `INITIAL-INPUT' (5th argument to `TeX-completing-read-multiple') + ;; is hard-coded to `TeX-esc'. + (let* ((crm-separator (regexp-quote TeX-esc)) + (fontdecl (mapconcat 'identity + (TeX-completing-read-multiple + (TeX-argument-prompt optional prompt "Font") + LaTeX-amsthm-fontdecl nil nil TeX-esc) + TeX-esc))) + (TeX-argument-insert fontdecl optional))) + (defun LaTeX-amsthm-env-label (environment) "Insert ENVIRONMENT, query for an optional argument and prompt for label. AUCTeX users should add ENVIRONMENT to @@ -106,6 +128,23 @@ make them available as new environments. Update (LaTeX-add-environments '("proof" LaTeX-amsthm-env-label)) (TeX-add-symbols + ;; Overrule the defintion in `latex.el': + '("newtheorem" + (TeX-arg-eval + (lambda () + (let ((nthm (TeX-read-string + (TeX-argument-prompt nil nil "Environment")))) + (LaTeX-add-amsthm-newtheorems nthm) + (LaTeX-add-environments (list nthm 'LaTeX-theorem-env-label)) + (format "%s" nthm)))) + [ TeX-arg-environment "Numbered like" ] + t [ (TeX-arg-eval progn (if (eq (save-excursion + (backward-char 2) + (preceding-char)) ?\]) + () + (TeX-arg-counter t "Within counter")) + "") ]) + '("newtheorem*" (TeX-arg-eval (lambda () @@ -119,8 +158,7 @@ make them available as new environments. Update (format "%s" heading))))) '("theoremstyle" - (TeX-arg-eval completing-read - "Style: " + (TeX-arg-eval completing-read "Style: " LaTeX-amsthm-theoremstyle-list)) "qedhere" "swapnumbers" @@ -136,11 +174,9 @@ make them available as new environments. Update (format "%s" nthmstyle)))) (TeX-arg-length "Space above") (TeX-arg-length "Space below") - (TeX-arg-eval completing-read - "Body font: " LaTeX-amsthm-fontdecl) + (LaTeX-arg-amsthm-fontdecl "Body font") "Indent amount" - (TeX-arg-eval completing-read - "Theorem head font: " LaTeX-amsthm-fontdecl) + (LaTeX-arg-amsthm-fontdecl "Theorem head font") "Punctuation after head" (TeX-arg-length "Space after head") "Theorem head spec")) diff --git a/style/biblatex.el b/style/biblatex.el index 8a42a452..06cd57a7 100644 --- a/style/biblatex.el +++ b/style/biblatex.el @@ -1,6 +1,6 @@ ;;; biblatex.el --- AUCTeX style for `biblatex.sty' version 2.8a. -;; Copyright (C) 2012-2014 Free Software Foundation, Inc. +;; Copyright (C) 2012-2014, 2016 Free Software Foundation, Inc. ;; Author: Ralf Angeli <ang...@caeruleus.net> ;; Maintainer: auctex-devel@gnu.org @@ -514,7 +514,7 @@ for citation keys." (progn (message "Searching for BibLaTeX styles...") (setq BibLaTeX-global-style-files - (mapcar 'identity (TeX-search-files-by-type 'bbxinputs 'global t t)))) + (TeX-search-files-by-type 'bbxinputs 'global t t))) ;; ...else, use for completion only standard BibLaTeX styles (see ยง3.3 of ;; Biblatex reference manual). (setq BibLaTeX-global-style-files diff --git a/style/cleveref.el b/style/cleveref.el index 755239da..4d039e19 100644 --- a/style/cleveref.el +++ b/style/cleveref.el @@ -1,6 +1,6 @@ ;;; cleveref.el --- Style hook for the `cleveref.sty' package. -;; Copyright (C) 2014 Free Software Foundation, Inc. +;; Copyright (C) 2014, 2015 Free Software Foundation, Inc. ;; Author: Matthew Leach <matt...@mattleach.net> ;; Maintainer: auctex-devel@gnu.org @@ -93,7 +93,12 @@ list of defined labels." ("labelcpageref" "{")) 'reference) ;; For syntactic fontification, e.g. verbatim constructs. - (font-latex-set-syntactic-keywords))) + (font-latex-set-syntactic-keywords)) + + ;; Activate RefTeX reference style. + (and LaTeX-reftex-ref-style-auto-activate + (fboundp 'reftex-ref-style-activate) + (reftex-ref-style-activate "Cleveref"))) LaTeX-dialect) (defvar LaTeX-cleveref-package-options diff --git a/style/enumitem.el b/style/enumitem.el index a527c86a..bbbfe79d 100644 --- a/style/enumitem.el +++ b/style/enumitem.el @@ -100,25 +100,14 @@ "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.") + "Local list of all environments definded with `\\newlist' plus +the ones initially 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.") +;; Setup for \newlist: -(defvar LaTeX-auto-enumitem-newlist nil - "Temporary for parsing the arguments of `\\newlist' from -`enumitem' package.") +(TeX-auto-add-type "enumitem-newlist" "LaTeX") (defvar LaTeX-enumitem-newlist-regexp '("\\\\newlist{\\([^}]+\\)}{\\([^}]+\\)}" @@ -126,7 +115,6 @@ plus available through `enumitem' package.") "Matches the arguments of `\\newlist' from `enumitem' package.") - ;; Setup for \SetEnumitemKey: (TeX-auto-add-type "enumitem-SetEnumitemKey" "LaTeX") @@ -137,7 +125,6 @@ package.") "Matches the arguments of `\\SetEnumitemKey' from `enumitem' package.") - ;; Setup for \SetEnumitemValue: (TeX-auto-add-type "enumitem-SetEnumitemValue" "LaTeX") @@ -158,9 +145,7 @@ 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 + (setq LaTeX-auto-enumitem-newlist nil LaTeX-auto-enumitem-SetEnumitemKey nil LaTeX-auto-enumitem-SetEnumitemValue nil)) @@ -168,26 +153,19 @@ package.") "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) + (dolist (env-type (LaTeX-enumitem-newlist-list)) (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)) + (LaTeX-add-environments (list env 'LaTeX-enumitem-env-with-opts)) + ;; Tell AUCTeX about parsed description like environments. (when (or (string-equal type "description") (string-equal type "description*")) - (add-to-list 'LaTeX-enumitem-newlist-list-item-arg - (list env))))) + (add-to-list 'LaTeX-item-list `(,env . LaTeX-item-argument))))) ;; Now add the parsed env's to the local list. - (when LaTeX-enumitem-newlist-list + (when (LaTeX-enumitem-newlist-list) (setq LaTeX-enumitem-newlist-list-local - (append LaTeX-enumitem-newlist-list - LaTeX-enumitem-newlist-list-local))) - ;; Tell AUCTeX about parsed description like environments. - (when LaTeX-enumitem-newlist-list-item-arg - (dolist (env LaTeX-enumitem-newlist-list-item-arg) - (add-to-list 'LaTeX-item-list `(,(car env) . LaTeX-item-argument))))) + (append (mapcar 'list (mapcar 'car (LaTeX-enumitem-newlist-list))) + LaTeX-enumitem-newlist-list-local)))) (add-hook 'TeX-auto-prepare-hook #'LaTeX-enumitem-auto-prepare t) (add-hook 'TeX-auto-cleanup-hook #'LaTeX-enumitem-auto-cleanup t) @@ -282,7 +260,6 @@ in `enumitem'-completions." (pushnew (list key (list val)) opts :test #'equal)) (setq LaTeX-enumitem-key-val-options-local (copy-alist opts))))) - (TeX-add-style-hook "enumitem" (lambda () @@ -347,6 +324,7 @@ in `enumitem'-completions." (string-equal type "description*")) (add-to-list 'LaTeX-item-list `(,name . LaTeX-item-argument))) (LaTeX-add-environments `(,name LaTeX-enumitem-env-with-opts)) + (LaTeX-add-enumitem-newlists (list name type)) (insert (format "{%s}" name) (format "{%s}" type)) (format "%s" depth))))) @@ -396,12 +374,23 @@ in `enumitem'-completions." '("AddEnumerateCounter" 3) '("AddEnumerateCounter*" 3) - ;; This command only makes sense for enumerate type environments. - ;; Currently, we offer all defined env's -- to be improved - ;; sometimes. + ;; "\restartlist" only works for lists defined with "resume" key. + ;; We will not extract that information and leave that to users. + ;; For completion, extract enumerated environments from + ;; `LaTeX-enumitem-newlist-list' and add "enumerate" to them. '("restartlist" - (TeX-arg-eval completing-read "List name: " - LaTeX-enumitem-newlist-list-local)) + (TeX-arg-eval + (lambda () + (let ((enums '("enumerate"))) + (when (LaTeX-provided-package-options-member "enumitem" "inline") + (pushnew "enumerate*" enums :test #'equal)) + (dolist (env-type (LaTeX-enumitem-newlist-list)) + (let ((env (car env-type)) + (type (cadr env-type))) + (when (or (string-equal type "enumerate") + (string-equal type "enumerate*")) + (pushnew env enums :test #'equal)))) + (completing-read "List name: " enums))))) ;; "Key" will be parsed and added to key-val list. '("SetEnumitemKey" LaTeX-arg-SetEnumitemKey) diff --git a/style/fancyref.el b/style/fancyref.el index 94b7e15e..ce3053d7 100644 --- a/style/fancyref.el +++ b/style/fancyref.el @@ -1,6 +1,6 @@ ;;; fancyref.el --- AUCTeX style file with support for fancyref.sty -;; Copyright (C) 1999, 2014 Free Software Foundation, Inc. +;; Copyright (C) 1999, 2014, 2015 Free Software Foundation, Inc. ;; Author: Carsten Dominik <domi...@strw.leidenuniv.nl> ;; Maintainer: auctex-devel@gnu.org @@ -92,7 +92,12 @@ ;; Fontification (when (and (featurep 'font-latex) (eq TeX-install-font-lock 'font-latex-setup)) - (font-latex-add-keywords '(("fref" "[{") ("Fref" "[{")) 'reference))) + (font-latex-add-keywords '(("fref" "[{") ("Fref" "[{")) 'reference)) + + ;; Activate RefTeX reference style. + (and LaTeX-reftex-ref-style-auto-activate + (fboundp 'reftex-ref-style-activate) + (reftex-ref-style-activate "Fancyref"))) LaTeX-dialect) ;; The following list keeps a list of available format names diff --git a/style/hologo.el b/style/hologo.el index 1795870d..64031cb4 100644 --- a/style/hologo.el +++ b/style/hologo.el @@ -1,4 +1,4 @@ -;;; holog.el --- AUCTeX style for `hologo.sty' (v1.10) +;;; hologo.el --- AUCTeX style for `hologo.sty' (v1.10) ;; Copyright (C) 2015 Free Software Foundation, Inc. diff --git a/style/hyperref.el b/style/hyperref.el index 630f24cb..c57c1887 100644 --- a/style/hyperref.el +++ b/style/hyperref.el @@ -1,6 +1,6 @@ ;;; hyperref.el --- AUCTeX style for `hyperref.sty' v6.83m -;; Copyright (C) 2008, 2013--2015 Free Software Foundation, Inc. +;; Copyright (C) 2008, 2013--2016 Free Software Foundation, Inc. ;; Author: Ralf Angeli <ang...@caeruleus.net> ;; Maintainer: auctex-devel@gnu.org @@ -277,6 +277,11 @@ (add-to-list 'LaTeX-verbatim-macros-with-braces-local "hyperimage") (add-to-list 'LaTeX-verbatim-macros-with-braces-local "hyperref") + ;; In hyperref package, \url macro is redefined and \url|...| can't be used, + ;; while it's possible when only url package (required by hyperref) is loaded + (setq LaTeX-verbatim-macros-with-delims-local + (remove "url" LaTeX-verbatim-macros-with-delims-local)) + ;; Fontification (when (and (fboundp 'font-latex-add-keywords) (fboundp 'font-latex-set-syntactic-keywords) @@ -299,9 +304,10 @@ ;; For syntactic fontification, e.g. verbatim constructs. (font-latex-set-syntactic-keywords)) - ;; RefTeX - (when (fboundp 'reftex-ref-style-activate) - (reftex-ref-style-activate "Hyperref"))) + ;; Activate RefTeX reference style. + (and LaTeX-reftex-ref-style-auto-activate + (fboundp 'reftex-ref-style-activate) + (reftex-ref-style-activate "Hyperref"))) LaTeX-dialect) (defun LaTeX-hyperref-package-options () diff --git a/style/ntheorem.el b/style/ntheorem.el new file mode 100644 index 00000000..630c09b2 --- /dev/null +++ b/style/ntheorem.el @@ -0,0 +1,426 @@ +;;; ntheorem.el --- AUCTeX style for `ntheorem.sty' (v1.33) + +;; Copyright (C) 2015 Free Software Foundation, Inc. + +;; Author: Arash Esbati <esbati'at'gmx.de> +;; Maintainer: auctex-devel@gnu.org +;; Created: 2015-10-31 +;; Keywords: tex + +;; This file is part of AUCTeX. + +;; AUCTeX is free software; you can redistribute it and/or modify it +;; under the terms of the GNU General Public License as published by +;; the Free Software Foundation; either version 3, or (at your option) +;; any later version. + +;; AUCTeX is distributed in the hope that it will be useful, but +;; WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;; General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with AUCTeX; see the file COPYING. If not, write to the Free +;; Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA +;; 02110-1301, USA. + +;;; Commentary: + +;; This file adds support for `ntheorem.sty' (v1.33) from 2011/08/15. +;; `ntheorem.sty' is and part of TeXLive. + +;; The style provides the function `LaTeX-ntheorem-env-label' which +;; enables new defined environments with "\newtheoreom" to interact +;; with AUCTeX and RefTeX mechanisms for inserting labels. Check +;; docstring of `LaTeX-ntheorem-env-label' for instructions. + +;;; Code + +(defvar LaTeX-ntheorem-theoremstyle-list + '(("plain") ("break") ("change") ("changebreak") ("margin") + ("marginbreak") ("nonumberplain") ("nonumberbreak") ("empty")) + "List of theorem styles provided by `ntheorem.el' and new ones +defined with \"\\newtheoremstyle\".") + +(defvar LaTeX-ntheorem-listtype-list + '(("all") ("allname") ("opt") ("optname")) + "List of predefined formatting options available for +\"\\theoremlisttype\" provided by `ntheorem.el' and new ones +defined with \"\\newtheoremlisttype\".") + +(defvar LaTeX-ntheorem-fontdecl + '(;; family + "rmfamily" "sffamily" "ttfamily" + ;; series + "mdseries" "bfseries" + ;; shape + "upshape" "itshape" "slshape" "scshape" + ;; size + "tiny" "scriptsize" "footnotesize" + "small" "normalsize" "large" + "Large" "LARGE" "huge" "Huge" + ;; reset macro + "normalfont") + "List of font declaration commands for \"\\newtheoremstyle\".") + +(defun LaTeX-arg-ntheorem-fontdecl (optional &optional prompt) + "Prompt for font declaration commands in \"\\theorem(body\|header)font\". +If OPTIONAL is non-nil, insert the resulting value as an optional +argument. Use PROMPT as the prompt string." + ;; `INITIAL-INPUT' (5th argument to `TeX-completing-read-multiple') + ;; is hard-coded to `TeX-esc'. + (let* ((crm-separator (regexp-quote TeX-esc)) + (fontdecl (mapconcat 'identity + (TeX-completing-read-multiple + (TeX-argument-prompt optional prompt "Font declaration") + LaTeX-ntheorem-fontdecl nil nil TeX-esc) + TeX-esc))) + (TeX-argument-insert fontdecl optional))) + +(defun LaTeX-ntheorem-env-label (environment) + "Insert ENVIRONMENT, query for an optional argument and prompt +for label. AUCTeX users should add ENVIRONMENT to +`LaTeX-label-alist' via customize or in init-file with: + + (add-to-list 'LaTeX-label-alist '(\"lemma\" . \"lem:\")) + +RefTeX users should customize or add ENVIRONMENT to +`LaTeX-label-alist' and `reftex-label-alist', e.g. + + (add-to-list 'LaTeX-label-alist '(\"lemma\" . \"lem:\")) + (add-to-list 'reftex-label-alist + '(\"lemma\" ?m \"lem:\" \"~\\ref{%s}\" + nil (\"Lemma\" \"lemma\") nil))" + (let ((opthead (TeX-read-string + (TeX-argument-prompt t nil "Heading")))) + (LaTeX-insert-environment environment + (when (and opthead + (not (string= opthead ""))) + (format "[%s]" opthead)))) + (when (LaTeX-label environment 'environment) + (LaTeX-newline) + (indent-according-to-mode))) + +;; Needed for auto-parsing +(require 'tex) + +;; Setup parsing for \newtheorem +(TeX-auto-add-type "ntheorem-newtheorem" "LaTeX") + +;; Setup parsing for \newtheoremstyle +(TeX-auto-add-type "ntheorem-newtheoremstyle" "LaTeX") + +;; Setup parsing for \newtheoremlisttype +(TeX-auto-add-type "ntheorem-newtheoremlisttype" "LaTeX") + +(defun LaTeX-ntheorem-auto-prepare () + "Clear `LaTeX-auto-ntheorem-newtheorem' and +`LaTeX-auto-ntheorem-newtheoremstyle' before parsing." + (setq LaTeX-auto-ntheorem-newtheorem nil) + (setq LaTeX-auto-ntheorem-newtheoremstyle nil) + (setq LaTeX-auto-ntheorem-newtheoremlisttype nil)) + +(defun LaTeX-ntheorem-auto-cleanup () + "Move parsed results from `LaTeX-auto-ntheorem-newtheorem' and +make them available as new environments. Update +`LaTeX-ntheorem-theoremstyle-list' with styles defined with +\"\\newtheoremstyle\"." + (dolist (newthm (mapcar 'car (LaTeX-ntheorem-newtheorem-list))) + (LaTeX-add-environments (list newthm 'LaTeX-ntheorem-env-label)) + (LaTeX-add-environments (list (concat newthm "*") + 'LaTeX-ntheorem-env-label))) + (dolist (newthmstyle (LaTeX-ntheorem-newtheoremstyle-list)) + (add-to-list (make-local-variable 'LaTeX-ntheorem-theoremstyle-list) + newthmstyle)) + (dolist (newthmlist (LaTeX-ntheorem-newtheoremlisttype-list)) + (add-to-list (make-local-variable 'LaTeX-ntheorem-listtype-list) + newthmlist)) + (when (LaTeX-provided-package-options-member "ntheorem" "thmmarks") + (dolist (nthm (mapcar 'car (LaTeX-ntheorem-newtheorem-list))) + (TeX-add-symbols (concat nthm "Symbol")))) + (dolist (nthm (mapcar 'car (LaTeX-ntheorem-newtheorem-list))) + (TeX-add-symbols (concat nthm "name")))) + +(add-hook 'TeX-auto-prepare-hook #'LaTeX-ntheorem-auto-prepare t) +(add-hook 'TeX-auto-prepare-hook #'LaTeX-ntheorem-auto-cleanup t) +(add-hook 'TeX-update-style-hook #'TeX-auto-parse t) + +(TeX-add-style-hook + "ntheorem" + (lambda () + + (TeX-auto-add-regexp + `(,(concat "\\\\newtheorem{\\(" TeX-token-char "+\\)}") + 1 LaTeX-auto-ntheorem-newtheorem)) + (TeX-auto-add-regexp + `(,(concat "\\\\newframedtheorem{\\(" TeX-token-char "+\\)}") + 1 LaTeX-auto-ntheorem-newtheorem)) + (TeX-auto-add-regexp + `(,(concat "\\\\newshadedtheorem{\\(" TeX-token-char "+\\)}") + 1 LaTeX-auto-ntheorem-newtheorem)) + (TeX-auto-add-regexp + `(,(concat "\\\\newtheoremstyle{\\(" TeX-token-char "+\\)}") + 1 LaTeX-auto-ntheorem-newtheoremstyle)) + (TeX-auto-add-regexp + `(,(concat "\\\\newtheoremlisttype{\\(" TeX-token-char "+\\)}") + 1 LaTeX-auto-ntheorem-newtheoremlisttype)) + + (TeX-add-symbols + ;; 2.2 Defining New Theorem Sets + ;; Overrule the defintion in `latex.el': + '("newtheorem" + (TeX-arg-eval + (lambda () + (let ((nthm (TeX-read-string + (TeX-argument-prompt nil nil "Environment")))) + (LaTeX-add-ntheorem-newtheorems nthm) + (LaTeX-add-environments (list nthm 'LaTeX-ntheorem-env-label)) + (LaTeX-add-environments (list (concat nthm "*") + 'LaTeX-ntheorem-env-label)) + (format "%s" nthm)))) + [ TeX-arg-environment "Numbered like" ] + t [ (TeX-arg-eval progn (if (eq (save-excursion + (backward-char 2) + (preceding-char)) ?\]) + () + (TeX-arg-counter t "Within counter")) + "") ]) + + '("renewtheorem" + (TeX-arg-eval completing-read "Environment: " + (LaTeX-ntheorem-newtheorem-list)) + [ TeX-arg-environment "Numbered like" ] + t [ (TeX-arg-eval progn (if (eq (save-excursion + (backward-char 2) + (preceding-char)) ?\]) + () + (TeX-arg-counter t "Within counter")) + "") ]) + + ;; 2.3 Defining the Layout of Theorem Sets + '("theoremstyle" + (TeX-arg-eval completing-read "Style: " + LaTeX-ntheorem-theoremstyle-list)) + + '("theorembodyfont" + (LaTeX-arg-ntheorem-fontdecl "Body font")) + + '("theoremheaderfont" + (LaTeX-arg-ntheorem-fontdecl "Header font")) + + '("theoremnumbering" + (TeX-arg-eval completing-read + (TeX-argument-prompt optional nil "Numbering scheme") + '("arabic" "roman" "Roman" "alph" "Alph" + "greek" "Greek" "fnsymbol"))) + + '("theoremseparator" "Separator") + + '("theorempreskip" + (TeX-arg-length "Skip before theorem")) + + '("theorempostskip" + (TeX-arg-length "Skip after theorem")) + + '("theoremindent" + (TeX-arg-free "Theorem indent")) + + (when (LaTeX-provided-package-options-member "ntheorem" "thmmarks") + '("theoremsymbol" t)) + + '("theoremprework" t) + '("theorempostwork" t) + + '("theoremclass" + (TeX-arg-eval completing-read "Theorem type: " + (append '(("LaTeX")) + (LaTeX-ntheorem-newtheorem-list)))) + + ;; 2.3.6 A Standard Set of Theorems + (when (LaTeX-provided-package-options-member "ntheorem" "standard") + (let ((env '("Theorem" "Lemma" "Proposition" + "Corollary" "Satz" "Korollar" + "Definition" "Example" "Beispiel" + "Anmerkung" "Bemerkung" "Remark" + "Proof" "Beweis"))) + (dolist (elt env) + (LaTeX-add-ntheorem-newtheorems elt) + (LaTeX-add-environments (list elt 'LaTeX-ntheorem-env-label)) + (LaTeX-add-environments (list (concat elt "*") + 'LaTeX-ntheorem-env-label))))) + + ;; 2.3.7 Framed and Boxed Theorems + '("newframedtheorem" + (TeX-arg-eval + (lambda () + (let ((nthm (TeX-read-string + (TeX-argument-prompt nil nil "Environment")))) + (LaTeX-add-ntheorem-newtheorems nthm) + (LaTeX-add-environments (list nthm 'LaTeX-ntheorem-env-label)) + (LaTeX-add-environments (list (concat nthm "*") + 'LaTeX-ntheorem-env-label)) + (format "%s" nthm)))) + [ TeX-arg-environment "Numbered like" ] + t [ (TeX-arg-eval progn (if (eq (save-excursion + (backward-char 2) + (preceding-char)) ?\]) + () + (TeX-arg-counter t "Within counter")) + "") ]) + + '("newshadedtheorem" + (TeX-arg-eval + (lambda () + (let ((nthm (TeX-read-string + (TeX-argument-prompt nil nil "Environment")))) + (LaTeX-add-ntheorem-newtheorems nthm) + (LaTeX-add-environments (list nthm 'LaTeX-ntheorem-env-label)) + (LaTeX-add-environments (list (concat nthm "*") + 'LaTeX-ntheorem-env-label)) + (format "%s" nthm)))) + [ TeX-arg-environment "Numbered like" ] + t [ (TeX-arg-eval progn (if (eq (save-excursion + (backward-char 2) + (preceding-char)) ?\]) + () + (TeX-arg-counter t "Within counter")) + "") ]) + '("shadecolor" + (TeX-arg-eval + (lambda () + (let ((color + (if (fboundp 'LaTeX-color-definecolor-list) + (completing-read "color: " (LaTeX-color-definecolor-list)) + (TeX-read-string "color: ")))) + (format "%s" color))))) + + '("theoremframepreskip" + (TeX-arg-length "Skip before framed theorem")) + + '("theoremframepostskip" + (TeX-arg-length "Skip after framed theorem")) + + '("theoreminframepreskip" + (TeX-arg-length "Skip inside framed theorem")) + + '("theoreminframepostskip" + (TeX-arg-length "Skip inside framed theorem")) + + ;; 2.4 Generating Theoremlists + '("listtheorems" + (TeX-arg-eval mapconcat 'identity + (TeX-completing-read-multiple + "Lists: " + (LaTeX-ntheorem-newtheorem-list)) ",")) + + ;; 2.4.2 Writing Extra Stuff to the Theorem File + '("addtheoremline" + (TeX-arg-eval completing-read "Environment: " + (LaTeX-ntheorem-newtheorem-list)) + t) + + '("addtheoremline*" + (TeX-arg-eval completing-read "Environment: " + (LaTeX-ntheorem-newtheorem-list)) + t) + + '("addtotheoremfile" + [ TeX-arg-eval completing-read "Environment: " + (LaTeX-ntheorem-newtheorem-list) ] + t) + + ;; 2.5.1 Defining New Theorem Layouts + '("newtheoremstyle" + (TeX-arg-eval + (lambda () + (let ((style (TeX-read-string + (TeX-argument-prompt optional nil "Style name")))) + (LaTeX-add-ntheorem-newtheoremstyles style) + (add-to-list (make-local-variable 'LaTeX-ntheorem-theoremstyle-list) + (list style)) + (format "%s" style)))) + 2) + + '("renewtheoremstyle" + (TeX-arg-eval completing-read "Style name: " + LaTeX-ntheorem-theoremstyle-list) + 2) + + ;; 2.5.2 Defining New Theorem List Layouts + '("newtheoremlisttype" + (TeX-arg-eval + (lambda () + (let ((layout (TeX-read-string + (TeX-argument-prompt optional nil "List layout name")))) + (LaTeX-add-ntheorem-newtheoremlisttypes layout) + (add-to-list (make-local-variable 'LaTeX-ntheorem-listtype-list) + (list layout)) + (format "%s" layout)))) + 3) + + '("renewtheoremlisttype" + (TeX-arg-eval completing-read "Style name: " + LaTeX-ntheorem-listtype-list) + 3) + + ;; 2.6 Setting End Marks + '("qedsymbol" t) + '("NoEndMark" 0) + + ;; 2.7 Extended Referencing Features + (when (LaTeX-provided-package-options-member "ntheorem" "thref") + '("thref" TeX-arg-ref)) ) + + ;; 2.6 Setting End Marks + ;; ... the endmark can manually be set by just saying \<name>Symbol. + (when (LaTeX-provided-package-options-member "ntheorem" "thmmarks") + (dolist (nthm (mapcar 'car (LaTeX-ntheorem-newtheorem-list))) + (TeX-add-symbols (concat nthm "Symbol")))) + + ;; 2.8 Miscellaneous + ;; Inside a theorem-like environment <env>, the name given as + ;; optional argument is accessible by \<env>name + (dolist (nthm (mapcar 'car (LaTeX-ntheorem-newtheorem-list))) + (TeX-add-symbols (concat nthm "name"))) + +;; Fontification + (when (and (featurep 'font-latex) + (eq TeX-install-font-lock 'font-latex-setup)) + (font-latex-add-keywords '(("newtheorem" "{[{[") + ("renewtheorem" "{[{[") + ("theoremstyle" "{") + ("theorembodyfont" "{") + ("theoremheaderfont" "{") + ("theoremnumbering" "{") + ("theoremseparator" "{") + ("theorempreskip" "{") + ("theorempostskip" "{") + ("theoremsymbol" "{") + ("theoremindent" "") + ("theoremprework" "{") + ("theorempostwork" "{") + ("theoremclass" "{") + ("newframedtheorem" "{[{[") + ("newshadedtheorem" "*{[{[") + ("shadecolor" "{") + ("theoremframepreskip" "{") + ("theoremframepostskip" "{") + ("theoreminframepreskip" "{") + ("theoreminframepostskip" "{") + ("listtheorems" "{") + ("addtheoremline" "*{{") + ("addtotheoremfile" "[{") + ("newtheoremstyle" "{{{") + ("renewtheoremstyle" "{{{") + ("newtheoremlisttype" "{{{{") + ("renewtheoremlisttype" "{{{{")) + 'function) + (font-latex-add-keywords '(("thref" "{")) + 'reference))) + LaTeX-dialect) + +(defvar LaTeX-ntheorem-package-options + '("standard" "noconfig" "framed" "thmmarks" "thref" "amsmath" "hyperref") + "Package options for the ntheorem package.") + +;;; ntheorem.el ends here diff --git a/style/subfigure.el b/style/subfigure.el index e129e62e..5d7525b7 100644 --- a/style/subfigure.el +++ b/style/subfigure.el @@ -47,8 +47,8 @@ ;; Install completion for labels: (setq TeX-complete-list (append - '(("\\\\[Ss]ubref{\\([^{}\n\r\\%,]*\\)" 1 LaTeX-label-list "}"))) - TeX-complete-list) + '(("\\\\[Ss]ubref{\\([^{}\n\r\\%,]*\\)" 1 LaTeX-label-list "}")) + TeX-complete-list)) ;; Fontification (when (and (featurep 'font-latex) diff --git a/style/theorem.el b/style/theorem.el new file mode 100644 index 00000000..d8466f10 --- /dev/null +++ b/style/theorem.el @@ -0,0 +1,174 @@ +;;; theorem.el --- AUCTeX style for `theorem.sty' (v2.2c) + +;; Copyright (C) 2015 Free Software Foundation, Inc. + +;; Author: Arash Esbati <esbati'at'gmx.de> +;; Maintainer: auctex-devel@gnu.org +;; Created: 2015-10-31 +;; Keywords: tex + +;; This file is part of AUCTeX. + +;; AUCTeX is free software; you can redistribute it and/or modify it +;; under the terms of the GNU General Public License as published by +;; the Free Software Foundation; either version 3, or (at your option) +;; any later version. + +;; AUCTeX is distributed in the hope that it will be useful, but +;; WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +;; General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with AUCTeX; see the file COPYING. If not, write to the Free +;; Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA +;; 02110-1301, USA. + +;;; Commentary: + +;; This file adds support for `theorem.sty' (v2.2c) from 2014/10/28. +;; `theorem.sty' is a standard LaTeX package and part of TeXLive. + +;; The style provides the function `LaTeX-theorem-env-label' which +;; enables new defined environments with "\newtheoreom" to interact +;; with AUCTeX and RefTeX mechanisms for inserting labels. Check +;; docstring of `LaTeX-theorem-env-label' for instructions. + +;;; Code: + +(defvar LaTeX-theorem-theoremstyle-list + '(("plain") ("break") ("margin") ("change") + ("marginbreak") ("changebreak")) + "List of theorem styles provided by `theorem.sty'.") + +(defvar LaTeX-theorem-fontdecl + '(;; family + "rmfamily" "sffamily" "ttfamily" + ;; series + "mdseries" "bfseries" + ;; shape + "upshape" "itshape" "slshape" "scshape" + ;; size + "tiny" "scriptsize" "footnotesize" + "small" "normalsize" "large" + "Large" "LARGE" "huge" "Huge" + ;; reset macro + "normalfont") + "List of font declaration commands for \"\\theorem(body\|header)font\".") + +(defun LaTeX-arg-theorem-fontdecl (optional &optional prompt) + "Prompt for font declaration commands in \"\\theorem(body\|header)font\". +If OPTIONAL is non-nil, insert the resulting value as an optional +argument. Use PROMPT as the prompt string." + ;; `INITIAL-INPUT' (5th argument to `TeX-completing-read-multiple') + ;; is hard-coded to `TeX-esc'. + (let* ((crm-separator (regexp-quote TeX-esc)) + (fontdecl (mapconcat 'identity + (TeX-completing-read-multiple + (TeX-argument-prompt optional prompt "Font") + LaTeX-theorem-fontdecl nil nil TeX-esc) + TeX-esc))) + (TeX-argument-insert fontdecl optional))) + +(defun LaTeX-theorem-env-label (environment) + "Insert ENVIRONMENT, query for an optional argument and prompt +for label. AUCTeX users should add ENVIRONMENT to +`LaTeX-label-alist' via customize or in init-file with: + + (add-to-list 'LaTeX-label-alist '(\"lemma\" . \"lem:\")) + +RefTeX users should customize or add ENVIRONMENT to +`LaTeX-label-alist' and `reftex-label-alist', e.g. + + (add-to-list 'LaTeX-label-alist '(\"lemma\" . \"lem:\")) + (add-to-list 'reftex-label-alist + '(\"lemma\" ?m \"lem:\" \"~\\ref{%s}\" + nil (\"Lemma\" \"lemma\") nil))" + (let ((opthead (TeX-read-string + (TeX-argument-prompt t nil "Heading")))) + (LaTeX-insert-environment environment + (when (and opthead + (not (string= opthead ""))) + (format "[%s]" opthead)))) + (when (LaTeX-label environment 'environment) + (LaTeX-newline) + (indent-according-to-mode))) + +;; Needed for auto-parsing +(require 'tex) + +;; Setup parsing for \newtheorem +(TeX-auto-add-type "theorem-newtheorem" "LaTeX") + +(defun LaTeX-theorem-auto-prepare () + "Clear `LaTeX-auto-theorem-newtheorem' before parsing." + (setq LaTeX-auto-theorem-newtheorem nil)) + +(defun LaTeX-theorem-auto-cleanup () + "Move parsed results from `LaTeX-auto-theorem-newtheorem' and +make them available as new environments." + (dolist (newthm (mapcar 'car (LaTeX-theorem-newtheorem-list))) + (LaTeX-add-environments (list newthm 'LaTeX-theorem-env-label)))) + +(add-hook 'TeX-auto-prepare-hook #'LaTeX-theorem-auto-prepare t) +(add-hook 'TeX-auto-prepare-hook #'LaTeX-theorem-auto-cleanup t) +(add-hook 'TeX-update-style-hook #'TeX-auto-parse t) + +(TeX-add-style-hook + "theorem" + (lambda () + + (TeX-auto-add-regexp + `(,(concat "\\\\newtheorem{\\(" TeX-token-char "+\\)}") + 1 LaTeX-auto-theorem-newtheorem)) + + (TeX-add-symbols + ;; Overrule the defintion in `latex.el': + '("newtheorem" + (TeX-arg-eval + (lambda () + (let ((nthm (TeX-read-string + (TeX-argument-prompt nil nil "Environment")))) + (LaTeX-add-theorem-newtheorems nthm) + (LaTeX-add-environments (list nthm 'LaTeX-theorem-env-label)) + (format "%s" nthm)))) + [ TeX-arg-environment "Numbered like" ] + t [ (TeX-arg-eval progn (if (eq (save-excursion + (backward-char 2) + (preceding-char)) ?\]) + () + (TeX-arg-counter t "Within counter")) + "") ]) + + '("theoremstyle" + (TeX-arg-eval completing-read + "Style: " + LaTeX-theorem-theoremstyle-list)) + + '("theorembodyfont" + (LaTeX-arg-theorem-fontdecl "Body font")) + + '("theoremheaderfont" + (LaTeX-arg-theorem-fontdecl "Header font")) + + '("theorempreskipamount" + (TeX-arg-length "Skip before theorem")) + + '("theorempostskipamount" + (TeX-arg-length "Skip after theorem"))) + + ;; Fontification + (when (and (featurep 'font-latex) + (eq TeX-install-font-lock 'font-latex-setup)) + (font-latex-add-keywords '(("theoremstyle" "{") + ("theorembodyfont" "{") + ("theoremheaderfont" "{") + ("theorempreskipamount" "{") + ("theorempostskipamount" "{")) + 'function))) + LaTeX-dialect) + +(defvar LaTeX-theorem-package-options nil + "Package options for the theorem package.") + +;;; theorem.el ends here diff --git a/style/varioref.el b/style/varioref.el index 8811391f..7684ba4a 100644 --- a/style/varioref.el +++ b/style/varioref.el @@ -1,6 +1,6 @@ ;;; varioref.el --- AUCTeX style file with support for varioref.sty -;; Copyright (C) 1999, 2013 Free Software Foundation, Inc. +;; Copyright (C) 1999, 2013, 2015 Free Software Foundation, Inc. ;; Author: Carsten Dominik <domi...@strw.leidenuniv.nl> ;; Mads Jensen <m...@inducks.org> @@ -64,7 +64,12 @@ ("\\\\fullref{\\([^{}\n\r\\%,]*\\)" 1 LaTeX-label-list "}") ("\\\\vpageref\\*?\\(\\[[^]]*\\]\\)*{\\([^{}\n\r\\%,]*\\)" 2 LaTeX-label-list "}")) - TeX-complete-list))) + TeX-complete-list)) + + ;; Activate RefTeX reference style. + (and LaTeX-reftex-ref-style-auto-activate + (fboundp 'reftex-ref-style-activate) + (reftex-ref-style-activate "Varioref"))) LaTeX-dialect) (defvar LaTeX-varioref-package-options diff --git a/tex-buf.el b/tex-buf.el index bc19f7d6..aced105f 100644 --- a/tex-buf.el +++ b/tex-buf.el @@ -680,8 +680,12 @@ omitted) and `TeX-region-file'." (setq cmd (TeX-command-default ;; File function should be called with nil `nondirectory' ;; argument, otherwise `TeX-command-sequence' won't work in - ;; included files not placed in `TeX-master-directory'. - (funcall TeX-command-sequence-file-function)) + ;; included files not placed in `TeX-master-directory'. In + ;; addition, `TeX-master-file' is called with the third + ;; argument (`ask') set to t, so that the master file is + ;; properly set. This is also what `TeX-command-master' + ;; does. + (funcall TeX-command-sequence-file-function nil nil t)) TeX-command-sequence-command t))) (TeX-command cmd TeX-command-sequence-file-function 0) (when reset @@ -885,8 +889,8 @@ the current style options." ;;; Command Hooks -(defvar TeX-after-TeX-LaTeX-command-finished-hook nil - "Hook being run after TeX/LaTeX finished successfully. +(defvar TeX-after-compilation-finished-functions nil + "Hook being run after TeX/LaTeX/ConTeXt 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. @@ -894,10 +898,14 @@ the viewer automatically after re-compilation of the document. If you use an emacs-internal viewer such as `doc-view-mode' or `pdf-view-mode', add `TeX-revert-document-buffer' to this hook.") +(make-obsolete-variable 'TeX-after-TeX-LaTeX-command-finished-hook + 'TeX-after-compilation-finished-functions + "11.89") + (defun TeX-revert-document-buffer (file) "Revert the buffer visiting FILE. This function is intended to be used in -`TeX-after-TeX-LaTeX-command-finished-hook' for users that view +`TeX-after-compilation-finished-functions' for users that view their compiled document with an emacs viewer such as `doc-view-mode' or `pdf-view-mode'. (Note that this function just calls `revert-buffer' in the respective buffer and thus @@ -1526,7 +1534,7 @@ Rerun to get mark in right position\\." nil t) (push (cons idx-file t) LaTeX-idx-changed-alist))) (unless TeX-error-list - (run-hook-with-args 'TeX-after-TeX-LaTeX-command-finished-hook + (run-hook-with-args 'TeX-after-compilation-finished-functions (with-current-buffer TeX-command-buffer (expand-file-name (TeX-active-master (TeX-output-extension))))))) @@ -1987,10 +1995,16 @@ original file." (set-buffer-modified-p nil) (save-buffer 0)))))) -(defun TeX-region-file (&optional extension nondirectory) +(defun TeX-region-file (&optional extension nondirectory _ignore) "Return TeX-region file name with EXTENSION. If optional second argument NONDIRECTORY is non-nil, do not include -the directory." +the directory. + +The compatibility argument IGNORE is ignored." + ;; The third argument `_ignore' is kept for symmetry with `TeX-master-file's + ;; third argument `ask'. For example, it's used in `TeX-command-sequence', + ;; where we don't know which function has to be called. Keep this in mind + ;; should you want to use another argument here. (concat (if nondirectory "" (TeX-master-directory)) (cond ((eq extension t) (concat TeX-region "." TeX-default-extension)) @@ -2256,7 +2270,7 @@ Return non-nil if an error or warning is found." "^\\(\\(?:Overfull\\|Underfull\\|Tight\\|Loose\\)\ \\\\.*?[0-9]+--[0-9]+\\)\\|" ;; LaTeX warning - "^\\(LaTeX [A-Za-z]*\\|Package [A-Za-z0-9]+ \\)Warning:.*")) + "^\\(\\(?:LaTeX [A-Za-z]*\\|Package [A-Za-z0-9]+ \\)Warning:.*\\)")) (error-found nil)) (while (cond diff --git a/tex-font.el b/tex-font.el index 8c0bf610..e2cb4b73 100644 --- a/tex-font.el +++ b/tex-font.el @@ -170,4 +170,4 @@ (provide 'tex-font) -;;; tex-font.el ends here \ No newline at end of file +;;; tex-font.el ends here diff --git a/tex-style.el b/tex-style.el index b03a004d..a1ffb970 100644 --- a/tex-style.el +++ b/tex-style.el @@ -1,6 +1,6 @@ ;;; tex-style.el --- Customizable variables for AUCTeX style files -;; Copyright (C) 2005, 2007, 2009, 2012-2014 +;; Copyright (C) 2005, 2007, 2009, 2012-2015 ;; Free Software Foundation, Inc. ;; Author: Reiner Steib <reiner.st...@gmx.de> @@ -34,6 +34,13 @@ ;; Note: We don't have any defcustom in plain TeX style files yet. Else we ;; should also create a TeX-style group. +;; Common + +(defcustom LaTeX-reftex-ref-style-auto-activate t + "Whether to activate automatically RefTeX reference styles." + :type 'boolean + :group 'LaTeX-style) + ;; style/amsmath.el (defcustom LaTeX-amsmath-label nil diff --git a/tex.el b/tex.el index ce0c344f..7f464b37 100644 --- a/tex.el +++ b/tex.el @@ -2210,10 +2210,6 @@ this variable to \"<none>\"." :group 'TeX-command :type 'regexp) -(defvar TeX-convert-master t - "*If not nil, automatically convert ``Master:'' lines to file variables. -This will be done when AUCTeX first try to use the master file.") - ;; Can be let-bound temporarily in order to inhibit the master file question ;; by using its value instead in case `TeX-master' is nil or 'shared. (defvar TeX-transient-master nil) @@ -2269,10 +2265,7 @@ If optional second argument NONDIRECTORY is non-nil, do not include the directory. If optional third argument ASK is non-nil, ask the user for the -name of master file if it cannot be determined otherwise. - -Currently it will check for the presence of a ``Master:'' line in -the beginning of the file, but that feature will be phased out." +name of master file if it cannot be determined otherwise." (interactive) (if (eq extension t) (setq extension TeX-default-extension)) @@ -2319,18 +2312,6 @@ the beginning of the file, but that feature will be phased out." ;; We might already know the name. ((or (eq TeX-master t) (stringp TeX-master)) TeX-master) - ;; Support the ``Master:'' line (under protest!) - ((re-search-forward - "^%% *[Mm]aster:?[ \t]*\\([^ \t\n]+\\)" 500 t) - (setq TeX-master - (TeX-strip-extension (TeX-match-buffer 1) - (list TeX-default-extension))) - (if TeX-convert-master - (progn - (beginning-of-line) - (kill-line 1) - (TeX-add-local-master)))) - ;; Ask the user (but add it as a local variable). (ask (TeX-master-file-ask))))) @@ -2622,8 +2603,10 @@ For supported dialects, see variables `TeX-style-hook-dialect'.") Supported values are described below: * `:bibtex' for files in BibTeX mode. +* `:context' for files in ConTeXt mode. * `:latex' for files in LaTeX mode, or any mode derived thereof. +* `:plain-tex' for files in plain-TeX mode. * `:texinfo' for Texinfo files. Purpose is notably to prevent non-Texinfo hooks to be run in @@ -2686,7 +2669,7 @@ side effect e.g. on variable `TeX-font-list'.") (load-file el))))) (defconst TeX-style-hook-dialect-weight-alist - '((:latex . 1) (:texinfo . 2) (:bibtex . 4)) + '((:latex . 1) (:texinfo . 2) (:bibtex . 4) (:plain-tex . 8) (:context . 16)) "Association list to map dialects to binary weight, in order to implement dialect sets as bitmaps." ) @@ -3881,7 +3864,8 @@ If TEX is a directory, generate style files for all files in the directory." (verb-macros-delims (when (boundp 'LaTeX-verbatim-macros-with-delims-local) LaTeX-verbatim-macros-with-delims-local)) (verb-macros-braces (when (boundp 'LaTeX-verbatim-macros-with-braces-local) - LaTeX-verbatim-macros-with-braces-local))) + LaTeX-verbatim-macros-with-braces-local)) + (dialect TeX-style-hook-dialect)) (TeX-unload-style style) (with-current-buffer (generate-new-buffer file) (erase-buffer) @@ -3907,7 +3891,9 @@ If TEX is a directory, generate style files for all files in the directory." env))) (mapc (lambda (el) (TeX-auto-insert el style)) TeX-auto-parser) - (insert "))\n\n") + (insert ")") + (if dialect (insert (concat "\n " (prin1-to-string dialect)))) + (insert ")\n\n") (write-region (point-min) (point-max) file nil 'silent) (kill-buffer (current-buffer)))) (if (file-exists-p (concat file "c")) diff --git a/texmathp.el b/texmathp.el index f13e2374..e83f5489 100644 --- a/texmathp.el +++ b/texmathp.el @@ -257,7 +257,7 @@ See the variable `texmathp-tex-commands' about which commands are checked." (interactive) (let* ((pos (point)) math-on sw-match (bound (save-excursion - (if (re-search-backward "[\n\t][ \t]*[\n\r]" + (if (re-search-backward "[\n\r][ \t]*[\n\r]" nil 1 texmathp-search-n-paragraphs) (match-beginning 0) (point-min))))