Fork me on GitHub
#cider
<
2024-02-25
>
Carsten Behring10:02:00

I am trying to setup my PC with a global deps.edn alias which is activate for any cider repl started on this PC from Emacs. I am aware of cider-clojure-cli-aliases and cider-clojure-cli-parameters, but they don't solve it. At least not when, I want both , a system-wide-alias and project specific cider-clojure-cli-aliases`` set via .dir-locals.el Any solution for this ?

vemv10:02:55

From memory, this wasn't possible, although it would totally make sense that it did šŸ™‚

Carsten Behring10:02:13

I managed it by monkey patch cider-clojure-cli-jack-in-dependencies and hardcode

(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\\)" "" (concat ":user:" cider-clojure-cli-aliases)))))
                    (if (string-prefix-p ":" aliases)
                        aliases
                      (concat ":" aliases)))
                "")

Carsten Behring10:02:31

Maybe an extension point would be nice. It would be rather "safe", as a wrong value would only return in a "warning" about unused alias

vemv10:02:24

A backwards-compatible change (similar to other recent changes) would be to: ā€¢ introduce a cider-clojure-cli-global-aliases var ā€¢ introduce a cider-clojure-cli-aliases function (elisp is a lisp-2, cider-clojure-cli-aliases can be both a var and a function) ā€¢ make the defun concat both vars, and also perform other cleanup like removing flags

šŸ‘ 1
vemv10:02:27

I think @U051BLM8F didn't want to introduce a lot of tooling-specific vars which may be part of the reason why things are a bit limited atm. After some discussion we'd welcome a PR as hinted

Carsten Behring10:02:40

I think the concept of a "global" alias makes sense

šŸ‘ 1
Carsten Behring10:02:00

but yes, tool specific ...

Carsten Behring10:02:45

For "leiningen" this is solvable without Cider support. For cli-deps not.

šŸ‘ 1
Carsten Behring11:02:04

https://github.com/clojure-emacs/cider/pull/3623 but only introducing the variable, not sure we need a "customizable" function: This could allow to "change order", no sure we need this. I think it's always: globals:locals:nrepl/cider

rafalw11:02:28

Hi, I have something like this

(comment
  (sexp0 ...)
  (sexp1 ...)
  (sexpN ...) ;; cursor is here
)
how to evaluate everything from sexp0 to sexpN ? Now I'm wrapping everything in do and evaluate whole do , but I wonder if I can avoid this wrapping?

vemv13:02:05

You could bind a key to something like

(cider-interactive-eval (replace-regexp-in-string "^\(comment" "(do" (cider-defun-at-point))
                        nil
                        (cider-defun-at-point 'bounds))
(I just quickly hacked that now - may have small issues but it's a starting point)

vemv13:02:52

Closest official thing we have is https://docs.cider.mx/cider/usage/code_evaluation.html#evaluating-code-inside-comments but 1) it doesn't solve the "do" problem, and 2) it's pretty flawed, as far as I've perceived. The approach per my snippet seems simpler than the current one - changing what to eval as a string is simpler than manipulating Clojure sexp traversal with Elisp. We could evolve my snippet to something official, eventually

daveliepmann13:02:28

I use cider-eval-region for this

šŸ‘ 4