### Description
It is showed only the first time running mpdel command. And after that, all command can work.
#### Repoduce
1. open emacs with `-q`
2. load libmpdel
3. `M-x libmpdel-playback-play-pause`
#### other scenario
If a buffer related to mpdel has been opend at first, the problem misses. For example:
1. open emacs with `-q`
2. load mpdel
3. `M-x mpdel-song-open`
4. `M-x libmpdel-playback-play-paus`
### Version
- mpdel `20210107.1303`
- libmpd `20210107.950`
- mpd `0.22.6`
### mpd config
```
music_directory ...
playlist_directory ...
db_file ...
state_file ...
sticker_file ...
bind_to_address ...
audio_output {
... pulseaudio
}
restore_paused "yes"
```
### Debug trace
```
Debugger entered--Lisp error: (wrong-number-of-arguments #<subr format> 0)
format()
apply(format nil)
libmpdel--raw-send-command-with-handler(nil nil)
libmpdel-send-command(nil)
libmpdel-playback-play-pause()
funcall-interactively(libmpdel-playback-play-pause)
call-interactively(libmpdel-playback-play-pause nil nil)
command-execute(libmpdel-playback-play-pause)
```
Thank you very much for your the bug report. I confirm the bug exists and has always existed. It never bothered me though because it fixes itself immediately :-). What happens is that some command depend on the playback state, e.g., libmpdel-playback-play-pause:
(defunlibmpdel-playback-play-pause()"Toggle between play and pause.
See also `libmpdel-playback-stop'."(interactive)(libmpdel-send-command(cl-caselibmpdel--play-state(play"pause 1")(pause"pause 0")(stop"play"))))
The variable libmpdel--play-state is nil by default and only gets a value after libmpdel has asked for the current status (through libmpdel-refresh-status). This is done when connecting to the MPD server. Unfortunately, this is asynchronous and, by the time the variable gets its value, the function libmpdel-playback-play-pause already read it and saw nil.
I think the way to fix that would be to rewrite state-dependent functions to something like:
(defunlibmpdel-playback-play-pause()"Toggle between play and pause.
See also `libmpdel-playback-stop'."(interactive)(libmpdel-get-state'play-state(lambda(play-state)(libmpdel-send-command(cl-caseplay-state(play"pause 1")(pause"pause 0")(stop"play"))))))
This would require implementing the function libmpdel-get-state but it should be simple.
Do you want to try to implement that?
Thank you very much for your the bug report. I confirm the bug exists and has always existed. It never bothered me though because it fixes itself immediately :-). What happens is that some command depend on the playback state, e.g., `libmpdel-playback-play-pause`:
```emacs
(defun libmpdel-playback-play-pause ()
"Toggle between play and pause.
See also `libmpdel-playback-stop'."
(interactive)
(libmpdel-send-command
(cl-case libmpdel--play-state
(play "pause 1")
(pause "pause 0")
(stop "play"))))
```
The variable `libmpdel--play-state` is `nil` by default and only gets a value after libmpdel has asked for the current status (through `libmpdel-refresh-status`). This is done when connecting to the MPD server. Unfortunately, this is asynchronous and, by the time the variable gets its value, the function `libmpdel-playback-play-pause` already read it and saw `nil`.
I think the way to fix that would be to rewrite state-dependent functions to something like:
```emacs
(defun libmpdel-playback-play-pause ()
"Toggle between play and pause.
See also `libmpdel-playback-stop'."
(interactive)
(libmpdel-get-state 'play-state
(lambda (play-state)
(libmpdel-send-command
(cl-case play-state
(play "pause 1")
(pause "pause 0")
(stop "play"))))))
```
This would require implementing the function `libmpdel-get-state` but it should be simple.
Do you want to try to implement that?
Description
It is showed only the first time running mpdel command. And after that, all command can work.
Repoduce
-q
M-x libmpdel-playback-play-pause
other scenario
If a buffer related to mpdel has been opend at first, the problem misses. For example:
-q
M-x mpdel-song-open
M-x libmpdel-playback-play-paus
Version
20210107.1303
20210107.950
0.22.6
mpd config
Debug trace
Thank you very much for your the bug report. I confirm the bug exists and has always existed. It never bothered me though because it fixes itself immediately :-). What happens is that some command depend on the playback state, e.g.,
libmpdel-playback-play-pause
:The variable
libmpdel--play-state
isnil
by default and only gets a value after libmpdel has asked for the current status (throughlibmpdel-refresh-status
). This is done when connecting to the MPD server. Unfortunately, this is asynchronous and, by the time the variable gets its value, the functionlibmpdel-playback-play-pause
already read it and sawnil
.I think the way to fix that would be to rewrite state-dependent functions to something like:
This would require implementing the function
libmpdel-get-state
but it should be simple.Do you want to try to implement that?