From 7c9348d8c8d4d506dd5696ec1a7a25b893b0778e Mon Sep 17 00:00:00 2001 From: Carsten Behring Date: Sun, 25 Feb 2024 12:39:25 +0100 Subject: [PATCH 1/5] introduced variable `cider-clojure-cli-global-aliases` --- cider.el | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/cider.el b/cider.el index 75f5f56e9..7853e7ca7 100644 --- a/cider.el +++ b/cider.el @@ -173,6 +173,19 @@ then concatenated into the \"-M[your-aliases]:cider/nrepl\" form." :safe #'stringp :package-version '(cider . "1.1")) + +(defcustom cider-clojure-cli-global-aliases + nil + "A list of global aliases to include when using the clojure cli. +It's value will be prepended to the value of `cider-clojure-cli-aliases` +Alias names should be of the form \":foo:bar\". +Leading \"-A\" \"-M\" \"-T\" or \"-X\" are stripped from aliases +then concatenated into the \"-M[your-aliases]:cider/nrepl\" form." + :type 'string + :safe #'stringp + :package-version '(cider . "1.1")) + + (defcustom cider-shadow-cljs-command "npx shadow-cljs" "The command used to execute shadow-cljs. @@ -850,14 +863,18 @@ your aliases contain any mains, the cider/nrepl one will be the one used." ;; TODO: global-options are deprecated and should be removed in CIDER 2.0 (if global-options (format "%s " global-options) "") deps-quoted - (if cider-clojure-cli-aliases - ;; remove exec-opts flags -A -M -T or -X from cider-clojure-cli-aliases - ;; concatenated with :cider/nrepl to ensure :cider/nrepl comes last - (let ((aliases (format "%s" (replace-regexp-in-string "^-\\(A\\|M\\|T\\|X\\)" "" cider-clojure-cli-aliases)))) - (if (string-prefix-p ":" aliases) - aliases - (concat ":" aliases))) - "") + (let ((final-cider-clojure-cli-aliases + (if cider-clojure-cli-global-aliases + (concat cider-clojure-cli-global-aliases ":" cider-clojure-cli-aliases) + cider-clojure-cli-aliases))) + (if final-cider-clojure-cli-aliases + ;; remove exec-opts flags -A -M -T or -X from cider-clojure-cli-aliases + ;; concatenated with :cider/nrepl to ensure :cider/nrepl comes last + (let ((aliases (format "%s" (replace-regexp-in-string "^-\\(A\\|M\\|T\\|X\\)" "" final-cider-clojure-cli-aliases)))) + (if (string-prefix-p ":" aliases) + aliases + (concat ":" aliases))) + "")) (if params (format " %s" params) "")))) (defun cider-shadow-cljs-jack-in-dependencies (global-opts params dependencies) From 7f4c7eff0d3e00caf8c36e14ce7ac1bb06601119 Mon Sep 17 00:00:00 2001 From: Carsten Behring Date: Sun, 25 Feb 2024 12:52:19 +0100 Subject: [PATCH 2/5] updated changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1363ed43f..1798f89d1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## master (unreleased) +- new configuration variable `cider-clojure-cli-global-aliases` + ### New features - [#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) From fa06ef25e958575f76b72849add10a8a034f44d9 Mon Sep 17 00:00:00 2001 From: Carsten Behring Date: Sun, 25 Feb 2024 13:20:43 +0100 Subject: [PATCH 3/5] handle all three cases --- cider.el | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/cider.el b/cider.el index 7853e7ca7..8574f220a 100644 --- a/cider.el +++ b/cider.el @@ -864,9 +864,10 @@ your aliases contain any mains, the cider/nrepl one will be the one used." (if global-options (format "%s " global-options) "") deps-quoted (let ((final-cider-clojure-cli-aliases - (if cider-clojure-cli-global-aliases - (concat cider-clojure-cli-global-aliases ":" cider-clojure-cli-aliases) - cider-clojure-cli-aliases))) + (cond ((and cider-clojure-cli-global-aliases cider-clojure-cli-aliases) + (concat cider-clojure-cli-global-aliases ":" cider-clojure-cli-aliases)) + (cider-clojure-cli-global-aliases cider-clojure-cli-global-aliases) + (t cider-clojure-cli-aliases)))) (if final-cider-clojure-cli-aliases ;; remove exec-opts flags -A -M -T or -X from cider-clojure-cli-aliases ;; concatenated with :cider/nrepl to ensure :cider/nrepl comes last From 350b3a5106b372114f47844e446cad66c2bde657 Mon Sep 17 00:00:00 2001 From: Carsten Behring Date: Sun, 7 Apr 2024 22:08:10 +0200 Subject: [PATCH 4/5] addressed changes from review --- CHANGELOG.md | 4 ++-- cider.el | 38 ++++++++++++++++++++++---------------- 2 files changed, 24 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8cd13ae28..cc63cf3fc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,10 +2,10 @@ ## master (unreleased) -- new configuration variable `cider-clojure-cli-global-aliases` -### New features +### New features +- [#3632](https://github.com/clojure-emacs/cider/pull/3623): new configuration variable `cider-clojure-cli-global-aliases` - [#3366](https://github.com/clojure-emacs/cider/pull/3366): Support display of error overlays with #dbg! and #break! reader macros. - [#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). - The `clojure-mode` dependency is still required for CIDER to function. diff --git a/cider.el b/cider.el index c12d00c89..cec2aaa53 100644 --- a/cider.el +++ b/cider.el @@ -176,14 +176,15 @@ then concatenated into the \"-M[your-aliases]:cider/nrepl\" form." (defcustom cider-clojure-cli-global-aliases nil - "A list of global aliases to include when using the clojure cli. -It's value will be prepended to the value of `cider-clojure-cli-aliases` + "Global aliases to include when jacking in with the clojure CLI. +This value should be a string of the form \":foo:bar\", and +will be prepended to the value of `cider-clojure-cli-aliases'. Alias names should be of the form \":foo:bar\". Leading \"-A\" \"-M\" \"-T\" or \"-X\" are stripped from aliases then concatenated into the \"-M[your-aliases]:cider/nrepl\" form." :type 'string :safe #'stringp - :package-version '(cider . "1.1")) + :package-version '(cider . "1.14")) (defcustom cider-shadow-cljs-command @@ -830,6 +831,23 @@ rules to quote it." (utf-16le-command (encode-coding-string command 'utf-16le))) (format "-encodedCommand %s" (base64-encode-string utf-16le-command t)))) + +(defun cider--combined-aliases () + "Creates the combined ailases as stringe seperated by ':'." + (let ((final-cider-clojure-cli-aliases + (cond ((and cider-clojure-cli-global-aliases cider-clojure-cli-aliases) + (concat cider-clojure-cli-global-aliases ":" cider-clojure-cli-aliases)) + (cider-clojure-cli-global-aliases cider-clojure-cli-global-aliases) + (t cider-clojure-cli-aliases)))) + (if final-cider-clojure-cli-aliases + ;; remove exec-opts flags -A -M -T or -X from cider-clojure-cli-aliases + ;; concatenated with :cider/nrepl to ensure :cider/nrepl comes last + (let ((aliases (format "%s" (replace-regexp-in-string "^-\\(A\\|M\\|T\\|X\\)" "" final-cider-clojure-cli-aliases)))) + (if (string-prefix-p ":" aliases) + aliases + (concat ":" aliases))) + ""))) + (defun cider-clojure-cli-jack-in-dependencies (global-options params dependencies &optional command) "Create Clojure tools.deps jack-in dependencies. Does so by concatenating DEPENDENCIES, PARAMS and GLOBAL-OPTIONS into a @@ -863,19 +881,7 @@ your aliases contain any mains, the cider/nrepl one will be the one used." ;; TODO: global-options are deprecated and should be removed in CIDER 2.0 (if global-options (format "%s " global-options) "") deps-quoted - (let ((final-cider-clojure-cli-aliases - (cond ((and cider-clojure-cli-global-aliases cider-clojure-cli-aliases) - (concat cider-clojure-cli-global-aliases ":" cider-clojure-cli-aliases)) - (cider-clojure-cli-global-aliases cider-clojure-cli-global-aliases) - (t cider-clojure-cli-aliases)))) - (if final-cider-clojure-cli-aliases - ;; remove exec-opts flags -A -M -T or -X from cider-clojure-cli-aliases - ;; concatenated with :cider/nrepl to ensure :cider/nrepl comes last - (let ((aliases (format "%s" (replace-regexp-in-string "^-\\(A\\|M\\|T\\|X\\)" "" final-cider-clojure-cli-aliases)))) - (if (string-prefix-p ":" aliases) - aliases - (concat ":" aliases))) - "")) + (cider--combined-aliases) (if params (format " %s" params) "")))) (defun cider-shadow-cljs-jack-in-dependencies (global-opts params dependencies) From 59c36e94f8c42265feb78fa2aacb2f94bf594a7b Mon Sep 17 00:00:00 2001 From: Carsten Behring Date: Sun, 7 Apr 2024 22:12:46 +0200 Subject: [PATCH 5/5] fixed spelling --- cider.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cider.el b/cider.el index cec2aaa53..5c2a1168e 100644 --- a/cider.el +++ b/cider.el @@ -833,7 +833,7 @@ rules to quote it." (defun cider--combined-aliases () - "Creates the combined ailases as stringe seperated by ':'." + "Creates the combined ailases as stringe separated by ':'." (let ((final-cider-clojure-cli-aliases (cond ((and cider-clojure-cli-global-aliases cider-clojure-cli-aliases) (concat cider-clojure-cli-global-aliases ":" cider-clojure-cli-aliases))