emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[nongnu] elpa/subed bbd239a 042/389: subed-srt--regenerate-ids: Wrap fun


From: ELPA Syncer
Subject: [nongnu] elpa/subed bbd239a 042/389: subed-srt--regenerate-ids: Wrap function body in atomic-change-group
Date: Fri, 3 Dec 2021 10:59:53 -0500 (EST)

branch: elpa/subed
commit bbd239a0ee26bb9ef003084fe669c04a7fa419c0
Author: Random User <rndusr@posteo.de>
Commit: Random User <rndusr@posteo.de>

    subed-srt--regenerate-ids: Wrap function body in atomic-change-group
---
 subed/subed-srt.el | 21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/subed/subed-srt.el b/subed/subed-srt.el
index 01adbcf..6e711e0 100644
--- a/subed/subed-srt.el
+++ b/subed/subed-srt.el
@@ -445,15 +445,18 @@ Return point or nil if there is no previous subtitle."
 (defun subed-srt--regenerate-ids ()
   "Ensure subtitle IDs start at 1 and are incremented by 1 for
 each subtitle."
-  (save-match-data
-    (save-excursion
-      (goto-char (point-min))
-      (let ((id 1))
-        (while (looking-at "^[0-9]+$")
-          (kill-word 1)
-          (insert (format "%d" id))
-          (setq id (1+ id))
-          (subed-srt-forward-subtitle-id))))))
+  (interactive)
+  (atomic-change-group
+    (save-match-data
+      (save-excursion
+        (goto-char (point-min))
+        (kill-word 1)
+        (insert "1")
+        (let ((id 2))
+          (while (subed-srt-forward-subtitle-id)
+            (kill-word 1)
+            (insert (format "%d" id))
+            (setq id (1+ id))))))))
 
 (defun subed-srt-sanitize ()
   "Remove surplus newlines and whitespace"



reply via email to

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