aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYuchen Pei <id@ypei.org>2025-06-29 17:16:44 +1000
committerYuchen Pei <id@ypei.org>2025-06-29 17:16:44 +1000
commit76ecdb1bb0f7f7b670b8885428b91b93ba27e60e (patch)
tree0d751b732aa66caeda247646aa6bfab512f00fe9
parentf29dbe5b84140223e3e9e6ed79c7b67e58a20a5a (diff)
[emacs] emms mark boundaries when soundtrack chosen
-rw-r--r--emacs/.emacs.d/init/ycp-emms.el1
-rw-r--r--emacs/.emacs.d/lisp/my/my-emms.el57
-rw-r--r--manual/singlefile-settings.json6
3 files changed, 44 insertions, 20 deletions
diff --git a/emacs/.emacs.d/init/ycp-emms.el b/emacs/.emacs.d/init/ycp-emms.el
index 2b52b17..0385a75 100644
--- a/emacs/.emacs.d/init/ycp-emms.el
+++ b/emacs/.emacs.d/init/ycp-emms.el
@@ -92,6 +92,7 @@
'my-emms-output-current-track-to-i3bar-file)
(add-hook 'emms-player-finished-hook 'my-emms-score-up-playing)
(add-hook 'emms-player-started-hook 'my-emms-score-up-chosen-bonus)
+ (add-hook 'emms-player-started-hook 'my-emms-playlist-maybe-mark-bounds)
(setq emms-player-next-function 'my-emms-next-track-or-random-group)
(setq emms-players-preference-f 'my-emms-players-preference)
(my-keybind dired-mode-map "e" #'my-dired-add-to-emms)
diff --git a/emacs/.emacs.d/lisp/my/my-emms.el b/emacs/.emacs.d/lisp/my/my-emms.el
index 799c5f3..50c1310 100644
--- a/emacs/.emacs.d/lisp/my/my-emms.el
+++ b/emacs/.emacs.d/lisp/my/my-emms.el
@@ -464,26 +464,49 @@ under /zzz-seren/."
(min end-ln maybe-group-end))))
(cons group-start group-end))))
+(defun my-emms-playlist-mark-bounds (group-end)
+ "Mark bounds of the current track group.
+
+An up arrow at the first played in the current group, and a down
+arrow at the end of the track group."
+ (overlay-put
+ (make-overlay (point) (point))
+ 'before-string (propertize
+ "x" 'display
+ `(left-fringe up-arrow emms-playlist-selected-face)))
+ (save-excursion
+ (goto-line (1- group-end))
+ (overlay-put
+ (make-overlay (point) (point))
+ 'before-string (propertize
+ "x" 'display
+ `(left-fringe down-arrow emms-playlist-selected-face)))))
+
(defun my-emms-playlist-random-group ()
(interactive)
(with-current-emms-playlist
(remove-overlays)
- (goto-line (1+ (random (count-lines (point-min) (point-max)))))
- (pcase-let ((`(,group-start . ,group-end) (my-emms-playlist-group-bounds)))
- (goto-line group-start)
- (overlay-put
- (make-overlay (point) (point))
- 'before-string (propertize
- "x" 'display
- `(left-fringe down-arrow emms-playlist-selected-face)))
- (save-excursion
- (goto-line (1- group-end))
- (overlay-put
- (make-overlay (point) (point))
- 'before-string (propertize
- "x" 'display
- `(left-fringe up-arrow emms-playlist-selected-face))))
- (emms-playlist-mode-play-current-track))))
+ (let ((random-line (1+ (random (count-lines (point-min) (point-max))))))
+ (goto-line random-line)
+ (pcase-let ((`(,group-start . ,group-end) (my-emms-playlist-group-bounds)))
+ (message "my-emms-playlist-random-group: (%d, %d)" random-line group-start)
+ (goto-line group-start)
+ (my-emms-playlist-mark-bounds group-end)
+ (emms-playlist-mode-play-current-track)))))
+
+(defun my-emms-playlist-maybe-mark-bounds ()
+ "Used as an `emms-player-started-hook'.
+
+If the last command is `emms-playlist-mode-play-smart' i.e. the
+user manually chose the track to play, and if
+`emms-player-next-function' is
+`my-emms-next-track-or-random-group', then mark boundaries since
+it would not have been marked otherwise."
+ (when (and (eq last-command 'emms-playlist-mode-play-smart)
+ (eq emms-player-next-function 'my-emms-next-track-or-random-group))
+ (with-current-emms-playlist
+ (pcase-let ((`(_ . ,group-end) (my-emms-playlist-group-bounds)))
+ (my-emms-playlist-mark-bounds group-end)))))
(defun my-emms-next-track-or-random-group ()
(interactive)
@@ -563,7 +586,7 @@ character."
(defvar my-emms-score-delta 1)
(defun my-emms-score-up-playing ()
- "Increase score by `my-emms-score-delta', then reset it to 1."
+ "Increase score by `my-emms-score-delta', then reset the score delta to 1."
(emms-score-change-score
my-emms-score-delta
(my-emms-get-display-name-1 (emms-score-current-selected-track-filename)))
diff --git a/manual/singlefile-settings.json b/manual/singlefile-settings.json
index 67c8cd6..3cdd2a8 100644
--- a/manual/singlefile-settings.json
+++ b/manual/singlefile-settings.json
@@ -51,7 +51,7 @@
"loadDeferredImagesDispatchScrollEvent": false,
"loadDeferredImagesBeforeFrames": false,
"contextMenuEnabled": true,
- "filenameTemplate": "%if-empty<{page-title}|No title> ({date-locale} {time-locale}).{filename-extension}",
+ "filenameTemplate": "%if-empty<{page-title}|No title>.{filename-extension}",
"filenameMaxLength": "192",
"filenameMaxLengthUnit": "bytes",
"filenameReplacementCharacter": "_",
@@ -62,7 +62,7 @@
"maxResourceSize": 10,
"networkTimeout": 0,
"confirmFilename": false,
- "filenameConflictAction": "uniquify",
+ "filenameConflictAction": "overwrite",
"displayInfobar": true,
"displayStats": false,
"backgroundSave": true,
@@ -182,4 +182,4 @@
],
"maxParallelWorkers": 12,
"processInForeground": false
-}
+} \ No newline at end of file