I'm sending these patches to the list as well.
Tue Dec 13 21:15:58 CST 2005 [EMAIL PROTECTED]
* Added `emms-playlist-sort-by-score'.
Tue Dec 13 21:11:57 CST 2005 [EMAIL PROTECTED]
* Fixed emms-score.el to accommordate with changes in EMMS2. I've also
reorganized the code structure a little bit and added bunches of new
user interface functions.
--
William
[Added `emms-playlist-sort-by-score'.
[EMAIL PROTECTED] {
hunk ./emms-playlist-sort.el 34
+(require 'emms-score)
+
hunk ./emms-playlist-sort.el 41
- ,(format "Sort emms playlist by %s." attribute)
+ ,(format "Sort emms playlist by %s, increasingly." attribute)
hunk ./emms-playlist-sort.el 55
+(defun emms-playlist-sort-by-score ()
+ "Sort emms playlist by score, decreasingly."
+ (interactive)
+ (emms-playlist-sort
+ (lambda (a b)
+ (> (emms-score-get-score (emms-track-get a 'name))
+ (emms-score-get-score (emms-track-get b 'name))))))
+
hunk ./emms-playlist-sort.el 79
-(define-key emms-playlist-mode-map
- emms-playlist-sort-prefix
- emms-playlist-sort-map)
+(eval-after-load "emms-playlist-sort.el"
+ (define-key emms-playlist-mode-map
+ emms-playlist-sort-prefix
+ emms-playlist-sort-map))
hunk ./emms-playlist-sort.el 104
-
}
[Fixed emms-score.el to accommordate with changes in EMMS2. I've also
[EMAIL PROTECTED]
reorganized the code structure a little bit and added bunches of new
user interface functions.
] {
hunk ./emms-score.el 1
-;;; emms-scores.el --- Scoring system for mp3player
+;;; emms-score.el --- Scoring system for mp3player
hunk ./emms-score.el 56
+;; TODO: (xwl)
+;; 1. show score on playlist buffer?
+;; 2. bug: everything(playing time, lyrics, ...) disppears on mode line
+;; when calling `emms-score-next-noerror'.
+
hunk ./emms-score.el 67
-(add-hook 'kill-emacs-hook 'emms-score-save-hash)
-
hunk ./emms-score.el 72
+
+;;; User Interfaces
+
+(defun emms-score (arg)
+ "Turn on emms-score if prefix argument ARG is a positive integer,
+off otherwise."
+ (interactive "p")
+ (if (and arg (> arg 0))
+ (progn
+ (emms-score-load-hash)
+ (remove-hook 'emms-player-finished-hook 'emms-next-noerror)
+ (add-hook 'emms-player-finished-hook 'emms-score-next-noerror)
+ (add-hook 'kill-emacs-hook 'emms-score-save-hash))
+ (emms-score-save-hash)
+ (remove-hook 'emms-player-finished-hook 'emms-score-next-noerror)
+ (add-hook 'emms-player-finished-hook 'emms-next-noerror)
+ (remove-hook 'kill-emacs-hook 'emms-score-save-hash)))
+
hunk ./emms-score.el 91
- "Change the current MOOD.
+ "Change the current MOOD.
hunk ./emms-score.el 97
+(defun emms-score-up-playing ()
+ (interactive)
+ (if emms-player-playing-p
+ (emms-score-change-score 1 (emms-score-current-selected-track-filename))
+ (error "No track currently playing")))
+
+(defun emms-score-down-playing ()
+ (interactive)
+ (if emms-player-playing-p
+ (emms-score-change-score -1 (emms-score-current-selected-track-filename))
+ (error "No track currently playing")))
+
+(defun emms-score-up-file-on-line ()
+ (interactive)
+ (emms-score-change-score 1 (emms-score-track-at-filename)))
+
+(defun emms-score-down-file-on-line ()
+ (interactive)
+ (emms-score-change-score -1 (emms-score-track-at-filename)))
+
+(defun emms-score-less-tolerant ()
+ "Only play mp3 with a higher score"
+ (interactive)
+ (setq emms-score-min-score (+ emms-score-min-score 1))
+ (message "Will play songs with a score >= %d" emms-score-min-score))
+
+(defun emms-score-more-tolerant ()
+ "Allow playing of mp3 with a lower score."
+ (interactive)
+ (setq emms-score-min-score (- emms-score-min-score 1))
+ (message "Will play songs with a score >= %d" emms-score-min-score))
+
+(defun emms-score-set-playing (score)
+ "Set score for current playing track."
+ (interactive "nSet score for playing track: ")
+ (if emms-player-playing-p
+ (emms-score-change-score score
(emms-score-current-selected-track-filename))
+ (error "No track currently playing")))
+
+(defun emms-score-set-file-on-line (score)
+ "Set score for track at point in emms-playlist buffer."
+ (interactive "nSet score for track at point: ")
+ (emms-score-change-score score (emms-score-track-at-filename)))
+
+(defun emms-score-set-tolerance (tolerance)
+ "Allow playing tracks with a score >= tolerance."
+ (interactive "nSet tolerance: ")
+ (setq emms-score-min-score tolerance)
+ (message "Will play songs with a score >= %d" emms-score-min-score))
+
+(defun emms-score-show ()
+ "Show current track's score in minibuf."
+ (interactive)
+ (message "track/tolerance score: %d/%d"
+ (emms-score-get-score
+ (emms-score-current-selected-track-filename))
+ emms-score-min-score))
+
+
+;;; Internal Functions
+
+(defun emms-score-current-selected-track-filename ()
+ "Return filename of current selected track."
+ (emms-track-get (emms-playlist-current-selected-track) 'name))
+
+(defun emms-score-track-at-filename ()
+ "Return file of track at point in emms-playlist buffer."
+ (emms-track-get (emms-playlist-track-at) 'name))
+
+;; TODO: Better merge this into `emms-next-noerror' in `emms.el'.(xwl)
+(defun emms-score-next-noerror ()
+ "Modify `emms-next-noerror' with score check.
+
+Better merge this into `emms-next-noerror' in `emms.el'."
+ (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"))))
+
hunk ./emms-score.el 217
- (puthash filename
- (plist-put sp emms-score-current-mood (+ sc score))
+ (puthash filename
+ (plist-put sp emms-score-current-mood (+ sc score))
hunk ./emms-score.el 222
-(defun emms-score-up-playing ()
- (interactive)
- (if emms-player-playing-p
- (emms-score-change-score 1 (emms-playlist-current-selected-track))
- (error "No track currently playing")))
-
-(defun emms-score-down-playing ()
- (interactive)
- (if emms-player-playing-p
- (emms-score-change-score -1 (emms-playlist-current-selected-track))
- (error "No track currently playing")))
-
-(defun emms-score-up-file-on-line ()
- (interactive)
- (emms-score-change-score 1 (emms-playlist-current-selected-track)))
-
-(defun emms-score-down-file-on-line ()
- (interactive)
- (emms-score-change-score -1 (emms-playlist-current-selected-track)))
-
-(defun emms-score (arg)
- "Turn on emms-score if prefix argument ARG is a positive integer,
-off otherwise."
- (interactive "p")
- (if (and arg (> arg 0))
- (progn
- (emms-score-load-hash)
- (remove-hook 'emms-player-stopped-hook 'emms-next-noerror)
- (add-hook 'emms-player-stopped-hook 'emms-score-next-noerror))
- (emms-score-save-hash)
- (remove-hook 'emms-player-stopped-hook 'emms-score-next-noerror)
- (add-hook 'emms-player-stopped-hook 'emms-next-noerror)))
-
-(defun emms-score-next-noerror ()
- "Play the next track in the playlist, but don't signal an error when
-we're at the end. This should be called when no player is playing.
-This is a suitable function to put in `emms-player-stopped-hook'."
- (interactive)
- (when emms-player-playing-p
- (error "A track is already playing."))
- (if (emms-playlist-next)
- (if (emms-score-check-score (emms-playlist-current-selected-track))
- (emms-start)
- (emms-score-next-noerror))
- (message "No track in playlist that matches your score anymore")))
-
hunk ./emms-score.el 223
- (puthash filename (list emms-score-current-mood emms-score-default-score)
+ (puthash filename
+ `(,emms-score-current-mood ,emms-score-default-score)
hunk ./emms-score.el 234
-
+
hunk ./emms-score.el 237
-
-(defun emms-score-lower-tolerance ()
- "Only play mp3 with a higher score"
- (interactive)
- (setq emms-score-min-score (+ emms-score-min-score 1)))
-
-(defun emms-score-be-more-tolerant ()
- "Allow playing of mp3 with a lower score"
- (interactive)
- (setq emms-score-min-score (- emms-score-min-score 1)))
}
_______________________________________________
Emms-help mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/emms-help