auctex-diffs
[Top][All Lists]
Advanced

[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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]