Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Vim Banshee - a command line wrapper for Banshee

Vim Banshee - a command line wrapper for Banshee

Based on Ben Klein's book The VimL Primer: Edit Like a Pro with Vim Plugins and Scripts I started to write this plugin and I want to go through it, explain it, what future plans he has and how it was tested.

Matthias Günther

July 27, 2015
Tweet

More Decks by Matthias Günther

Other Decks in Technology

Transcript

  1. Vimscript is called nowadays VimL is a dynamic imperative language:

    variables, expressions, control structures, built-in functions, user-defined functions, data structures, File I/O, regex pattern matching
  2. echom echo returns echo of expressions and saves them in

    message-history (:messages) good for debugging
  3. split :split … transforms string into a list (by default

    it takes whitespace but you can specifiy the second parameter as a own defined delimeter)
  4. system example let banshee = "banshee --query-album --query-artist" let playlist

    = split(system(banshee), '\n') echom string(playlist)
  5. append, line append(line, text) … appends the text to a

    buffer after a certain line in the file line(number) … takes the file position and returns the line number of that position in the current file
  6. examples let playlist = ['Vim' , 'Berlin', 'rockt'] for track

    in playlist call append(line('$'), track) endfor :echo line('w$') 33G ma :echo line("'a")
  7. bufexists, bufnr bufexists({expr}) … result is a number, which is

    non-zero if the buffer exists bufnr({expr}) … result is the number of a buffer (displayed by the :ls command
  8. command command[!] [{attr}…] {cmd} {rep} … define a user command.

    The name of the command is {cmd} and its replacement text is {rep}. The ! can be used to overwrite any preexisting commands.
  9. Isolated test environment #!/bin/bash banshee --play-enqued fixtures/crystals.mp3 fixtures/focus.mp3 & vim

    -Nu <(cat << EOF filetype off set rtp+=~/.vim/plugged/vader.vim set rtp+=~/.vim/plugged/vim-banshee filetype plugin indent on syntax enable EOF) +Vader*
  10. Test file Execute (BansheeInfo display title, artist and album): !banshee

    --play redir => test BansheeInfo redir END AssertEqual get(split(test), 0), 'Crystals' AssertEqual get(split(test), 2), 'Professor' AssertEqual get(split(test), 3), 'Kliq' AssertEqual get(split(test), 5), 'Curriculum' AssertEqual get(split(test), 6), 'Vitae' Execute (:BansheeNext play the next song): ...
  11. Test results Starting Vader: 1 suite(s), 10 case(s) Starting Vader:

    /home/wm/.vim/plugged/vim-banshee/test/banshee.vader ( 1/10) [EXECUTE] BansheeInfo display title, artist and album ( 2/10) [EXECUTE] :BansheeNext play the next song ( 3/10) [EXECUTE] :BansheePrevious play the previous song ( 4/10) [EXECUTE] :BansheeRestart, :BansheePlay, :BansheeStop, :BansheeSetPosition, :BansheeDuration ( 5/10) [EXECUTE] :BansheePause stop playing the current song ( 6/10) [EXECUTE] :BansheeToggle pauses and plays a song ( 7/10) [EXECUTE] :BansheeStop stop playing a song and when it's played again, it will start from the beginning ( 8/10) [EXECUTE] :BansheeSetRating and :BansheeSetVolume ( 9/10) [EXECUTE] Existance of commands :BansheeShow, :BansheeFullscreen, :BansheeHide, :BansheeStopWhenFinished (10/10) [EXECUTE] Existance of dialog commands: :BansheeImportMedia, :BansheeOpenLocation, :BansheePreferences Success/Total: 10/10 Success/Total: 10/10 (assertions: 26/26) Elapsed time: 17.128639 sec.
  12. Coupon Code Code is: zBOOKCLUBvimberlin It is good for a

    35% discount off of The VimL Primer => valid until the end of July, 2015