Some extension for EMMS.

View: New views
5 Messages — Rating Filter:   Alert me  

Some extension for EMMS.

by Andy Stewart-5 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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.



_______________________________________________
Emms-help mailing list
Emms-help@...
http://lists.gnu.org/mailman/listinfo/emms-help

Re: Some extension for EMMS.

by Yoni Rabkin-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Andy Stewart <lazycat.manatee@...> writes:

> Hi, everyone.
>
> I use EMMS everyday.
>
> Below is my extension EMMS.

Have you thought of adding some of them to the Emacswiki
[http://www.emacswiki.org/emacs/EMMS] or thereabouts?

--
   "Cut your own wood and it will warm you twice"



_______________________________________________
Emms-help mailing list
Emms-help@...
http://lists.gnu.org/mailman/listinfo/emms-help

Re: Some extension for EMMS.

by Andy Stewart-5 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Yoni Rabkin <yoni@...> writes:

> Andy Stewart <lazycat.manatee@...> writes:
>
>> Hi, everyone.
>>
>> I use EMMS everyday.
>>
>> Below is my extension EMMS.
>
> Have you thought of adding some of them to the Emacswiki
> [http://www.emacswiki.org/emacs/EMMS] or thereabouts?

If can, can you modified those functions and add to EMMS?
I think some functions will very useful for EMMS (example,
emms-mark-duplicate-track. etc.)



_______________________________________________
Emms-help mailing list
Emms-help@...
http://lists.gnu.org/mailman/listinfo/emms-help

Re: Re: Some extension for EMMS.

by Yoni Rabkin-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Andy Stewart <lazycat.manatee@...> writes:

> Yoni Rabkin <yoni@...> writes:
>
>> Andy Stewart <lazycat.manatee@...> writes:
>>
>>> Hi, everyone.
>>>
>>> I use EMMS everyday.
>>>
>>> Below is my extension EMMS.
>>
>> Have you thought of adding some of them to the Emacswiki
>> [http://www.emacswiki.org/emacs/EMMS] or thereabouts?
>
> If can, can you modified those functions and add to EMMS?
> I think some functions will very useful for EMMS (example,
> emms-mark-duplicate-track. etc.)

The best way to get them included into Emms would be if you prepared a
patch against the git repo and sent that into the list for inclusion (or
just joined up as a developer). Waiting for someone else to integrate
these into Emms for you might take an unbounded amount of time.

Otherwise, as standalone functions they are best included on the wiki
page so people can add them to their own installations.

--
   "Cut your own wood and it will warm you twice"



_______________________________________________
Emms-help mailing list
Emms-help@...
http://lists.gnu.org/mailman/listinfo/emms-help

Re: Re: Some extension for EMMS.

by Michael Olson-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Yoni Rabkin <yoni@...> writes:

> The best way to get them included into Emms would be if you prepared a
> patch against the git repo and sent that into the list for inclusion
> (or just joined up as a developer). Waiting for someone else to
> integrate these into Emms for you might take an unbounded amount of
> time.

Also, a copyright assignment would need to be made.  I've sent Andy the
instructions off-list.

--
|       Michael Olson  |  FSF Associate Member #652     |
| http://mwolson.org/  |  Hobbies: Lisp, HCoop          |
| Projects: Emacs, Muse, ERC, EMMS, ErBot, DVC, Planner |
`-------------------------------------------------------'


_______________________________________________
Emms-help mailing list
Emms-help@...
http://lists.gnu.org/mailman/listinfo/emms-help