diff options
author | Wenbin Ye <wenbinye@gmail.com> | 2006-11-27 15:41:00 +0000 |
---|---|---|
committer | Wenbin Ye <wenbinye@gmail.com> | 2006-11-27 15:41:00 +0000 |
commit | 3ba64d032d74107a7e0cbaf376a6d803b0883db9 (patch) | |
tree | f1caf215413a7138c871d59de476e80e7ca6e3b9 | |
parent | 358e193b021835ff0b9de91b35959ed518bb9455 (diff) |
Fix lyrics minibuffer display. Amixer display playback and more useful commands
darcs-hash:20061127154113-1e472-b3fb81d5e2e6e3669932a4927e30d18f2cb118da.gz
-rw-r--r-- | emms-lyrics.el | 71 | ||||
-rw-r--r-- | emms-volume-amixer.el | 37 |
2 files changed, 66 insertions, 42 deletions
diff --git a/emms-lyrics.el b/emms-lyrics.el index 22bfa13..54a7417 100644 --- a/emms-lyrics.el +++ b/emms-lyrics.el @@ -114,6 +114,7 @@ at time-i, display lyric-i.") (defvar emms-lyrics-mode-line-string "" "current lyric.") +(defvar emms-lyrics-find-lyric-function nil) (defun emms-lyrics-read-file (file) "Read a lyric file(LRC format). FILE should end up with \".lrc\", its content looks like one of the @@ -125,38 +126,39 @@ following: FILE should be under the same directory as the music file, or under `emms-lyrics-dir'." - (when (eq 'file (emms-track-get - (emms-playlist-current-selected-track) - 'type)) - (unless (file-exists-p file) - (setq file (emms-lyrics-find-lyric file))) - (when (and file (not (string= file "")) (file-exists-p file)) - (with-temp-buffer - (let ((coding-system-for-read emms-lyrics-coding-system)) - (insert-file-contents file) - (while (search-forward-regexp "\\[[0-9:.]+\\].*" nil t) - (let ((lyric-string (match-string 0)) - (time 0) - (lyric "")) - (setq lyric - (emms-replace-regexp-in-string ".*\\]" "" lyric-string)) - (while (string-match "\\[[0-9:.]+\\]" lyric-string) - (let* ((time-string (match-string 0 lyric-string)) - (semi-pos (string-match ":" time-string))) - (setq time - (+ (* (string-to-number - (substring time-string 1 semi-pos)) - 60) - (string-to-number - (substring time-string - (1+ semi-pos) - (1- (length time-string)))))) - (setq lyric-string - (substring lyric-string (length time-string))) - (setq emms-lyrics-alist - (append emms-lyrics-alist `((,time ,lyric)))) - (setq time 0)))))) - t)))) + (if (eq 'file (emms-track-get + (emms-playlist-current-selected-track) + 'type)) + (unless (file-exists-p file) + (setq file (emms-lyrics-find-lyric file))) + (setq file (funcall emms-lyrics-find-lyric-function file))) + (when (and file (not (string= file "")) (file-exists-p file)) + (with-temp-buffer + (let ((coding-system-for-read emms-lyrics-coding-system)) + (insert-file-contents file) + (while (search-forward-regexp "\\[[0-9:.]+\\].*" nil t) + (let ((lyric-string (match-string 0)) + (time 0) + (lyric "")) + (setq lyric + (emms-replace-regexp-in-string ".*\\]" "" lyric-string)) + (while (string-match "\\[[0-9:.]+\\]" lyric-string) + (let* ((time-string (match-string 0 lyric-string)) + (semi-pos (string-match ":" time-string))) + (setq time + (+ (* (string-to-number + (substring time-string 1 semi-pos)) + 60) + (string-to-number + (substring time-string + (1+ semi-pos) + (1- (length time-string)))))) + (setq lyric-string + (substring lyric-string (length time-string))) + (setq emms-lyrics-alist + (append emms-lyrics-alist `((,time ,lyric)))) + (setq time 0)))))) + t))) (defun emms-lyrics-start () "Start displaying lryics." @@ -169,7 +171,7 @@ FILE should be under the same directory as the music file, or under 'name))) (emms-lyrics-read-file (emms-replace-regexp-in-string - (file-name-extension file) "lrc" file))) + (concat "\\." (file-name-extension file) "\\'") ".lrc" file))) (emms-lyrics-set-timer))) (defun emms-lyrics-stop () @@ -332,7 +334,8 @@ display." (format emms-lyrics-display-format lyric)) (force-mode-line-update)) (when emms-lyrics-display-on-minibuffer - (message lyric)))) + (unless (minibuffer-window-active-p (selected-window)) + (message lyric))))) (defun emms-lyrics-find-lyric (file) "Use `emms-source-file-gnu-find' to find lrc FILE. You should specify diff --git a/emms-volume-amixer.el b/emms-volume-amixer.el index 7a35435..379dfdb 100644 --- a/emms-volume-amixer.el +++ b/emms-volume-amixer.el @@ -49,17 +49,38 @@ (defun emms-volume-amixer-sset-master (var) "Change amixer master volume by VAR." - (start-process "mixer" nil "amixer" "sset" emms-volume-amixer-control var)) - -(defun emms-volume-amixer-raise () - "Increase volume by 2%." - (interactive) - (emms-volume-amixer-sset-master "2%+")) + (message "Playback channels: %s" + (with-temp-buffer + (when (zerop + (call-process "amixer" nil (current-buffer) nil + "sset" emms-volume-amixer-control + (format "%d%%%s" (abs var) + (if (< var 0) "-" "+")))) + (if (re-search-backward "\\[\\([0-9]+%\\)\\]" nil t) + (match-string 1)))))) + +(defvar emms-volume-amixer-raise-commands + '(?p ?k up ?+ ?=)) +(defvar emms-volume-amixer-lower-commands + '(?n ?j down ?-)) + +(defun emms-volume-amixer-raise (&optional arg) + (interactive "P") + (if arg + (emms-volume-amixer-sset-master -2) + (emms-volume-amixer-sset-master 2)) + (let (command) + (while (progn + (setq command (read-event)) + (cond ((member command emms-volume-amixer-raise-commands) + (emms-volume-amixer-sset-master 2)) + ((member command emms-volume-amixer-lower-commands) + (emms-volume-amixer-sset-master -2))))) + (setq unread-command-events (list command)))) (defun emms-volume-amixer-lower () - "Decrease volume by 2%." (interactive) - (emms-volume-amixer-sset-master "2%-")) + (emms-volume-amixer-raise -1)) (provide 'emms-volume-amixer) |