branch: elpa/subed
commit 9493763fdeac232cffb9bd4aa2b217abd8fc30ee
Author: Sacha Chua <[email protected]>
Commit: Sacha Chua <[email protected]>
1.3.0: Don't sort by default
* subed/subed-config.el (subed-sanitize-functions):
Don't sort by default.
* tests/test-subed-common.el ("subed-common"): Don't sort by default.
* tests/test-subed-vtt.el ("subed-vtt"): Don't
sort by default.
Other minor changes:
* tests/test-subed-common.el (file): Load
undercover-init.el more flexibly.
* subed/subed-vtt.el (subed--set-subtitle-comment):
Handle empty comments.
* subed/ol-subed.el (org-subed-store-link): Don't
store the msecs in the link if there aren't any.
* subed/subed-common.el (subed-parse-file): Try to
parse with less overhead.
---
NEWS.org | 4 ++++
README.org | 6 ++++++
subed/ol-subed.el | 6 +++++-
subed/subed-common.el | 3 ++-
subed/subed-config.el | 1 -
subed/subed-vtt.el | 2 +-
tests/test-subed-common.el | 11 +++++++----
tests/test-subed-vtt.el | 25 -------------------------
8 files changed, 25 insertions(+), 33 deletions(-)
diff --git a/NEWS.org b/NEWS.org
index 31a82f4ed45..c551718adfe 100644
--- a/NEWS.org
+++ b/NEWS.org
@@ -1,6 +1,10 @@
#+OPTIONS: toc:nil
* subed news
+** Version 1.3.0 - 2026-01-03 - Sacha Chua
+
+- subed no longer sorts subtitles by default on saving the file, since that
was taking a long time.
+ If you would like to sort subtitles, use =subed-sort=.
** Version 1.2.25 - 2025-01-28 - Sacha Chua
diff --git a/README.org b/README.org
index e3732c740f4..ceacc4e3f93 100644
--- a/README.org
+++ b/README.org
@@ -551,6 +551,12 @@ using generic functions such as
~subed-jump-to-subtitle-id~.
You'll need to install the =buttercup= and =package-lint= Emacs packages.
You'll also need =GNU Make= so that you can work with Makefiles. To run the
tests, use the command =make test=.
+To re-run tests automatically when files change, something like nodemon might
be helpful.
+
+#+begin_src sh :eval no
+nodemon -w tests/*.el -w subed/*.el -x "make test"
+#+end_src
+
** Contributions
:PROPERTIES:
:CUSTOM_ID: subed-contributions
diff --git a/subed/ol-subed.el b/subed/ol-subed.el
index 73fc9bfe830..12101657c49 100644
--- a/subed/ol-subed.el
+++ b/subed/ol-subed.el
@@ -37,7 +37,11 @@
:text (subed-subtitle-text)
:description (or (subed-subtitle-comment) (subed-subtitle-text)))
(org-link-add-props
- :link (concat "subed:" (buffer-file-name) "::"
(number-to-string (subed-subtitle-msecs-start))))
+ :link (concat "subed:" (buffer-file-name)
+ (if (subed-subtitle-msecs-start)
+ (concat
+ "::" (number-to-string (subed-subtitle-msecs-start)))
+ "")))
org-store-link-plist))
;;;###autoload
diff --git a/subed/subed-common.el b/subed/subed-common.el
index 9c55db0cbf3..3e5b4b742a3 100644
--- a/subed/subed-common.el
+++ b/subed/subed-common.el
@@ -651,7 +651,8 @@ If MODE-FUNC is non-nil, use that function to initialize
the mode.
Otherwise, initialize the mode based on the filename."
(when (and filename (file-exists-p filename))
(with-temp-buffer
- (let ((subed-auto-play-media nil))
+ (let ((subed-auto-play-media nil)
+ (subed-mode-hook nil))
(insert-file-contents filename)
(if mode-func
(funcall mode-func)
diff --git a/subed/subed-config.el b/subed/subed-config.el
index 1e9773261f7..0eea5f46908 100644
--- a/subed/subed-config.el
+++ b/subed/subed-config.el
@@ -178,7 +178,6 @@ Other values aside from the ones specified above will be
treated as nil."
(defcustom subed-sanitize-functions
'(subed-sanitize-format
- subed-sort
subed-trim-overlap-maybe-sanitize)
"Functions to call when sanitizing subtitles."
:type '(repeat function)
diff --git a/subed/subed-vtt.el b/subed/subed-vtt.el
index e7a00e4fa25..8d53d7b1ce3 100644
--- a/subed/subed-vtt.el
+++ b/subed/subed-vtt.el
@@ -394,7 +394,7 @@ Use the format-specific function for MAJOR-MODE."
If COMMENT is nil or the empty string, remove the comment.
If SUB-ID is not given, use the subtitle on point.
Use the format-specific function for MAJOR-MODE."
- (setq comment (string-trim comment))
+ (setq comment (and comment (string-trim comment)))
(let ((comment-start (subed-jump-to-subtitle-comment sub-id)))
;; remove previous comment
(if comment-start
diff --git a/tests/test-subed-common.el b/tests/test-subed-common.el
index 43d519381e8..efdb31d595f 100644
--- a/tests/test-subed-common.el
+++ b/tests/test-subed-common.el
@@ -1,6 +1,9 @@
;; -*- lexical-binding: t; eval: (buttercup-minor-mode) -*-
-(load-file "./tests/undercover-init.el")
+(dolist (file '("undercover-init.el" "./tests/undercover-init.el"))
+ (when (file-exists-p file)
+ (load-file file)))
+
(require 'subed-srt)
(require 'subed-mpv)
@@ -3485,13 +3488,13 @@ This is another.
(expect (subed-subtitle-msecs-start 1)
:to-equal 1000)
(expect (subed-subtitle-msecs-stop 1)
:to-equal 2000))))
(describe "when configured to trim on save,"
- (it "trims overlaps after sorting."
+ (it "trims overlaps."
(with-temp-srt-buffer
(let ((subed-trim-overlap-on-save t)
(subed-subtitle-spacing 200))
(insert "1\n00:00:01,000 -->
00:00:02,000\nA\n\n"
-
"2\n00:00:04,000 --> 00:00:06,000\nA\n\n"
-
"3\n00:00:03,000 --> 00:00:04,500\nA\n\n"
+
"2\n00:00:03,000 --> 00:00:04,500\nA\n\n"
+ "3\n00:00:04,000 --> 00:00:06,000\nA\n\n"
"4\n00:00:05,000 --> 00:00:06,000\nA\n\n")
(subed-prepare-to-save)
(expect (subed-subtitle-msecs-stop 1)
:to-equal 2000)
diff --git a/tests/test-subed-vtt.el b/tests/test-subed-vtt.el
index 103b1286877..e46a9beb487 100644
--- a/tests/test-subed-vtt.el
+++ b/tests/test-subed-vtt.el
@@ -2263,31 +2263,6 @@ Hello world
"\n"
"00:12:01.000 --> 00:01:05.123\n"
"Foo.\n"))))
- (it "runs before saving."
- (with-temp-vtt-buffer
- (insert mock-vtt-data)
- (goto-char (point-min))
- (re-search-forward "01:01")
- (replace-match "12:01")
- (goto-char (point-min))
- (re-search-forward "02:02")
- (replace-match "10:02")
- (goto-char (point-min))
- (re-search-forward "03:03")
- (replace-match "11:03")
- (subed-prepare-to-save)
- (expect (buffer-string) :to-equal
- (concat
- "WEBVTT\n"
- "\n"
- "00:10:02.234 --> 00:02:10.345\n"
- "Bar.\n"
- "\n"
- "00:11:03.45 --> 00:03:15.5\n"
- "Baz.\n"
- "\n"
- "00:12:01.000 --> 00:01:05.123\n"
- "Foo.\n"))))
(describe "point preservation"
(it "works when subtitle text is non-empty."
(with-temp-vtt-buffer