aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohnathan Rabkin <yonirabkin@member.fsf.org>2013-08-16 13:27:37 -0400
committerJohnathan Rabkin <yonirabkin@member.fsf.org>2013-08-16 13:27:37 -0400
commitbc052418b84f343478e80f9dde44a419de9fd6ee (patch)
tree86af084b7396cf6f3bb74e427bec992f2b4a993a
parent5d8b53a421fd7bf486316a81ee4e7ab0658c17a9 (diff)
* lisp/emms-score.el: Stop `emms-score-load-hash' from reading empty score file.
Reads the score file into a string, then only proceeds if the string is not empty. I ran it myself, and appears to be working correctly. Thanks to Ian D.
-rw-r--r--lisp/emms-score.el17
1 files changed, 9 insertions, 8 deletions
diff --git a/lisp/emms-score.el b/lisp/emms-score.el
index 78e17db..f4cb5cc 100644
--- a/lisp/emms-score.el
+++ b/lisp/emms-score.el
@@ -246,14 +246,15 @@ See also `emms-next-noerror'."
"Load score hash from `emms-score-file'."
(interactive)
(if (file-exists-p emms-score-file)
- (mapc (lambda (elt)
- (puthash (car elt) (cdr elt) emms-score-hash))
- (read
- (with-temp-buffer
- (emms-insert-file-contents emms-score-file)
- (buffer-string))))
- ;; when file not exists, make empty but valid score file
- (emms-score-save-hash)))
+ (let ((score-string (with-temp-buffer
+ (emms-insert-file-contents emms-score-file)
+ (buffer-string))))
+ (if (> (length score-string) 0)
+ (mapc (lambda (elt)
+ (puthash (car elt) (cdr elt) emms-score-hash))
+ (read score-string)))
+ ;; when file not exists, make empty but valid score file
+ (emms-score-save-hash))))
(defun emms-score-get-plist (filename)
(gethash filename emms-score-hash))