zsh-users
 help / color / mirror / code / Atom feed
From: Eike von Seggern <eikevons@yahoo.de>
To: zsh-users@zsh.org
Subject: Re: Completion nyxmms2
Date: Sun, 21 Nov 2010 15:56:24 +0100	[thread overview]
Message-ID: <20101121145624.GA3479@matzbach> (raw)
In-Reply-To: <101120115618.ZM6420@torch.brasslantern.com>

[-- Attachment #1: Type: text/plain, Size: 691 bytes --]

On Sat, Nov 20, 2010 at 11:56 -0800, Bart Schaefer wrote:
> On Nov 20,  6:05pm, Michel wrote:
>} Subject: Completion nyxmms2
>}
>} Hello everybody !
>} 
>} I use xmms2 with nyxmms2 to listen my songs but I don't have the
>} completion with nyxmms2.
>} Exist a file for the completion of nyxmms2 ?
> 
> http://www.mail-archive.com/xmms2-devel@lists.xmms.se/msg02017.html
> 
> That thread mentions sending us the completions to include with zsh,
> but I don't think that ever happened.

Hi,

attached is the _nyxmms2 file that I use. I don't remember where I got
it from. Probably from the xmms2 web site. I haven't updated it
recently, but it works well with Dr.No for me.

tschuess
    eike

[-- Attachment #2: _nyxmms2 --]
[-- Type: text/plain, Size: 4671 bytes --]

#compdef nyxmms2

_nyxmms2_command() {
    local nyxmms2_cmds

    nyxmms2_cmds=(
        add:"add the matching media or files to a playlist"
        addpls:"add a playlist file"
        scap:"stop, clear playlist, add arguments and start playing"
        list:"lists the playlist"
        search:"Search and print all media matching the pattern"
        remove:"remove the matching media from a playlist"
        clear:"clears the playlist"

        play:"starts playback"
        pause:"pause playback"
        stop:"stops playback"
        toggle:"toggles playback status between play/pause"

        seek:"seek to a specific place in current song"
        next:"play next song"
        prev:"play previous song"
        jump:"take a leap in the playlist"

        move:"move a entry in the playlist"
        collection:"collection manipulation - type 'nyxmms2 help collection' for more extensive help"
        playlist:"playlist manipulation - type 'nyxmms2 help playlist' for more
extensive help"
        server:"server manipulation - type 'nyxmms2 help server' for more extensive help"

        status:"display playback status, either continuously or once"
        info:"display all the properties for all media matching the pattern"
        help:"print help about a command"
    )

    if (( CURRENT == 1 )); then
        _describe -t command "nyxmms2 commands" nyxmms2_cmds
    else
        local curcontext="$curcontext"
    fi

    local cmd=$words[1]

    local curcontext="${curcontext%:*}:nyxmms2-${cmd}"
    _call_function ret _nyxmms2_$cmd
}

_nyxmms2_jump() {
    songlist=(${"$(nyxmms2 list)"})
    playlistitems=()
    for song ($songlist); do
        if [[ $song = (#b)'  '\[(<->)/(<->)\]' '(*)' '\((*)\) ]]; then
                        playlistitems+=("$match[1][$match[3]]")
        fi
    done

    _values -s ' ' 'playlist items' ${(On)playlistitems}

}

_nyxmms2_playlist() {
    local playlist_cmds
    playlist_cmds=(
        list:"list all playlists"
        switch:"change the active playlist"
        create:"create a new playlist"
        rename:"rename a playlist"
        remove:"remove the given playlist"
        clear:"clear a playlist, by default, clear the active playlist"
        shuffle:"shuffle a playlist, by default, shuffle the active playlist"
        sort:"sort a playlist, by default, sort the active playlist."
        config:"configure a playlist, by default, sort the active playlist."
    )
    if (( CURRENT == 2 )); then
        _describe -t command "nyxmms2 playlist commands" playlist_cmds
    else
        local curcontext="$curcontext"
    fi

    local cmd=$words[2]

    local curcontext="${curcontext%:*}:nyxmms2-${cmd}"
    _call_function ret _nyxmms2_playlist_$cmd
}

_nyxmms2_playlist_helper() {
    local list
    oifs="$IFS"
    IFS="

    list=($(nyxmms2 playlist list|sed 's/^..//'))
    IFS="$oifs"
    _describe -t command "nyxmms2 playlists" list
}

_nyxmms2_playlist_switch() {
    _nyxmms2_playlist_helper
}

_nyxmms2_playlist_sort() {
    _nyxmms2_playlist_helper
}

_nyxmms2_playlist_shuffle() {
    _nyxmms2_playlist_helper
}

_nyxmms2_playlist_clear() {
    _nyxmms2_playlist_helper
}

_nyxmms2_playlist_remove() {
    _nyxmms2_playlist_helper
}

#FIXME: TODO rename, other sort args, config

_nyxmms2_collection() {
    local collection_cmds
    collection_cmds=(
        list:"list all collection" 
        show:"display a human-readable description of a collection"
        create:"create a new collection"
        rename:"rename a collection"
        remove:"remove a collection"
        config:"get or set attributes for the given collection"
    )
    if (( CURRENT == 2 )); then
        _describe -t command "nyxmms2 collection commands" collection_cmds
    else
        local curcontext="$curcontext"
    fi

    local cmd=$words[2]

    local curcontext="${curcontext%:*}:nyxmms2-${cmd}"
    _call_function ret _nyxmms2_collection_$cmd
}

_nyxmms2_collection_helper() {
    local list
    oifs="$IFS"
    IFS="

    list=($(nyxmms2 collection list|sed 's/^..//'))
    IFS="$oifs"
    _describe -t command "nyxmms2 playlists" list
}

_nyxmms2_collection_rename() {
    _nyxmms2_collection_helper
}

_nyxmms2_collection_config() {
    _nyxmms2_collection_helper
}
_nyxmms2_collection_remove() {
    _nyxmms2_collection_helper
}

_nyxmms2_collection_show() {
    _nyxmms2_collection_helper
}

_nyxmms2_add() {
    _files
}

_nyxmms2_scap() {
    _files
}

_nyxmms2() {
    _arguments \
        '--format[specify the format of song display]:format string' \
        '--no-status[prevent printing song status on completion]' \
        '*::nyxmms2 command:_nyxmms2_command'
}

_nyxmms2 "$@"

      reply	other threads:[~2010-11-21 15:48 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-20 18:05 Michel
2010-11-20 19:56 ` Bart Schaefer
2010-11-21 14:56   ` Eike von Seggern [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20101121145624.GA3479@matzbach \
    --to=eikevons@yahoo.de \
    --cc=zsh-users@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).