 (defvar bitbucket/project-keys-file "~/.bitbucket-project-keys")
 (defvar bitbucket/url-rest-api "http://cuso.edb.se/stash/rest/api/1.0/")
 
-(defun bitbucket/get-project-keys ()
-  "Gets the Bitbucket projects keys that are 'cached' in bitbucket/project-keys-file."
+(defun bitbucket/get-project-keys (&optional project-keys-file)
+  "Gets the Bitbucket projects keys from PROJECT-KEYS-FILE (defaults to bitbucket/project-keys-file)."
   (split-string (with-temp-buffer
-                  (insert-file-contents bitbucket/project-keys-file)
+                  (insert-file-contents (or project-keys-file bitbucket/project-keys-file))
                   (buffer-string)) "\n" t))
 
 (defun bitbucket/get-clone-commands (repo-regexp)

          (delete-file file-name))
      (bitbucket/update-project-keys username password)
      (dolist (project
               (mapcar (lambda (p) (replace-regexp-in-string ":.*" "" p)) (bitbucket/get-project-keys)))
        (let ((repo-buffer (url-retrieve-synchronously (concat bitbucket/url-rest-api "projects/" project "/repos?limit=1000"))))
          (if repo-buffer
              (progn

                  (insert clone-commands)
                  (insert "\n")
                  (write-region (point-min) (point-max) file-name t)
                  (kill-buffer)
                  (chmod file-name 484)))))))))

(provide 'bitbucket)

