[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 3d8d93e4 1/2: ; Make code more resilient
From: |
Arash Esbati |
Subject: |
master 3d8d93e4 1/2: ; Make code more resilient |
Date: |
Thu, 17 Nov 2022 15:29:52 -0500 (EST) |
branch: master
commit 3d8d93e4fd1ee55a23859656c553385ca493ace0
Author: Arash Esbati <arash@gnu.org>
Commit: Arash Esbati <arash@gnu.org>
; Make code more resilient
* style/enumitem.el (LaTeX-arg-enumitem-SetEnumitemValue): Check
if the first argument was really inserted before searching back.
("enumitem"): Remove unnecessary `and'.
---
style/enumitem.el | 24 +++++++++++++-----------
1 file changed, 13 insertions(+), 11 deletions(-)
diff --git a/style/enumitem.el b/style/enumitem.el
index e08f7c89..f8e8737b 100644
--- a/style/enumitem.el
+++ b/style/enumitem.el
@@ -274,15 +274,17 @@ Insert key and value in brackets if OPTIONAL is non-nil."
"Ask and insert for a new value added to an existing key.
This is the second mandatory argument of \\SetEnumitemValue
macro. Insert the value in brackets if OPTIONAL is non-nil."
- (let ((key (save-excursion
- (and (re-search-backward "\\\\SetEnumitemValue{\\([^}]+\\)}"
- (line-beginning-position) t)
- (match-string-no-properties 1))))
+ (let ((key (when (= (preceding-char) (string-to-char TeX-grcl))
+ (save-excursion
+ (re-search-backward "\\\\SetEnumitemValue{\\([^}]+\\)}"
+ (line-beginning-position) t)
+ (match-string-no-properties 1))))
(val (TeX-read-string
(TeX-argument-prompt optional nil "String value"))))
- (LaTeX-add-enumitem-SetEnumitemValues
- (list (concat "\\SetEnumitemValue{" key "}{" val "}")
- key val))
+ (when key
+ (LaTeX-add-enumitem-SetEnumitemValues
+ (list (concat "\\SetEnumitemValue{" key "}{" val "}")
+ key val)))
(TeX-argument-insert val optional)))
(TeX-add-style-hook
@@ -447,10 +449,10 @@ macro. Insert the value in brackets if OPTIONAL is
non-nil."
(TeX-arg-completing-read
,(lambda ()
(save-excursion
- (and (re-search-backward "\\\\SetEnumitemValue{\\([^}]+\\)}"
- (line-beginning-position) t)
- (cadr (assoc (match-string-no-properties 1)
- LaTeX-enumitem-key-val-options)))))
+ (re-search-backward "\\\\SetEnumitemValue{\\([^}]+\\)}"
+ (line-beginning-position) t)
+ (cadr (assoc (match-string-no-properties 1)
+ LaTeX-enumitem-key-val-options))))
"Replacement"))
;; v3.6 has a macro for visual debugging.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master 3d8d93e4 1/2: ; Make code more resilient,
Arash Esbati <=