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

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

[nongnu] elpa/subed 3c97061 264/389: Add subed--init-alist variable to t


From: ELPA Syncer
Subject: [nongnu] elpa/subed 3c97061 264/389: Add subed--init-alist variable to track supported formats
Date: Fri, 3 Dec 2021 11:00:38 -0500 (EST)

branch: elpa/subed
commit 3c970614c769bce02894410da057469c73cc336a
Author: Random User <rndusr@posteo.de>
Commit: Random User <rndusr@posteo.de>

    Add subed--init-alist variable to track supported formats
---
 subed/subed-config.el |  3 +++
 subed/subed.el        | 10 +++++++++-
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/subed/subed-config.el b/subed/subed-config.el
index 9ef10b3..7833d59 100644
--- a/subed/subed-config.el
+++ b/subed/subed-config.el
@@ -36,6 +36,9 @@
 (defvar-local subed--subtitle-format nil
   "Short form of the name of the subtitle format in the current buffer (e.g. 
\"srt\").")
 
+(defvar subed--init-alist '(("srt" . subed-srt--init))
+  "Alist that maps file extensions to format-specific init functions.")
+
 (defvar subed-mode-map
   (let ((subed-mode-map (make-keymap)))
     (define-key subed-mode-map (kbd "M-n") #'subed-forward-subtitle-text)
diff --git a/subed/subed.el b/subed/subed.el
index 2c94c78..187db6c 100644
--- a/subed/subed.el
+++ b/subed/subed.el
@@ -131,8 +131,16 @@ Key bindings:
       (subed-mode-disable)
     (subed-mode-enable)))
 
+;; Internally, supported formats are listed in `subed--init-alist', which
+;; associates file extensions with format-specific init methods (e.g. "srt" ->
+;; subed-srt--init).  Here we map each file extension as a regexp to
+;; `subed-mode-enable', which will call the format-specific init method and do
+;; generic init stuff.
 ;;;###autoload
-(add-to-list 'auto-mode-alist '("\\.srt\\'" . subed-mode-enable))
+(dolist (item subed--init-alist)
+  (let ((file-ext-regex (car item)))
+    (add-to-list 'auto-mode-alist (cons (concat "\\." file-ext-regex "\\'")
+                                        'subed-mode-enable))))
 
 (provide 'subed)
 ;;; subed.el ends here



reply via email to

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