[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/subed 3511026 091/389: Move utilities to the top
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/subed 3511026 091/389: Move utilities to the top |
Date: |
Fri, 3 Dec 2021 11:00:03 -0500 (EST) |
branch: elpa/subed
commit 3511026664db9ba7e0aa8e14ca70a73494d1b800
Author: Random User <rndusr@posteo.de>
Commit: Random User <rndusr@posteo.de>
Move utilities to the top
---
subed/subed.el | 77 +++++++++++++++++++++++++++++-----------------------------
1 file changed, 39 insertions(+), 38 deletions(-)
diff --git a/subed/subed.el b/subed/subed.el
index 92f2b56..0512322 100644
--- a/subed/subed.el
+++ b/subed/subed.el
@@ -119,6 +119,45 @@
(set-window-point debug-window (goto-char (point-max))))))))
+;;; Utilities
+
+(defmacro subed--save-excursion (&rest body)
+ "Restore relative point within current subtitle after executing BODY.
+This also works if the buffer changes (e.g. when sorting
+subtitles) as long the subtitle IDs don't change."
+ (save-excursion
+ `(let ((sub-id (subed--subtitle-id))
+ (sub-pos (subed--subtitle-relative-point)))
+ (progn ,@body)
+ (subed-jump-to-subtitle-id sub-id)
+ ;; Subtitle text may have changed and we may not be able to move to the
+ ;; exact original position
+ (condition-case nil
+ (forward-char sub-pos)
+ ('beginning-of-buffer nil)
+ ('end-of-buffer nil)))))
+
+(defmacro subed--for-each-subtitle (&optional beg end &rest body)
+ "Run BODY for each subtitle between the region specified by BEG and END.
+If END is nil, it defaults to `point-max'.
+If BEG and END are both nil, run BODY only on the subtitle at point.
+Before BODY is run, point is placed on the subtitle's ID."
+ (declare (indent defun))
+ `(if (not ,beg)
+ ;; Run body on subtitle at point
+ (progn (save-excursion (subed-jump-to-subtitle-id)
+ ,@body))
+ (progn
+ ;; Run body on multiple subtitles
+ (save-excursion
+ (goto-char ,beg)
+ (subed-jump-to-subtitle-id)
+ (progn ,@body)
+ (while (and (<= (point) (or ,end (point-max)))
+ (subed-forward-subtitle-id))
+ (progn ,@body))))))
+
+
;;; Moving subtitles
(defun subed-move-subtitle-forward (&optional arg beg end)
@@ -399,44 +438,6 @@ buffer."
(subed-mpv-playback-speed
subed-playback-speed-while-not-typing))))))))
-;;; Stuff
-
-(defmacro subed--save-excursion (&rest body)
- "Restore relative point within current subtitle after executing BODY.
-This also works if the buffer changes (e.g. when sorting
-subtitles) as long the subtitle IDs don't change."
- (save-excursion
- `(let ((sub-id (subed--subtitle-id))
- (sub-pos (subed--subtitle-relative-point)))
- (progn ,@body)
- (subed-jump-to-subtitle-id sub-id)
- ;; Subtitle text may have changed and we may not be able to move to the
- ;; exact original position
- (condition-case nil
- (forward-char sub-pos)
- ('beginning-of-buffer nil)
- ('end-of-buffer nil)))))
-
-(defmacro subed--for-each-subtitle (&optional beg end &rest body)
- "Run BODY for each subtitle between the region specified by BEG and END.
-If END is nil, it defaults to `point-max'.
-If BEG and END are both nil, run BODY only on the subtitle at point.
-Before BODY is run, point is placed on the subtitle's ID."
- (declare (indent defun))
- `(if (not ,beg)
- ;; Run body on subtitle at point
- (progn (save-excursion (subed-jump-to-subtitle-id)
- ,@body))
- (progn
- ;; Run body on multiple subtitles
- (save-excursion
- (goto-char ,beg)
- (subed-jump-to-subtitle-id)
- (progn ,@body)
- (while (and (<= (point) (or ,end (point-max)))
- (subed-forward-subtitle-id))
- (progn ,@body))))))
-
(defun subed-guess-video-file ()
"Return path to video if replacing the buffer file name's
extension with members of `subed-video-extensions' yields an
- [nongnu] elpa/subed 0fe0c82 059/389: When opening debug window, always split horizontally, (continued)
- [nongnu] elpa/subed 0fe0c82 059/389: When opening debug window, always split horizontally, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 4e31010 062/389: mpv returns nil as "time-pos" in at least one circumstance, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 1c8e0d1 064/389: Sanitize separator between start and stop time, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 3c1a1b4 065/389: Don't validate anything if buffer is empty, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed ce14b0d 074/389: Adjust comment, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 8fa0f6c 078/389: Remove debugging messages, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 96e7fcf 086/389: Add subed--get-seconds-move, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 189e5aa 088/389: Make more functions available format-agnosticly, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 14d52d7 089/389: Add subed--for-each-subtitle, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 7710790 090/389: Add subed-move-subtitle-forward/backward, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 3511026 091/389: Move utilities to the top,
ELPA Syncer <=
- [nongnu] elpa/subed 81aca87 008/389: Be more robust when moving forward/backward to subtitle text, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 8e4bd20 069/389: Fix indentation, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 6e525b9 079/389: Add screenshot, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed bf9ceeb 094/389: Reduce word count by 1, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 42199eb 095/389: Workaround for GitHub's lack of support for ~~/path/in/home~, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 5c51000 101/389: Call time-adjusted-hook functions with start time, not stop time, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 53d1e33 102/389: Fix error when adjusting start/stop time in empty buffer, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed a0cb0f1 108/389: Keep region active during subtitle movement, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 2c7554a 109/389: Wrap subed--for-each-subtitle in atomic-change-group, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed e792e0f 122/389: Fix test description, ELPA Syncer, 2021/12/03