[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/subed 82e3f57f95: Consolidate format-specific faces
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/subed 82e3f57f95: Consolidate format-specific faces |
Date: |
Wed, 14 Sep 2022 20:59:24 -0400 (EDT) |
branch: elpa/subed
commit 82e3f57f954091ef3d23e0072da9f70819ab3dec
Author: Sacha Chua <sacha@sachachua.com>
Commit: Sacha Chua <sacha@sachachua.com>
Consolidate format-specific faces
Consolidate the different faces to subed-id-face, subed-time-face, and
subed-time-separator-face. Add tests for font-locking. Dropped text
font-locking for now since we didn't have a good regular expression
for it.
Obsolete:
- subed-srt-id-face
- subed-srt-time-face
- subed-srt-time-separator-face
- subed-srt-text-face
- subed-vtt-id-face
- subed-vtt-time-face
- subed-vtt-time-separator-face
- subed-vtt-text-face
- subed-ass-id-face
- subed-ass-time-face
- subed-ass-time-separator-face
- subed-ass-text-face
Thanks to Igor for the bug report!
* subed/subed-ass.el (subed-ass-font-lock-keywords): Change faces and
remove text regexp.
(subed-ass--regexp-start): Allow extra space.
* subed/subed-config.el: Obsolete format-specific faces.
(subed-id-face): Rename.
(subed-time-face): Rename.
(subed-time-separator-face): Rename.
* subed/subed-srt.el (subed-srt-font-lock-keywords): Change faces and
remove text regexp.
* subed/subed-vtt.el (subed-vtt-font-lock-keywords): Change faces and
remove text regexp.
* tests/test-subed-ass.el ("ASS"): Add tests for fontlocking.
* tests/test-subed-vtt.el ("VTT"): Add tests for fontlocking.
* tests/test-subed-srt.el ("SRT"): Add tests for fontlocking.
---
NEWS.org | 23 +++++++++++++++++++++++
subed/subed-ass.el | 7 +++----
subed/subed-config.el | 33 +++++++++++++++------------------
subed/subed-srt.el | 7 +++----
subed/subed-vtt.el | 5 ++---
subed/subed.el | 2 +-
tests/test-subed-ass.el | 13 ++++++++++++-
tests/test-subed-srt.el | 16 +++++++++++++++-
tests/test-subed-vtt.el | 13 ++++++++++++-
9 files changed, 86 insertions(+), 33 deletions(-)
diff --git a/NEWS.org b/NEWS.org
index bd46233480..4b35c439f0 100644
--- a/NEWS.org
+++ b/NEWS.org
@@ -1,4 +1,27 @@
* subed news
+** Version 1.0.9 - 2022-09-14 - Sacha Chua
+
+- Consolidated the different faces to subed-id-face, subed-time-face,
+ and subed-time-separator-face. Added tests for font-locking. Dropped
+ text font-locking for now since we didn't have a good regular
+ expression for it.
+
+ Obsolete:
+ - subed-srt-id-face
+ - subed-srt-time-face
+ - subed-srt-time-separator-face
+ - subed-srt-text-face
+ - subed-vtt-id-face
+ - subed-vtt-time-face
+ - subed-vtt-time-separator-face
+ - subed-vtt-text-face
+ - subed-ass-id-face
+ - subed-ass-time-face
+ - subed-ass-time-separator-face
+ - subed-ass-text-face
+
+Thanks to Igor for the bug report!
+
** Version 1.0.8 - 2022-09-08 - Sacha Chua
- Added support for SRT comment syntax thanks to mbork.
diff --git a/subed/subed-ass.el b/subed/subed-ass.el
index ba2be08955..5eb8e24c6a 100644
--- a/subed/subed-ass.el
+++ b/subed/subed-ass.el
@@ -36,16 +36,15 @@
(defconst subed-ass-font-lock-keywords
(list
- '("\\([0-9]+:\\)?[0-9]+:[0-9]+\\.[0-9]+" . 'subed-ass-time-face)
- '(",[0-9]+ \\(-->\\) [0-9]+:" 1 'subed-ass-time-separator-face t)
- '("^.*$" . 'subed-ass-text-face))
+ '("\\([0-9]+:\\)?[0-9]+:[0-9]+\\(\\.[0-9]+\\)?" . 'subed-time-face)
+ '("\\(?:[0-9]+:\\)?[0-9]+:[0-9]+\\(?:\\.[0-9]+\\)? *\\(,\\)
*\\(?:[0-9]+:\\)?[0-9]+:[0-9]+\\(?:\\.[0-9]+\\)?" 1 'subed-time-separator-face
t))
"Highlighting expressions for `subed-mode'.")
;;; Parsing
(defconst subed-ass--regexp-timestamp
"\\(\\([0-9]+\\):\\)?\\([0-9]+\\):\\([0-9]+\\)\\(\\.\\([0-9]+\\)\\)?")
-(defconst subed-ass--regexp-start
"\\(?:Dialogue\\|Comment\\|Picture\\|Sound\\|Movie\\|Command\\): [0-9]+,")
+(defconst subed-ass--regexp-start
"\\(?:Dialogue\\|Comment\\|Picture\\|Sound\\|Movie\\|Command\\): +[0-9]+,")
(defconst subed-ass--regexp-separator "\n")
(cl-defmethod subed--timestamp-to-msecs (time-string &context (major-mode
subed-ass-mode))
diff --git a/subed/subed-config.el b/subed/subed-config.el
index 4ecf0ea668..78a74fd3b2 100644
--- a/subed/subed-config.el
+++ b/subed/subed-config.el
@@ -45,33 +45,30 @@
;; Syntax highlighting
-(defface subed-srt-id-face
+(defface subed-id-face
'((t (:inherit 'font-lock-constant-face)))
"Each subtitle's consecutive number")
-(defface subed-srt-time-face
+(defface subed-time-face
'((t (:inherit 'font-lock-string-face)))
"Start and stop times of subtitles")
-(defface subed-srt-time-separator-face
+(defface subed-time-separator-face
'((t (:inherit 'font-lock-comment-face)))
"Separator between the start and stop time (\" --> \")")
-(defface subed-srt-text-face
- '((t (:inherit 'default)))
- "Text of the subtitle")
-
-(defface subed-vtt-time-face
- '((t (:inherit 'font-lock-string-face)))
- "Start and stop times of subtitles")
-
-(defface subed-vtt-time-separator-face
- '((t (:inherit 'font-lock-comment-face)))
- "Separator between the start and stop time (\" --> \")")
-
-(defface subed-vtt-text-face
- '((t (:inherit 'default)))
- "Text of the subtitle")
+(define-obsolete-face-alias 'subed-srt-id-face 'subed-id-face "2022-09-14")
+(define-obsolete-face-alias 'subed-srt-time-face 'subed-time-face "2022-09-14")
+(define-obsolete-face-alias 'subed-srt-time-separator-face
'subed-time-separator-face "2022-09-14")
+(defface subed-srt-text-face nil "Obsolete, do not use.")
+(define-obsolete-face-alias 'subed-vtt-id-face 'subed-id-face "2022-09-14")
+(define-obsolete-face-alias 'subed-vtt-time-face 'subed-time-face "2022-09-14")
+(define-obsolete-face-alias 'subed-vtt-time-separator-face
'subed-time-separator-face "2022-09-14")
+(defface subed-vtt-text-face nil "Obsolete, do not use.")
+(define-obsolete-face-alias 'subed-ass-id-face 'subed-id-face "2022-09-14")
+(define-obsolete-face-alias 'subed-ass-time-face 'subed-time-face "2022-09-14")
+(define-obsolete-face-alias 'subed-ass-time-separator-face
'subed-time-separator-face "2022-09-14")
+(defface subed-ass-text-face nil "Obsolete, do not use.")
;; Variables
diff --git a/subed/subed-srt.el b/subed/subed-srt.el
index 97927ba090..9eda9bba9e 100644
--- a/subed/subed-srt.el
+++ b/subed/subed-srt.el
@@ -36,10 +36,9 @@
(defconst subed-srt-font-lock-keywords
(list
- '("^[0-9]+$" . 'subed-srt-id-face)
- '("[0-9]+:[0-9]+:[0-9]+,[0-9]+" . 'subed-srt-time-face)
- '(",[0-9]+ \\(-->\\) [0-9]+:" 1 'subed-srt-time-separator-face t)
- '("^.*$" . 'subed-srt-text-face))
+ '("^[0-9]+$" . 'subed-id-face)
+ '("[0-9]+:[0-9]+:[0-9]+,[0-9]+" . 'subed-time-face)
+ '(",[0-9]+ +\\(-->\\) +[0-9]+:" 1 'subed-time-separator-face t))
"Highlighting expressions for `subed-mode'.")
diff --git a/subed/subed-vtt.el b/subed/subed-vtt.el
index 05bdc5dd7e..904166d794 100644
--- a/subed/subed-vtt.el
+++ b/subed/subed-vtt.el
@@ -36,9 +36,8 @@
(defconst subed-vtt-font-lock-keywords
(list
- '("\\([0-9]+:\\)?[0-9]+:[0-9]+\\.[0-9]+" . 'subed-vtt-time-face)
- '(",[0-9]+ \\(-->\\) [0-9]+:" 1 'subed-vtt-time-separator-face t)
- '("^.*$" . 'subed-vtt-text-face))
+ '("\\([0-9]+:\\)?[0-9]+:[0-9]+\\.[0-9]+" . 'subed-time-face)
+ '("\\.[0-9]+ +\\(-->\\) +[0-9]+:" 1 'subed-time-separator-face t))
"Highlighting expressions for `subed-mode'.")
diff --git a/subed/subed.el b/subed/subed.el
index 06b18ced70..2a264964f1 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.8
+;; Version: 1.0.9
;; Maintainer: Sacha Chua <sacha@sachachua.com>
;; Author: Random User
;; Keywords: convenience, files, hypermedia, multimedia
diff --git a/tests/test-subed-ass.el b/tests/test-subed-ass.el
index 692956bddd..481023dd7f 100644
--- a/tests/test-subed-ass.el
+++ b/tests/test-subed-ass.el
@@ -389,4 +389,15 @@ Dialogue: 0,0:00:17.00,0:00:19.80,Default,,0,0,0,,I hope
it works.
(describe "Converting msecs to timestamp"
(it "uses the right format"
(with-temp-ass-buffer
- (expect (subed-msecs-to-timestamp 1410) :to-equal "0:00:01.41")))))
+ (expect (subed-msecs-to-timestamp 1410) :to-equal "0:00:01.41"))))
+ (describe "Font-locking"
+ (it "recognizes ASS syntax."
+ (with-temp-ass-buffer
+ (insert mock-ass-data)
+ (font-lock-fontify-buffer)
+ (goto-char (point-min))
+ (re-search-forward "00:11")
+ (expect (face-at-point) :to-equal 'subed-time-face)
+ (re-search-forward ",")
+ (backward-char 1)
+ (expect (face-at-point) :to-equal 'subed-time-separator-face)))))
diff --git a/tests/test-subed-srt.el b/tests/test-subed-srt.el
index bfad61c461..57f53b5ebe 100644
--- a/tests/test-subed-srt.el
+++ b/tests/test-subed-srt.el
@@ -1539,4 +1539,18 @@ Baz.
(re-search-backward "comment")
(expect (nth 4 (syntax-ppss)) :to-be t)
(re-search-forward "Hello")
- (expect (nth 4 (syntax-ppss)) :to-be nil)))))
+ (expect (nth 4 (syntax-ppss)) :to-be nil))))
+ (describe "Font-locking"
+ (it "recognizes SRT syntax."
+ (with-temp-srt-buffer
+ (insert mock-srt-data)
+ (font-lock-fontify-buffer)
+ (goto-char (point-min))
+ (re-search-forward "00:01:01")
+ (expect (face-at-point) :to-equal 'subed-time-face)
+ (re-search-forward "-->")
+ (backward-char 1)
+ (expect (face-at-point) :to-equal 'subed-time-separator-face)
+ (re-search-forward "^2$")
+ (goto-char (match-beginning 0))
+ (expect (face-at-point) :to-equal 'subed-id-face)))))
diff --git a/tests/test-subed-vtt.el b/tests/test-subed-vtt.el
index ea77a4051b..49d529200e 100644
--- a/tests/test-subed-vtt.el
+++ b/tests/test-subed-vtt.el
@@ -1287,4 +1287,15 @@ This is another test here.
(subed-merge-with-next)
(expect (subed-subtitle-text) :to-equal "Bar.\nBaz.")
(expect (subed-subtitle-msecs-start) :to-equal 122234)
- (expect (subed-subtitle-msecs-stop) :to-equal 195500)))))
+ (expect (subed-subtitle-msecs-stop) :to-equal 195500))))
+ (describe "Font-locking"
+ (it "recognizes VTT syntax."
+ (with-temp-vtt-buffer
+ (insert mock-vtt-data)
+ (font-lock-fontify-buffer)
+ (goto-char (point-min))
+ (re-search-forward "00:01:01")
+ (expect (face-at-point) :to-equal 'subed-time-face)
+ (re-search-forward "-->")
+ (backward-char 1)
+ (expect (face-at-point) :to-equal 'subed-time-separator-face)))))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [nongnu] elpa/subed 82e3f57f95: Consolidate format-specific faces,
ELPA Syncer <=