[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/mpv 338af25d20 23/50: add mpv-on-event-hook
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/mpv 338af25d20 23/50: add mpv-on-event-hook |
Date: |
Tue, 28 Dec 2021 00:58:40 -0500 (EST) |
branch: elpa/mpv
commit 338af25d2039297369e3f17e538e8654bf4c4040
Author: Johann Klähn <kljohann@gmail.com>
Commit: Johann Klähn <kljohann@gmail.com>
add mpv-on-event-hook
---
mpv.el | 18 +++++++++++++-----
1 file changed, 13 insertions(+), 5 deletions(-)
diff --git a/mpv.el b/mpv.el
index 908fc4c951..80e4df89c5 100644
--- a/mpv.el
+++ b/mpv.el
@@ -66,6 +66,12 @@
(defcustom seek-step 5
"Step size in seconds used when seeking.")
+(defcustom on-event-hook nil
+ "Hook to run when an event message is received.
+The hook will be called with the parsed JSON message as its only an
+argument. See \"List of events\" in the mpv man page."
+ :type 'hook)
+
(defvar -process nil)
(defvar -queue nil)
@@ -138,7 +144,7 @@ This is a verbatim copy of `tq-filter' that uses
Replacement for `tq-process-buffer' that ignores regular expressions
\(answers are always passed to the first handler in the queue) and
-drops unsolicited event messages."
+passes unsolicited event messages to `mpv-on-event-hook'."
(goto-char (point-min))
(skip-chars-forward "^{")
(let ((answer (ignore-errors (json-read))))
@@ -147,13 +153,15 @@ drops unsolicited event messages."
;; event messages have form {"event": ...}
;; answers have form {"error": ..., "data": ...}
;; FIXME: handle errors?
- (unless (or (assoc 'event answer) (tq-queue-empty tq))
+ (cond
+ ((assoc 'event answer)
+ (run-hook-with-args 'mpv-on-event-hook answer))
+ ((not (tq-queue-empty tq))
(unwind-protect
- ;; (condition-case nil
(funcall (tq-queue-head-fn tq)
(cdr (assoc 'data answer)))
- ;; (error nil))
- (tq-queue-pop tq)))
+ (tq-queue-pop tq))))
+ ;; Recurse to check for further JSON messages.
(-tq-process-buffer tq))))
:autoload
- [nongnu] elpa/mpv 4774d52c8c 48/50: Merge pull request #21 from sachac/master, (continued)
- [nongnu] elpa/mpv 4774d52c8c 48/50: Merge pull request #21 from sachac/master, ELPA Syncer, 2021/12/28
- [nongnu] elpa/mpv 604b32d7e6 11/50: add play command, ELPA Syncer, 2021/12/28
- [nongnu] elpa/mpv 15c51ddc5e 10/50: remove dependency on dash library, ELPA Syncer, 2021/12/28
- [nongnu] elpa/mpv 059135de39 28/50: version 0.1.0, ELPA Syncer, 2021/12/28
- [nongnu] elpa/mpv 9e1781249f 27/50: convert numbers to strings before encoding as JSON, ELPA Syncer, 2021/12/28
- [nongnu] elpa/mpv 79e01bf89b 35/50: Remove stale socket files when mpv process is gone, ELPA Syncer, 2021/12/28
- [nongnu] elpa/mpv 4dddd55c5e 41/50: Add mpv-version., ELPA Syncer, 2021/12/28
- [nongnu] elpa/mpv 2d40c45505 38/50: Add mpv-seek and mpv-revert-seek commands, ELPA Syncer, 2021/12/28
- [nongnu] elpa/mpv a5c6eed9ac 44/50: Add volume control commands, ELPA Syncer, 2021/12/28
- [nongnu] elpa/mpv 3a43c9e60a 14/50: reorder function definitions, ELPA Syncer, 2021/12/28
- [nongnu] elpa/mpv 338af25d20 23/50: add mpv-on-event-hook,
ELPA Syncer <=
- [nongnu] elpa/mpv 937bdf522a 17/50: implement seeking and changing of playback speed, ELPA Syncer, 2021/12/28
- [nongnu] elpa/mpv 0e4318b45f 13/50: improve docstrings, ELPA Syncer, 2021/12/28
- [nongnu] elpa/mpv 0579b5c707 09/50: support inserting org timer list items, ELPA Syncer, 2021/12/28
- [nongnu] elpa/mpv ce3bbfac36 22/50: add mpv-default-options, ELPA Syncer, 2021/12/28
- [nongnu] elpa/mpv 9ef359d712 20/50: fix generation of autoloads, ELPA Syncer, 2021/12/28
- [nongnu] elpa/mpv 9ff4d5d80b 25/50: fix mpv-insert-playback-position, ELPA Syncer, 2021/12/28
- [nongnu] elpa/mpv 705e81b8a6 42/50: Make mpv-version more verbose and update its docstring as suggested, ELPA Syncer, 2021/12/28
- [nongnu] elpa/mpv ed83369372 39/50: Fix mpv-seek-to-position-at-point for start-of-playback position, ELPA Syncer, 2021/12/28
- [nongnu] elpa/mpv 2d24187f7b 43/50: Merge pull request #9 from firmart/patch-mpv-version, ELPA Syncer, 2021/12/28
- [nongnu] elpa/mpv ed9c7b0028 21/50: move functions to public interface, ELPA Syncer, 2021/12/28