[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/subed fcd2299f36: New function subed-parse-file
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/subed fcd2299f36: New function subed-parse-file |
Date: |
Mon, 7 Nov 2022 12:59:41 -0500 (EST) |
branch: elpa/subed
commit fcd2299f365eb37ced4a838bd39aaefd6c6ac576
Author: Sacha Chua <sacha@sachachua.com>
Commit: Sacha Chua <sacha@sachachua.com>
New function subed-parse-file
* subed/subed-common.el (subed-parse-file): New function.
(subed-subtitle-list): Make it a regular function instead of a generic one.
---
NEWS.org | 4 ++++
subed/subed-common.el | 20 +++++++++++++++++++-
subed/subed.el | 2 +-
3 files changed, 24 insertions(+), 2 deletions(-)
diff --git a/NEWS.org b/NEWS.org
index 804b3c7f4d..4e520c849e 100644
--- a/NEWS.org
+++ b/NEWS.org
@@ -1,4 +1,8 @@
* subed news
+** Version 1.0.18 - 2022-11-08 - Sacha Chua
+
+New function subed-parse-file.
+
** Version 1.0.17 - 2022-11-07 - Sacha Chua
New command subed-align in the subed-align.el file lets you use aeneas
diff --git a/subed/subed-common.el b/subed/subed-common.el
index 8974109491..3c7619f091 100644
--- a/subed/subed-common.el
+++ b/subed/subed-common.el
@@ -320,7 +320,25 @@ Return new point."
end (save-excursion (goto-char (point-max)))))
(delete-region beg end)))
-(subed-define-generic-function subtitle-list (&optional beg end)
+(defun subed-parse-file (filename &optional mode-func)
+ "Return the subtitles from FILENAME in a list.
+If MODE-FUNC is non-nil, use that function to initialize the mode.
+Otherwise, initialize the mode based on the filename."
+ (when (file-exists-p filename)
+ (with-temp-buffer
+ (insert-file-contents filename)
+ (if mode-func
+ (funcall mode-func)
+ (let ((mode-entry
+ (seq-find (lambda (mode-alist)
+ (string-match (car mode-alist) filename))
+ auto-mode-alist)))
+ (if mode-entry
+ (funcall (cdr mode-entry))
+ (subed-tsv-mode))))
+ (subed-subtitle-list))))
+
+(defun subed-subtitle-list (&optional beg end)
"Return the subtitles from BEG to END as a list.
The list will contain entries of the form (id start stop text).
If BEG and END are not specified, use the whole buffer."
diff --git a/subed/subed.el b/subed/subed.el
index adf7bdf365..05e693b85a 100644
--- a/subed/subed.el
+++ b/subed/subed.el
@@ -1,6 +1,6 @@
;;; subed.el --- A major mode for editing subtitles -*- lexical-binding: t;
-*-
-;; Version: 1.0.17
+;; Version: 1.0.18
;; Maintainer: Sacha Chua <sacha@sachachua.com>
;; Author: Random User
;; Keywords: convenience, files, hypermedia, multimedia
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [nongnu] elpa/subed fcd2299f36: New function subed-parse-file,
ELPA Syncer <=