[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/subed db93f2717e 1/2: Run subed-guess-format when subed-mo
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/subed db93f2717e 1/2: Run subed-guess-format when subed-mode is loaded |
Date: |
Mon, 11 Sep 2023 16:01:16 -0400 (EDT) |
branch: elpa/subed
commit db93f2717e0a98d41f4b20676389e60c0858efe1
Author: Sacha Chua <sacha@sachachua.com>
Commit: Sacha Chua <sacha@sachachua.com>
Run subed-guess-format when subed-mode is loaded
* subed/subed.el (subed-mode): Add subed-guess-format to
after-change-major-mode-hook. Thanks to consolers for reporting this!
* tests/test-subed-common.el ("Guessing the format"): Add test.
---
subed/subed.el | 1 +
tests/test-subed-common.el | 14 ++++++++++++++
2 files changed, 15 insertions(+)
diff --git a/subed/subed.el b/subed/subed.el
index cc6d24ebe4..991004851b 100644
--- a/subed/subed.el
+++ b/subed/subed.el
@@ -136,6 +136,7 @@ Key bindings:
(add-hook 'after-save-hook #'subed-mpv-reload-subtitles :append :local)
(add-hook 'kill-buffer-hook #'subed-mpv-kill :append :local)
(add-hook 'kill-emacs-hook #'subed-mpv-kill :append :local)
+ (add-hook 'after-change-major-mode-hook #'subed-guess-format :append :local)
(when subed-trim-overlap-check-on-load
(subed-trim-overlap-check))
(when subed-auto-play-media
diff --git a/tests/test-subed-common.el b/tests/test-subed-common.el
index cf22b5fea1..0fa4c9a42b 100644
--- a/tests/test-subed-common.el
+++ b/tests/test-subed-common.el
@@ -10858,3 +10858,17 @@ Baz.
(progn (subed-jump-to-subtitle-id 2) (point))
(progn (subed-jump-to-subtitle-end 3) (point)))
(expect (current-kill 0) :to-equal "Bar.\nBaz.\n"))))
+
+(describe "Guessing the format"
+ (it "works when the generic functions is called."
+ (let ((file (make-temp-file "subed-test" nil ".srt"))
+ (auto-mode-alist '(("\\.srt\\'" . subed-mode))))
+ (find-file file)
+ (expect major-mode :to-equal 'subed-srt-mode)
+ (delete-file file)))
+ (it "does not cause a loop when the more-specific function is called."
+ (let ((file (make-temp-file "subed-test" nil ".srt"))
+ (auto-mode-alist '(("\\.srt\\'" . subed-srt-mode))))
+ (find-file file)
+ (expect major-mode :to-equal 'subed-srt-mode)
+ (delete-file file))))