[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/auctex 978ebea1e8 16/48: Simplify implementation of sty
From: |
Tassilo Horn |
Subject: |
[elpa] externals/auctex 978ebea1e8 16/48: Simplify implementation of style/thmtools.el |
Date: |
Fri, 18 Nov 2022 14:27:43 -0500 (EST) |
branch: externals/auctex
commit 978ebea1e8b58ee88ec43e0887e16faad97dab0c
Author: Arash Esbati <arash@gnu.org>
Commit: Arash Esbati <arash@gnu.org>
Simplify implementation of style/thmtools.el
* style/thmtools.el
(LaTeX-thmtools-declaretheoremstyle-key-val-options): Rename from
`LaTeX-thmtools-declaretheoremstyle-key-val'.
(LaTeX-thmtools-declaretheorem-key-val-options): Rename from
`LaTeX-thmtools-declaretheorem-key-val'.
(LaTeX-thmtools-listoftheorems-key-val-options): Rename from
`LaTeX-thmtools-listoftheorems-key-val'.
New functions now return only a key=val alist and don't query.
(LaTeX-arg-thmtools-declaretheoremstyle):
(LaTeX-arg-thmtools-declaretheorem): Insert only the mandatory
argument. The query for the optional one happens in the hook.
(LaTeX-arg-thmtools-listoftheorems): Removed as not needed.
---
style/thmtools.el | 162 +++++++++++++++++++++++-------------------------------
1 file changed, 68 insertions(+), 94 deletions(-)
diff --git a/style/thmtools.el b/style/thmtools.el
index 4a1067b922..dcf02db8d5 100644
--- a/style/thmtools.el
+++ b/style/thmtools.el
@@ -82,10 +82,8 @@
(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."
+(defun LaTeX-thmtools-declaretheoremstyle-key-val-options ()
+ "Return key=val list for \\declaretheoremstyle macro."
(let ((lengths (mapcar (lambda (x)
(concat TeX-esc x))
(mapcar #'car (LaTeX-length-list))))
@@ -96,93 +94,73 @@ minibuffer. PROMPT replaces the standard one."
"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)))
+ `(("spaceabove" ,lengths)
+ ("spacebelow" ,lengths)
+ ("headfont" ,fonts)
+ ("notefont" ,fonts)
+ ("bodyfont" ,fonts)
+ ("headpunct")
+ ("notebraces")
+ ("postheadspace" ,lengths)
+ ("headformat" ("margin" "swapnumber" "\\NUMBER" "\\NAME" "\\NOTE"))
+ ("headindent" ,lengths))))
(defun LaTeX-arg-thmtools-declaretheoremstyle (optional &optional prompt)
- "Insert the key=val and style name defined by \\declaretheoremstyle.
+ "Insert the 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."
+(defun LaTeX-thmtools-declaretheorem-key-val-options ()
+ "Return key=val list for \\declaretheorem macro."
(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")))
- prompt)))
+ `(("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.
+ "Insert the 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 ((env (TeX-read-string
(TeX-argument-prompt optional prompt "Environment"))))
(LaTeX-add-environments `(,env LaTeX-thmtools-env-label))
- (TeX-argument-insert env optional))
- (let ((TeX-arg-opening-brace "[")
- (TeX-arg-closing-brace "]"))
- (TeX-argument-insert
- (LaTeX-thmtools-declaretheorem-key-val t)
- t)))
-
-(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."
+ (TeX-argument-insert env optional)))
+
+(defun LaTeX-thmtools-listoftheorems-key-val-options ()
+ "Return key=val list for \\listoftheorems macro."
(let ((lengths (mapcar (lambda (x)
(concat TeX-esc x))
(mapcar #'car (LaTeX-length-list))))
@@ -197,25 +175,14 @@ minibuffer. PROMPT replaces the standard one."
(mapcar #'car (LaTeX-ntheorem-newtheorem-list)))
;; thmtools version is called \declaretheorem:
(mapcar #'car (LaTeX-thmtools-declaretheorem-list)))))
- (TeX-read-key-val
- optional
- `(("title")
- ("ignore" ,thms)
- ("ignoreall" ("true" "false"))
- ("show" ,thms)
- ("showall" ("true" "false"))
- ("onlynamed" ,thms)
- ("swapnumber" ("true" "false"))
- ("numwidth" ,lengths))
- prompt)))
-
-(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))
+ `(("title")
+ ("ignore" ,thms)
+ ("ignoreall" ("true" "false"))
+ ("show" ,thms)
+ ("showall" ("true" "false"))
+ ("onlynamed" ,thms)
+ ("swapnumber" ("true" "false"))
+ ("numwidth" ,lengths))))
(defun LaTeX-thmtools-env-label (environment)
"Insert thmtools ENVIRONMENT, query for an optional argument and label.
@@ -273,10 +240,17 @@ RET in order to leave it empty.")
(TeX-auto-add-regexp LaTeX-thmtools-declaretheorem-regexp)
(TeX-add-symbols
- '("declaretheoremstyle" LaTeX-arg-thmtools-declaretheoremstyle)
- '("declaretheorem" LaTeX-arg-thmtools-declaretheorem)
+ '("declaretheoremstyle"
+ [TeX-arg-key-val (LaTeX-thmtools-declaretheoremstyle-key-val-options)]
+ LaTeX-arg-thmtools-declaretheoremstyle)
+
+ '("declaretheorem"
+ LaTeX-arg-thmtools-declaretheorem
+ [TeX-arg-key-val (LaTeX-thmtools-declaretheorem-key-val-options)])
+
+ '("listoftheorems"
+ [TeX-arg-key-val (LaTeX-thmtools-listoftheorems-key-val-options)])
- '("listoftheorems" [ LaTeX-arg-thmtools-listoftheorems ])
`("ignoretheorems"
(TeX-arg-completing-read-multiple
,(lambda () (append
- [elpa] externals/auctex 49987f08dd 19/48: Provide completion candidates for `TeX-arg-length', (continued)
- [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, 2022/11/18
- [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 <=
- [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
- [elpa] externals/auctex 8775c8355f 13/48: Replace `TeX-arg-url-urlstyle' in style/url.el, Tassilo Horn, 2022/11/18
- [elpa] externals/auctex a7a7209a08 33/48: Extend the argument list of some functions, Tassilo Horn, 2022/11/18
- [elpa] externals/auctex c8d638ac9d 40/48: Use `functionp' to recognize a function, Tassilo Horn, 2022/11/18
- [elpa] externals/auctex 835e01ddb6 36/48: Extend the argument list of `TeX-arg-string', Tassilo Horn, 2022/11/18
- [elpa] externals/auctex e83a4b87b3 25/48: Use the correct function to retrieve the key=vals, Tassilo Horn, 2022/11/18
- [elpa] externals/auctex a617944b4b 08/48: Fix style/xspace.el, Tassilo Horn, 2022/11/18