emms-patches
[Top][All Lists]
Advanced

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

[Emms-patches] [COMMIT] Introduce emms-completing-read.


From: Michael Olson
Subject: [Emms-patches] [COMMIT] Introduce emms-completing-read.
Date: Fri, 8 Aug 2008 08:59:56 -0700

This allows users to specify which completing-read function to use,
defaulting to ido-completing-read.  The relevant option is
emms-completing-read-function.

Thanks to Thierry Volpiatto for the idea.
---
 lisp/emms-source-playlist.el |    2 +-
 lisp/emms-streams.el         |    2 +-
 lisp/emms-tag-editor.el      |   20 +++++++++++---------
 lisp/emms.el                 |   23 +++++++++++++++++++++--
 4 files changed, 34 insertions(+), 13 deletions(-)

diff --git a/lisp/emms-source-playlist.el b/lisp/emms-source-playlist.el
index 08f62a3..35ed254 100644
--- a/lisp/emms-source-playlist.el
+++ b/lisp/emms-source-playlist.el
@@ -113,7 +113,7 @@ If `emms-source-playlist-default-format' is non-nil, use it
 instead of prompting the user."
   (or emms-source-playlist-default-format
       (intern
-       (completing-read
+       (emms-completing-read
         (concat "Playlist format: (default: "
                 (if emms-source-playlist-format-history
                     (car emms-source-playlist-format-history)
diff --git a/lisp/emms-streams.el b/lisp/emms-streams.el
index 711ad6f..c394eaf 100644
--- a/lisp/emms-streams.el
+++ b/lisp/emms-streams.el
@@ -436,7 +436,7 @@ Don't forget to run `emms-stream-save-bookmarks-file' after 
!"
     (read-string "Name of the bookmark: ")
     (read-string "URL: ")
     nil
-    (completing-read
+    (emms-completing-read
      "Type (url, streamlist, or lastfm): "
      (mapcar #'list '("url" "streamlist" "lastfm")))))
   (unless fd (setq fd (emms-stream-determine-fd name)))
diff --git a/lisp/emms-tag-editor.el b/lisp/emms-tag-editor.el
index 5f9d78e..783abb0 100644
--- a/lisp/emms-tag-editor.el
+++ b/lisp/emms-tag-editor.el
@@ -299,8 +299,8 @@ a selected region.
  If `transient-mark-mode' is on and the mark is active, the
 changes will only take effect on the tracks in the region."
   (interactive
-   (list (completing-read "Set tag: "
-                          emms-tag-editor-tags nil t)
+   (list (emms-completing-read "Set tag: "
+                               emms-tag-editor-tags nil t)
          (read-from-minibuffer "To: ")))
   (save-excursion
     (save-restriction
@@ -320,8 +320,8 @@ replacement in title tags.
 If `transient-mark-mode' is on and the mark is active, the
 changes will only take effect on the tracks in the region."
   (interactive
-   (cons (completing-read "Replace in tag: "
-                          emms-tag-editor-tags nil t)
+   (cons (emms-completing-read "Replace in tag: "
+                               emms-tag-editor-tags nil t)
          (let ((common (query-replace-read-args
                         (if (and transient-mark-mode mark-active)
                             "Query replace regexp in region"
@@ -363,11 +363,13 @@ changes will only take effect on the tracks in the 
region."
 If `transient-mark-mode' is on and the mark is active, the
 changes will only take effect on the tracks in the region."
   (interactive
-   (let* ((tag1 (intern (completing-read "Tag 1: "
-                                         emms-tag-editor-tags nil t)))
-          (tag2 (intern (completing-read "Tag 2: "
-                                         (assq-delete-all tag1 (copy-sequence 
emms-tag-editor-tags))
-                                         nil t))))
+   (let* ((tag1 (intern (emms-completing-read "Tag 1: "
+                                              emms-tag-editor-tags nil t)))
+          (tag2 (intern (emms-completing-read
+                         "Tag 2: "
+                         (assq-delete-all tag1
+                                          (copy-sequence emms-tag-editor-tags))
+                         nil t))))
      (list tag1 tag2)))
   (save-excursion
     (save-restriction
diff --git a/lisp/emms.el b/lisp/emms.el
index 1d8e827..b74c687 100644
--- a/lisp/emms.el
+++ b/lisp/emms.el
@@ -86,6 +86,18 @@ track by track normally."
   :group 'emms
   :type 'boolean)
 
+(defcustom emms-completing-read-function
+  (if (and (boundp 'ido-mode)
+           ido-mode)
+      'ido-completing-read
+    'completing-read)
+  "Function to call when prompting user to choose between a list of options.
+This should take the same arguments as `completing-read'.
+Some possible values are `completing-read' and `ido-completing-read'.
+Note that you must set `ido-mode' if using`ido-completing-read'."
+  :group 'emms
+  :type 'function)
+
 (defcustom emms-track-description-function 'emms-track-simple-description
   "*Function for describing an EMMS track in a user-friendly way."
   :group 'emms
@@ -502,6 +514,13 @@ See  `emms-repeat-track'."
   (when (not emms-player-playing-p)
     (error "No EMMS player playing right now")))
 
+(defun emms-completing-read (&rest args)
+  "Read a string in the minibuffer, with completion.
+Set `emms-completing-read' to determine which function to use.
+
+See `completing-read' for a description of ARGS."
+  (apply emms-completing-read-function args))
+
 
 ;;; Compatibility functions
 
@@ -671,8 +690,8 @@ for that purpose.")
                                         #'(lambda (lbuf rbuf)
                                             (< (length (car lbuf))
                                                (length (car rbuf)))))))))
-           (completing-read "Playlist buffer to make current: "
-                            buf-list nil t default))))
+           (emms-completing-read "Playlist buffer to make current: "
+                                 buf-list nil t default))))
   (let ((buf (if buffer
                  (get-buffer buffer)
                (current-buffer))))
-- 
debian.1.5.6.1.19.ge6b2





reply via email to

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