auctex-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 83622003 4/5: * style/enumitem.el ("enumitem"): Replace `TeX-arg-


From: Arash Esbati
Subject: master 83622003 4/5: * style/enumitem.el ("enumitem"): Replace `TeX-arg-eval'.
Date: Tue, 13 Dec 2022 06:33:01 -0500 (EST)

branch: master
commit 83622003aa2bd9a8402f7f4edfc9abd0d0d05031
Author: Arash Esbati <arash@gnu.org>
Commit: Arash Esbati <arash@gnu.org>

    * style/enumitem.el ("enumitem"): Replace `TeX-arg-eval'.
---
 style/enumitem.el | 35 ++++++++++++++++++++---------------
 1 file changed, 20 insertions(+), 15 deletions(-)

diff --git a/style/enumitem.el b/style/enumitem.el
index f8e8737b..6363a244 100644
--- a/style/enumitem.el
+++ b/style/enumitem.el
@@ -343,25 +343,30 @@ macro.  Insert the value in brackets if OPTIONAL is 
non-nil."
     ;; But we go the extra mile to improve the user experience and add
     ;; the arguments directly to appropriate lists.
     ;; \newlist{<name>}{<type>}{<max-depth>}
-    '("newlist"
-      (TeX-arg-eval
-       (lambda ()
-         (let ((name (TeX-read-string "Name: "))
-               (type (completing-read
-                      "Type: "
-                      (mapcar #'cadr (LaTeX-enumitem-newlist-list))))
-               (depth (TeX-read-string "Max-depth: ")))
-           (when (or (string-equal type "description")
-                     (string-equal type "description*"))
-             (add-to-list 'LaTeX-item-list `(,name . LaTeX-item-argument)))
+    `("newlist"
+      ,(lambda (optional)
+         (let ((name (TeX-read-string
+                      (TeX-argument-prompt optional nil "Name"))))
            (LaTeX-add-environments
             `(,name LaTeX-env-item-args
                     [TeX-arg-key-val (LaTeX-enumitem-key-val-options)]))
-           (LaTeX-add-enumitem-newlists (list name type))
            (TeX-ispell-skip-setcdr `((,name ispell-tex-arg-end 0)))
-           (TeX-argument-insert name nil)
-           (TeX-argument-insert type nil)
-           (format "%s" depth)))))
+           (TeX-argument-insert name optional)))
+      (TeX-arg-completing-read ,(lambda ()
+                                  (mapcar #'cadr
+                                          (LaTeX-enumitem-newlist-list)))
+                               "Type")
+      (TeX-arg-string "Max-depth")
+      ,(lambda (_optional)
+         (save-excursion
+           (re-search-backward "\\\\newlist{\\([^}]+\\)}{\\([^}]+\\)}"
+                               (line-beginning-position) t))
+         (let ((name (match-string-no-properties 1))
+               (type (match-string-no-properties 2)))
+           (when (or (string-equal type "description")
+                     (string-equal type "description*"))
+             (add-to-list 'LaTeX-item-list `(,name . LaTeX-item-argument)))
+           (LaTeX-add-enumitem-newlists (list name type)))))
 
     ;; \renewlist{<name>}{<type>}{<max-depth>}
     `("renewlist"



reply via email to

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