emms-help
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[emms-help] Some extension for EMMS.


From: Andy Stewart
Subject: [emms-help] Some extension for EMMS.
Date: Sun, 19 Oct 2008 15:51:01 +0800
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux)

Hi, everyone.

I use EMMS everyday.

Below is my extension EMMS.

------------------------------> Extensions start <------------------------------

(defun emms-play-matching (pattern)
  "Play matching song."
  (interactive "sPlay song matching: ")
  (when emms-playlist-buffer
    (save-excursion
      (set-buffer emms-playlist-buffer)
      (emms-playlist-clear)))
  (emms-play-find my-music-default-directory pattern))

(defun emms-jump-to-file ()
  "Jump to postion of current playing music."
  (interactive)
  (let* ((music-file (emms-track-name (emms-playlist-current-selected-track))) 
;get playing music file name
         (music-folder (file-name-directory music-file))) ;get playing music 
directory
    (dired-x-find-file music-folder)                      ;jump to music 
directory
    (dired-goto-file music-file)))                        ;jump to music file 
postion

(defun emms-delete-file-from-disk ()
  "Delete this file from disk."
  (interactive)
  (let* ((current-track (emms-track-name (emms-playlist-track-at))))
    (when (yes-or-no-p (format "Are you really want to delete \' %s \' from 
disk? " current-track))
      (if (string-equal current-track (emms-playlist-play-filename))
          (emms-stop))
      (emms-playlist-mode-kill-entire-track)
      (dired-delete-file current-track)
      (message (format "Have delete \' %s \' from disk." current-track)))))

(defun emms-playlist-play-filename ()
  "Return the filename the current play."
  (cdr (assoc 'name (emms-playlist-current-selected-track))))

(defun emms-play-online()
  "Play online music use emms."
  (interactive)
  (if (w3m-anchor)
      (emms-play-url (w3m-anchor))
    (message "No valid url in here.")))

(defun emms-mark-track-and-move-next ()
  "Mark the current track, and move next track."
  (interactive)
  (call-interactively 'emms-mark-track)
  (call-interactively 'next-line))

(defun emms-mark-unmark-track-and-move-next ()
  "Unmark the current track, and move next track."
  (interactive)
  (call-interactively 'emms-mark-unmark-track)
  (call-interactively 'next-line))


(defun emms-tag-editor-next-same-field ()
  "Jump to next same field."
  (interactive)
  (let (filed-name)
    (save-excursion
      (beginning-of-line)
      (if (search-forward-regexp "^[^ ]*[ \t]+= " (line-end-position) t)
          (setq filed-name (buffer-substring (match-beginning 0) (match-end 
0)))))
    (if (not (null filed-name))
        (progn
          (search-forward-regexp filed-name (point-max) t)
          (goto-char (match-end 0))))))

(defun emms-tag-editor-prev-same-field ()
  "Jump to previous same field."
  (interactive)
  (let (filed-name)
    (save-excursion
      (beginning-of-line)
      (if (search-forward-regexp "^[^ ]*[ \t]+= " (line-end-position) t)
          (setq filed-name (buffer-substring (match-beginning 0) (match-end 
0)))))
    (if (not (null filed-name))
        (progn
          (beginning-of-line)
          (search-backward-regexp filed-name (point-min) t)
          (goto-char (match-end 0))
          ))))


(defun emms-tag-editor-set-all+ ()
  "Set TAG to VALUE in all tracks.
If transient-mark-mode is turned on, you can apply the command to
a selected region.

 If `transient-mark-mode' is on and the mark is active, the
changes will only take effect on the tracks in the region.

This function is extension `emms-tag-editor-set-all',
make user can modified TAG content, not just type."
  (interactive)
  (let (tag current-value value)
    (setq tag (completing-read "Set tag: " emms-tag-editor-tags nil t))
    (save-excursion
      (goto-char (point-min))
      (search-forward-regexp (concat "^" tag "[ \t]+= ") (point-max) t 1)
      (setq current-value (buffer-substring (match-end 0) (line-end-position))))
    (setq value (read-from-minibuffer "To: " current-value))
    (save-excursion
      (save-restriction
        (if (and mark-active transient-mark-mode)
            (narrow-to-region (region-beginning) (region-end)))
        (goto-char (point-min))
        (while (re-search-forward (concat "^" (regexp-quote tag)) nil t)
          (skip-chars-forward " \t=")
          (delete-region (point) (line-end-position))
          (insert value))))))


(defun emms-tag-editor-set-tracknumber ()
  "Set `info-tracknumber' tag with a init increment value
and special alternation number."
  (interactive)
  (let (init-number alternation-number times)
    (setq init-number (read-number "Init number: " 1))
    (setq alternation-number (read-number "Alternation number: " 1))
    (setq times 0)
    (save-excursion
      (save-restriction
        (if (and mark-active transient-mark-mode)
            (narrow-to-region (region-beginning) (region-end)))
        (goto-char (point-min))
        (while (re-search-forward (concat "^info-tracknumber") nil t)
          (skip-chars-forward " \t=")
          (delete-region (point) (line-end-position))
          (insert (format "%s" (+ init-number (* alternation-number times))))
          (setq times (1+ times))
          )))))

(defun emms-mark-duplicate-track ()
  "Mark duplicate track."
  (interactive)
  (let (current-track-title next-track-title)
    (emms-playlist-sort-by-info-title)
    (goto-char (point-min))
    (while (not (eobp))
      (save-excursion
        (setq current-track-title (emms-playlist-current-title))
        (forward-line +1)
        (setq next-track-title (emms-playlist-current-title)))
      (if (string-equal current-track-title next-track-title)
          (progn
            (emms-mark-track)
            (forward-line +1)
            (emms-mark-track))
        (forward-line +1)))
    (emms-first-mark-track)))

(defun emms-first-mark-track ()
  "Jump to first mark track."
  (interactive)
  (let ((original-point (point))
        (original-column (current-column)))
    (goto-char (point-min))
    (if (search-forward-regexp (format "^%c" emms-mark-char) nil t)
        (goto-column original-column)
      (goto-char original-point))))

(defun emms-last-mark-track ()
  "Jump to last mark track."
  (interactive)
  (let ((original-point (point))
        (original-column (current-column)))
    (goto-char (point-max))
    (if (search-backward-regexp (format "^%c" emms-mark-char) nil t)
        (goto-column original-column)
      (goto-char original-point))))

(defun emms-next-mark-track ()
  "Jump to next mark track."
  (interactive)
  (let ((original-point (point))
        (original-column (current-column)))
    (if (bolp)
        (forward-char +1))
    (if (search-forward-regexp (format "^%c" emms-mark-char) nil t)
        (goto-column original-column)
      (goto-char original-point))))

(defun emms-prev-mark-track ()
  "Jump to previous mark track."
  (interactive)
  (let ((original-point (point))
        (original-column (current-column)))
    (if (not (bolp))
        (beginning-of-line))
    (if (search-backward-regexp (format "^%c" emms-mark-char) nil t)
        (goto-column original-column)
      (goto-char original-point))))

(defun emms-playlist-current-title ()
  "Return the filename the current play."
  (cdr (assoc 'info-title (emms-playlist-track-at))))
    
------------------------------> Extensions end   <------------------------------

Enjoy! :)

 -- Andy.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]