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

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

[nongnu] elpa/subed 0e05076 072/389: subed-srt-sanitize: Properly trim t


From: ELPA Syncer
Subject: [nongnu] elpa/subed 0e05076 072/389: subed-srt-sanitize: Properly trim trailing newlines
Date: Fri, 3 Dec 2021 10:59:59 -0500 (EST)

branch: elpa/subed
commit 0e05076f9fd057ea411a45d71bbc477d4639681d
Author: Random User <rndusr@posteo.de>
Commit: Random User <rndusr@posteo.de>

    subed-srt-sanitize: Properly trim trailing newlines
---
 subed/subed-srt.el | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/subed/subed-srt.el b/subed/subed-srt.el
index ca8318f..701a5b5 100644
--- a/subed/subed-srt.el
+++ b/subed/subed-srt.el
@@ -500,8 +500,8 @@ each subtitle."
   (atomic-change-group
     (save-match-data
       (subed--save-excursion
-       ;; Remove trailing whitespace from each line and empty lines from end 
of buffer
-       (delete-trailing-whitespace (point-min) nil)
+       ;; Remove trailing whitespace from each line
+       (delete-trailing-whitespace (point-min) (point-max))
 
        ;; Remove leading spaces and tabs from each line
        (goto-char (point-min))
@@ -523,11 +523,13 @@ each subtitle."
              (delete-region prev-sub-end (point))
              (insert "\n\n"))))
 
-       ;; Remove trailing newlines
+       ;; Two trailing newline if last subtitle text is empty,
+       ;; one trailing newline otherwise
        (goto-char (point-max))
        (subed-srt-move-to-subtitle-end)
-       (when (looking-at "\n\\{2,\\}")
-         (replace-match "\n"))
+       (unless (looking-at "\n\\'")
+         (delete-region (point) (point-max))
+         (insert "\n"))
 
        ;; Ensure there is one space before and after " --> "
        (goto-char (point-min))



reply via email to

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