Different actions on different candidates in ivy
(defvar kitchinhub-root "~/Dropbox/KitchinHUB/"
"Root directory to clone KitchinHUB repos in.")
(defvar jkitchin-github-root "~/Dropbox/jkitchin-github/"
"Root directory to clone jkitchin repos in.")
(defun jkitchin-open-repo (repo)
"Open REPO from jkitchin@github."
(unless (file-directory-p (expand-file-name repo jkitchin-github-root))
(let ((default-directory (file-name-as-directory jkitchin-github-root)))
(shell-command
(format "git clone git@github.com:jkitchin/%s.git" repo))))
;; Now open it
(find-file (expand-file-name repo jkitchin-github-root))
(magit-status))
(defun kitchinhub-open-repo (repo)
"Open REPO from KitchinHUB."
(unless (file-directory-p (expand-file-name repo kitchinhub-root))
(let ((default-directory (file-name-as-directory kitchinhub-root)))
(shell-command
(format
"git clone git@github.com:KitchinHUB/%s.git" repo))))
;; Now open it
(find-file (expand-file-name repo kitchinhub-root))
(magit-status))
(setq jkitchin-candidates (loop for repo in '("scimax" "org-ref")
collect (list repo 'jkitchin-open-repo repo))
kitchinhub-candidates (loop for repo in '("kitchingroup-66" "kitchingroup")
collect (list repo 'kitchinhub-open-repo repo)))
(ivy-read "repo:" (append
jkitchin-candidates
kitchinhub-candidates)
:action (lambda (repo) (funcall (elt repo 0) (elt repo 1))))