Finding Windows by Buffers
The mpc#DisplayPlaylist code that we just copied from the original OpenMPC opens a new window, and then loses track of it. The next time the function is called, it opens another window.
To see this in action, open the editor and then start the plugin with :call OpenMPC(). Run that command a few times: you’ll see a new window open every time the function calls mpc#DisplayPlaylist. The code doesn’t check for or switch to any window that’s already opened to our playlist.
Let’s remedy this. We’ll change mpc#DisplayPlaylist so that if we already have a playlist window open when we call OpenMPC, we switch to the open playlist from the current window. Because the job of mpc#DisplayPlaylist is only to display the playlist, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access