Skip to content

Commit

Permalink
Regenerate IDs after creating a subtitle file
Browse files Browse the repository at this point in the history
* subed/subed-common.el (subed-create-file):
Regenerate IDs after creation.
* subed/subed-common.el (subed-convert): Skip IDs
on conversion.
  • Loading branch information
sachac committed Oct 7, 2024
1 parent 47403ce commit 010b98c
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions subed/subed-common.el
Original file line number Diff line number Diff line change
Expand Up @@ -2307,7 +2307,8 @@ If INIT-FUNC is non-nil, call that function to initialize."
(subed-guess-format filename)
(if init-func (funcall init-func))
(subed-auto-insert)
(subed-append-subtitle-list subtitles))))
(subed-append-subtitle-list subtitles)
(subed-regenerate-ids))))

(defun subed-convert (format &optional include-comments)
"Create a buffer with the current subtitles converted to FORMAT.
Expand All @@ -2316,7 +2317,9 @@ INCLUDE-COMMENTS is non-nil or `subed-convert' is called with a
prefix argument, include comments in TXT output."
(interactive (list (completing-read "To format: " '("VTT" "SRT" "ASS" "TSV" "TXT"))
current-prefix-arg))
(let* ((subtitles (subed-subtitle-list))
(let* ((subtitles
(mapcar (lambda (sub) (cons nil (cdr sub))) ; remove ID
(subed-subtitle-list)))
(new-filename (concat (file-name-base (or (buffer-file-name) (buffer-name))) "."
(downcase format)))
(mode-func (pcase format
Expand All @@ -2341,7 +2344,8 @@ prefix argument, include comments in TXT output."
(when (functionp mode-func) (funcall mode-func) (subed-auto-insert))
(if (string= format "TXT")
(insert (subed-subtitle-list-text subtitles include-comments))
(mapc (lambda (sub) (apply #'subed-append-subtitle nil (cdr sub))) subtitles))
(mapc (lambda (sub) (apply #'subed-append-subtitle nil (cdr sub)))
subtitles))
(current-buffer))))

;;; Wdiff
Expand Down

0 comments on commit 010b98c

Please sign in to comment.