Skip to content

Commit 432078e

Browse files
committed
Refactor some lame duplicated code
1 parent 85bbdb9 commit 432078e

File tree

1 file changed

+11
-51
lines changed

1 file changed

+11
-51
lines changed

cider.el

Lines changed: 11 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -325,11 +325,11 @@ Sub-match 1 must be the project path.")
325325
Throws an error if PROJECT-TYPE is unknown. Known types are
326326
\"lein\", \"boot\", and \"gradle\"."
327327
(pcase project-type
328-
("lein" (cider--lein-resolve-command))
329-
("boot" (cider--boot-resolve-command))
330-
("clojure-cli" (cider--clojure-cli-resolve-command))
331-
("shadow-cljs" (cider--shadow-cljs-resolve-command))
332-
("gradle" (cider--gradle-resolve-command))
328+
("lein" (cider--resolve-command cider-lein-command))
329+
("boot" (cider--resolve-command cider-boot-command))
330+
("clojure-cli" (cider--resolve-command cider-clojure-cli-command))
331+
("shadow-cljs" (cider--resolve-command cider-shadow-cljs-command))
332+
("gradle" (cider--resolve-command cider-gradle-command))
333333
(_ (user-error "Unsupported project type `%s'" project-type))))
334334

335335
(defun cider-jack-in-global-options (project-type)
@@ -976,54 +976,14 @@ choose."
976976
(t cider-default-repl-command))))
977977

978978

979-
;; TODO: Implement a check for `cider-lein-command' over tramp
980-
(defun cider--lein-resolve-command ()
981-
"Find `cider-lein-command' on `exec-path' if possible, or return nil.
979+
;; TODO: Implement a check for command presence over tramp
980+
(defun cider--resolve-command (command)
981+
"Find COMMAND on `exec-path' if possible, or return nil.
982982
983983
In case `default-directory' is non-local we assume the command is available."
984-
(when-let* ((command (or (and (file-remote-p default-directory) cider-lein-command)
985-
(executable-find cider-lein-command)
986-
(executable-find (concat cider-lein-command ".bat")))))
987-
(shell-quote-argument command)))
988-
989-
;; TODO: Implement a check for `cider-boot-command' over tramp
990-
(defun cider--boot-resolve-command ()
991-
"Find `cider-boot-command' on `exec-path' if possible, or return nil.
992-
993-
In case `default-directory' is non-local we assume the command is available."
994-
(when-let* ((command (or (and (file-remote-p default-directory) cider-boot-command)
995-
(executable-find cider-boot-command)
996-
(executable-find (concat cider-boot-command ".exe")))))
997-
(shell-quote-argument command)))
998-
999-
;; TODO: Implement a check for `cider-gradle-command' over tramp
1000-
(defun cider--gradle-resolve-command ()
1001-
"Find `cider-gradle-command' on `exec-path' if possible, or return nil.
1002-
1003-
In case `default-directory' is non-local we assume the command is available."
1004-
(when-let* ((command (or (and (file-remote-p default-directory) cider-gradle-command)
1005-
(executable-find cider-gradle-command)
1006-
(executable-find (concat cider-gradle-command ".exe")))))
1007-
(shell-quote-argument command)))
1008-
1009-
;; TODO: Implement a check for `cider-clojure-cli-command' over tramp
1010-
(defun cider--clojure-cli-resolve-command ()
1011-
"Find `cider-clojure-cli-command' on `exec-path' if possible, or return nil.
1012-
1013-
In case `default-directory' is non-local we assume the command is available."
1014-
(when-let* ((command (or (and (file-remote-p default-directory) cider-clojure-cli-command)
1015-
(executable-find cider-clojure-cli-command)
1016-
(executable-find (concat cider-clojure-cli-command ".exe")))))
1017-
(shell-quote-argument command)))
1018-
1019-
;; TODO: Implement a check for `cider-shadow-cljs-command' over tramp
1020-
(defun cider--shadow-cljs-resolve-command ()
1021-
"Find `cider-shadow-cljs-command' on `exec-path' if possible, or return nil.
1022-
1023-
In case `default-directory' is non-local we assume the command is available."
1024-
(when-let* ((command (or (and (file-remote-p default-directory) cider-shadow-cljs-command)
1025-
(executable-find cider-shadow-cljs-command)
1026-
(executable-find (concat cider-shadow-cljs-command ".exe")))))
984+
(when-let* ((command (or (and (file-remote-p default-directory) command)
985+
(executable-find command)
986+
(executable-find (concat command ".bat")))))
1027987
(shell-quote-argument command)))
1028988

1029989

0 commit comments

Comments
 (0)