Skip to content

Potpourri/spacemacs-emms

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

media layer

img/media.png

Table of Contents

Description

Fork note: This layer is based on @alejandroerickson’s PR from syl20bnr/spacemacs#6435.

This layer installs and configures media library management software EMMS.

https://www.gnu.org/software/emms/

Install

To use the media layer:

  • place this repository in one of Spacemacs’s layer directories (~/.emacs.d/private/local/exwm, ~/.spacemacs.d/private/exwm, or ~/.spacemacs.d/layers/exwm)
  • add the layer in your ~/.spacemacs
(setq-default dotspacemacs-configuration-layers '(media))

Optionally, if you have a collection of media files in a single directory tree, you can set the root directory of that tree as EMMS’s default.

(setq emms-source-file-default-directory "/path/to/music/")

When you first open the EMMS browser it will prompt you to add music. It then builds a cache of track info, defaulting to the directory ~/.emacs.d/.cache/emms. Before doing so install a track info reader to properly extract track information, otherwise you will encounter errors and the track info will not be read. We recommend you use TagLib, see EMMS manual - for how-to compile and install. If you use Nix, then see my overlay.

If it compiles successfully, put the executable in your PATH (you can check the value of PATH with the getenv command). Now when you add music it should populate the smart browser properly with names of tracks, albums, artists, etc. Re-add your music by deleting the ~/.emacs.d/.cache/emms directory, where the cache and history are located.

Find the home page and full manual here:

Most importantly, you will need a media player. By default, the media layer is set up to support mpg321, ogg123, mplayer, and vlc. Install one of these and ensure that Emacs can find it in your PATH.

EMMS configuration

The default configuration for EMMS in the media layer does not show tracks in the mode-line, in order to minimise intrusion upon those who do not wish to customise the layer.

EMMS is configured with the following defaults:

  • all stable features of EMMS loaded
  • No track in mode-line
  • F7 to toggle emms smart browse
  • TagLib is the track info reader
  • Several key bindings have been changed to suite evil-mode

Configuring media keys

Configuring media keys (play/pause, next, previous) is system dependent, of course, but once you learn how to map them to terminal commands you can try something like the following:

emacsclient --eval "(emms-pause)" || \
emacsclient  --eval  "(emms-playlist-mode-go)"\
--eval "(goto-line 1)" --eval "(emms-playlist-mode-play-smart)" \
--eval  "(emms-playlist-mode-bury-buffer)" || \
emacsclient --eval "(emms-browser)" \
--eval "(emms-browse-by-album)"  --eval "(emms-browser-goto-random)" \
--eval "(emms-browser-add-tracks-and-play)" || \
say Open and cue up an E M M S playlist in emacs.

If the Emacs server is running and EMMS is loaded with at least one track in the emms-browser, then above command-line instruction will (in order) try to play a paused track, try to play the next track after the cursor in the playlist, choose an album at random and play it, adding the tracks to the playlist. Failing all of that it issues an audible error message (which here uses a buit-in function on Mac OS X).

Commands for previous and next buttons are similar:

 emacsclient --eval "(emms-next)" || \
 emacsclient  --eval  "(emms-playlist-mode-go)" --eval "(goto-line \
	 1)" --eval "(emms-playlist-mode-play-smart)" --eval \
	 "(emms-playlist-mode-bury-buffer)" ||\
	 emacsclient --eval "(emms-browser)"  --eval
	 "(emms-browse-by-album)"  --eval "(emms-browser-goto-random)"
	 --eval "(emms-browser-add-tracks-and-play)" ||  say Open and cue
	 up an E M M S playlist in emacs. 
 emacsclient --eval "(emms-previous)" || \
	 emacsclient  --eval  "(emms-playlist-mode-go)" --eval "(goto-line \
	 1)" --eval "(emms-playlist-mode-play-smart)" --eval \
	 "(emms-playlist-mode-bury-buffer)" ||\
	 emacsclient --eval "(emms-browser)"  --eval
	 "(emms-browse-by-album)"  --eval "(emms-browser-goto-random)"
	 --eval "(emms-browser-add-tracks-and-play)" ||  say Open and cue
	 up an E M M S playlist in emacs.

Setting the media keys on Mac OS X

Mac OS X media keys can be rebound with Karabiner (formerly KeyRemap4MacBook). First, merge the file `private.xml` included in the media layer must with `~/Library/Application\ Support/Karabiner/private.xml`. Second, open Karabiner preferences and press “Reload XML”. Third, and finally, tick the three boxes related to EMMS.

Key bindings

EMMS browser and playlist modes can be access with leader keys. In Vim-style Spacemacs leader keys are accessed with SPC (as described in the table) and with Emacs style Spacemacs they are accessed with M-m.

Leader Key BindingDescription
SPC a mmusic prefix
SPC a m eEMMS prefix
SPC a m e pOpen current playlist in current buffer.
SPC a m e bOpen music browser in current buffer.
SPC a RETToggle smart browser (browser/playlist/close) in current buffer.
SPC a SPCPlay/pause do-what-I-mean.
SPC a .Play next track.
SPC a ,Play previous track.

In addition, the smart browser can be accessed through F7

Emacs-state key bindings are documented for each mode at

Evilified keybindings

A few key bindings differ in evilified-state.

Interactive Playlists

Key BindingDescription
aAdd files in the playlist at point to the current playlist buffer. If we are in the current playlist, make a new playlist buffer and set it as current.
bSet the current playlist buffer.
lStart playing the next track in the playlist.
hStart playing the previous track in the playlist.
LGo to the first track in the playlist.
HGo to the last track in the playlist.
pPaste tracks from kill-ring
sStop playing.
P“yank-pop” (who thought of these names, anyway?)
>Seek ten seconds forward.
<Seek ten seconds backward.
.Seek one minute forward.
,Seek one minute backward.
fDescribe the currently playing track in the minibuffer.
cDisplay the current track in the center of the screen.
TABPause.
RETStart playing the track under point. Note that this is also available with <mouse-2>.
M-<Go to the first track in the playlist.
M->Go to the last track in the playlist.
rGo to a randomly selected track in the playlist.
EEdit track information.
qPut the interactive playlist buffer at the end of the list of all buffers.
WSave the current playlist buffer to a file. By default, Emms will ask you for confirmation before overwriting an existing playlist. You can silently overwrite existing playlist by setting emms-source-playlist-ask-before-overwrite to nil.
?Describe the mode.
KCut (kill) marked tracks.
DCut (kill) track at point.
ONew line above point.
MEnable playlist mark-mode.

Mark Playlists

In addition to most of the commands for normal playlists, Mark Playlists offer the usual marking features. Operations should occur on all marked tracks.

When tracks are marked you can operate on them:

Key BindingDescription
mMarks the current track and sets point one line forward. If a prefix argument ARG is given, it will mark the next ARG tracks and set point accordingly. A negative argument marks backward.
UUnmarks all tracks in the playlist.
tToggles mark on the current track.
uUnmarks same way as emms-mark-forward marks.
% mMarks all tracks in the playlist matching the given regular expression. A prefix argument means to unmark them instead.
Key BindingDescription
DDeletes the marked tracks from the playlist.
KCut (kill) marked tracks.
WAdds the marked tracks to the kill-ring, so that you can yank them into another playlist.
MDisable playlist mark-mode.

EMMS Browser

Key BindingDescription
S-RETAdd all tracks at point, and play the first added track.
RETAdd all tracks at point.
tShow or hide (kill) subitems under the current line.
1Collapse everything.
2Expand all top level items one level.
3Expand all top level items two levels.
4Expand all top level items three levels.
CClear the playlist.
EExpand everything.
dView the current directory in dired.
qBury the browser buffer.
rJump to a random track.
/Isearch through the buffer.
<Redisplay with the previous filter.
>Redisplay with the next filter.
?See the Emacs documentation for the function.
C-/Undo the previous playlist action.
S-TABJump to the previous non-track element.
TABJump to the next non-track element.
s ASearch the collection by album.
s aSearch the collection by artist.
s sSearch the collection by names.
s tSearch the collection by title.
b 1Browse the collection by artist.
b 2Browse the collection by album.
b 3Browse the collection by genre.
b 4Browse the collection by year.
W a pLookup the album using Pitchfork.
W a wLookup the album using Wikipedia.

Track (tag) Information Editor

Tag editor is entered from playlists with E.

Evilified bindings are not available yet, but use C-c C-c to submit and exit track information.

Issues

  • When Browser Search is initiated it comes up in normal-state instead of evilified state.
  • Add keybindings for track information editor
  • helm-emms does not narrow as it should.
  • layer does not support MusicPD yet
  • layer does not support emms-lyrics yet

License

GPLv3