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

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

[nongnu] elpa/subed 727275d 043/389: subed-srt-sanitize: Wrap function b


From: ELPA Syncer
Subject: [nongnu] elpa/subed 727275d 043/389: subed-srt-sanitize: Wrap function body in atomic-change-group
Date: Fri, 3 Dec 2021 10:59:53 -0500 (EST)

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

    subed-srt-sanitize: Wrap function body in atomic-change-group
---
 subed/subed-srt.el | 59 +++++++++++++++++++++++++++---------------------------
 1 file changed, 30 insertions(+), 29 deletions(-)

diff --git a/subed/subed-srt.el b/subed/subed-srt.el
index 6e711e0..ae8e4e1 100644
--- a/subed/subed-srt.el
+++ b/subed/subed-srt.el
@@ -461,35 +461,36 @@ each subtitle."
 (defun subed-srt-sanitize ()
   "Remove surplus newlines and whitespace"
   (interactive)
-  (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 leading spaces and tabs from each line
-     (goto-char (point-min))
-     (while (re-search-forward "^[[:blank:]]+" nil t)
-       (replace-match ""))
-
-     ;; Remove leading newlines
-     (goto-char (point-min))
-     (while (looking-at "\\`\n+")
-       (replace-match ""))
-
-     ;; Replace separators between subtitles with double newlines
-     (goto-char (point-min))
-     (while (subed-srt-forward-subtitle-id)
-       (let ((prev-sub-end (save-excursion (when 
(subed-srt-backward-subtitle-end)
-                                             (point)))))
-         (when prev-sub-end
-           (delete-region prev-sub-end (point))
-           (insert "\n\n"))))
-
-     ;; Remove trailing newlines
-     (goto-char (point-max))
-     (subed-srt-move-to-subtitle-end)
-     (when (looking-at "\n*")
-       (replace-match "\n")))))
+  (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 leading spaces and tabs from each line
+       (goto-char (point-min))
+       (while (re-search-forward "^[[:blank:]]+" nil t)
+         (replace-match ""))
+
+       ;; Remove leading newlines
+       (goto-char (point-min))
+       (while (looking-at "\\`\n+")
+         (replace-match ""))
+
+       ;; Replace separators between subtitles with double newlines
+       (goto-char (point-min))
+       (while (subed-srt-forward-subtitle-id)
+         (let ((prev-sub-end (save-excursion (when 
(subed-srt-backward-subtitle-end)
+                                               (point)))))
+           (when prev-sub-end
+             (delete-region prev-sub-end (point))
+             (insert "\n\n"))))
+
+       ;; Remove trailing newlines
+       (goto-char (point-max))
+       (subed-srt-move-to-subtitle-end)
+       (when (looking-at "\n*")
+         (replace-match "\n"))))))
 
 (defun subed-srt-sort ()
   "Sanitize, then sort subtitles by start time and re-number them."



reply via email to

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