Christophe Weblog Wiki Code Publications Music
Allow user configuration of download directory
[iplayer-el.git] / iplayer.el
index a27450b6da1250ab823320641887dceb5dcd15ab..7e1726bf66cc49e828a91c0a4384f0ae9efd58fa 100644 (file)
 ;; convenient interface to BBC iPlayer.
 
 ;;; Code:
+
+(defgroup iplayer nil
+  "Browse and download BBC TV/radio shows."
+  :prefix "iplayer-"
+  :group 'applications)
+
+(defcustom iplayer-download-directory "~/iPlayer/"
+  "Directory into which shows will be downloaded."
+  :group 'iplayer
+  :type 'directory)
+
 (defvar iplayer-updating-cache-process nil)
 (defvar iplayer-updating-cache-sentinel-info nil)
 (defvar iplayer-updating-cache-sentinel-executing nil)
 
 Used in the `iplayer-preset' command.")
 
+(defun iplayer-frob-presets (presets)
+  (cond
+   ((version< emacs-version "24")
+    (mapcar (lambda (x) (cons (read-kbd-macro (car x)) (cdr x))) presets))
+   (t presets)))
+
 (define-iplayer-command iplayer-preset (&optional keys)
   "Switch display to a preset channel.
 
 The presets are defined in the variable `iplayer-presets'."
   (interactive)
   (let ((keys (or (and keys (concat keys)) (this-command-keys)))
-        (presets (mapcar (lambda (x) (cons (read-kbd-macro (car x)) (cdr x))) iplayer-presets)))
+        (presets (iplayer-frob-presets iplayer-presets)))
     (cond
      ((= (length keys) 1)
       (let ((channel (cdr (assoc keys presets))))
@@ -186,7 +203,7 @@ The presets are defined in the variable `iplayer-presets'."
   (interactive)
   (let ((id (get-text-property (point) 'iplayer-id)))
     (if id
-        (let ((default-directory "~/iPlayer/"))
+        (let ((default-directory iplayer-download-directory))
           ;; should probably use a process filter instead to give us a
           ;; progress bar
           (message "downloading id %s" id)