Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Various style changes.

  • Loading branch information...
commit c44889b5a398b2deec66d6f62f79bb598346d3b2 1 parent 2ab8b56
@stassats authored
View
12 classes.lisp
@@ -20,7 +20,7 @@
not-permitted unknown-command not-exist
playlist-size-exceed already-updating exist)))
-(define-constant +error-ids-alist+
+(defparameter *error-ids-alist*
'((2 . bad-argument)
(3 . incorrect-password)
(4 . not-permitted)
@@ -28,14 +28,12 @@
(50 . not-exist)
(51 . playlist-size-exceed)
(54 . already-updating)
- (56 . exist))
- :test #'equal)
+ (56 . exist)))
-(define-constant +tag-types+
+(defparameter *tag-types*
'(:artist :album :title :track :name :genre :date
:composer :performer :comment :disc :filename :any)
- :test #'equal
- :documentation "Types of tags for using in `search' and `find'")
+ "Types of tags for using in `search' and `find'")
(defclass track ()
((file
@@ -114,7 +112,7 @@
(macrolet ((generate-commands (class names)
`(progn
,@(mapcar (lambda (name)
- `(defmethod ,name ((stream stream-usocket))
+ `(defmethod ,name ((stream usocket:stream-usocket))
(,name (,class stream))))
names))))
(generate-commands status
View
6 commands.lisp
@@ -14,7 +14,7 @@
(defcommand disconnect ()
"Close connection."
- (socket-close connection))
+ (usocket:socket-close connection))
(defcommand now-playing ()
"Return instance of playlist with current song."
@@ -243,7 +243,7 @@
(defcommand find-tracks (type what)
"Find tracks in the database with a case sensitive, exact match."
- (assert (member type +tag-types+))
+ (assert (member type *tag-types*))
(check-args string what)
(parse-list (send "find" type what) 'track))
@@ -255,7 +255,7 @@ then list all `metadata-1' in which `metadata-2' has value `search-term'."
(defcommand search-tracks (type what)
"Find tracks in the database with a case sensitive, inexact match."
- (assert (member type +tag-types+))
+ (assert (member type *tag-types*))
(check-args string what)
(parse-list (send "search" type what) 'track))
View
2  mpd.asd
@@ -9,7 +9,7 @@
:name "mpd"
:description "MPD client"
:serial t
- :depends-on (#:usocket #:alexandria)
+ :depends-on (#:usocket)
:components ((:file "package")
(:file "classes")
(:file "mpd")
View
36 mpd.lisp
@@ -10,9 +10,9 @@
(defun connect (&key (host *defualt-host*) (port *default-port*) password)
"Connect to MPD."
- (let ((connection (socket-connect host port)))
+ (let ((connection (usocket:socket-connect host port)))
(prog1 (values connection
- (read-answer (socket-stream connection)))
+ (read-answer (usocket:socket-stream connection)))
(when password
(password connection password)))))
@@ -27,7 +27,7 @@
;; Error format: `ACK [<error id>@<position>] {<comand name>} <description>'
(let* ((error-id (parse-integer text :start 5 :junk-allowed t))
(delimiter (position #\] text))
- (condition (cdr (assoc error-id +error-ids-alist+))))
+ (condition (cdr (assoc error-id *error-ids-alist*))))
(error condition :text (subseq text (+ delimiter 2)))))
(defmacro with-mpd ((var &rest options) &body body)
@@ -38,7 +38,7 @@
(defun send-command (connection command)
"Send command to MPD."
- (let ((stream (socket-stream connection)))
+ (let ((stream (usocket:socket-stream connection)))
(unless (open-stream-p stream)
(error 'mpd-error :text (format nil "The stream ~A is not opened." stream)))
(write-line command stream)
@@ -52,11 +52,9 @@
(defun split-value (string)
"Split a string `key: value' into (list :key value)."
- (let* ((column-position (position #\: string))
- (key (to-keyword
- (subseq string 0 column-position)))
- (value (subseq string (+ 2 column-position))))
- (process-value key value)))
+ (let ((column (position #\: string)))
+ (process-value (to-keyword (subseq string 0 column))
+ (subseq string (+ 2 column)))))
(defun split-values (strings)
"Transform a list of strings 'key: value' into the plist."
@@ -81,7 +79,8 @@
(parse-integer time :start (1+ stop))))))
(defun string-not-zerop (string)
- (not (string= string "0")))
+ (when (string/= string "0")
+ t))
(defun filter-keys (strings)
"Transform a list of strings 'key: value' into a list of values."
@@ -100,8 +99,7 @@
(let (track)
(flet ((create-track ()
(when track
- (list
- (apply 'make-instance class track)))))
+ (list (apply 'make-instance class track)))))
(nconc
(mapcan (lambda (x)
(let ((pair (split-value x)))
@@ -118,7 +116,7 @@
;;;
(defun process-string (string)
- "Check for emtpy strings, end escape strings when needed."
+ "Check for emtpy strings, and escape strings when needed."
(when string
(let ((string
(string-trim '(#\Space #\Tab #\Newline) string)))
@@ -137,16 +135,12 @@
(remove nil (list ,@commands)))))
(defmacro defcommand (name parameters &body body)
- (multiple-value-bind (forms decl doc) (parse-body body :documentation t)
- `(defun ,name (connection ,@parameters)
- ,@decl ,doc
- ,@forms)))
+ `(defun ,name (connection ,@parameters)
+ ,@body))
(defmacro defmethod-command (name parameters &body body)
- (multiple-value-bind (forms decl) (parse-body body)
- `(defmethod ,name (connection ,@parameters)
- ,@decl
- ,@forms)))
+ `(defmethod ,name (connection ,@parameters)
+ ,@body))
(defmacro check-args (type &rest args)
"Check string and integer arguments."
View
4 package.lisp
@@ -1,9 +1,9 @@
;;; -*- Mode: Lisp -*-
-(in-package :cl-user)
+(in-package #:cl-user)
(defpackage #:mpd
- (:use #:cl #:usocket #:alexandria)
+ (:use #:cl)
(:export
#:*defualt-host*
#:*default-port*
Please sign in to comment.
Something went wrong with that request. Please try again.