cider

A channel dedicated to the Clojure Interactive Development Environment that Rocks (aka CIDER). :cider:
Yehonathan Sharvit 2021-04-07T06:48:21.181100Z

Sometimes, I need to require a namespace for its side-effects (e.g. defmethod declarations).

(ns foo
  (:require bar))
But cider-refactor removes `bar` from the require list, as it “Remove any unused libspec vectors”. Does anyone know a way to tell clj-refactor to keep `bar`?

jumar 2021-04-07T07:09:39.181300Z

I don't know how to instruct clj-refactor to do this but I tend to write a comment why it's supposed to be there and check diffs before I commit the changes (+ extra code review step which should catch that too).

Yehonathan Sharvit 2021-04-07T07:12:48.181500Z

That’s what I did. But I missed it during code review. And boom! My lib was corrupted.

Yehonathan Sharvit 2021-04-07T07:13:22.181700Z

It’s also hard to catch with unit tests because the namespace is loaded by some tests.

jumar 2021-04-07T07:23:35.181900Z

The other thing is that I don't really encounter this issue much - which specific function from clj-refactor triggers this behavior? I mostly use cljr-add-require-to-ns and that seems to work fine (that is doesn't touch the other, even unused, requires; just sorts them)

jumar 2021-04-07T07:24:10.182100Z

For unused requires I simply remove them manually after quick inspection - relying on "linter errors" reported by clj-kondo

Yehonathan Sharvit 2021-04-07T07:41:55.182300Z

This one: https://github.com/clojure-emacs/clj-refactor.el/wiki/cljr-clean-ns

jumar 2021-04-07T07:49:17.182500Z

Yeah, I never use that.

dpsutton 2021-04-07T12:21:32.183100Z

(comment bar/keep-me)

dpsutton 2021-04-07T12:21:53.183500Z

We do this a lot at work

Yehonathan Sharvit 2021-04-07T12:32:45.183700Z

You really call the function keep-me ?

dpsutton 2021-04-07T12:47:30.185Z

Yeah it doesn’t need to resolve, just show up as a use of the namespace. The keep-me makes it clear what it’s purpose is

Yehonathan Sharvit 2021-04-07T13:00:41.185200Z

Cool

vemv 2021-04-07T17:09:44.187100Z

What I normally do is placing a require below the ns form. There's no difference to the compiler - ns is just standardized syntax sugar over require It's fairly easy to see why a top-level require is there so I generally don't even attach an explanatory comment to them

👍 3
bozhidar 2021-04-07T14:46:32.186100Z

More context - I was considering to use C-c C-e for the eval keymap, as it'd be more convenient than C-c C-v.

bozhidar 2021-04-07T14:46:51.186400Z

(or at least it will be easier to remember)

bozhidar 2021-04-07T14:50:50.186700Z

More on the subject - https://docs.cider.mx/cider/usage/code_evaluation.html#keybindings

tvaughan 2021-04-07T15:12:36.186800Z

Yes, many many times a day

nivekuil 2021-04-07T17:18:52.187300Z

I always use C-x C-e or C-c C-p but I might start using C-c C-e now that I know it exists. Is it an upgrade from C-c C-v? it would be for me on dvorak but seems worse for qwerty

bozhidar 2021-04-07T20:13:43.187600Z

Whether it's easier to press it debatable, but it seems like a better mnemonic to me, as it (e)val in its name.

bozhidar 2021-04-07T20:14:12.187800Z

Also the keybinding in quesiton won't change much - it will become C-c C-e (C)-e.

bozhidar 2021-04-07T20:15:06.188Z

The only reason why C-c C-e and C-x C-e both are both mapped to the same command is to mimic SLIME - early on it seemed like a good idea, but as CIDER has way more commands than SLIME at some point I started to regret wasting keybindings in this fashion.

bozhidar 2021-04-07T20:15:55.188200Z

Anyways, I don't feel strongly about this, I was just wondering how attached people are to this. I've never used C-c C-e myself.

tvaughan 2021-04-07T20:18:03.188400Z

I won't mind if it's changed