From: Fredrik Tolf Date: Tue, 5 Jan 2010 05:31:32 +0000 (+0100) Subject: Made mpcl:connect more standardized. X-Git-Url: http://git.dolda2000.com/gitweb/?a=commitdiff_plain;h=5a4158dd6fb3a1ed9e358900f53c582c4ae30148;hp=9d561d5d6bc68bb900271677cfc5e2b7e191eac3;p=lisp-utils.git Made mpcl:connect more standardized. --- diff --git a/mpcl.lisp b/mpcl.lisp index 4cc6656..98a545e 100644 --- a/mpcl.lisp +++ b/mpcl.lisp @@ -192,7 +192,19 @@ :message "Invalid response from mpd: ~A" :inputs (list line)))))))) -(defun connect (&key (host "localhost") (port 6600)) +(defun default-host () + (block nil + #+sbcl (let ((host (sb-posix:getenv "MPD_HOST"))) + (when host (return host))) + "localhost")) + +(defun default-port () + (block nil + #+sbcl (let ((port (sb-posix:getenv "MPD_PORT"))) + (when port (return (parse-integer port)))) + 6600)) + +(defun connect (&key (host (default-host)) (port (default-port))) "Connect to a running MPD." (disconnect) (with-conn-lock