From 888e703448bf5c0ed70469e0912fa070e327c5fb Mon Sep 17 00:00:00 2001 From: Daniel Borchmann Date: Sat, 2 Mar 2019 13:37:05 +0100 Subject: [PATCH] =?UTF-8?q?[Music]=20Introduce=20=E2=80=98db/music?= =?UTF-8?q?=E2=80=99=20and=20move=20code=20there?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit All music related functions that do not directly depend on EMMS will now go into ‘db/music’, with the intention that if we in the future replace EMMS with something else, the API provided by ‘db/music’ will still be valid. This does not mean, however, that functions in ‘db/music’ may not use functions from EMMS. --- init.el | 14 ++++++++++++-- site-lisp/db-emms.el | 24 ------------------------ site-lisp/db-music.el | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 47 insertions(+), 26 deletions(-) create mode 100644 site-lisp/db-music.el diff --git a/init.el b/init.el index 24c24c0..e570c95 100644 --- a/init.el +++ b/init.el @@ -2054,8 +2054,7 @@ search commands like `db/helm-shortcuts’." :config (require 'emms)) (use-package db-emms - :commands (db/play-playlist - db/emms-source-file-directory-tree-find + :commands (db/emms-source-file-directory-tree-find db/emms-track-description db/emms-playlist-mode-insert-track emms-control/body)) @@ -2070,6 +2069,17 @@ search commands like `db/helm-shortcuts’." (require 'emms) (require 'helm-adaptive))) +(use-package db-music + :commands (db/play-playlist)) + +(defcustom db/playlist nil + "List of songs to include in random playlist." + :group 'personal-settings + :type '(alist :value-type (choice (const :tag "Undecided" :undecided) + (const :tag "Include" :include) + (const :tag "Exclude" :exclude)) + :key-type file)) + ;; * Shells and such diff --git a/site-lisp/db-emms.el b/site-lisp/db-emms.el index a971939..ba8e6e4 100644 --- a/site-lisp/db-emms.el +++ b/site-lisp/db-emms.el @@ -31,30 +31,6 @@ (declare-function string-remove-prefix "subr-x") (declare-function emms-with-inhibit-read-only-t "emms") - -;; Custom playlist - -(defun db/play-playlist () - "Play `db/personal-playlist’ in dedicated EMMS buffer." - (interactive) - (require 'emms) - (save-window-excursion - (let ((music-buffer-name "*EMMS Playlist* -- Misc")) - (unless (get-buffer music-buffer-name) - (emms-playlist-new music-buffer-name)) - (with-current-buffer (get-buffer music-buffer-name) - (emms-stop) - (emms-playlist-set-playlist-buffer) - (emms-playlist-current-clear) - (emms-playlist-current-insert-source - 'emms-insert-directory-tree - (expand-file-name "songs/" emms-source-file-default-directory)) - (goto-char (point-min)) - (emms-shuffle) - ;; (emms-playlist-sort-by-play-count) - (emms-playlist-select-first) - (emms-start))))) - ;; Custom file finder diff --git a/site-lisp/db-music.el b/site-lisp/db-music.el new file mode 100644 index 0000000..0499549 --- /dev/null +++ b/site-lisp/db-music.el @@ -0,0 +1,35 @@ +;;; db-music.el -- Music related stuff -*- lexical-binding: t -*- + +;;; Commentary: + +;;; Code: + + +;; Custom playlist + +(defun db/play-playlist () + "Start playing songs from `db/playlist’" + (interactive) + (require 'emms) + (save-window-excursion + (let ((music-buffer-name "*EMMS Playlist* -- Personal")) + (unless (get-buffer music-buffer-name) + (emms-playlist-new music-buffer-name)) + (with-current-buffer (get-buffer music-buffer-name) + (emms-stop) + (emms-playlist-set-playlist-buffer) + (emms-playlist-current-clear) + (dolist (track db/playlist) + (when (eq :include (cdr track)) + (emms-playlist-current-insert-source 'emms-insert-file (car track)))) + (goto-char (point-min)) + (emms-shuffle) + (emms-playlist-select-first) + (emms-start))))) + + +;; End + +(provide 'db-music) + +;;; db-music ends here