[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."
- [nongnu] elpa/subed 9b95137 104/389: Test subed--for-each-subtitle more thoroughly, (continued)
- [nongnu] elpa/subed 9b95137 104/389: Test subed--for-each-subtitle more thoroughly, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed ec03689 105/389: Fix subed--for-each-subtitle, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed a7cbce6 107/389: Test subed-move-subtitle-forward/backward more thoroughly, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 5da6d79 112/389: Add "pause with key" to features, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 868d05c 114/389: Adjust some variable descriptions, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 6cf5df4 036/389: Remove annoying minibuffer messages, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 3927690 037/389: Some rewording, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 62d5d3d 038/389: Use (unless ...) instead of (when (not ...)), ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 166988c 041/389: Special subtitle separator when moving to end of subtitle, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed e471802 046/389: Adjust test description, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 727275d 043/389: subed-srt-sanitize: Wrap function body in atomic-change-group,
ELPA Syncer <=
- [nongnu] elpa/subed a30a4b1 054/389: subed-srt-regenerate-ids: Don't change buffer unless it's necessary, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 5fd2009 055/389: subed-mpv: Handle invalid JSON, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed c865969 058/389: Toggle subed-mode when `subed-mode' is called, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 65bfba6 057/389: When enabling debugging, expect the debug window to exist, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed dc60c27 060/389: subed-srt--subtitle-id-at-msecs: Try to ignore invalid time stamps, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 0781285 061/389: Make mpv RPC socket and client buffer unique per buffer, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 2f86a8e 030/389: Add function: subed-srt--subtitle-text, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 17f3ae5 034/389: Add/fix tests for srt parsing changes, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed fb9354c 039/389: Adjust tests for subed-srt-move-to-subtitle-end, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 4e3e42f 044/389: subed-srt-sort: Wrap function body in atomic-change-group, ELPA Syncer, 2021/12/03