[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/auctex ff5a83f345 17/48: Simplify implementation of sty
From: |
Tassilo Horn |
Subject: |
[elpa] externals/auctex ff5a83f345 17/48: Simplify implementation of style/thm-restate.el |
Date: |
Fri, 18 Nov 2022 14:27:43 -0500 (EST) |
branch: externals/auctex
commit ff5a83f34534f534d95decb9bb4159c7bda817bf
Author: Arash Esbati <arash@gnu.org>
Commit: Arash Esbati <arash@gnu.org>
Simplify implementation of style/thm-restate.el
* style/thm-restate.el (LaTeX-thmrestate-restatable-marco-regexp):
Recognize the starred version of the environment as well.
(LaTeX-thmrestate-auto-cleanup): Fontify new macros.
(LaTeX-env-thmrestate-restatable): Insert only the last mandatory
argument. Other arguments are included in the style hook.
(LaTeX-thm-restate-package-options): New variable.
---
style/thm-restate.el | 93 +++++++++++++++++++++++++++++++++-------------------
1 file changed, 59 insertions(+), 34 deletions(-)
diff --git a/style/thm-restate.el b/style/thm-restate.el
index 15d33a9cda..9f85050b5a 100644
--- a/style/thm-restate.el
+++ b/style/thm-restate.el
@@ -1,6 +1,6 @@
;;; thm-restate.el --- AUCTeX style for `thm-restate.sty' (v66) -*-
lexical-binding: t; -*-
-;; Copyright (C) 2018, 2020 Free Software Foundation, Inc.
+;; Copyright (C) 2018--2022 Free Software Foundation, Inc.
;; Author: Arash Esbati <arash@gnu.org>
;; Maintainer: auctex-devel@gnu.org
@@ -39,14 +39,17 @@
;; Silence the parser:
(declare-function LaTeX-thmtools-declaretheorem-list
"thmtools" ())
+(declare-function font-latex-add-keywords
+ "font-latex"
+ (keywords class))
;; Setup for macro names defined with
-;; \begin{restatable}[<Heading>]{<env-name>}{<macro name>}:
+;; \begin{restatable*?}[<Heading>]{<env-name>}{<macro name>}:
(TeX-auto-add-type "thmrestate-restatable-macro" "LaTeX")
(defvar LaTeX-thmrestate-restatable-marco-regexp
- `(,(concat "\\\\begin{restatable}"
+ `(,(concat "\\\\begin{restatable\\*?}"
"[ \t\n\r%]*"
"\\(?:\\[[^]]*\\]\\)?"
"[ \t\n\r%]*"
@@ -62,43 +65,25 @@
(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))))
+ (TeX-add-symbols newmac (concat newmac "*"))
+ (when (and (featurep 'font-latex)
+ (eq TeX-install-font-lock 'font-latex-setup))
+ (font-latex-add-keywords `((,newmac "*"))
+ 'function))))
(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)
+ "Insert last argument of restatable environment from thm-restate package."
(let ((mac (TeX-read-string
(TeX-argument-prompt optional nil "Macro"))))
- (TeX-add-symbols `(,mac 0)
- `(,(concat mac "*") 0))
+ (when (and (featurep 'font-latex)
+ (eq TeX-install-font-lock 'font-latex-setup))
+ (font-latex-add-keywords `((,mac "*"))
+ 'function))
+ (TeX-add-symbols mac (concat mac "*"))
(TeX-argument-insert mac optional)))
(TeX-add-style-hook
@@ -113,8 +98,48 @@
;; Provide restatable\\*? environment
(LaTeX-add-environments
- '("restatable" LaTeX-env-args LaTeX-env-thmrestate-restatable)
- '("restatable*" LaTeX-env-args LaTeX-env-thmrestate-restatable)))
+ `("restatable" LaTeX-env-args
+ [TeX-arg-string "Heading"]
+ (TeX-arg-completing-read
+ ;; Name of the environment we are referring to; this can be
+ ;; defined via amsthm.sty, ntheorem.sty or thmtools.sty:
+ ,(lambda ()
+ (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)))
+ "Environment")
+ LaTeX-env-thmrestate-restatable)
+
+ `("restatable*" LaTeX-env-args
+ [TeX-arg-string "Heading"]
+ (TeX-arg-completing-read
+ ;; Name of the environment we are referring to; this can be
+ ;; defined via amsthm.sty, ntheorem.sty or thmtools.sty:
+ ,(lambda ()
+ (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)))
+ "Environment")
+ LaTeX-env-thmrestate-restatable)))
TeX-dialect)
+(defvar LaTeX-thm-restate-package-options nil
+ "Package options for the thm-restate package.")
+
;;; thm-restate.el ends here
- [elpa] externals/auctex 05cd0440c5 02/48: Use `TeX-arg-completing-read-multiple', (continued)
- [elpa] externals/auctex 05cd0440c5 02/48: Use `TeX-arg-completing-read-multiple', Tassilo Horn, 2022/11/18
- [elpa] externals/auctex 0c482642cc 32/48: Simplify implementation of style/currvita.el, Tassilo Horn, 2022/11/18
- [elpa] externals/auctex 615e12f650 42/48: Simplify implementation of style/tcolorbox.el, Tassilo Horn, 2022/11/18
- [elpa] externals/auctex b9548da54a 38/48: Simplify implementation of style/tcolorboxlib-theorems.el, Tassilo Horn, 2022/11/18
- [elpa] externals/auctex 8e3137f641 15/48: Simplify implementation of style/titlesec.el, Tassilo Horn, 2022/11/18
- [elpa] externals/auctex 20cabef81f 20/48: ; Delete unnecessary `TeX-arg-string', Tassilo Horn, 2022/11/18
- [elpa] externals/auctex 49987f08dd 19/48: Provide completion candidates for `TeX-arg-length', Tassilo Horn, 2022/11/18
- [elpa] externals/auctex 52738d11b2 39/48: Remove entry in `LaTeX-completion-function-map-alist-keyval', Tassilo Horn, 2022/11/18
- [elpa] externals/auctex 8f70cd5211 14/48: Simplify implementation of style/ulem.el, Tassilo Horn, 2022/11/18
- [elpa] externals/auctex d5ff42e0bd 34/48: Simplify implementation of style/enumitem.el, Tassilo Horn, 2022/11/18
- [elpa] externals/auctex ff5a83f345 17/48: Simplify implementation of style/thm-restate.el,
Tassilo Horn <=
- [elpa] externals/auctex 0ee39626e4 01/48: Use `TeX-arg-completing-read', Tassilo Horn, 2022/11/18
- [elpa] externals/auctex 5949388ca2 12/48: Simplify argument queries in style/wrapfig.el, Tassilo Horn, 2022/11/18
- [elpa] externals/auctex 47f9ead1c6 44/48: Respect `TeX-exit-mark' when inserting enviroments, Tassilo Horn, 2022/11/18
- [elpa] externals/auctex c6c7c3f024 22/48: ; Use #' to quote function, Tassilo Horn, 2022/11/18
- [elpa] externals/auctex c0c9556338 30/48: Don't insert empty node name, Tassilo Horn, 2022/11/18
- [elpa] externals/auctex 978ebea1e8 16/48: Simplify implementation of style/thmtools.el, Tassilo Horn, 2022/11/18
- [elpa] externals/auctex d3970b77da 09/48: ; * latex.el (LaTeX-common-initialization): Remove dupe textcircled., Tassilo Horn, 2022/11/18
- [elpa] externals/auctex a0ba387b2c 23/48: ; Trivial cleanups, Tassilo Horn, 2022/11/18
- [elpa] externals/auctex 04a3138c81 45/48: Simplify implementation of style/theorem.el, Tassilo Horn, 2022/11/18
- [elpa] externals/auctex 316550f0bf 29/48: Fix `ConTeXt-add-environments', Tassilo Horn, 2022/11/18