From f41ab1b873b476f76ca380b3252d7bb855f394e0 Mon Sep 17 00:00:00 2001 From: Pierre Neidhardt Date: Fri, 22 Feb 2019 16:58:48 +0100 Subject: [PATCH] EMMS: Use emms-browser-cache-thumbnail-async to make helm-emms usable --- .emacs.d/lisp/init-emms.el | 4 +++- .emacs.d/lisp/patch-emms.el | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 .emacs.d/lisp/patch-emms.el diff --git a/.emacs.d/lisp/init-emms.el b/.emacs.d/lisp/init-emms.el index 59117263..f640c1db 100644 --- a/.emacs.d/lisp/init-emms.el +++ b/.emacs.d/lisp/init-emms.el @@ -6,11 +6,13 @@ (emms-all) (emms-history-load) +(require 'patch-emms) + (setq emms-player-list (list emms-player-mpv) emms-source-file-default-directory (file-truename "~/music") emms-source-file-directory-tree-function 'emms-source-file-directory-tree-find ;; Cover thumbnails. - emms-browser-covers 'emms-browser-cache-thumbnail) + emms-browser-covers 'emms-browser-cache-thumbnail-async) (add-to-list 'emms-player-mpv-parameters "--no-audio-display") (add-to-list 'emms-info-functions 'emms-info-cueinfo) diff --git a/.emacs.d/lisp/patch-emms.el b/.emacs.d/lisp/patch-emms.el new file mode 100644 index 00000000..633c4a20 --- /dev/null +++ b/.emacs.d/lisp/patch-emms.el @@ -0,0 +1,19 @@ +;; REVIEW: The following should be included in EMMS 5.2. + +(defvar emms-browser--cache-hash nil) +(defun emms-browser-cache-thumbnail-async (dir size) + (unless emms-browser--cache-hash + (setq emms-browser--cache-hash (make-hash-table :test 'equal))) + (let* ((key (cons dir size)) + (val (gethash key emms-browser--cache-hash))) + (or val + (puthash key (emms-browser-cache-thumbnail dir size) + emms-browser--cache-hash)))) + +(defun emms-browser-clear-cache-hash () + (interactive) + (clrhash emms-browser--cache-hash)) + +(setq emms-browser-covers 'emms-browser-cache-thumbnail-async) + +(provide 'patch-emms)