(define-key map (kbd "<") 'squeeze-control-previous-track)
(define-key map (kbd "s") 'squeeze-control-select-player)
(define-key map (kbd "a") 'squeeze-list-albums)
+ (define-key map (kbd "!") 'squeeze-control-reconnect)
map))
(defvar squeeze-control-current-player nil)
(port (read-number "Port: " port)))
(cons host port)))
+(cl-defmacro with-squeeze-parameters ((address port) &body body)
+ (declare (indent 1))
+ `(progn
+ (unless ,address (setq ,address squeeze-server-address))
+ (unless ,port (setq ,port squeeze-server-port))
+ (when current-prefix-arg
+ (let ((parameters (squeeze-read-server-parameters ,address ,port)))
+ (setq ,address (car parameters)
+ ,port (cdr parameters))))
+ ,@body))
+
(defun squeeze (&optional address port)
(interactive)
- (unless address (setq address squeeze-server-address))
- (unless port (setq port squeeze-server-port))
- (when current-prefix-arg
- (let ((parameters (squeeze-read-server-parameters address port)))
- (setq address (car parameters)
- port (cdr parameters))))
- (let ((buffer (make-comint-in-buffer "squeeze" nil (cons address port))))
- (switch-to-buffer buffer)
- (squeeze-mode)))
+ (with-squeeze-parameters (address port)
+ (let ((buffer (make-comint-in-buffer "squeeze" nil (cons address port))))
+ (switch-to-buffer buffer)
+ (squeeze-mode))))
(defun squeeze-control (&optional address port)
(interactive)
- (unless address (setq address squeeze-server-address))
- (unless port (setq port squeeze-server-port))
- (when current-prefix-arg
- (let ((parameters (squeeze-read-server-parameters address port)))
- (setq address (car parameters)
- port (cdr parameters))))
- (let ((current-prefix-arg nil))
- (squeeze address port))
- (let ((buffer (get-buffer-create "*squeeze-control*")))
- (switch-to-buffer buffer)
- (squeeze-control-listen)
- (squeeze-control-refresh)
- (squeeze-control-display-players)))
+ (with-squeeze-parameters (address port)
+ (let ((current-prefix-arg nil))
+ (squeeze address port))
+ (let ((buffer (get-buffer-create "*squeeze-control*")))
+ (switch-to-buffer buffer)
+ (squeeze-control-listen)
+ (squeeze-control-refresh)
+ (squeeze-control-display-players))))
+
+(defun squeeze-control-reconnect (&optional address port)
+ (interactive)
+ (with-squeeze-parameters (address port)
+ (kill-buffer (get-buffer "*squeeze*"))
+ (let ((current-prefix-arg nil))
+ (squeeze-control address port))))
(defun squeeze-list-albums ()
(interactive)