summary refs log tree commit diff
diff options
context:
space:
mode:
authorFranck Cuny <franckcuny@gmail.com>2016-11-11 15:18:40 -0800
committerFranck Cuny <franckcuny@gmail.com>2016-11-11 15:18:40 -0800
commit47ca64545e762d9b3901dc895cc44657e947368e (patch)
tree6a0c6b6d784bf07abfa962f232e33a38f11d9216
parentRemove broken debug message. (diff)
downloadpants.el-47ca64545e762d9b3901dc895cc44657e947368e.tar.gz
Make the build to work with `ido'.
When the completion system was set to `ido', the user was prompted which
target to use, but nothing would be executed.
-rw-r--r--pants.el41
1 files changed, 24 insertions, 17 deletions
diff --git a/pants.el b/pants.el
index 151b45f..b11478c 100644
--- a/pants.el
+++ b/pants.el
@@ -138,23 +138,30 @@
       (while (re-search-forward "^\\(.+\\)$" nil t)
         (setq target (match-string 1))
         (push target targets)))
-    (cond
-     ((eq pants-completion-system 'ivy)
-      (if (fboundp 'ivy-read)
-          (ivy-read "Pants Targets" targets
-                    :action (lambda (target) (funcall action target)))
-        (user-error "Please install ivy from https://github.com/abo-abo/swiper")))
-     ((eq pants-completion-system 'helm)
-      (if (fboundp 'helm)
-          (helm :sources
-                `((name . "Pants Targets")
-                  (candidates . ,targets)
-                  (action . action))
-                :buffer "*helm pants targets*"
-                :prompt "pants: ")
-        (user-error "Please install helm from https://github.com/emacs-helm/helm")))
-     ((eq pants-completion-system 'ido)
-      (ido-completing-read "Pants target: " targets)))))
+    (let (res)
+      (setq res
+            (cond
+             ((eq pants-completion-system 'ivy)
+              (if (fboundp 'ivy-read)
+                  (ivy-read "Pants Targets" targets
+                            :action (prog1 action
+                                      (setq action nil)))
+                (user-error "Please install ivy from https://github.com/abo-abo/swiper")))
+             ((eq pants-completion-system 'helm)
+              (if (fboundp 'helm)
+                  (helm :sources
+                        (helm-make-source "Pants" 'helm-source-sync
+                                          :candidates targets
+                                          :action (prog1 action
+                                                    (setq action nil))
+                                          :buffer "*helm pants targets*"
+                                          :prompt "pants: "))
+                (user-error "Please install helm from https://github.com/emacs-helm/helm")))
+             ((eq pants-completion-system 'ido)
+              (ido-completing-read "Pants target: " targets))))
+      (if action
+          (funcall action res)
+        res))))
 
 (defun pants--get-build-file-for-current-buffer ()
   "Finds the nearest build file for the current buffer"