diff options
author | Abhishek Reddy <mail@abhishek.geek.nz> | 2016-05-07 07:35:11 +1200 |
---|---|---|
committer | Bozhidar Batsov <bozhidar.batsov@gmail.com> | 2016-05-06 12:35:11 -0700 |
commit | 775b7d2d080935622d9ce1b769080630cb94739d (patch) | |
tree | 08dcc1343634b811e655e516f2f94caddf8cf0b3 | |
parent | 3bdfd2ff4a100d51cd805453d131aae020a0d874 (diff) |
Ensure cider-jack-in fails gracefully when build tools are not found (#1733)
-rw-r--r-- | CHANGELOG.md | 3 | ||||
-rw-r--r-- | cider.el | 54 |
2 files changed, 32 insertions, 25 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 7f3d2702..b9810eed 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,8 @@ * Signal an error sooner if the user misconfigured `cider-known-endpoints`. * `cider-inspect-read-and-inspect` is obsolete. Use `cider-inspect-expression` instead. * Extremely long overlays are truncated and `cider-inspect-last-result` is recommended. +* Signal `user-error` instead of `error` on jack-in if a project type is not supported. +* Users with `boot.sh` instead of `boot` should customize `cider-boot-command` instead of relying on automatic detection. ### Bugs fixed @@ -33,6 +35,7 @@ * [#1561](https://github.com/clojure-emacs/cider/issues/1561): Use an appropriate font-lock-face for variables, macros and functions in the ns-browser. * [#1708](https://github.com/clojure-emacs/cider/issues/1708): Fix `cider-popup-buffer-display` when another frame is used for the error buffer. +* [#1733](https://github.com/clojure-emacs/cider/pull/1733): Better error handling when no boot command is found in exec-path. ## 0.12.0 (2016-04-16) @@ -109,8 +109,7 @@ version from the CIDER package or library.") :group 'cider) (defcustom cider-boot-command - (or (executable-find "boot") - (executable-find "boot.sh")) + "boot" "The command used to execute Boot." :type 'string :group 'cider @@ -210,29 +209,30 @@ Sub-match 1 must be the project path.") (interactive) (message "CIDER %s" (cider--version))) -(defun cider-command-present-p (project-type) - "Check if the command matching PROJECT-TYPE is present." - (pcase project-type - ("lein" 'cider--lein-present-p) - ("boot" 'cider--boot-present-p) - ("gradle" 'cider--gradle-present-p) - (_ (error "Unsupported project type `%s'" project-type)))) - (defun cider-jack-in-command (project-type) "Determine the command `cider-jack-in' needs to invoke for the PROJECT-TYPE." (pcase project-type ("lein" cider-lein-command) ("boot" cider-boot-command) ("gradle" cider-gradle-command) - (_ (error "Unsupported project type `%s'" project-type)))) + (_ (user-error "Unsupported project type `%s'" project-type)))) +(defun cider-jack-in-resolve-command (project-type) + "Determine the resolved file path to `cider-jack-in-command' if it can be +found for the PROJECT-TYPE" + (pcase project-type + ("lein" (cider--lein-resolve-command)) + ("boot" (cider--boot-resolve-command)) + ("gradle" (cider--gradle-resolve-command)) + (_ (user-error "Unsupported project type `%s'" project-type)))) + (defun cider-jack-in-params (project-type) "Determine the commands params for `cider-jack-in' for the PROJECT-TYPE." (pcase project-type ("lein" cider-lein-parameters) ("boot" cider-boot-parameters) ("gradle" cider-gradle-parameters) - (_ (error "Unsupported project type `%s'" project-type)))) + (_ (user-error "Unsupported project type `%s'" project-type)))) ;;; Jack-in dependencies injection @@ -472,22 +472,25 @@ If CLJS-TOO is non-nil, also start a ClojureScript REPL session with its own buffer." (interactive "P") (setq cider-current-clojure-buffer (current-buffer)) - (let ((project-type (cider-project-type))) - (if (funcall (cider-command-present-p project-type)) + (let* ((project-type (cider-project-type)) + (command (cider-jack-in-command project-type)) + (command-resolved (cider-jack-in-resolve-command project-type)) + (command-params (cider-jack-in-params project-type))) + (if command-resolved (let* ((project (when prompt-project (read-directory-name "Project: "))) (project-dir (clojure-project-dir (or project (cider-current-dir)))) (params (if prompt-project (read-string (format "nREPL server command: %s " - (cider-jack-in-params project-type)) - (cider-jack-in-params project-type)) - (cider-jack-in-params project-type))) + command-params) + command-params) + command-params)) (params (if cider-inject-dependencies-at-jack-in (cider-inject-jack-in-dependencies params project-type) params)) - (cmd (format "%s %s" (cider-jack-in-command project-type) params))) + (cmd (format "%s %s" command-resolved params))) (when-let ((repl-buff (cider-find-reusable-repl-buffer nil project-dir))) (let ((nrepl-create-client-buffer-function #'cider-repl-create) (nrepl-use-this-as-repl-buffer repl-buff)) @@ -495,7 +498,7 @@ own buffer." project-dir cmd (when cljs-too #'cider-create-sibling-cljs-repl))))) (message "The %s executable (specified by `cider-lein-command' or `cider-boot-command') isn't on your `exec-path'" - (cider-jack-in-command project-type))))) + command)))) ;;;###autoload (defun cider-jack-in-clojurescript (&optional prompt-project) @@ -657,25 +660,26 @@ choose." (car choices)) (t cider-default-repl-command)))) + ;; TODO: Implement a check for `cider-lein-command' over tramp -(defun cider--lein-present-p () - "Check if `cider-lein-command' is on the `exec-path'. +(defun cider--lein-resolve-command () + "Find `cider-lein-command' on `exec-path' if possible, or return `nil'. In case `default-directory' is non-local we assume the command is available." (or (file-remote-p default-directory) (executable-find cider-lein-command) (executable-find (concat cider-lein-command ".bat")))) -(defun cider--boot-present-p () - "Check if `cider-boot-command' is on the `exec-path'. +(defun cider--boot-resolve-command () + "Find `cider-boot-command' on `exec-path' if possible, or return `nil'. In case `default-directory' is non-local we assume the command is available." (or (file-remote-p default-directory) (executable-find cider-boot-command) (executable-find (concat cider-boot-command ".exe")))) -(defun cider--gradle-present-p () - "Check if `cider-gradle-command' is on the `exec-path'. +(defun cider--gradle-resolve-command () + "Find `cider-gradle-command' on `exec-path' if possible, or return `nil'. In case `default-directory' is non-local we assume the command is available." (or (file-remote-p default-directory) |