[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/mpv bc89524528 15/50: use timer formatting from org-timer.
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/mpv bc89524528 15/50: use timer formatting from org-timer.el |
Date: |
Tue, 28 Dec 2021 00:58:37 -0500 (EST) |
branch: elpa/mpv
commit bc89524528bf91d608ad8416c0fb9ae534a311c8
Author: Johann Klähn <kljohann@gmail.com>
Commit: Johann Klähn <kljohann@gmail.com>
use timer formatting from org-timer.el
---
mpv.el | 47 ++++++++++++++++++-----------------------------
1 file changed, 18 insertions(+), 29 deletions(-)
diff --git a/mpv.el b/mpv.el
index 3f2454281b..f69c33368b 100644
--- a/mpv.el
+++ b/mpv.el
@@ -4,7 +4,7 @@
;; Author: Johann Klähn <kljohann@gmail.com>
;; Keywords: tools, multimedia
-;; Package-Requires: ((json "1.3"))
+;; Package-Requires: ((json "1.3") (org "8.0"))
;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
@@ -37,8 +37,10 @@
(eval-when-compile (require 'names))
-(require 'tq)
(require 'json)
+(require 'org)
+(require 'org-timer)
+(require 'tq)
(define-namespace mpv-
:package mpv
@@ -48,14 +50,6 @@
"Name or path to the mpv executable."
:type 'file)
-(defvar -position-format "%H:%M:%S"
- "Format used for inserting playback position.")
-(defvar -position-regexp
- (rx (group (repeat 2 num)) ":"
- (group (repeat 2 num)) ":"
- (group (repeat 2 num))))
-(defvar -position-skipchars ":[:digit:]")
-
(defvar -process nil)
(defvar -queue nil)
@@ -137,10 +131,10 @@ drops unsolicited event messages."
;; FIXME: handle errors?
(unless (or (assoc 'event answer) (tq-queue-empty tq))
(unwind-protect
- (condition-case nil
- (funcall (tq-queue-head-fn tq)
- (cdr (assoc 'data answer)))
- (error nil))
+ ;; (condition-case nil
+ (funcall (tq-queue-head-fn tq)
+ (cdr (assoc 'data answer)))
+ ;; (error nil))
(tq-queue-pop tq)))
(-tq-process-buffer tq))))
@@ -174,19 +168,15 @@ When called with a non-nil ARG, insert a timer list item
like `org-timer-item'."
(let ((buffer (current-buffer)))
(-enqueue '("get_property" "playback-time")
(lambda (time)
- (let* ((secs (truncate time))
- (usecs (round (* 1000 (- time secs)))))
- (with-current-buffer buffer
- (funcall
- (if arg #'-position-insert-as-org-item #'insert)
- (format-time-string -position-format
- `(0 ,secs ,usecs 0) t))))))))
+ (with-current-buffer buffer
+ (funcall
+ (if arg #'-position-insert-as-org-item #'insert)
+ (org-timer-secs-to-hms (round time))))))))
(defun -position-insert-as-org-item (time-string)
"Insert a description-type item with the playback position TIME-STRING.
See `org-timer-item' which this is based on."
- (require 'org)
(let ((itemp (org-in-item-p)) (pos (point)))
(cond
;; In a timer list, insert with `org-list-insert-item',
@@ -200,7 +190,7 @@ See `org-timer-item' which this is based on."
(looking-at org-list-full-item-re)
(goto-char (match-end 0))))
;; In a list of another type, don't break anything: throw an error.
- (itemp (goto-char pos) (error "This is not a timer list"))
+ (itemp (goto-char pos) (user-error "This is not a timer list"))
;; Else, start a new list.
(t
(beginning-of-line)
@@ -213,12 +203,11 @@ See `org-timer-item' which this is based on."
This can be used with the `org-open-at-point-functions' hook."
(interactive)
(save-excursion
- (skip-chars-backward -position-skipchars (point-at-bol))
- (when (looking-at -position-regexp)
- (let ((hours (string-to-number (match-string 1)))
- (mins (string-to-number (match-string 2)))
- (secs (string-to-number (match-string 3))))
- (-enqueue `("seek" ,(+ (* 3600 hours) (* 60 mins) secs) "absolute")
#'ignore)))))
+ (skip-chars-backward ":[:digit:]" (point-at-bol))
+ (when (looking-at "[0-9]+:[0-9]\\{2\\}:[0-9]\\{2\\}")
+ (let ((secs (org-timer-hms-to-secs (match-string 0))))
+ (when (> secs 0)
+ (-enqueue `("seek" ,secs "absolute") #'ignore))))))
)
(provide 'mpv)
- [nongnu] elpa/mpv 6338f0d6b5 12/50: rename to mpv.el, (continued)
- [nongnu] elpa/mpv 6338f0d6b5 12/50: rename to mpv.el, ELPA Syncer, 2021/12/28
- [nongnu] elpa/mpv e3fad297cd 18/50: add README.md, ELPA Syncer, 2021/12/28
- [nongnu] elpa/mpv c6b3fa013c 36/50: Add mpv-run-command function to synchronously run commands, ELPA Syncer, 2021/12/28
- [nongnu] elpa/mpv 9dedf3b7c1 34/50: Monkey-patch org-timer-item instead of reimplementing, ELPA Syncer, 2021/12/28
- [nongnu] elpa/mpv 174cd4b68b 31/50: call expand-file-name on files passed to mpv-play, ELPA Syncer, 2021/12/28
- [nongnu] elpa/mpv 3849da1e45 01/50: root commit, ELPA Syncer, 2021/12/28
- [nongnu] elpa/mpv 33ca8987ed 03/50: work around spurious event messages, ELPA Syncer, 2021/12/28
- [nongnu] elpa/mpv 6fe510798a 26/50: fix mpv-speed-set, ELPA Syncer, 2021/12/28
- [nongnu] elpa/mpv fcdca618df 29/50: add badge for MELPA stable, ELPA Syncer, 2021/12/28
- [nongnu] elpa/mpv d7bb3a7082 40/50: Add sleep and timeout to mpv-kill and mpv-play, ELPA Syncer, 2021/12/28
- [nongnu] elpa/mpv bc89524528 15/50: use timer formatting from org-timer.el,
ELPA Syncer <=
- [nongnu] elpa/mpv b026ae5bb6 46/50: Merge pull request #19 from c1-g/volume, ELPA Syncer, 2021/12/28
- [nongnu] elpa/mpv 1e666079b8 05/50: skip junk at beginning of buffer, ELPA Syncer, 2021/12/28
- [nongnu] elpa/mpv 8c0933630b 08/50: add seek-to-position-at-point, ELPA Syncer, 2021/12/28
- [nongnu] elpa/mpv 03fe7a536a 24/50: add mpv-on-start-hook and mpv-on-exit-hook, ELPA Syncer, 2021/12/28
- [nongnu] elpa/mpv 3021c55fa5 32/50: Merge pull request #1 from magnusstahre/expand-tilde, ELPA Syncer, 2021/12/28
- [nongnu] elpa/mpv f31cbdb94a 37/50: Add convenience functions to get and set properties, ELPA Syncer, 2021/12/28
- [nongnu] elpa/mpv f0f61db3af 47/50: Add COPYING file following GPL, ELPA Syncer, 2021/12/28
- [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