branch: elpa/subed commit 5c510001a2e6a53181db37ecf9230cbb21c3d636 Author: Random User <rnd...@posteo.de> Commit: Random User <rnd...@posteo.de>
Call time-adjusted-hook functions with start time, not stop time --- subed/subed-config.el | 5 +++-- subed/subed-srt.el | 3 ++- tests/test-subed-srt.el | 4 ++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/subed/subed-config.el b/subed/subed-config.el index f4120c9..4d6fa2f 100644 --- a/subed/subed-config.el +++ b/subed/subed-config.el @@ -243,8 +243,9 @@ hardcoded." ;; Hooks (defvar subed-subtitle-time-adjusted-hook () - "Functions to call when a subtitle's start or stop time has -changed.") + "Functions to call when a subtitle's start or stop time has changed. +The functions are called with the relevant subtitle ID and the +subtitle's start time.") (defvar-local subed-point-motion-hook nil "Functions to call after point changed.") diff --git a/subed/subed-srt.el b/subed/subed-srt.el index ac8b536..135c363 100644 --- a/subed/subed-srt.el +++ b/subed/subed-srt.el @@ -316,7 +316,8 @@ Return point or nil if there is no previous subtitle." (replace-match (subed-srt--msecs-to-timestamp msecs-new)))) (when subed-subtitle-time-adjusted-hook (let ((sub-id (subed-srt--subtitle-id))) - (run-hook-with-args 'subed-subtitle-time-adjusted-hook sub-id msecs-new))))) + (run-hook-with-args 'subed-subtitle-time-adjusted-hook sub-id + (subed-srt--subtitle-msecs-start)))))) (defun subed-srt-increase-start-time (&optional arg) "Add `subed-seconds-adjust' milliseconds to start time of current subtitle. diff --git a/tests/test-subed-srt.el b/tests/test-subed-srt.el index efa2d6c..9a0ff2e 100644 --- a/tests/test-subed-srt.el +++ b/tests/test-subed-srt.el @@ -616,7 +616,7 @@ Baz. (expect 'foo :to-have-been-called-times 1) (subed-srt-jump-to-subtitle-id 1) (subed-srt-increase-stop-time) - (expect 'foo :to-have-been-called-with 1 65223) + (expect 'foo :to-have-been-called-with 1 61000) (expect 'foo :to-have-been-called-times 2) (subed-srt-jump-to-subtitle-end 2) (subed-srt-decrease-start-time) @@ -624,7 +624,7 @@ Baz. (expect 'foo :to-have-been-called-times 3) (subed-srt-jump-to-subtitle-text 3) (subed-srt-decrease-stop-time 100) - (expect 'foo :to-have-been-called-with 3 195400) + (expect 'foo :to-have-been-called-with 3 183550) (expect 'foo :to-have-been-called-times 4)))) (it "adjusts the start/stop time." (with-temp-buffer