[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/subed d076bac 285/389: Make enforced subtitle boundaries o
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/subed d076bac 285/389: Make enforced subtitle boundaries optional |
Date: |
Fri, 3 Dec 2021 11:00:42 -0500 (EST) |
branch: elpa/subed
commit d076bac12420f4ebcedccdd4f34ee983c9fe5815
Author: Random User <rndusr@posteo.de>
Commit: Random User <rndusr@posteo.de>
Make enforced subtitle boundaries optional
---
subed/subed-common.el | 76 ++++++++++++++++++++++++++++-----------------------
1 file changed, 42 insertions(+), 34 deletions(-)
diff --git a/subed/subed-common.el b/subed/subed-common.el
index 8e80025..82ed3c2 100644
--- a/subed/subed-common.el
+++ b/subed/subed-common.el
@@ -151,17 +151,18 @@ Before BODY is run, point is placed on the subtitle's ID."
(defun subed-adjust-subtitle-time-start (msecs &optional
ignore-negative-duration
- ignore-spacing)
+ ignore-overlap)
"Add MSECS milliseconds to start time (use negative value to subtract).
-Unless IGNORE-NEGATIVE-DURATION is non-nil, reduce MSECS so that
-the start time isn't larger than the stop time. Zero-length
-subtiltes are always allowed.
+Unless either IGNORE-NEGATIVE-DURATION or
+`subed-enforce-time-boundaries' are non-nil, adjust MSECS so that
+the stop time isn't smaller than the start time. Zero-length
+subtitles are always allowed.
-Unless IGNORE-SPACING is non-nil, if the adjustment would result
-in gaps between subtitles being smaller than
-`subed-subtitle-spacing', reduce MSECS so that this doesn't
-happen.
+Unless either IGNORE-OVERLAP or `subed-enforce-time-boundaries'
+are non-nil, ensure that there are no gaps between subtitles
+smaller than `subed-subtitle-spacing' milliseconds by adjusting
+MSECS if necessary.
Return the number of milliseconds the start time was adjusted or
nil if nothing changed."
@@ -171,38 +172,42 @@ nil if nothing changed."
(when msecs-new
(if (> msecs 0)
;; Adding to start time
- (unless ignore-negative-duration
+ (unless (or ignore-negative-duration
+ (not subed-enforce-time-boundaries))
(let ((msecs-stop (subed-subtitle-msecs-stop)))
(setq msecs-new (min msecs-new msecs-stop))))
;; Subtracting from start time
- (unless ignore-spacing
+ (unless (or ignore-overlap
+ (not subed-enforce-time-boundaries))
(let* ((msecs-prev-stop (save-excursion (when
(subed-backward-subtitle-id)
(subed-subtitle-msecs-stop))))
(msecs-min (if msecs-prev-stop
(+ msecs-prev-stop subed-subtitle-spacing) 0)))
(when msecs-min
(setq msecs-new (max msecs-new msecs-min))))))
- ;; msecs-new must be bigger than the current start time if we are adding
+ ;; MSECS-NEW must be bigger than the current start time if we are adding
;; or smaller if we are subtracting.
- (when (or (and (> msecs 0) (> msecs-new msecs-start)) ;; Adding
- (and (< msecs 0) (< msecs-new msecs-start))) ;; Subtracting
+ (when (and (>= msecs-new 0) ;; Ignore
negative times
+ (or (and (> msecs 0) (> msecs-new msecs-start)) ;; Adding
+ (and (< msecs 0) (< msecs-new msecs-start)))) ;;
Subtracting
(subed-set-subtitle-time-start msecs-new)
(subed--run-subtitle-time-adjusted-hook)
(- msecs-new msecs-start)))))
(defun subed-adjust-subtitle-time-stop (msecs &optional
ignore-negative-duration
- ignore-spacing)
+ ignore-overlap)
"Add MSECS milliseconds to stop time (use negative value to subtract).
-Unless IGNORE-NEGATIVE-DURATION is non-nil, increase MSECS so
-that the stop time isn't smaller than the start time.
-Zero-length subtiltes are always allowed.
+Unless either IGNORE-NEGATIVE-DURATION or
+`subed-enforce-time-boundaries' are non-nil, adjust MSECS so that
+the stop time isn't smaller than the start time. Zero-length
+subtitles are always allowed.
-Unless IGNORE-SPACING is non-nil, if the adjustment would result
-in gaps between subtitles being smaller than
-`subed-subtitle-spacing', reduce MSECS so that this doesn't
-happen.
+Unless either IGNORE-OVERLAP or `subed-enforce-time-boundaries'
+are non-nil, ensure that there are no gaps between subtitles
+smaller than `subed-subtitle-spacing' milliseconds by adjusting
+MSECS if necessary.
Return the number of milliseconds the stop time was adjusted or
nil if nothing changed."
@@ -212,7 +217,8 @@ nil if nothing changed."
(when msecs-new
(if (> msecs 0)
;; Adding to stop time
- (unless ignore-spacing
+ (unless (or ignore-overlap
+ (not subed-enforce-time-boundaries))
(let* ((msecs-next-start (save-excursion (when
(subed-forward-subtitle-id)
(subed-subtitle-msecs-start))))
(msecs-max (when msecs-next-start
@@ -220,13 +226,15 @@ nil if nothing changed."
(when msecs-max
(setq msecs-new (min msecs-new msecs-max)))))
;; Subtracting from stop time
- (unless ignore-negative-duration
+ (unless (or ignore-negative-duration
+ (not subed-enforce-time-boundaries))
(let ((msecs-start (subed-subtitle-msecs-start)))
(setq msecs-new (max msecs-new msecs-start)))))
- ;; msecs-new must be bigger than the current stop time if we are adding
or
+ ;; MSECS-NEW must be bigger than the current stop time if we are adding
or
;; smaller if we are subtracting.
- (when (or (and (> msecs 0) (> msecs-new msecs-stop)) ;; Adding
- (and (< msecs 0) (< msecs-new msecs-stop))) ;; Subtracting
+ (when (and (>= msecs-new 0) ;; Ignore
negative times
+ (or (and (> msecs 0) (> msecs-new msecs-stop)) ;; Adding
+ (and (< msecs 0) (< msecs-new msecs-stop)))) ;;
Subtracting
(subed-set-subtitle-time-stop msecs-new)
(subed--run-subtitle-time-adjusted-hook)
(- msecs-new msecs-stop)))))
@@ -313,21 +321,21 @@ When moving subtitles backward (MSECS < 0), it's the same
thing
but we move the start time first."
(if (> msecs 0)
;; Moving forward
- (lambda (msecs &optional ignore-spacing)
+ (lambda (msecs &optional ignore-overlap)
(let ((msecs (subed-adjust-subtitle-time-stop msecs
:ignore-negative-duration
- ignore-spacing)))
+ ignore-overlap)))
(when msecs (subed-adjust-subtitle-time-start msecs
:ignore-negative-duration
- ignore-spacing))))
+ ignore-overlap))))
;; Moving backward
- (lambda (msecs &optional ignore-spacing)
+ (lambda (msecs &optional ignore-overlap)
(let ((msecs (subed-adjust-subtitle-time-start msecs
:ignore-negative-duration
- ignore-spacing)))
+ ignore-overlap)))
(when msecs (subed-adjust-subtitle-time-stop msecs
:ignore-negative-duration
- ignore-spacing))))))
+ ignore-overlap))))))
(defun subed--move-current-subtitle (msecs)
"Move subtitle on point by MSECS milliseconds."
@@ -361,7 +369,7 @@ but we move the start time first."
(throw 'bumped-into-subtitle t))
(subed-backward-subtitle-id)
(subed-for-each-subtitle beg (point) :reverse
- (move-subtitle msecs :ignore-spacing)))
+ (move-subtitle msecs :ignore-negative-duration)))
;; Start on first subtitle to see if/how far we can move backward.
(save-excursion
(goto-char beg)
@@ -369,7 +377,7 @@ but we move the start time first."
(throw 'bumped-into-subtitle t))
(subed-forward-subtitle-id)
(subed-for-each-subtitle (point) end nil
- (move-subtitle msecs :ignore-spacing)))))))))
+ (move-subtitle msecs :ignore-negative-duration)))))))))
(defun subed-move-subtitles (msecs &optional beg end)
"Move subtitles between BEG and END MSECS milliseconds forward.
- [nongnu] elpa/subed f6acfdd 266/389: Re-order function suffixes, (continued)
- [nongnu] elpa/subed f6acfdd 266/389: Re-order function suffixes, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 50a4717 268/389: Fix tests, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 7f361c2 269/389: Explain "adjust", "move" and "shift" in subed-mode docstring, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed d71655f 276/389: Fix parens, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed b740511 277/389: Use mark-active instead of use-region-p, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed e8612e7 279/389: Unify optional argument name, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed d1b308e 280/389: Make subed-subtitle-time-adjusted-hook buffer-local, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 0302aa9 278/389: Move screenshow below introduction, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed c8cf4b7 281/389: Don't insert too many mock subtitles, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 3245922 282/389: Focus correct subtitle, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed d076bac 285/389: Make enforced subtitle boundaries optional,
ELPA Syncer <=
- [nongnu] elpa/subed b5667c4 286/389: Add tests for subed-enforce-time-boundaries, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed dde5dfd 287/389: Simplify subed-mpv--client-buffer, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed b1c5b88 354/389: Some adjustments to subed-split-subtitle, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 5f1ad41 355/389: "mpv" instead of "MPV" (see `man mpv`, https://mpv.io etc), ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed a83ee74 357/389: Remove trailing space, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed da4dac9 358/389: Two spaces after sentence to make `make test` pass, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 49ddccc 359/389: Move subed--init-alist to subed.el, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 8263b33 360/389: subed-split-subtitle: Use offset or text fraction, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed 1c52f1b 361/389: Add tests for splitting subtitles and handle more cases, ELPA Syncer, 2021/12/03
- [nongnu] elpa/subed e065632 362/389: Fix previous commit for subed-set-subtitle-text, ELPA Syncer, 2021/12/03