[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/subed e065632 362/389: Fix previous commit for subed-set-s
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/subed e065632 362/389: Fix previous commit for subed-set-subtitle-text |
Date: |
Fri, 3 Dec 2021 11:00:58 -0500 (EST) |
branch: elpa/subed
commit e06563288f0a33942b310eb1e412749bcdf13be0
Author: Sacha Chua <sacha@sachachua.com>
Commit: Sacha Chua <sacha@sachachua.com>
Fix previous commit for subed-set-subtitle-text
* subed/subed-common.el (subed-set-subtitle-text): Remove
unneccessary new function that got included.
(subed-split-subtitle): Remove subed-set-subtitle-text.
* tests/test-subed-common.el ("Splitting subtitles"): Add test case
for empty subtitle.
---
subed/subed-common.el | 13 ++-----------
tests/test-subed-common.el | 18 ++++++++++++++++++
2 files changed, 20 insertions(+), 11 deletions(-)
diff --git a/subed/subed-common.el b/subed/subed-common.el
index a3ea291..5b5be90 100644
--- a/subed/subed-common.el
+++ b/subed/subed-common.el
@@ -621,16 +621,6 @@ following manner:
(subed-regenerate-ids-soon))
(point))
-(defun subed-set-subtitle-text (text &optional sub-id)
- "Set subtitle text to TEXT.
-
-If SUB-ID is not given, set the text of the current subtitle.
-
-Return the new subtitle text."
- (delete-region (subed-jump-to-subtitle-text sub-id)
- (or (subed-jump-to-subtitle-end sub-id) (point)))
- (insert text))
-
(defun subed-split-subtitle (&optional offset)
"Split current subtitle at point.
@@ -685,7 +675,8 @@ position of the point."
(new-text (string-trim (buffer-substring (point) text-end)))
(new-start-timestamp (+ split-timestamp subed-subtitle-spacing)))
(subed-set-subtitle-time-stop split-timestamp)
- (subed-set-subtitle-text (string-trim (buffer-substring-no-properties
text-beg (point))))
+ (delete-region (point) (progn (subed-jump-to-subtitle-end)
(skip-chars-forward " \t") (point)))
+ (when (looking-at "[ \t]+") (replace-match ""))
(subed-append-subtitle nil new-start-timestamp orig-end (string-trim
new-text)))
(subed-regenerate-ids-soon)
(point)))
diff --git a/tests/test-subed-common.el b/tests/test-subed-common.el
index d6266eb..5bb3cc3 100644
--- a/tests/test-subed-common.el
+++ b/tests/test-subed-common.el
@@ -2134,6 +2134,24 @@ Baz.
)
(describe "Splitting subtitles"
+ (it "handles empty subtitles"
+ (with-temp-srt-buffer
+ (insert "1
+00:01:23,000 --> 00:02:34,567
+
+")
+ (forward-line -1)
+ (let ((subed-subtitle-spacing 100))
+ (subed-split-subtitle 100))
+ (expect (buffer-string) :to-equal
+"1
+00:01:23,000 --> 00:01:23,100
+
+
+0
+00:01:23,200 --> 00:02:34,567
+
+")))
(describe "when there are multiple lines"
:var ((text "1
00:01:23,000 --> 00:02:34,567
- [nongnu] elpa/subed d076bac 285/389: Make enforced subtitle boundaries optional, (continued)
- [nongnu] elpa/subed d076bac 285/389: Make enforced subtitle boundaries optional, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed b5667c4 286/389: Add tests for subed-enforce-time-boundaries, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed dde5dfd 287/389: Simplify subed-mpv--client-buffer, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed b1c5b88 354/389: Some adjustments to subed-split-subtitle, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 5f1ad41 355/389: "mpv" instead of "MPV" (see `man mpv`, https://mpv.io etc), ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed a83ee74 357/389: Remove trailing space, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed da4dac9 358/389: Two spaces after sentence to make `make test` pass, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 49ddccc 359/389: Move subed--init-alist to subed.el, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 8263b33 360/389: subed-split-subtitle: Use offset or text fraction, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 1c52f1b 361/389: Add tests for splitting subtitles and handle more cases, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed e065632 362/389: Fix previous commit for subed-set-subtitle-text,
ELPA Syncer <=
- [nongnu] elpa/subed ec7b222 368/389: Enable CPS showing by default and improve CPS toggling functions, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed f28ad22 379/389: Make subed-mpv-jump-to-current-subtitle interactive, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed c76ba50 387/389: Prompt for playback speed factor, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 9d0aa0f 388/389: Make make-subtitle a generic function, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed d0dfa1a 389/389: Preliminary support for .ass files (Advanced SubStation Alpha), ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed f30780e 249/389: Default keybinding: C-M-i -> subed-insert-subtitle-adjacent, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed f8793fb 330/389: Move motion hooks from subed-config.el to subed-common.el, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 31556c6 372/389: Add functions for bold and italic and change keybindings, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed ba22919 289/389: Add subed-mpv-jump-to-current-subtitle, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 14ebbbb 293/389: subed-srt--subtitle-id-at-msecs: Return nil if no matching subtitle, ELPA Syncer, 2021/12/03