From 4cc4dd97c40f4275f1e4aba0ac5964feb1a7e278 Mon Sep 17 00:00:00 2001 From: Yoni Rabkin Date: Sun, 8 Jul 2018 21:23:09 -0400 Subject: * lisp/emms-score.el: Use `emms-ok-track-function' Simplify and correct the way emms-score skips tracks. --- lisp/emms-score.el | 28 ++++++---------------------- 1 file changed, 6 insertions(+), 22 deletions(-) (limited to 'lisp') diff --git a/lisp/emms-score.el b/lisp/emms-score.el index bb6d433..8c783c5 100644 --- a/lisp/emms-score.el +++ b/lisp/emms-score.el @@ -1,7 +1,7 @@ ;;; emms-score.el --- Scoring system for mp3player ;; Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, -;; 2009 Free Software Foundation, Inc. +;; 2009, 2018 Free Software Foundation, Inc. ;; Authors: Jean-Philippe Theberge , ;; Yoni Rabkin @@ -87,13 +87,13 @@ off otherwise." (if (and arg (> arg 0)) (progn (setq emms-score-enabled-p t) - (setq emms-player-next-function 'emms-score-next-noerror) (emms-score-load-hash) + (setq emms-ok-track-function 'emms-score-ok-track-function) (unless noninteractive (add-hook 'kill-emacs-hook 'emms-score-save-hash))) (setq emms-score-enabled-p nil) - (setq emms-player-next-function 'emms-next-noerror) (emms-score-save-hash) + (setq emms-ok-track-function 'emms-default-ok-track-function) (remove-hook 'kill-emacs-hook 'emms-score-save-hash))) ;;;###autoload @@ -209,25 +209,9 @@ The score hash is automatically saved." "Return file of track at point in emms-playlist buffer." (emms-track-get (emms-playlist-track-at) 'name)) -(defun emms-score-next-noerror () - "Run `emms-next-noerror' with score check. -See also `emms-next-noerror'." - (interactive) - (when emms-player-playing-p - (error "A track is already being played")) - (cond (emms-repeat-track - (emms-start)) - ((condition-case nil - (progn - (emms-playlist-current-select-next) - t) - (error nil)) - (if (emms-score-check-score - (emms-score-current-selected-track-filename)) - (emms-start) - (emms-score-next-noerror))) - (t - (message "No next track in playlist")))) +(defun emms-score-ok-track-function (track) + "Decide if to skip or play TRACK." + (emms-score-check-score (emms-track-get track 'name))) (defun emms-score-save-hash () "Save score hash in `emms-score-file'." -- cgit v1.2.3