[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] /srv/bzr/emacs/trunk r109424: * lisp/mpc.el: Support passw
From: |
Stefan Monnier |
Subject: |
[Emacs-diffs] /srv/bzr/emacs/trunk r109424: * lisp/mpc.el: Support password in host argument. |
Date: |
Sat, 04 Aug 2012 03:37:27 -0400 |
User-agent: |
Bazaar (2.5.0) |
------------------------------------------------------------
revno: 109424
author: Michal Nazarewicz <address@hidden>
committer: Stefan Monnier <address@hidden>
branch nick: trunk
timestamp: Sat 2012-08-04 03:37:27 -0400
message:
* lisp/mpc.el: Support password in host argument.
(mpc--proc-connect): Parse and use new password element.
Set mpc-proc variable instead of returning process.
(mpc-proc): Adjust accordingly.
modified:
lisp/ChangeLog
lisp/mpc.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog 2012-08-03 11:51:11 +0000
+++ b/lisp/ChangeLog 2012-08-04 07:37:27 +0000
@@ -1,3 +1,10 @@
+2012-08-04 Michal Nazarewicz <address@hidden> (tiny change)
+
+ * lisp/mpc.el: Support password in host argument.
+ (mpc--proc-connect): Parse and use new password element.
+ Set mpc-proc variable instead of returning process.
+ (mpc-proc): Adjust accordingly.
+
2012-08-03 Eli Zaretskii <address@hidden>
* whitespace.el (whitespace-display-mappings): Use Unicode
=== modified file 'lisp/mpc.el'
--- a/lisp/mpc.el 2012-07-10 11:51:54 +0000
+++ b/lisp/mpc.el 2012-08-04 07:37:27 +0000
@@ -199,9 +199,10 @@
(defcustom mpc-host
(concat (or (getenv "MPD_HOST") "localhost")
(if (getenv "MPD_PORT") (concat ":" (getenv "MPD_PORT"))))
- "Host (and port) where the Music Player Daemon is running.
-The format is \"HOST\" or \"HOST:PORT\" where PORT defaults to 6600
-and HOST defaults to localhost."
+ "Host (and port) where the Music Player Daemon is running. The
+format is \"HOST\", \"HOST:PORT\", \"address@hidden" or
+\"address@hidden:PORT\" where PASSWORD defaults to no password, PORT
+defaults to 6600 and HOST defaults to localhost."
:type 'string)
(defvar mpc-proc nil)
@@ -252,20 +253,30 @@
(funcall callback)))))))))
(defun mpc--proc-connect (host)
- (mpc--debug "Connecting to %s..." host)
- (with-current-buffer (get-buffer-create (format " *mpc-%s*" host))
- ;; (pop-to-buffer (current-buffer))
- (let (proc)
- (while (and (setq proc (get-buffer-process (current-buffer)))
- (progn ;; (debug)
- (delete-process proc)))))
- (erase-buffer)
- (let ((port 6600))
- (when (string-match ":[^.]+\\'" host)
- (setq port (substring host (1+ (match-beginning 0))))
- (setq host (substring host 0 (match-beginning 0)))
- (unless (string-match "[^[:digit:]]" port)
- (setq port (string-to-number port))))
+ (let ((port 6600)
+ pass)
+
+ (when (string-match "\\`\\(?:\\(.*\\)@\\)?\\(.*?\\)\\(?::\\(.*\\)\\)?\\'"
+ host)
+ (let ((v (match-string 1 host)))
+ (when (and (stringp v) (not (string= "" v)))
+ (setq pass v)))
+ (let ((v (match-string 3 host)))
+ (setq host (match-string 2 host))
+ (when (and (stringp v) (not (string= "" v)))
+ (setq port
+ (if (string-match "[^[:digit:]]" v)
+ (string-to-number v)
+ v)))))
+
+ (mpc--debug "Connecting to %s:%s..." host port)
+ (with-current-buffer (get-buffer-create (format " *mpc-%s:%s*" host port))
+ ;; (pop-to-buffer (current-buffer))
+ (let (proc)
+ (while (and (setq proc (get-buffer-process (current-buffer)))
+ (progn ;; (debug)
+ (delete-process proc)))))
+ (erase-buffer)
(let* ((coding-system-for-read 'utf-8-unix)
(coding-system-for-write 'utf-8-unix)
(proc (open-network-stream "MPC" (current-buffer) host port)))
@@ -282,7 +293,9 @@
(set-process-query-on-exit-flag proc nil)
;; This may be called within a process filter ;-(
(with-local-quit (mpc-proc-sync proc))
- proc))))
+ (setq mpc-proc proc)
+ (when pass
+ (mpc-proc-cmd (list "password" pass) nil))))))
(defun mpc--proc-quote-string (s)
(if (numberp s) (number-to-string s)
@@ -306,11 +319,11 @@
(nreverse alists)))
(defun mpc-proc ()
- (or (and mpc-proc
- (buffer-live-p (process-buffer mpc-proc))
- (not (memq (process-status mpc-proc) '(closed)))
- mpc-proc)
- (setq mpc-proc (mpc--proc-connect mpc-host))))
+ (unless (and mpc-proc
+ (buffer-live-p (process-buffer mpc-proc))
+ (not (memq (process-status mpc-proc) '(closed))))
+ (mpc--proc-connect mpc-host))
+ mpc-proc)
(defun mpc-proc-check (proc)
(let ((error-text (process-get proc 'mpc-proc-error)))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] /srv/bzr/emacs/trunk r109424: * lisp/mpc.el: Support password in host argument.,
Stefan Monnier <=