[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/auctex 74c4843 40/48: Add new style/thmtools.el and sty
From: |
Tassilo Horn |
Subject: |
[elpa] externals/auctex 74c4843 40/48: Add new style/thmtools.el and style/thm-restate.el |
Date: |
Sun, 16 Sep 2018 01:47:27 -0400 (EDT) |
branch: externals/auctex
commit 74c48433e3bfd2b97b0a6f69324748629fcaf1f4
Author: Arash Esbati <address@hidden>
Commit: Arash Esbati <address@hidden>
Add new style/thmtools.el and style/thm-restate.el
* Makefile.in (STYLESRC): Add new styles.
* style/thmtools.el:
* style/thm-restate.el: New files.
---
style/thm-restate.el | 115 ++++++++++++++++++++
style/thmtools.el | 299 +++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 414 insertions(+)
diff --git a/style/thm-restate.el b/style/thm-restate.el
new file mode 100644
index 0000000..595a582
--- /dev/null
+++ b/style/thm-restate.el
@@ -0,0 +1,115 @@
+;;; thm-restate.el --- AUCTeX style for `thm-restate.sty' (v66)
+
+;; Copyright (C) 2018 Free Software Foundation, Inc.
+
+;; Author: Arash Esbati <address@hidden>
+;; Maintainer: address@hidden
+;; Created: 2018-07-07
+;; 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 `thm-restate.sty'. `thm-restate.sty' is
+;; part of `thmtools' package (v66) from 2014/04/21. `thmtools.sty'
+;; is part of TeXLive.
+
+;;; Code:
+
+;; Needed for auto-parsing.
+(require 'tex)
+
+;; Setup for macro names defined with
+;; \begin{restatable}[<Heading>]{<env-name>}{<macro name>}:
+
+(TeX-auto-add-type "thmrestate-restatable-macro" "LaTeX")
+
+(defvar LaTeX-thmrestate-restatable-marco-regexp
+ `(,(concat "\\\\begin{restatable}"
+ "[ \t\n\r%]*"
+ "\\(?:\\[[^]]*\\]\\)?"
+ "[ \t\n\r%]*"
+ "\\(?:{[^}]+}\\)"
+ "[ \t\n\r%]*"
+ "{\\([^}]+\\)}")
+ 1 LaTeX-auto-thmrestate-restatable-macro))
+
+(defun LaTeX-thmrestate-auto-prepare ()
+ "Clear `LaTeX-auto-thmrestate-restatable-macro' before parsing."
+ (setq LaTeX-auto-thmrestate-restatable-macro nil))
+
+(defun LaTeX-thmrestate-auto-cleanup ()
+ "Process parsed elements from thm-restate package."
+ (dolist (newmac (mapcar #'car (LaTeX-thmrestate-restatable-macro-list)))
+ (TeX-add-symbols `(,newmac 0)
+ `(,(concat newmac "*") 0))))
+
+(add-hook 'TeX-auto-prepare-hook #'LaTeX-thmrestate-auto-prepare t)
+(add-hook 'TeX-auto-cleanup-hook #'LaTeX-thmrestate-auto-cleanup t)
+(add-hook 'TeX-update-style-hook #'TeX-auto-parse t)
+
+(defun LaTeX-env-thmrestate-restatable (optional)
+ "Insert arguments for restatable environment from thm-restate package."
+ ;; The optional heading argument:
+ (let ((TeX-arg-opening-brace LaTeX-optop)
+ (TeX-arg-closing-brace LaTeX-optcl))
+ (TeX-argument-insert
+ (TeX-read-string
+ (TeX-argument-prompt t nil "Heading"))
+ t))
+ ;; Name of the environment we are referring to; this can be defined
+ ;; via amsthm.sty, ntheorem.sty or thmtools.sty:
+ (TeX-argument-insert
+ (completing-read
+ (TeX-argument-prompt optional nil "Environment")
+ (append
+ ;; Cater for environments defined with amsthm's \newtheorem
+ (when (and (fboundp 'LaTeX-amsthm-newtheorem-list)
+ (LaTeX-amsthm-newtheorem-list))
+ (LaTeX-amsthm-newtheorem-list))
+ ;; Cater for environments defined with ntheorem's \newtheorem
+ (when (and (fboundp 'LaTeX-ntheorem-newtheorem-list)
+ (LaTeX-ntheorem-newtheorem-list))
+ (LaTeX-ntheorem-newtheorem-list))
+ ;; Environments defined with \declaretheorem
+ (LaTeX-thmtools-declaretheorem-list)))
+ optional)
+ (let ((mac (TeX-read-string
+ (TeX-argument-prompt optional nil "Macro"))))
+ (TeX-add-symbols `(,mac 0)
+ `(,(concat mac "*") 0))
+ (TeX-argument-insert mac optional)))
+
+(TeX-add-style-hook
+ "thm-restate"
+ (lambda ()
+
+ ;; Run the style hook `thmtools.el':
+ (TeX-run-style-hooks "thmtools")
+
+ ;; Add thm-restate to the parser
+ (TeX-auto-add-regexp LaTeX-thmrestate-restatable-marco-regexp)
+
+ ;; Provide restatable\\*? environment
+ (LaTeX-add-environments
+ '("restatable" LaTeX-env-args LaTeX-env-thmrestate-restatable)
+ '("restatable*" LaTeX-env-args LaTeX-env-thmrestate-restatable)))
+ LaTeX-dialect)
+
+;;; thm-restate.el ends here
diff --git a/style/thmtools.el b/style/thmtools.el
new file mode 100644
index 0000000..9c3b51c
--- /dev/null
+++ b/style/thmtools.el
@@ -0,0 +1,299 @@
+;;; thmtools.el --- AUCTeX style for `thmtools.sty' (v66)
+
+;; Copyright (C) 2018 Free Software Foundation, Inc.
+
+;; Author: Arash Esbati <address@hidden>
+;; Maintainer: address@hidden
+;; Created: 2018-07-07
+;; 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 `thmtools.sty' (v66) from 2014/04/21.
+;; `thmtools.sty' is part of TeXLive.
+
+;;; Code:
+
+;; Needed for auto-parsing.
+(require 'tex)
+
+;; Setup for \declaretheoremstyle:
+(TeX-auto-add-type "thmtools-declaretheoremstyle" "LaTeX")
+
+(defvar LaTeX-thmtools-declaretheoremstyle-regexp
+ `(,(concat "\\\\declaretheoremstyle"
+ "[ \t\n\r%]*"
+ "\\(?:\\[[^][]*"
+ "\\(?:{[^}{]*"
+ "\\(?:{[^}{]*"
+ "\\(?:{[^}{]*}[^}{]*\\)*"
+ "}[^}{]*\\)*"
+ "}[^][]*\\)*"
+ "\\]\\)?"
+ "[ \t\n\r%]*"
+ "{\\([^}]+\\)}")
+ 1 LaTeX-auto-thmtools-declaretheoremstyle)
+ "Matches the argument of \\declaretheoremstyle from thmtools package.")
+
+;; Setup for \declaretheorem:
+(TeX-auto-add-type "thmtools-declaretheorem" "LaTeX")
+
+(defvar LaTeX-thmtools-declaretheorem-regexp
+ `(,(concat "\\\\declaretheorem"
+ "[ \t\n\r%]*"
+ "\\(?:\\[[^][]*"
+ "\\(?:{[^}{]*"
+ "\\(?:{[^}{]*"
+ "\\(?:{[^}{]*}[^}{]*\\)*"
+ "}[^}{]*\\)*"
+ "}[^][]*\\)*"
+ "\\]\\)?"
+ "[ \t\n\r%]*"
+ "{\\([^}]+\\)}")
+ 1 LaTeX-auto-thmtools-declaretheorem)
+ "Matches the argument of \\declaretheorem from thmtools package.")
+
+(defun LaTeX-thmtools-auto-prepare ()
+ "Clear `LaTeX-auto-thmtools-*' before parsing."
+ (setq LaTeX-auto-thmtools-declaretheoremstyle nil
+ LaTeX-auto-thmtools-declaretheorem nil))
+
+(defun LaTeX-thmtools-auto-cleanup ()
+ "Process parsed elements from thmtools package."
+ (dolist (newthm (mapcar #'car (LaTeX-thmtools-declaretheorem-list)))
+ (LaTeX-add-environments `(,newthm LaTeX-thmtools-env-label))))
+
+(add-hook 'TeX-auto-prepare-hook #'LaTeX-thmtools-auto-prepare t)
+(add-hook 'TeX-auto-cleanup-hook #'LaTeX-thmtools-auto-cleanup t)
+(add-hook 'TeX-update-style-hook #'TeX-auto-parse t)
+
+(defun LaTeX-thmtools-declaretheoremstyle-key-val (optional &optional prompt)
+ "Query and return a key=val string for \\declaretheoremstyle macro.
+If OPTIONAL is non-nil, indicate an optional argument in
+minibuffer. PROMPT replaces the standard one."
+ (let ((lengths (mapcar (lambda (x)
+ (concat TeX-esc x))
+ (mapcar #'car (LaTeX-length-list))))
+ (fonts (mapcar (lambda (x)
+ (concat TeX-esc x))
+ '("rmfamily" "sffamily" "ttfamily" "mdseries" "bfseries"
+ "upshape" "itshape" "slshape" "scshape"
+ "tiny" "scriptsize" "footnotesize"
+ "small" "normalsize" "large"
+ "Large" "LARGE" "huge" "Huge" "normalfont"))))
+ (TeX-read-key-val
+ optional
+ `(("spaceabove" ,lengths)
+ ("spacebelow" ,lengths)
+ ("headfont" ,fonts)
+ ("notefont" ,fonts)
+ ("bodyfont" ,fonts)
+ ("headpunct")
+ ("notebraces")
+ ("postheadspace" ,lengths)
+ ("headformat" ("margin" "swapnumber" "\\NUMBER" "\\NAME" "\\NOTE"))
+ ("headindent" ,lengths))
+ prompt)))
+
+(defun LaTeX-arg-thmtools-declaretheoremstyle (optional &optional prompt)
+ "Insert the key=val and style name defined by \\declaretheoremstyle.
+If OPTIONAL is non-nil, also insert the second argument in square
+brackets. PROMPT replaces the standard one for the second
+argument."
+ (let ((TeX-arg-opening-brace "[")
+ (TeX-arg-closing-brace "]"))
+ (TeX-argument-insert
+ (LaTeX-thmtools-declaretheoremstyle-key-val t)
+ t))
+ (let ((style (TeX-read-string
+ (TeX-argument-prompt optional prompt "Style"))))
+ (LaTeX-add-thmtools-declaretheoremstyles style)
+ (TeX-argument-insert style optional)))
+
+(defun LaTeX-thmtools-declaretheorem-key-val (optional &optional prompt)
+ "Query and return a key=val string for \\declaretheorem macro.
+If OPTIONAL is non-nil, indicate an optional argument in
+minibuffer. PROMPT replaces the standard one."
+ (let ((counters (mapcar #'car (LaTeX-counter-list))))
+ (TeX-read-key-val
+ optional
+ `(("parent" ,counters)
+ ("numberwithin" ,counters)
+ ("within" ,counters)
+ ("sibling" ,counters)
+ ("numberlike" ,counters)
+ ("sharenumber" ,counters)
+ ("title")
+ ("name")
+ ("heading")
+ ("numbered" ("yes" "no" "unless unique"))
+ ("style"
+ ,(append
+ ;; check for \newtheoremstyle from amsthm.sty:
+ (when (and (fboundp 'LaTeX-amsthm-newtheoremstyle-list)
+ (LaTeX-amsthm-newtheoremstyle-list))
+ (mapcar #'car (LaTeX-amsthm-newtheoremstyle-list)))
+ ;; check for \newtheoremstyle from ntheorem.sty:
+ (when (and (fboundp 'LaTeX-ntheorem-newtheoremstyle-list)
+ (LaTeX-ntheorem-newtheoremstyle-list))
+ (mapcar #'car (LaTeX-ntheorem-newtheoremstyle-list)))
+ ;; thmtools version is called \declaretheoremstyle:
+ (mapcar #'car (LaTeX-thmtools-declaretheoremstyle-list))))
+ ("preheadhook")
+ ("postheadhook")
+ ("prefoothook")
+ ("postfoothook")
+ ("refname")
+ ("Refname")
+ ("shaded" ("textwidth" "bgcolor" "rulecolor" "rulewidth" "margin"))
+ ("thmbox" ("L" "M" "S"))))))
+
+(defun LaTeX-arg-thmtools-declaretheorem (optional &optional prompt)
+ "Insert the key=val and environment name defined by \\declaretheorem.
+If OPTIONAL is non-nil, also insert the second argument in square
+brackets. PROMPT replaces the standard one for the second
+argument."
+ (let ((TeX-arg-opening-brace "[")
+ (TeX-arg-closing-brace "]"))
+ (TeX-argument-insert
+ (LaTeX-thmtools-declaretheorem-key-val t)
+ t))
+ (let ((env (TeX-read-string
+ (TeX-argument-prompt optional prompt "Environment"))))
+ (LaTeX-add-environments `(,env LaTeX-thmtools-env-label))
+ (TeX-argument-insert env optional)))
+
+(defun LaTeX-thmtools-listoftheorems-key-val (optional &optional prompt)
+ "Query and return a key=val string for \\listoftheorems macro.
+If OPTIONAL is non-nil, indicate an optional argument in
+minibuffer. PROMPT replaces the standard one."
+ (let ((lengths (mapcar (lambda (x)
+ (concat TeX-esc x))
+ (mapcar #'car (LaTeX-length-list))))
+ (thms (append
+ ;; check for \newtheorem from amsthm.sty:
+ (when (and (fboundp 'LaTeX-amsthm-newtheorem-list)
+ (LaTeX-amsthm-newtheorem-list))
+ (mapcar #'car (LaTeX-amsthm-newtheorem-list)))
+ ;; check for \newtheorem from ntheorem.sty:
+ (when (and (fboundp 'LaTeX-ntheorem-newtheorem-list)
+ (LaTeX-ntheorem-newtheorem-list))
+ (mapcar #'car (LaTeX-ntheorem-newtheorem-list)))
+ ;; thmtools version is called \declaretheorem:
+ (mapcar #'car (LaTeX-thmtools-declaretheorem-list)))))
+ (TeX-read-key-val
+ optional
+ `(("numwidth" ,lengths)
+ ("ignore" ,thms)
+ ("onlynamed" ,thms)
+ ("show" ,thms)
+ ("ignoreall" ("true" "false"))
+ ("showall" ("true" "false"))))))
+
+(defun LaTeX-arg-thmtools-listoftheorems (optional &optional prompt)
+ "Insert the key=val to \\listoftheorems macro.
+If OPTIONAL is non-nil, insert the result square brackets.
+OPTIONAL and PROMPT are passed to `LaTeX-thmtools-listoftheorems-key-val'."
+ (TeX-argument-insert
+ (LaTeX-thmtools-listoftheorems-key-val optional prompt)
+ optional))
+
+(defun LaTeX-thmtools-env-label (environment)
+ "Insert thmtools ENVIRONMENT, query for an optional argument and label.
+AUCTeX users should add ENVIRONMENT to `LaTeX-label-alist' via
+customize or in init-file with:
+
+ (add-to-list \\='LaTeX-label-alist \\='(\"theorem\" . \"thm:\"))
+
+RefTeX users should customize or add ENVIRONMENT to
+`LaTeX-label-alist' and `reftex-label-alist', e.g.
+
+ (add-to-list \\='LaTeX-label-alist \\='(\"theorem\" . \"thm:\"))
+ (add-to-list \\='reftex-label-alist
+ \\='(\"theorem\" ?m \"thm:\" \"~\\ref{%s}\"
+ nil (\"Theorem\" \"theorem\") nil))"
+ (let* ((choice (read-char
+ (TeX-argument-prompt nil nil "Heading (h), Key=val (k), Empty
(RET)")))
+ (opthead (cond ((= choice ?h)
+ (TeX-read-string
+ (TeX-argument-prompt t nil "Heading")))
+ ((= choice ?k)
+ (TeX-read-key-val
+ t
+ `(("name")
+ ("continues" ,(mapcar #'car (LaTeX-label-list)))
+ ("restate" ,(mapcar #'car (LaTeX-label-list)))
+ ;; We don't offer a label key here: It is
+ ;; marked "experimental" in the manual and
+ ;; inserting and parsing \label{foo} is
+ ;; much easier for AUCTeX and RefTeX
+ ;; ("label")
+ ("listhack" ("true" "false")))))
+ (t ""))))
+ (LaTeX-insert-environment environment
+ (when (and opthead
+ (not (string= opthead "")))
+ (format "[%s]" opthead))))
+ (when (LaTeX-label environment 'environment)
+ (LaTeX-newline)
+ (indent-according-to-mode)))
+
+(TeX-add-style-hook
+ "thmtools"
+ (lambda ()
+
+ ;; Add thmtools to the parser.
+ (TeX-auto-add-regexp LaTeX-thmtools-declaretheoremstyle-regexp)
+ (TeX-auto-add-regexp LaTeX-thmtools-declaretheorem-regexp)
+
+ (TeX-add-symbols
+ '("declaretheoremstyle" LaTeX-arg-thmtools-declaretheoremstyle)
+ '("declaretheorem" LaTeX-arg-thmtools-declaretheorem)
+
+ '("listoftheorems" [ LaTeX-arg-thmtools-listoftheorems ])
+ '("ignoretheorems"
+ (TeX-arg-eval mapconcat #'identity
+ (TeX-completing-read-multiple
+ (TeX-argument-prompt optional nil "Environment(s)")
+ (append
+ ;; check for \newtheorem from amsthm.sty:
+ (when (and (fboundp 'LaTeX-amsthm-newtheorem-list)
+ (LaTeX-amsthm-newtheorem-list))
+ (mapcar #'car (LaTeX-amsthm-newtheorem-list)))
+ ;; check for \newtheorem from ntheorem.sty:
+ (when (and (fboundp 'LaTeX-ntheorem-newtheorem-list)
+ (LaTeX-ntheorem-newtheorem-list))
+ (mapcar #'car (LaTeX-ntheorem-newtheorem-list)))
+ ;; thmtools version is called \declaretheorem:
+ (mapcar #'car (LaTeX-thmtools-declaretheorem-list))))
+ ","))
+ '("listtheoremname" 0))
+
+ ;; Fontification
+ (when (and (featurep 'font-latex)
+ (eq TeX-install-font-lock 'font-latex-setup))
+ (font-latex-add-keywords '(("declaretheoremstyle" "[{")
+ ("declaretheorem" "[{")
+ ("listoftheorems" "[")
+ ("ignoretheorems" "{"))
+ 'function)))
+ LaTeX-dialect)
+
+;;; thmtools.el ends here
- [elpa] externals/auctex 0d8f8a2 14/48: Prevent spurious newlines to be added, (continued)
- [elpa] externals/auctex 0d8f8a2 14/48: Prevent spurious newlines to be added, Tassilo Horn, 2018/09/16
- [elpa] externals/auctex 527bcb2 16/48: ; * doc/auctex.texi (Processor Options): Add note of case in an option., Tassilo Horn, 2018/09/16
- [elpa] externals/auctex 7371b46 07/48: Add support for dvipdfmx to \includegraphics, Tassilo Horn, 2018/09/16
- [elpa] externals/auctex 4afd633 11/48: Update key=val options to geometry package v5.8, Tassilo Horn, 2018/09/16
- [elpa] externals/auctex 6a17a52 24/48: ; * doc/changes.texi (News in 12.2): Add news about removed option., Tassilo Horn, 2018/09/16
- [elpa] externals/auctex ff08d38 28/48: Fix region compilation with \usepackage[utf8]{inputenc}, Tassilo Horn, 2018/09/16
- [elpa] externals/auctex cad042f 31/48: Add note and test about the change involving non-ascii file name, Tassilo Horn, 2018/09/16
- [elpa] externals/auctex 5ce08ab 33/48: Raise robustness of call of dvipng command, Tassilo Horn, 2018/09/16
- [elpa] externals/auctex 3741b8c 26/48: Prepare for UTF-8 with BOM, Tassilo Horn, 2018/09/16
- [elpa] externals/auctex 4816092 36/48: Fix possible endless loop, Tassilo Horn, 2018/09/16
- [elpa] externals/auctex 74c4843 40/48: Add new style/thmtools.el and style/thm-restate.el,
Tassilo Horn <=
- [elpa] externals/auctex ff8f183 39/48: ; * style/floatrow.el (LaTeX-floatrow-update-key-val-options): Use `setq' inside the loop., Tassilo Horn, 2018/09/16
- [elpa] externals/auctex e0caf59 25/48: Drop compatibility code for older emacsen in preview-latex, Tassilo Horn, 2018/09/16
- [elpa] externals/auctex 1fef01c 45/48: Update style/lettrine.el to package version 2.01, Tassilo Horn, 2018/09/16
- [elpa] externals/auctex cff843b 17/48: Remove obsolete option related to Japanese TeX, Tassilo Horn, 2018/09/16
- [elpa] externals/auctex a59c754 35/48: Adjust test for known emacs bug, Tassilo Horn, 2018/09/16
- [elpa] externals/auctex 0d5c1c0 41/48: ; Fix last commit and push missing Makefile.in., Tassilo Horn, 2018/09/16
- [elpa] externals/auctex 45747b9 42/48: Add \eqref to RefTeX's reference styles, Tassilo Horn, 2018/09/16
- [elpa] externals/auctex a8ea127 29/48: Accept non-ascii file name in accord with change in TL 2018, Tassilo Horn, 2018/09/16
- [elpa] externals/auctex 48325a7 20/48: Update URLs further, Tassilo Horn, 2018/09/16
- [elpa] externals/auctex 8d30dc1 37/48: Add new style/marginnote.el, Tassilo Horn, 2018/09/16