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

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

[nongnu] elpa/subed f1f8e2ad56 13/22: Bugfixes to make VTT editing work


From: ELPA Syncer
Subject: [nongnu] elpa/subed f1f8e2ad56 13/22: Bugfixes to make VTT editing work
Date: Tue, 1 Feb 2022 14:06:09 -0500 (EST)

branch: elpa/subed
commit f1f8e2ad56f9573db42254899d40c6556e4c9ce9
Author: Sacha Chua <sacha@sachachua.com>
Commit: Sacha Chua <sacha@sachachua.com>

    Bugfixes to make VTT editing work
    
    * subed/subed-common.el (jump-to-subtitle-id-at-msecs): Handle
    string IDs as given by VTT and ASS.
    * subed/subed-mpv.el (subed-mpv--client-filter): Guard against
    issues when the event is being processed from a non-subed buffer.
---
 subed/subed-common.el |  2 +-
 subed/subed-mpv.el    | 45 +++++++++++++++++++++++----------------------
 2 files changed, 24 insertions(+), 23 deletions(-)

diff --git a/subed/subed-common.el b/subed/subed-common.el
index cbdccb4bb1..da6db32bf6 100644
--- a/subed/subed-common.el
+++ b/subed/subed-common.el
@@ -125,7 +125,7 @@ Return point or nil if point is still on the same subtitle.
 See also `subed-subtitle-id-at-msecs'."
   (let ((current-sub-id (subed-subtitle-id))
         (target-sub-id (subed-subtitle-id-at-msecs msecs)))
-    (when (and target-sub-id current-sub-id (not (= target-sub-id 
current-sub-id)))
+    (when (and target-sub-id current-sub-id (not (equal target-sub-id 
current-sub-id)))
       (subed-jump-to-subtitle-id target-sub-id))))
 
 (subed-define-generic-function jump-to-subtitle-text-at-msecs (msecs)
diff --git a/subed/subed-mpv.el b/subed/subed-mpv.el
index 4701e07564..3575d7c0ca 100644
--- a/subed/subed-mpv.el
+++ b/subed/subed-mpv.el
@@ -214,28 +214,29 @@ string."
   ;; Therefore we maintain a buffer and process only complete lines.
   (when (buffer-live-p (process-buffer proc))
     (let ((orig-buffer (current-buffer)))
-         (with-current-buffer (process-buffer proc)
-        ;; Insert new response where previous response ended
-           (let* ((proc-mark (process-mark proc))
-               (moving (= (point) proc-mark)))
-                 (save-excursion
-                   (goto-char proc-mark)
-                   (insert response)
-                   (set-marker proc-mark (point)))
-                 (if moving (goto-char proc-mark)))
-           ;; Process and remove all complete lines of JSON (lines are 
complete if
-           ;; they end with \n)
-           (let ((p0 (point-min)))
-                 (while (progn (goto-char p0)
-                        (end-of-line)
-                                   (equal (following-char) ?\n))
-                   (let* ((p1 (point))
-                              (line (buffer-substring p0 p1)))
-                         (delete-region p0 (+ p1 1))
-              ;; Return context to the subtitle file buffer because we're using
-              ;; buffer-local variables to store player state.
-              (with-current-buffer orig-buffer
-                           (subed-mpv--client-handle-json line)))))))))
+      (when (derived-mode-p 'subed-mode)
+             (with-current-buffer (process-buffer proc)
+          ;; Insert new response where previous response ended
+               (let* ((proc-mark (process-mark proc))
+                 (moving (= (point) proc-mark)))
+                       (save-excursion
+                         (goto-char proc-mark)
+                         (insert response)
+                         (set-marker proc-mark (point)))
+                       (if moving (goto-char proc-mark)))
+               ;; Process and remove all complete lines of JSON (lines are 
complete if
+               ;; they end with \n)
+               (let ((p0 (point-min)))
+                       (while (progn (goto-char p0)
+                          (end-of-line)
+                                           (equal (following-char) ?\n))
+                         (let* ((p1 (point))
+                                      (line (buffer-substring p0 p1)))
+                                 (delete-region p0 (+ p1 1))
+                ;; Return context to the subtitle file buffer because we're 
using
+                ;; buffer-local variables to store player state.
+                (with-current-buffer orig-buffer
+                                   (subed-mpv--client-handle-json 
line))))))))))
 
 (defun subed-mpv--client-handle-json (json-string)
   "Process server response JSON-STRING."



reply via email to

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