[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/subed 89df304 304/389: subed-srt--sanitize: Don't insert n
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/subed 89df304 304/389: subed-srt--sanitize: Don't insert newline in empty buffer |
Date: |
Fri, 3 Dec 2021 11:00:46 -0500 (EST) |
branch: elpa/subed
commit 89df304c94a7170da12929c83a5f09f302e747b0
Author: Random User <rndusr@posteo.de>
Commit: Random User <rndusr@posteo.de>
subed-srt--sanitize: Don't insert newline in empty buffer
---
subed/subed-srt.el | 17 ++++++++++-------
tests/test-subed-srt.el | 5 +++++
2 files changed, 15 insertions(+), 7 deletions(-)
diff --git a/subed/subed-srt.el b/subed/subed-srt.el
index c9ddb9b..06e5d29 100644
--- a/subed/subed-srt.el
+++ b/subed/subed-srt.el
@@ -481,13 +481,16 @@ scheduled call is canceled and another call is scheduled
in
(delete-region prev-sub-end (point))
(insert "\n\n"))))
- ;; Two trailing newline if last subtitle text is empty,
- ;; one trailing newline otherwise
- (goto-char (point-max))
- (subed-srt--jump-to-subtitle-end)
- (unless (looking-at "\n\\'")
- (delete-region (point) (point-max))
- (insert "\n"))
+ ;; Two trailing newline if last subtitle text is empty, one trailing
+ ;; newline otherwise; do nothing in empty buffer (no graphical
+ ;; characters)
+ (goto-char (point-min))
+ (when (re-search-forward "[[:graph:]]" nil t)
+ (goto-char (point-max))
+ (subed-srt--jump-to-subtitle-end)
+ (unless (looking-at "\n\\'")
+ (delete-region (point) (point-max))
+ (insert "\n")))
;; One space before and after " --> "
(goto-char (point-min))
diff --git a/tests/test-subed-srt.el b/tests/test-subed-srt.el
index a4af646..3a13f88 100644
--- a/tests/test-subed-srt.el
+++ b/tests/test-subed-srt.el
@@ -1385,6 +1385,11 @@ Baz.
(expect (buffer-string) :not :to-equal mock-srt-data)
(subed-srt--sanitize)
(expect (buffer-string) :to-equal mock-srt-data)))
+ (it "does not insert newline in empty buffer."
+ (with-temp-srt-buffer
+ (expect (buffer-string) :to-equal "")
+ (subed-srt--sanitize)
+ (expect (buffer-string) :to-equal "")))
)
(describe "Renumbering"
- [nongnu] elpa/subed f30780e 249/389: Default keybinding: C-M-i -> subed-insert-subtitle-adjacent, (continued)
- [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
- [nongnu] elpa/subed 2e18727 294/389: Pause video initially, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 3d5902b 295/389: Reword comment, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 3baf5c1 296/389: subed-mpv--client-filter: Store process mark in variable, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 08d5033 301/389: Remove unused variable subed-mode--enabled-p, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 070384b 302/389: subed--set-subtitle-loop: Don't croak on empty file, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 89df304 304/389: subed-srt--sanitize: Don't insert newline in empty buffer,
ELPA Syncer <=
- [nongnu] elpa/subed b0a4ff0 307/389: Fix parentheses, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 8007c12 308/389: Make debugging window a bit smaller, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed ec38a0b 317/389: Add function: subed-mpv-add-subtitles, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 7764909 324/389: Add some (require ...)s to prevent compiler warnings, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed a084f5d 326/389: Improve comment, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed cd3af86 328/389: Silence checkdoc, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 29d8b84 337/389: Initial implementation of subed-vtt.el, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 6db0005 338/389: New function subed-mpv-play-video-from-url, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed d3df6f2 347/389: Fix "test" target in Makefile, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 5b8c23a 348/389: New commands: subed-merge-with-next, subed-merge-with-previous, ELPA Syncer, 2021/12/03