branch: elpa/subed commit 4d2c26da9c89b138cf16ba9b1524fc4d655ddc95 Author: Random User <rnd...@posteo.de> Commit: Random User <rnd...@posteo.de>
Add subed-srt--regenerate-ids-soon-timer --- subed/subed-srt.el | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/subed/subed-srt.el b/subed/subed-srt.el index 50d54b2..2f69b3b 100644 --- a/subed/subed-srt.el +++ b/subed/subed-srt.el @@ -494,6 +494,20 @@ each subtitle." (insert id-str))) (setq id (1+ id)))))))) +(defvar-local subed-srt--regenerate-ids-soon-timer nil) +(defun subed-srt--regenerate-ids-soon () + "Run `subed-srt--regenerate-ids' in 100ms unless this function +is called again within the next 100ms, in which case the +previously scheduled call is canceled and another call is +scheduled in 100ms." + (interactive) + (when subed-srt--regenerate-ids-soon-timer + (cancel-timer subed-srt--regenerate-ids-soon-timer)) + (setq subed-srt--regenerate-ids-soon-timer + (run-at-time 0.1 nil (lambda () + (setq subed-srt--regenerate-ids-soon-timer nil) + (subed-srt--regenerate-ids))))) + (defun subed-srt--sanitize () "Remove surplus newlines and whitespace." (interactive)