branch: elpa/subed
commit a44616d79637672a81c47ad9a1d036cfa34049ba
Author: Sacha Chua <sa...@sachachua.com>
Commit: Sacha Chua <sa...@sachachua.com>

    New command subed-section-comments-as-chapters
    
    * subed/subed-common.el (subed-section-comments-as-chapters):
    New command.
---
 subed/subed-common.el | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/subed/subed-common.el b/subed/subed-common.el
index a994445b60..ebadacace7 100644
--- a/subed/subed-common.el
+++ b/subed/subed-common.el
@@ -636,6 +636,7 @@ Return new point."
       (remove-overlays beg end)
       (kill-region beg end))))
 
+;;;###autoload
 (defun subed-parse-file (filename &optional mode-func)
   "Return the subtitles from FILENAME in a list.
 If MODE-FUNC is non-nil, use that function to initialize the mode.
@@ -717,6 +718,24 @@ before including them."
               end)
              include-comments)))
 
+(defun subed-section-comments-as-chapters ()
+  "Copy subtitle comments as chapters for video descriptions."
+  (interactive)
+  (let ((result (mapconcat
+                                                                (lambda (sub)
+                                                                        (if 
(elt sub 4)
+                                                                               
         (concat (format-seconds "%02h:%z%02m:%02s"
+                                                                               
                                                                                
                         (floor (/ (elt sub 1) 1000)))
+                                                                               
                                         " "
+                                                                               
                                         (string-trim (elt sub 4))
+                                                                               
                                         "\n")
+                                                                               
 ""))
+                                                                
(subed-subtitle-list)
+                                                                "")))
+    (when (called-interactively-p 'any)
+      (kill-new result))
+    result))
+
 (subed-define-generic-function sanitize ()
   "Sanitize this file."
   (interactive)

Reply via email to