branch: elpa/subed commit aecaf3deca964dd35f282f1798d493da47d6fb1e Author: Random User <rnd...@posteo.de> Commit: Random User <rnd...@posteo.de>
Better support for fill-paragraph --- subed/subed-srt.el | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/subed/subed-srt.el b/subed/subed-srt.el index 6561140..df075de 100644 --- a/subed/subed-srt.el +++ b/subed/subed-srt.el @@ -550,8 +550,22 @@ scheduled call is canceled and another call is scheduled in "This function is called when subed-mode is entered for a SRT file." (setq-local subed--subtitle-format "srt") (setq-local font-lock-defaults '(subed-srt-font-lock-keywords)) - (setq-local paragraph-start "^[[:alnum:]\n]+") - (setq-local paragraph-separate "\n\n")) + ;; Support for fill-paragraph (M-q) + (let ((timestamps-regexp (concat subed-srt--regexp-timestamp + " *--> *" + subed-srt--regexp-timestamp))) + (setq-local paragraph-separate (concat "^\\(" + (mapconcat 'identity `("[[:blank:]]*" + "[[:digit:]]+" + ,timestamps-regexp) "\\|") + "\\)$")) + (setq-local paragraph-start (concat "\\(" + ;; Mulitple speakers in the same + ;; subtitle are often distinguished with + ;; a "-" at the start of the line. + (mapconcat 'identity '("^-" + "[[:graph:]]*$") "\\|") + "\\)")))) (provide 'subed-srt) ;;; subed-srt.el ends here