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

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

[nongnu] elpa/subed a30a4b1 054/389: subed-srt-regenerate-ids: Don't cha


From: ELPA Syncer
Subject: [nongnu] elpa/subed a30a4b1 054/389: subed-srt-regenerate-ids: Don't change buffer unless it's necessary
Date: Fri, 3 Dec 2021 10:59:55 -0500 (EST)

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

    subed-srt-regenerate-ids: Don't change buffer unless it's necessary
---
 subed/subed-srt.el | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/subed/subed-srt.el b/subed/subed-srt.el
index a117b40..5078deb 100644
--- a/subed/subed-srt.el
+++ b/subed/subed-srt.el
@@ -451,12 +451,16 @@ each subtitle."
     (save-match-data
       (save-excursion
         (goto-char (point-min))
-        (kill-word 1)
-        (insert "1")
+        (subed-srt-move-to-subtitle-id)
+        (unless (string= (current-word) "1")
+          (kill-word 1)
+          (insert "1"))
         (let ((id 2))
           (while (subed-srt-forward-subtitle-id)
-            (kill-word 1)
-            (insert (format "%d" id))
+            (let ((id-str (number-to-string id)))
+              (unless (string= (current-word) id-str)
+                (kill-word 1)
+                (insert id-str)))
             (setq id (1+ id))))))))
 
 (defun subed-srt-sanitize ()



reply via email to

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