Fork me on GitHub
#cider
<
2019-05-25
>
borkdude09:05:48

would it be an idea for CIDER to remove a var from the namespace when you actually delete it from your buffer?

borkdude09:05:14

(without needing the whole reloaded tooling)

dominicm11:05:56

@borkdude you mean by doing a diff on deletion?

borkdude11:05:04

yes, so when I delete (defn foo []), the var #'user/foo gets unmapped from *ns*

benedek14:05:21

oh the beauty of repl based tooling.. would not be really intuitive as foo does not magically appear in your repl when you type the defn form either..

borkdude15:05:02

that’s true, but there is no analog for the reverse of C-x C-e is there?

jr0cket19:05:36

C-c C-u is the analog, cider-undef

borkdude19:05:34

That’s handy, thanks. I would like to see this coupled with actually deleting something like (defn foo []) from the buffer somehow

jr0cket19:05:43

something like cider-undef-delete-defn seems like it would be useful and not to hard to add maybe?

borkdude19:05:02

yeah, I’ll propose something like this in a ticket

jr0cket19:05:14

looking at the cider-undef code it seems to send an undef op for a specifc ns and symbol via nrepl. I wonder if its as simple as just sending an undef and ns to unload everything from that ns?

borkdude19:05:48

I actually don’t want to undef everything, just the thing I manually deleted

borkdude15:05:28

I guess you can manually do the unmap, but it would be nice if CIDER has something more ergonomic for this? like select a form and delete it via a special CIDER function that also unmaps the var

borkdude15:05:34

or a configurable thing

benedek15:05:09

or something like a reset buffer?

benedek15:05:54

so C-c C-k with a prefix would unmap all from curr ns and load the buffer

borkdude15:05:10

yes please!

borkdude15:05:33

I would love to have that as the default behavior of C-c C-k

benedek15:05:39

suppose once you have that easy to remap keys. no idea how would you go about asking ppl if they liked this as default for the most used (guessing here too) cider feature

borkdude15:05:13

yeah, it should probably be configurable somehow

borkdude15:05:28

and not break the current behavior, although I don’t know why you would have it any other way.

benedek15:05:40

wanna file a feature request @borkdude? i am not volunteering necessarily but feels like a good idea

borkdude15:05:34

I made a poll here to see how people feel about it: https://twitter.com/borkdude/status/1132307547468238848

borkdude15:05:46

after I gather some more feedback, I’ll post the issue

borkdude15:05:37

one disadvantage would be that if you have some vars in a comment, they would be gone after the reload

dpsutton15:05:39

would this break deftypes, defrecords, etc?

borkdude15:05:47

that’s why fine-grained remove would be better

dpsutton15:05:01

can't you end up with types with the same string name but are different under the hood?

benedek15:05:44

i thought there was something fixed around this but don't quite remember the details

benedek15:05:10

i think @bronsa created or solved it... maybe...

borkdude15:05:29

it seems there is also cider-ns-reload and cider-ns-reload-all, maybe there should be a variant named cider-ns-reset which does this behavior

benedek15:05:49

so maybe this is already available

borkdude15:05:00

well, no ns-reload does what require does when you do :reload I think

borkdude15:05:26

or maybe there is: https://github.com/clojure-emacs/cider/blob/master/doc/miscellaneous_features.md#reloading-code I have to read this carefully, but now I’m afk for cooking dinner 🙂

borkdude15:05:47

cider-ns-refresh throws an exception in my emacs, not sure what this is

borkdude15:05:56

it tries to (re)load namespaces that are in my test directory, that need deps I haven’t loaded in my REPL, so it crashes 😕

borkdude15:05:30

what I would need is a more fine-grained behavior than “try to reload all namespaces you can find”, just the current one

qythium17:05:05

same here, I tend to have lots of scratch files in a dev folder acting like a persistent REPL history / ad hoc tests

qythium17:05:02

which cider-ns-refresh ends up trying to reload indiscriminately and throwing an error on random broken snippets