Skip to content

Commit 6b60332

Browse files
authored
Introduce variable cider-clojure-cli-global-aliases (#3623)
1 parent ebab3c7 commit 6b60332

File tree

2 files changed

+35
-9
lines changed

2 files changed

+35
-9
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22

33
## master (unreleased)
44

5-
### New features
65

6+
7+
### New features
8+
- [#3632](https://github.com/clojure-emacs/cider/pull/3623): new configuration variable `cider-clojure-cli-global-aliases`
79
- [#3366](https://github.com/clojure-emacs/cider/pull/3366): Support display of error overlays with #dbg! and #break! reader macros.
810
- [#3622](https://github.com/clojure-emacs/cider/pull/3461): Basic support for using CIDER from [clojure-ts-mode](https://github.com/clojure-emacs/clojure-ts-mode).
911
- The `clojure-mode` dependency is still required for CIDER to function.

cider.el

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,20 @@ then concatenated into the \"-M[your-aliases]:cider/nrepl\" form."
173173
:safe #'stringp
174174
:package-version '(cider . "1.1"))
175175

176+
177+
(defcustom cider-clojure-cli-global-aliases
178+
nil
179+
"Global aliases to include when jacking in with the clojure CLI.
180+
This value should be a string of the form \":foo:bar\", and
181+
will be prepended to the value of `cider-clojure-cli-aliases'.
182+
Alias names should be of the form \":foo:bar\".
183+
Leading \"-A\" \"-M\" \"-T\" or \"-X\" are stripped from aliases
184+
then concatenated into the \"-M[your-aliases]:cider/nrepl\" form."
185+
:type 'string
186+
:safe #'stringp
187+
:package-version '(cider . "1.14"))
188+
189+
176190
(defcustom cider-shadow-cljs-command
177191
"npx shadow-cljs"
178192
"The command used to execute shadow-cljs.
@@ -817,6 +831,23 @@ rules to quote it."
817831
(utf-16le-command (encode-coding-string command 'utf-16le)))
818832
(format "-encodedCommand %s" (base64-encode-string utf-16le-command t))))
819833

834+
835+
(defun cider--combined-aliases ()
836+
"Creates the combined ailases as stringe separated by ':'."
837+
(let ((final-cider-clojure-cli-aliases
838+
(cond ((and cider-clojure-cli-global-aliases cider-clojure-cli-aliases)
839+
(concat cider-clojure-cli-global-aliases ":" cider-clojure-cli-aliases))
840+
(cider-clojure-cli-global-aliases cider-clojure-cli-global-aliases)
841+
(t cider-clojure-cli-aliases))))
842+
(if final-cider-clojure-cli-aliases
843+
;; remove exec-opts flags -A -M -T or -X from cider-clojure-cli-aliases
844+
;; concatenated with :cider/nrepl to ensure :cider/nrepl comes last
845+
(let ((aliases (format "%s" (replace-regexp-in-string "^-\\(A\\|M\\|T\\|X\\)" "" final-cider-clojure-cli-aliases))))
846+
(if (string-prefix-p ":" aliases)
847+
aliases
848+
(concat ":" aliases)))
849+
"")))
850+
820851
(defun cider-clojure-cli-jack-in-dependencies (global-options params dependencies &optional command)
821852
"Create Clojure tools.deps jack-in dependencies.
822853
Does so by concatenating DEPENDENCIES, PARAMS and GLOBAL-OPTIONS into a
@@ -850,14 +881,7 @@ your aliases contain any mains, the cider/nrepl one will be the one used."
850881
;; TODO: global-options are deprecated and should be removed in CIDER 2.0
851882
(if global-options (format "%s " global-options) "")
852883
deps-quoted
853-
(if cider-clojure-cli-aliases
854-
;; remove exec-opts flags -A -M -T or -X from cider-clojure-cli-aliases
855-
;; concatenated with :cider/nrepl to ensure :cider/nrepl comes last
856-
(let ((aliases (format "%s" (replace-regexp-in-string "^-\\(A\\|M\\|T\\|X\\)" "" cider-clojure-cli-aliases))))
857-
(if (string-prefix-p ":" aliases)
858-
aliases
859-
(concat ":" aliases)))
860-
"")
884+
(cider--combined-aliases)
861885
(if params (format " %s" params) ""))))
862886

863887
(defun cider-shadow-cljs-jack-in-dependencies (global-opts params dependencies)

0 commit comments

Comments
 (0)