aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Olson <mwolson@gnu.org>2006-01-06 03:21:00 +0000
committerMichael Olson <mwolson@gnu.org>2006-01-06 03:21:00 +0000
commit6181ec571579b78c12424a7f55347be6b24f169c (patch)
treec878012e413de24fa17ec0af1f3105c2377eae17
parent60f527e70b40ecbf7cd6fef39e58acdc3ae3c87b (diff)
emms-player-mpd: Escape specials in filenames like the other MPD clients do.
darcs-hash:20060106032121-1bfb2-ff568ec3dbc6ef6477c89e20d9af1bdffc0b48a7.gz
-rw-r--r--emms-player-mpd.el13
1 files changed, 11 insertions, 2 deletions
diff --git a/emms-player-mpd.el b/emms-player-mpd.el
index 69a8bfb..b0d0903 100644
--- a/emms-player-mpd.el
+++ b/emms-player-mpd.el
@@ -353,6 +353,14 @@ This usually means removing a prefix."
file
(file-relative-name file emms-player-mpd-music-directory)))
+(defun emms-player-mpd-quote-file (file)
+ "Escape special characters in FILE and surround in double-quotes."
+ (concat "\""
+ (emms-replace-regexp-in-string
+ "\"" "\\\\\""
+ (emms-replace-regexp-in-string "\\\\" "\\\\\\\\" file))
+ "\""))
+
;;; MusicPD commands
(defun emms-player-mpd-clear ()
@@ -365,7 +373,7 @@ If we succeed in adding the file, return non-nil, nil otherwise."
(setq file (emms-player-mpd-get-filename file))
(let ((output (emms-player-mpd-parse-response
(emms-player-mpd-send-and-wait
- (concat "add \"" file "\"")))))
+ (concat "add " (emms-player-mpd-quote-file file))))))
(if (car output)
(progn
(when emms-player-mpd-verbose
@@ -497,7 +505,8 @@ info from MusicPD."
(setq info (emms-player-mpd-get-alist
(emms-player-mpd-parse-response
(emms-player-mpd-send-and-wait
- (concat "find filename \"" file "\"")))))))
+ (concat "find filename "
+ (emms-player-mpd-quote-file file))))))))
(when info
(dolist (data info)
(let ((name (car data))