summary refs log tree commit diff
diff options
context:
space:
mode:
authorFranck Cuny <franckcuny@gmail.com>2016-11-11 14:07:54 -0800
committerFranck Cuny <franckcuny@gmail.com>2016-11-11 14:07:54 -0800
commitbd9b74bc1ac377408a62994c0927a2eb36e1fc0e (patch)
tree85b9fcdc1ad29eda79bdaedca6513c3342fcd7fc
parentAdd a new `defcustom` to support various completion systems. (diff)
downloadpants.el-bd9b74bc1ac377408a62994c0927a2eb36e1fc0e.tar.gz
Use the configured completion system.
A user can specify which completion system he wants to use. If the
system is installed, we use it, otherwise we return an error to the
user, asking her to install it.
-rw-r--r--pants.el19
1 files changed, 17 insertions, 2 deletions
diff --git a/pants.el b/pants.el
index 02ab5b3..955bd7e 100644
--- a/pants.el
+++ b/pants.el
@@ -131,8 +131,23 @@
       (while (re-search-forward "^\\(.+\\)$" nil t)
         (setq target (match-string 1))
         (push target targets)))
-    (ivy-read "Pants Targets" targets
-              :action (lambda (target) (funcall action target)))))
+    (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)))))
 
 (defun pants--get-build-file-for-current-buffer ()
   "Finds the nearest build file for the current buffer"