branch: elpa/subed commit 9d54f396fffadb1af26ca97d236e4e3883393237 Author: Random User <rnd...@posteo.de> Commit: Random User <rnd...@posteo.de>
Be more robust when getting start/stop time --- subed/subed-srt.el | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/subed/subed-srt.el b/subed/subed-srt.el index 272750f..9d98cc7 100644 --- a/subed/subed-srt.el +++ b/subed/subed-srt.el @@ -91,18 +91,20 @@ after MSECS if there is one and its start time is >= MSECS + (subed-srt--subtitle-id))) (defun subed-srt--subtitle-msecs-start (&optional sub-id) - "Subtitle start time in milliseconds." + "Subtitle start time in milliseconds or nil if it can't be found." (let ((timestamp (save-excursion - (subed-srt-move-to-subtitle-time-start sub-id) - (buffer-substring (point) (+ (point) subed-srt--length-timestamp))))) - (subed-srt--timestamp-to-msecs timestamp))) + (when (subed-srt-move-to-subtitle-time-start sub-id) + (buffer-substring (point) (+ (point) subed-srt--length-timestamp)))))) + (when timestamp + (subed-srt--timestamp-to-msecs timestamp)))) (defun subed-srt--subtitle-msecs-stop (&optional sub-id) - "Subtitle stop time in milliseconds." + "Subtitle stop time in milliseconds or nil if it can't be found." (let ((timestamp (save-excursion - (subed-srt-move-to-subtitle-time-stop sub-id) - (buffer-substring (point) (+ (point) subed-srt--length-timestamp))))) - (subed-srt--timestamp-to-msecs timestamp))) + (when (subed-srt-move-to-subtitle-time-stop sub-id) + (buffer-substring (point) (+ (point) subed-srt--length-timestamp)))))) + (when timestamp + (subed-srt--timestamp-to-msecs timestamp)))) (defun subed-srt--subtitle-relative-point () "Point relative to subtitle's ID, i.e. point within subtitle."