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

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

[nongnu] elpa/subed 9e661cc 351/389: New command subed-split-subtitle sp


From: ELPA Syncer
Subject: [nongnu] elpa/subed 9e661cc 351/389: New command subed-split-subtitle splits at point with MPV timestamp
Date: Fri, 3 Dec 2021 11:00:56 -0500 (EST)

branch: elpa/subed
commit 9e661ccb921db72aa56ae9199e6c302f019e3a6e
Author: Sacha Chua <sacha@sachachua.com>
Commit: Random User <rndusr@posteo.de>

    New command subed-split-subtitle splits at point with MPV timestamp
    
    * subed/subed.el (subed-mode-map): Bind M-. to subed-split-subtitle.
    * subed/subed-common.el (subed-split-subtitle): New command.
---
 subed/subed-common.el | 15 +++++++++++++++
 subed/subed.el        |  1 +
 2 files changed, 16 insertions(+)

diff --git a/subed/subed-common.el b/subed/subed-common.el
index d501331..2a8942c 100644
--- a/subed/subed-common.el
+++ b/subed/subed-common.el
@@ -631,6 +631,21 @@ Update the end timestamp accordingly."
       (subed-merge-with-next)
     (error "No previous subtitle to merge into")))
 
+(defun subed-split-subtitle ()
+  "Split current subtitle at point using timestamp from MPV."
+  (interactive)
+  (let* ((end-timestamp (subed-subtitle-msecs-stop))
+         (orig (point))
+         (text (buffer-substring orig (save-excursion 
(subed-jump-to-subtitle-end) (point)))))
+    (unless subed-mpv-playback-position
+      (error "Not playing back in MPV"))
+    (when (or (> subed-mpv-playback-position end-timestamp)
+              (< subed-mpv-playback-position (subed-subtitle-msecs-start)))
+      (error "Not in the currently playing subtitle segment"))
+    (subed-set-subtitle-time-stop subed-mpv-playback-position)
+    (delete-region (point) (subed-jump-to-subtitle-end))
+    (subed-append-subtitle nil subed-mpv-playback-position end-timestamp 
(string-trim text))))
+
 ;;; Replay time-adjusted subtitle
 
 (defun subed-replay-adjusted-subtitle-p ()
diff --git a/subed/subed.el b/subed/subed.el
index 7ae7807..0374f21 100644
--- a/subed/subed.el
+++ b/subed/subed.el
@@ -58,6 +58,7 @@
     (define-key subed-mode-map (kbd "M-k") #'subed-kill-subtitle)
     (define-key subed-mode-map (kbd "M-m") #'subed-merge-with-next)
     (define-key subed-mode-map (kbd "M-M") #'subed-merge-with-previous)
+    (define-key subed-mode-map (kbd "M-.") #'subed-split-subtitle)
     (define-key subed-mode-map (kbd "M-s") #'subed-sort)
     (define-key subed-mode-map (kbd "M-SPC") #'subed-mpv-toggle-pause)
     (define-key subed-mode-map (kbd "C-c C-d") #'subed-toggle-debugging)



reply via email to

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