[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/mpv 0579b5c707 09/50: support inserting org timer list ite
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/mpv 0579b5c707 09/50: support inserting org timer list items |
Date: |
Tue, 28 Dec 2021 00:58:35 -0500 (EST) |
branch: elpa/mpv
commit 0579b5c707c506cb6186c92cef3f52ea16a60235
Author: Johann Klähn <kljohann@gmail.com>
Commit: Johann Klähn <kljohann@gmail.com>
support inserting org timer list items
---
mpv-mode.el | 39 ++++++++++++++++++++++++++++++++++-----
1 file changed, 34 insertions(+), 5 deletions(-)
diff --git a/mpv-mode.el b/mpv-mode.el
index 0a7b78cb21..3faae03575 100644
--- a/mpv-mode.el
+++ b/mpv-mode.el
@@ -137,17 +137,46 @@ drops unsolicited event messages."
(interactive)
(-enqueue '("cycle" "pause") #'ignore))
-(defun insert-playback-position ()
- "Insert the current playback position at point."
- (interactive)
+(defun insert-playback-position (&optional arg)
+ "Insert the current playback position at point.
+
+When called with a prefix, insert a timer list item like `org-timer-item'."
+ (interactive "P")
(let ((buffer (current-buffer)))
(-enqueue '("get_property" "playback-time")
(lambda (time)
(let* ((secs (truncate time))
(usecs (round (* 1000 (- time secs)))))
(with-current-buffer buffer
- (insert (format-time-string -position-format
- `(0 ,secs ,usecs 0) t))))))))
+ (funcall
+ (if arg #'-position-insert-as-org-item #'insert)
+ (format-time-string -position-format
+ `(0 ,secs ,usecs 0) t))))))))
+
+(defun -position-insert-as-org-item (time-string)
+ "Insert a description-type item with the playback position.
+
+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',
+ ;; then fix the list.
+ ((and itemp (goto-char itemp) (org-at-item-timer-p))
+ (let* ((struct (org-list-struct))
+ (prevs (org-list-prevs-alist struct))
+ (s (concat time-string " :: ")))
+ (setq struct (org-list-insert-item pos struct prevs nil s))
+ (org-list-write-struct struct (org-list-parents-alist struct))
+ (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"))
+ ;; Else, start a new list.
+ (t
+ (beginning-of-line)
+ (org-indent-line)
+ (insert (concat "- " time-string " :: "))))))
(defun seek-to-position-at-point ()
"Jump to playback position as inserted by
`mpv-mode-insert-playback-position'."
- [nongnu] elpa/mpv 059135de39 28/50: version 0.1.0, (continued)
- [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, 2021/12/28
- [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 <=
- [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
- [nongnu] elpa/mpv ec4929ad5d 19/50: fix package header for melpa, ELPA Syncer, 2021/12/28
- [nongnu] elpa/mpv 9bd6d36cc7 50/50: Fix #16, ELPA Syncer, 2021/12/28
- [nongnu] elpa/mpv 32f1478ed2 33/50: Remove dependency on names package, ELPA Syncer, 2021/12/28