branch: elpa/subed commit aae6f0c337d1cf5cda183637c4bb337128073755 Author: Random User <rnd...@posteo.de> Commit: Random User <rnd...@posteo.de>
Add function: subed-srt--run-subtitle-time-adjusted-hook --- subed/subed-srt.el | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/subed/subed-srt.el b/subed/subed-srt.el index e6b467d..228700c 100644 --- a/subed/subed-srt.el +++ b/subed/subed-srt.el @@ -304,10 +304,8 @@ Return point or nil if there is no previous subtitle." (save-excursion (subed-srt-jump-to-subtitle-time-start) (when (looking-at subed-srt--regexp-timestamp) - (replace-match (subed-srt--msecs-to-timestamp msecs-new)))) - (when subed-subtitle-time-adjusted-hook - (run-hook-with-args 'subed-subtitle-time-adjusted-hook - (subed-srt--subtitle-id) msecs-new))))) + (replace-match (subed-srt--msecs-to-timestamp msecs-new)))))) + (subed-srt--run-subtitle-time-adjusted-hook)) (defun subed-srt--adjust-subtitle-stop-relative (msecs) "Add MSECS milliseconds to stop time (use negative value to subtract)." @@ -317,11 +315,16 @@ Return point or nil if there is no previous subtitle." (save-excursion (subed-srt-jump-to-subtitle-time-stop) (when (looking-at subed-srt--regexp-timestamp) - (replace-match (subed-srt--msecs-to-timestamp msecs-new)))) - (when subed-subtitle-time-adjusted-hook - (run-hook-with-args 'subed-subtitle-time-adjusted-hook - (subed-srt--subtitle-id) - (subed-srt--subtitle-msecs-start)))))) + (replace-match (subed-srt--msecs-to-timestamp msecs-new)))))) + (subed-srt--run-subtitle-time-adjusted-hook)) + +(defun subed-srt--run-subtitle-time-adjusted-hook () + "Run `subed-subtitle-time-adjusted-hook' functions with +subtitle ID and start time of the adjusted subtitle." + (when subed-subtitle-time-adjusted-hook + (run-hook-with-args 'subed-subtitle-time-adjusted-hook + (subed-srt--subtitle-id) + (subed-srt--subtitle-msecs-start)))) (defun subed-srt-increase-start-time (&optional arg) "Add `subed-milliseconds-adjust' milliseconds to start time of current subtitle.