@@ -161,6 +161,17 @@ command when there is no ambiguity."
161161 :group 'cider
162162 :package-version '(cider . " 0.13.0" ))
163163
164+ (defcustom cider-allow-jack-in-without-project 'warn
165+ " Controls what happens when doing `cider-jack-in' outside a project.
166+ When set to 'warn you'd prompted to confirm the command.
167+ When set to t `cider-jack-in' will quietly continue.
168+ When set to nil `cider-jack-in' will fail."
169+ :type '(choice (const :tag " always" t )
170+ (const 'warn )
171+ (const :tag " never" nil ))
172+ :group 'cider
173+ :package-version '(cider . " 0.14.0" ))
174+
164175(defcustom cider-known-endpoints nil
165176 " A list of connection endpoints where each endpoint is a list.
166177For example: \\= '((\" label\" \" host\" \" port\" )).
@@ -513,12 +524,20 @@ own buffer."
513524 params))
514525
515526 (cmd (format " %s %s " command-resolved params)))
516- (when-let ((repl-buff (cider-find-reusable-repl-buffer nil project-dir)))
517- (let ((nrepl-create-client-buffer-function #'cider-repl-create )
518- (nrepl-use-this-as-repl-buffer repl-buff))
519- (nrepl-start-server-process
520- project-dir cmd
521- (when cljs-too #'cider-create-sibling-cljs-repl )))))
527+ (if (or project-dir cider-allow-jack-in-without-project)
528+ (progn
529+ (when (or project-dir
530+ (eq cider-allow-jack-in-without-project t )
531+ (and (null project-dir)
532+ (eq cider-allow-jack-in-without-project 'warn )
533+ (y-or-n-p " Are you sure you want to run `cider-jack-in' without a Clojure project? " )))
534+ (when-let ((repl-buff (cider-find-reusable-repl-buffer nil project-dir)))
535+ (let ((nrepl-create-client-buffer-function #'cider-repl-create )
536+ (nrepl-use-this-as-repl-buffer repl-buff))
537+ (nrepl-start-server-process
538+ project-dir cmd
539+ (when cljs-too #'cider-create-sibling-cljs-repl ))))))
540+ (user-error " `cider-jack-in' is not allowed without a Clojure project" )))
522541 (user-error " The %s executable isn't on your `exec-path' " command))))
523542
524543;;;### autoload
0 commit comments