Pulse when moving the cursor to the currently playing song in *empc* buffer
This commit is contained in:
parent
702624395d
commit
96d9ef4bda
1 changed files with 25 additions and 15 deletions
40
empc.el
40
empc.el
|
|
@ -64,6 +64,10 @@
|
||||||
(defvar empc-current-playlist nil)
|
(defvar empc-current-playlist nil)
|
||||||
(defvar empc-current-playlist-songs nil)
|
(defvar empc-current-playlist-songs nil)
|
||||||
(defvar empc-mode-line-string "")
|
(defvar empc-mode-line-string "")
|
||||||
|
(defvar empc-may-pulse nil)
|
||||||
|
(when (require 'pulse nil t)
|
||||||
|
(setq empc-may-pulse t))
|
||||||
|
|
||||||
(defconst empc-response-regexp
|
(defconst empc-response-regexp
|
||||||
"^\\(OK\\( MPD \\)?\\|ACK \\[\\([0-9]+\\)@[0-9]+\\] \\(.+\\)\\)\n+\\'"
|
"^\\(OK\\( MPD \\)?\\|ACK \\[\\([0-9]+\\)@[0-9]+\\] \\(.+\\)\\)\n+\\'"
|
||||||
"Regexp that matches the valid status strings that MusicPD can
|
"Regexp that matches the valid status strings that MusicPD can
|
||||||
|
|
@ -179,7 +183,8 @@ According to what is in the diff, several actions can be performed:
|
||||||
(when (plist-get status-diff :songid)
|
(when (plist-get status-diff :songid)
|
||||||
(setq notify '(lambda () (when empc-current-playlist-songs
|
(setq notify '(lambda () (when empc-current-playlist-songs
|
||||||
(empc-mode-line-song (gethash (plist-get status-diff :songid)
|
(empc-mode-line-song (gethash (plist-get status-diff :songid)
|
||||||
empc-current-playlist-songs))))))
|
empc-current-playlist-songs)))))
|
||||||
|
(empc-playlist-goto-current-song))
|
||||||
(when (plist-get status-diff :state)
|
(when (plist-get status-diff :state)
|
||||||
(if (eq (plist-get status-diff :state) 'play)
|
(if (eq (plist-get status-diff :state) 'play)
|
||||||
(progn
|
(progn
|
||||||
|
|
@ -198,8 +203,7 @@ According to what is in the diff, several actions can be performed:
|
||||||
(empc-status-on/off-stringify empc-current-status :consume)
|
(empc-status-on/off-stringify empc-current-status :consume)
|
||||||
(empc-status-on/off-stringify empc-current-status :xfade))))))
|
(empc-status-on/off-stringify empc-current-status :xfade))))))
|
||||||
(when notify
|
(when notify
|
||||||
(funcall notify))
|
(funcall notify))))
|
||||||
(empc-playlist-goto-current-song)))
|
|
||||||
|
|
||||||
(defun empc-parse-status-attr (attr value)
|
(defun empc-parse-status-attr (attr value)
|
||||||
"Parse a single attribute from status."
|
"Parse a single attribute from status."
|
||||||
|
|
@ -230,19 +234,25 @@ According to what is in the diff, several actions can be performed:
|
||||||
|
|
||||||
(defun empc-playlist-goto-current-song ()
|
(defun empc-playlist-goto-current-song ()
|
||||||
"Put point at currently playing song."
|
"Put point at currently playing song."
|
||||||
|
(interactive)
|
||||||
(when (get-buffer "*empc*")
|
(when (get-buffer "*empc*")
|
||||||
(let ((buffer nil))
|
(let ((buffer nil))
|
||||||
(dolist (frame (frame-list))
|
(unless (called-interactively-p)
|
||||||
(with-selected-frame frame
|
(dolist (frame (frame-list))
|
||||||
(when (get-buffer-window "*empc*")
|
(with-selected-frame frame
|
||||||
(setq buffer (get-buffer-window "*empc*"))
|
(when (get-buffer-window "*empc*")
|
||||||
(with-selected-window buffer
|
(with-selected-window (get-buffer-window "*empc*")
|
||||||
(goto-char (point-min))
|
(goto-char (point-min))
|
||||||
(forward-line (plist-get empc-current-status :song))))))
|
(forward-line (plist-get empc-current-status :song))
|
||||||
(unless buffer
|
(when (and (not buffer) empc-may-pulse)
|
||||||
(with-current-buffer "*empc*"
|
(pulse-momentary-highlight-one-line (point))))
|
||||||
(goto-char (point-min))
|
(setq buffer (get-buffer-window "*empc*"))))))
|
||||||
(forward-line (plist-get empc-current-status :song)))))))
|
(unless buffer
|
||||||
|
(with-current-buffer "*empc*"
|
||||||
|
(goto-char (point-min))
|
||||||
|
(forward-line (plist-get empc-current-status :song))
|
||||||
|
(when (and (called-interactively-p) empc-may-pulse)
|
||||||
|
(pulse-momentary-highlight-one-line (point))))))))
|
||||||
|
|
||||||
(defun empc-populate-playlist-buffer ()
|
(defun empc-populate-playlist-buffer ()
|
||||||
"Write playlist into the *empc* buffer."
|
"Write playlist into the *empc* buffer."
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue