emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/cider 511b242ed2: pwsh 7.3 quoting rules compatibility (#3


From: ELPA Syncer
Subject: [nongnu] elpa/cider 511b242ed2: pwsh 7.3 quoting rules compatibility (#3593)
Date: Sat, 2 Dec 2023 09:59:09 -0500 (EST)

branch: elpa/cider
commit 511b242ed25cb42184f2d2109543350f641e26d2
Author: ikappaki <34983288+ikappaki@users.noreply.github.com>
Commit: GitHub <noreply@github.com>

    pwsh 7.3 quoting rules compatibility (#3593)
    
    Co-authored-by: ikappaki <ikappaki@users.noreply.github.com>
    Co-authored-by: shishini <shishini@users.noreply.github.com>
---
 CHANGELOG.md                                      |  4 ++++
 cider.el                                          |  5 ++++-
 doc/modules/ROOT/pages/basics/up_and_running.adoc | 19 ++++++++++++++-----
 test/cider-tests.el                               |  6 +++---
 test/integration/integration-tests.el             |  6 +++++-
 5 files changed, 30 insertions(+), 10 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 6ce8adfae1..f4fbcc50e5 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,10 @@
 
 ## master (unreleased)
 
+### Changes
+
+- [#3588](https://github.com/clojure-emacs/cider/issues/3588): Compatibility 
with pwsh 7.3 quoting rules.
+
 ## 1.12.0 (2023-11-24)
 
 ### Changes
diff --git a/cider.el b/cider.el
index 601bc03998..b673bdda70 100644
--- a/cider.el
+++ b/cider.el
@@ -810,7 +810,10 @@ rules to quote it."
 (defun cider--powershell-encode-command (cmd-params)
   "Base64 encode the powershell command and jack-in CMD-PARAMS for 
clojure-cli."
   (let* ((quoted-params cmd-params)
-         (command (format "clojure %s" quoted-params))
+         ;; Also ensure compatibility with pwsh 7.3 quoting rules
+         ;;
+         ;; https://stackoverflow.com/a/59036879
+         (command (format "$PSNativeCommandArgumentPassing = 'Legacy'; clojure 
%s" quoted-params))
          (utf-16le-command (encode-coding-string command 'utf-16le)))
     (format "-encodedCommand %s" (base64-encode-string utf-16le-command t))))
 
diff --git a/doc/modules/ROOT/pages/basics/up_and_running.adoc 
b/doc/modules/ROOT/pages/basics/up_and_running.adoc
index f212c8e51e..c8e17cc312 100644
--- a/doc/modules/ROOT/pages/basics/up_and_running.adoc
+++ b/doc/modules/ROOT/pages/basics/up_and_running.adoc
@@ -208,11 +208,20 @@ so we'll examine them tool by tool.
 * `cider-clojure-cli-parameters` - the command-line parameters to start a REPL
 * `cider-clojure-cli-aliases` - a list of aliases to be used at jack-in time
 
-To use `cider-jack-in` with `tools.deps` on Windows set the
-`cider-clojure-cli-command` to `"powershell"`. This happens by default
-if you are on Windows and no `clojure` executable is found. Using
-`"powershell"` will Base64 encode the clojure launch command before
-passing it to PowerShell and avoids shell-escaping issues.
+On MS-Windows, CIDER will employ `PowerShell` to execute Clojure if no
+`clojure` executable is found in the PATH (e.g. like the one supplied
+by https://github.com/borkdude/deps.clj[deps.clj]). The default
+executable used is `powershell` which is available on all Windows
+platforms. Using `PowerShell` will Base64 encode the clojure launch
+command before passing it to PowerShell and avoids shell-escaping
+issues.
+
+The functionality of `cider-clojure-cli-command` has been verified
+with the following alternatives
+
+* `pwsh`: This option proves beneficial when the user has installed the 
https://github.com/clojure/tools.deps.alpha/wiki/clj-on-Windows[ClojureTools] 
module on pwsh in a directory not accessible by the system's PowerShell 
installation.
+* `deps.exe`: This executable is part of the tools provided by
+  https://github.com/borkdude/deps.clj[deps.clj] as an alternative name for 
`clojure.exe`.
 
 NOTE: Alternatively you can use WSL (e.g. to run nREPL and Emacs there), which
 will likely result in a better overall development experience.
diff --git a/test/cider-tests.el b/test/cider-tests.el
index d89db352e1..19f8d01b7f 100644
--- a/test/cider-tests.el
+++ b/test/cider-tests.el
@@ -420,12 +420,12 @@
     (expect (cider--powershell-encode-command "cmd-params")
             :to-equal (concat "-encodedCommand "
                               ;; Eval to reproduce reference string below: 
(base64-encode-string (encode-coding-string "clojure cmd-params" 'utf-16le) t)
-                              
"YwBsAG8AagB1AHIAZQAgAGMAbQBkAC0AcABhAHIAYQBtAHMA")))
+                              
"JABQAFMATgBhAHQAaQB2AGUAQwBvAG0AbQBhAG4AZABBAHIAZwB1AG0AZQBuAHQAUABhAHMAcwBpAG4AZwAgAD0AIAAnAEwAZQBnAGEAYwB5ACcAOwAgAGMAbABvAGoAdQByAGUAIABjAG0AZAAtAHAAYQByAGEAbQBzAA==")))
   (it "escapes double quotes by repeating them"
     (expect (cider--powershell-encode-command "\"cmd-params\"")
             :to-equal (concat "-encodedCommand "
                               ;; Eval to reproduce reference string below: 
(base64-encode-string (encode-coding-string "clojure "\"cmd-params\""" 
'utf-16le) t)
-                              
"YwBsAG8AagB1AHIAZQAgACIAYwBtAGQALQBwAGEAcgBhAG0AcwAiAA=="))))
+                              
"JABQAFMATgBhAHQAaQB2AGUAQwBvAG0AbQBhAG4AZABBAHIAZwB1AG0AZQBuAHQAUABhAHMAcwBpAG4AZwAgAD0AIAAnAEwAZQBnAGEAYwB5ACcAOwAgAGMAbABvAGoAdQByAGUAIAAiAGMAbQBkAC0AcABhAHIAYQBtAHMAIgA="))))
 
 (describe "cider--update-jack-in-cmd"
   (describe "when 'clojure-cli project type and \"powershell\" command"
@@ -441,7 +441,7 @@
       (expect (plist-get (cider--update-jack-in-cmd nil) :jack-in-cmd)
               :to-equal (concat "resolved-powershell -encodedCommand "
                                 ;; Eval to reproduce reference string below: 
(base64-encode-string (encode-coding-string "clojure "\"cmd-params"\"" 
'utf-16le) t)
-                                
"YwBsAG8AagB1AHIAZQAgACIAYwBtAGQALQBwAGEAcgBhAG0AcwAiAA=="))))
+                                
"JABQAFMATgBhAHQAaQB2AGUAQwBvAG0AbQBhAG4AZABBAHIAZwB1AG0AZQBuAHQAUABhAHMAcwBpAG4AZwAgAD0AIAAnAEwAZQBnAGEAYwB5ACcAOwAgAGMAbABvAGoAdQByAGUAIAAiAGMAbQBkAC0AcABhAHIAYQBtAHMAIgA="))))
   (describe "when 'clojure-cli project type"
     (it "uses main opts in an alias to prevent other mains from winning"
       (setq-local cider-jack-in-dependencies nil)
diff --git a/test/integration/integration-tests.el 
b/test/integration/integration-tests.el
index a337e63fb0..c4ddf8cba4 100644
--- a/test/integration/integration-tests.el
+++ b/test/integration/integration-tests.el
@@ -187,7 +187,11 @@ If CLI-COMMAND is nil, then use the default."
     (jack-in-clojure-cli-test nil))
 
   (when (eq system-type 'windows-nt)
-    (it "to clojure tools cli (alternative deps.exe)"
+    (it "to clojure tools cli (alternative pwsh)"
+      (jack-in-clojure-cli-test "pwsh")))
+
+(when (eq system-type 'windows-nt)
+  (it "to clojure tools cli (alternative deps.exe)"
       (jack-in-clojure-cli-test "deps.exe")))
 
   (it "to leiningen"



reply via email to

[Prev in Thread] Current Thread [Next in Thread]