emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/subed aecaf3d 309/389: Better support for fill-paragraph


From: ELPA Syncer
Subject: [nongnu] elpa/subed aecaf3d 309/389: Better support for fill-paragraph
Date: Fri, 3 Dec 2021 11:00:47 -0500 (EST)

branch: elpa/subed
commit aecaf3deca964dd35f282f1798d493da47d6fb1e
Author: Random User <rndusr@posteo.de>
Commit: Random User <rndusr@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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]