[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/subed 5c39418 323/389: Copy subed-srt--msecs-to-timestamp
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/subed 5c39418 323/389: Copy subed-srt--msecs-to-timestamp to subed-common.el |
Date: |
Fri, 3 Dec 2021 11:00:50 -0500 (EST) |
branch: elpa/subed
commit 5c39418ac26e2c845d5e01c7607cf3bfef28af17
Author: Random User <rndusr@posteo.de>
Commit: Random User <rndusr@posteo.de>
Copy subed-srt--msecs-to-timestamp to subed-common.el
This duplicates code, but it's very little and it eliminates a compiler
warning.
---
subed/subed-common.el | 25 ++++++++++++++++---------
1 file changed, 16 insertions(+), 9 deletions(-)
diff --git a/subed/subed-common.el b/subed/subed-common.el
index 53b7634..bad7eb7 100644
--- a/subed/subed-common.el
+++ b/subed/subed-common.el
@@ -76,6 +76,13 @@
;;; Utilities
+(defun subed-msecs-to-timestamp (msecs)
+ "Convert MSECS to human-readable string."
+ ;; 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))))
+
(defmacro subed-save-excursion (&rest body)
"Restore relative point within current subtitle after executing BODY.
This also works if the buffer changes (e.g. when sorting
@@ -664,7 +671,7 @@ If QUIET is non-nil, do not display a message in the
minibuffer."
(defun subed--replay-adjusted-subtitle (msecs-start)
"Seek player to MSECS-START."
- (subed-debug "Replaying subtitle at: %s" (subed-srt--msecs-to-timestamp
msecs-start))
+ (subed-debug "Replaying subtitle at: %s" (subed-msecs-to-timestamp
msecs-start))
(subed-mpv-jump msecs-start))
@@ -708,7 +715,7 @@ If QUIET is non-nil, do not display a message in the
minibuffer."
(when (and (not (use-region-p)) ;; Don't sync with active-mark in
transient-mark-mode
(subed-jump-to-subtitle-text-at-msecs msecs))
(subed-debug "Synchronized point to playback position: %s -> #%s"
- (subed-srt--msecs-to-timestamp msecs) (subed-subtitle-id))
+ (subed-msecs-to-timestamp msecs) (subed-subtitle-id))
;; post-command-hook is not triggered because we didn't move interactively.
;; But there's not really a difference, e.g. the minor mode `hl-line'
breaks
;; unless we call its post-command function, so we do it manually.
@@ -835,11 +842,11 @@ If QUIET is non-nil, do not display a message in the
minibuffer."
(setq subed--subtitle-loop-start (- msecs-start (*
subed-loop-seconds-before 1000))
subed--subtitle-loop-stop (+ msecs-stop (*
subed-loop-seconds-after 1000)))
(subed-debug "Set loop: %s - %s"
- (subed-srt--msecs-to-timestamp subed--subtitle-loop-start)
- (subed-srt--msecs-to-timestamp subed--subtitle-loop-stop))
+ (subed-msecs-to-timestamp subed--subtitle-loop-start)
+ (subed-msecs-to-timestamp subed--subtitle-loop-stop))
(message "Looping over %s - %s"
- (subed-srt--msecs-to-timestamp subed--subtitle-loop-start)
- (subed-srt--msecs-to-timestamp subed--subtitle-loop-stop)))))
+ (subed-msecs-to-timestamp subed--subtitle-loop-start)
+ (subed-msecs-to-timestamp subed--subtitle-loop-stop)))))
(defun subed--ensure-subtitle-loop (cur-msecs)
"Jump to current subtitle start time if CUR-MSECS is after stop time."
@@ -848,9 +855,9 @@ If QUIET is non-nil, do not display a message in the
minibuffer."
(when (or (< cur-msecs subed--subtitle-loop-start)
(> cur-msecs subed--subtitle-loop-stop))
(subed-debug "%s -> Looping over %s - %s"
- (subed-srt--msecs-to-timestamp cur-msecs)
- (subed-srt--msecs-to-timestamp subed--subtitle-loop-start)
- (subed-srt--msecs-to-timestamp subed--subtitle-loop-stop))
+ (subed-msecs-to-timestamp cur-msecs)
+ (subed-msecs-to-timestamp subed--subtitle-loop-start)
+ (subed-msecs-to-timestamp subed--subtitle-loop-stop))
(subed-mpv-jump subed--subtitle-loop-start))))
- [nongnu] elpa/subed e1fd29b 312/389: subed-srt--regenerate-ids: Do not modify empty buffer, (continued)
- [nongnu] elpa/subed e1fd29b 312/389: subed-srt--regenerate-ids: Do not modify empty buffer, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed ca015d4 313/389: Fix one compile warning, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 317c411 314/389: Remove declarations, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 72020af 315/389: Use long options, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed be43268 316/389: Fix test-compile target, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 3753706 318/389: Fix warning about missing function: subed-mpv--sub-add-after-save, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 473fbc2 319/389: subed-srt--subtitle-text: Improve docstring, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 05ba952 320/389: Only add subtitles file if subed-subtitle-id returns non-nil, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed ea11119 321/389: Inform compiler about unused variables to prevent warnings, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed e8a68c2 322/389: subed-srt--msecs-to-timestamp: Explain save-match-data, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 5c39418 323/389: Copy subed-srt--msecs-to-timestamp to subed-common.el,
ELPA Syncer <=
- [nongnu] elpa/subed ecfec2b 325/389: Move debugging functions to subed-debug.el, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed f69f769 327/389: Set subed-mode-map in subed.el, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed d110f79 329/389: Stop disabling point-to-player sync on file-loaded event, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed dd4dc8c 332/389: Automatically disable point-to-player sync while looping, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 5957cbe 333/389: Set default subed-loop-seconds-after/before to 1, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed e71a64b 339/389: Refactor common code into subed-mpv-play-video, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed daaf480 340/389: subed-vtt: Fix navigation code, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 9642945 346/389: Further fixes to let tests pass, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 0968590 344/389: Fix separator search in subed-srt--validate, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 9e661cc 351/389: New command subed-split-subtitle splits at point with MPV timestamp, ELPA Syncer, 2021/12/03