branch: externals/mpdired commit 356aae09c4f39cc4af90cbdc28b8eb9cb7296fbd Author: Manuel Giraud <man...@ledu-giraud.fr> Commit: Manuel Giraud <man...@ledu-giraud.fr>
ideas and hack --- ideas.org | 8 ++++++++ mpdired.el | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 61 insertions(+), 1 deletion(-) diff --git a/ideas.org b/ideas.org new file mode 100644 index 0000000000..e1ff3e187c --- /dev/null +++ b/ideas.org @@ -0,0 +1,8 @@ +* 2 vue : selection et queue (currently playing songs) +* interface dired-like +** vue queue + - d x : select, remove file + - D + - % m : with playlistfind +* mode déconnecté au maximum +* don't mess with the mode-line diff --git a/mpdired.el b/mpdired.el index acd06556cc..4a8fc4ce6d 100644 --- a/mpdired.el +++ b/mpdired.el @@ -1 +1,53 @@ -;; nothing +(defcustom mpd-host (or (getenv "MPD_HOST") "localhost") + "Host for MPD.") + +(defcustom mpd-port (or (getenv "MPD_PORT") 6600) + "Host for MPD.") + +(defun my-filter (proc string) + (when (buffer-live-p (process-buffer proc)) + (with-current-buffer (process-buffer proc) + (let ((moving (= (point) (process-mark proc)))) + (save-excursion + ;; Insert the text, advancing the process marker. + (goto-char (process-mark proc)) + (insert string) + (set-marker (process-mark proc) (point))) + (if moving (goto-char (process-mark proc))) + (when (re-search-backward "^OK$" nil t) + (set-buffer-modified-p nil) + (message "Fini")))))) + +(defun msg-me (process event) + (princ + (format "Process: %s had the event '%s'" process event))) + +(defvar *mpdired-process* nil) + +(defun mpdired-local-p (host) + ;; Hack: if the `expand-file-name' of host leads to an existing + ;; file, that should be our Unix socket. + (file-exists-p (expand-file-name host))) + +(defun mpc-connect () + (with-current-buffer (get-buffer-create "*mpc*") + (erase-buffer) + (let* ((localp (mpdired-local-p mpd-host)) + (host (if localp (expand-file-name mpd-host) mpd-host))) + ;; Create a new connection if needed + (unless (and *mpdired-process* + (eq (process-status *mpdired-process*) 'open)) + (setq *mpdired-process* (make-network-process :name "mpdired" + :buffer (current-buffer) + :host host + :service (if localp host mpd-port) + :family (if localp 'local) + :coding 'utf-8 + :filter 'my-filter + :sentinel 'msg-me))) + ;;(process-send-string proc "list album\n") + ;;(process-send-string proc "playlistinfo\n") + (process-send-string *mpdired-process* "listall \"\"\n") + ;;(process-send-string proc "close\n") + ;;(buffer-string) + )))