branch: elpa/subed commit a30a4b105b767d33cc31aadbb881a423893bf88d Author: Random User <rnd...@posteo.de> Commit: Random User <rnd...@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 ()