[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/subed 5e9518da77 18/22: Work around direct call of subed-m
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/subed 5e9518da77 18/22: Work around direct call of subed-mode by guessing format |
Date: |
Tue, 1 Feb 2022 14:06:12 -0500 (EST) |
branch: elpa/subed
commit 5e9518da77a3c79a5f84fded676025a706b34d8d
Author: Sacha Chua <sacha@sachachua.com>
Commit: Sacha Chua <sacha@sachachua.com>
Work around direct call of subed-mode by guessing format
* README.org (Important change in v1.0.0): Document v1.0.0 breaking
change.
* subed/subed.el: Bump version to 1.0.0.
(subed-mode): Add subed-guess-format function.
(subed-guess-format): New function works around direct calls of
subed-mode.
---
README.org | 17 +++++++++++++++++
subed/subed.el | 16 +++++++++++++++-
2 files changed, 32 insertions(+), 1 deletion(-)
diff --git a/README.org b/README.org
index 0035ad4c93..5dc51c4016 100644
--- a/README.org
+++ b/README.org
@@ -10,6 +10,23 @@ corresponding video with [[https://mpv.io/][mpv]]. At the
moment, the only supp
SubRip ( ~.srt~), WebVTT ( ~.vtt~ ), and Advanced SubStation Alpha ( ~.ass~,
experimental ).
[[file:https://raw.githubusercontent.com/rndusr/subed/master/screenshot.jpg]]
+** Important change in v1.0.0
+
+~subed~ now uses ~subed-srt-mode~, ~subed-vtt-mode~, and
+~subed-ass-mode~ instead of directly using ~subed-mode~. These modes
+should be automatically associated with the ~.vtt~, ~.srt~, and ~.ass~
+extensions. If the generic ~subed-mode~ is loaded instead of the
format-specific mode,
+you may get an error such as:
+
+#+begin_example
+Error in post-command-hook (subed--post-command-handler):
(cl-no-applicable-method subed--subtitle-id)
+#+end_example
+
+If you set ~auto-mode-alist~ manually in your config, please make sure
+you associate extensions the appropriate format-specific mode instead
+of ~subed-mode~. The specific backend functions (ex:
+~subed-srt--jump-to-subtitle-id~) are also deprecated in favor of
+using generic functions such as ~subed-jump-to-subtitle-id~.
** Features
- Quickly jump to next (~M-n~) and previous (~M-p~) subtitle text.
diff --git a/subed/subed.el b/subed/subed.el
index 59187e897e..34f830a775 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: 0.1.0
+;; Version: 1.0.0
;; Keywords: convenience, files, hypermedia, multimedia
;; URL: https://github.com/rndusr/subed
;; Package-Requires: ((emacs "25.1"))
@@ -124,6 +124,7 @@ Adjust - Increase or decrease start or stop time of a
subtitle
Key bindings:
\\{subed-mode-map}"
:group 'subed
+ (add-hook 'subed-mode-hook #'subed-guess-format :local)
(add-hook 'post-command-hook #'subed--post-command-handler :append :local)
(add-hook 'before-save-hook #'subed-prepare-to-save :append :local)
(add-hook 'after-save-hook #'subed-mpv-reload-subtitles :append :local)
@@ -135,5 +136,18 @@ Key bindings:
(when subed-auto-find-video
(add-hook 'subed-mode-hook #'subed-auto-find-video-maybe :append :local)))
+(defun subed-guess-format ()
+ "Set this buffer's format to a more specific subed mode format.
+This is a workaround for the transition to using format-specific
+modes such as `subed-srt-mode' while `auto-mode-alist' might
+still refer to `subed-mode'. It will also switch to the
+format-specific mode if `subed-mode' is called directly."
+ (when (and (eq major-mode 'subed-mode)
+ (buffer-file-name))
+ (pcase (file-name-extension (buffer-file-name))
+ ("vtt" (subed-vtt-mode))
+ ("srt" (subed-srt-mode))
+ ("ass" (subed-ass-mode)))))
+
(provide 'subed)
;;; subed.el ends here
- [nongnu] elpa/subed 8a9b219706 01/22: Create derived modes for the different types of subtitles., (continued)
- [nongnu] elpa/subed 8a9b219706 01/22: Create derived modes for the different types of subtitles., ELPA Syncer, 2022/02/01
- [nongnu] elpa/subed 0264eb4ef1 08/22: Bump version to 0.1.0 and add missing undercover-init.el, ELPA Syncer, 2022/02/01
- [nongnu] elpa/subed a0d633d7ac 09/22: Fix spaces in Makefile, ELPA Syncer, 2022/02/01
- [nongnu] elpa/subed 4cab871f58 03/22: Add undercover support for coverage testing, ELPA Syncer, 2022/02/01
- [nongnu] elpa/subed 3c7ac78393 12/22: Define jump-to-subtitle-text-at-msecs, ELPA Syncer, 2022/02/01
- [nongnu] elpa/subed f1f8e2ad56 13/22: Bugfixes to make VTT editing work, ELPA Syncer, 2022/02/01
- [nongnu] elpa/subed d6b46496f8 11/22: Fix save hook name, ELPA Syncer, 2022/02/01
- [nongnu] elpa/subed e1b24bff31 05/22: Remove duplicate functions, ELPA Syncer, 2022/02/01
- [nongnu] elpa/subed 5c4ac92ddc 07/22: Add NEWS.org file, ELPA Syncer, 2022/02/01
- [nongnu] elpa/subed f3b48e319e 16/22: Use function instead of quote in subed-define-generic-function, ELPA Syncer, 2022/02/01
- [nongnu] elpa/subed 5e9518da77 18/22: Work around direct call of subed-mode by guessing format,
ELPA Syncer <=
- [nongnu] elpa/subed 5ed05ad398 02/22: Implement mode-specific functions with cl-defmethod, ELPA Syncer, 2022/02/01
- [nongnu] elpa/subed 1f7e32e176 06/22: README.org: document branches, mention autoloads, ELPA Syncer, 2022/02/01
- [nongnu] elpa/subed a58b002fe9 15/22: Clean up undercover-init.el, ELPA Syncer, 2022/02/01
- [nongnu] elpa/subed 3e99c6cb6f 22/22: Merge branch 'derived-mode' into main, ELPA Syncer, 2022/02/01
- [nongnu] elpa/subed b3a4ae08ab 10/22: Add missing tests for merging and subtitle ID at msecs, ELPA Syncer, 2022/02/01
- [nongnu] elpa/subed 94c28993b7 21/22: Define obsolete function aliases, ELPA Syncer, 2022/02/01
- [nongnu] elpa/subed 00d5525712 17/22: Add autoloads, ELPA Syncer, 2022/02/01
- [nongnu] elpa/subed 52fa457512 20/22: subed-define-generic-function: edebug and indent like a defun, ELPA Syncer, 2022/02/01
- [nongnu] elpa/subed 3199cd60d8 19/22: Document subed-define-generic-function, ELPA Syncer, 2022/02/01