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

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

[nongnu] elpa/subed e8a68c2 322/389: subed-srt--msecs-to-timestamp: Expl


From: ELPA Syncer
Subject: [nongnu] elpa/subed e8a68c2 322/389: subed-srt--msecs-to-timestamp: Explain save-match-data
Date: Fri, 3 Dec 2021 11:00:50 -0500 (EST)

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

    subed-srt--msecs-to-timestamp: Explain save-match-data
---
 subed/subed-srt.el | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/subed/subed-srt.el b/subed/subed-srt.el
index 6c86163..6ef5c3d 100644
--- a/subed/subed-srt.el
+++ b/subed/subed-srt.el
@@ -59,9 +59,10 @@ Return nil if TIME-STRING doesn't match the pattern."
 
 (defun subed-srt--msecs-to-timestamp (msecs)
   "Convert MSECS to string in the format HH:MM:SS,MS."
-  (save-match-data
-    (concat (format-seconds "%02h:%02m:%02s" (/ msecs 1000))
-            "," (format "%03d" (mod msecs 1000)))))
+  ;; We need to wrap format-seconds in save-match-data because it does regexp
+  ;; stuff and we need to preserve our own match-data.
+  (concat (save-match-data (format-seconds "%02h:%02m:%02s" (/ msecs 1000)))
+          "," (format "%03d" (mod msecs 1000))))
 
 (defun subed-srt--subtitle-id ()
   "Return the ID of the subtitle at point or nil if there is no ID."



reply via email to

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