stumpwm-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[STUMP] Re: contrib/mpd.lisp sbcl support


From: Vitaly Mayatskikh
Subject: [STUMP] Re: contrib/mpd.lisp sbcl support
Date: Thu, 14 Feb 2008 19:29:47 +0100
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1 (gnu/linux)

Vitaly Mayatskikh <address@hidden> writes:

> Hi there!
>
> I've modified a bit mpd.lisp to support sbcl. I'm not sure if original
> mpd.lisp was designed for cmucl, may be for clisp?

It was for clisp. Morgan Veyret has modified it to handle clisp again ;)

>From 4ba6e110410ef31a04edf421271120571ff51ee3 Mon Sep 17 00:00:00 2001
From: Morgan Veyret <address@hidden>
Date: Wed, 13 Feb 2008 21:41:28 +0100
Subject: [PATCH] Merged sbcl patch and replaced cmucl stuff with clisp

---
 contrib/mpd.lisp |   37 +++++++++++++++++++++++++++----------
 1 files changed, 27 insertions(+), 10 deletions(-)

diff --git a/contrib/mpd.lisp b/contrib/mpd.lisp
index 2c714e1..055aa51 100644
--- a/contrib/mpd.lisp
+++ b/contrib/mpd.lisp
@@ -35,13 +35,29 @@
 
 ;;mpd client
 (defparameter *mpd-socket* nil)
-(defparameter *mpd-server* "localhost")
+(defparameter *mpd-server*
+  #+clisp
+  "localhost"
+  #+sbcl
+  #(127 0 0 1)
+  )
 (defparameter *mpd-port* 6600)
 
+(defmacro with-mpd-connection (&body body)
+  `(if *mpd-socket*
+       (handler-case (progn ,@body)
+                     (error (c) (progn
+                                  (message "Error with mpd connection: ~a" c)
+                                  (setf *mpd-socket* nil))))
+     (message "Error: not connected to mpd~%")))
+
 (defun mpd-send (command)
   "Send command to stream ending with newline"
   (with-mpd-connection
-   (ext:write-char-sequence
+   (#+clisp
+    ext:write-char-sequence
+    #+sbcl
+    write-sequence
     (concatenate  'string command (string #\Newline))
     *mpd-socket*)))
 
@@ -78,11 +94,19 @@
 
 (defun mpd-connect ()
   "Connect to mpd server"
-  (setf *mpd-socket*
+    (setq *mpd-socket*
+          #+clisp
         (handler-case (socket:socket-connect *mpd-port* *mpd-server*
                                              :element-type 'character)
                       ((or system::simple-os-error error)
                        (err)
+                         (format t  "Error connecting to mpd: ~a~%" err)))
+          #+sbcl
+          (handler-case (let ((s (make-instance 'sb-bsd-sockets:inet-socket 
:type :stream :protocol :tcp)))
+                          (sb-bsd-sockets:socket-connect s *mpd-server* 
*mpd-port*)
+                          (sb-bsd-sockets:socket-make-stream s :input t 
:output t :buffering :none))
+                        ((or simple-error error)
+                         (err)
                        (format t  "Error connecting to mpd: ~a~%" err))))
   (when *mpd-socket*
     (read-line *mpd-socket*)))
@@ -98,13 +122,6 @@
   (mpd-send cmd)
   (mpd-receive))
 
-(defmacro with-mpd-connection (&body body)
-  `(if *mpd-socket*
-       (handler-case (progn ,@body)
-                     (error (c) (progn
-                                  (message "Error with mpd connection: ~a" c)
-                                  (setf *mpd-socket* nil))))
-     (message "Error: not connected to mpd~%")))
 
 ;;mpd formatter
 (dolist (a '((#\m fmt-mpd-status)))
-- 
1.5.2.2

-- 
wbr, Vitaly

reply via email to

[Prev in Thread] Current Thread [Next in Thread]