Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transfer meaningful file and line information on hot code eval #1392

Closed
kotarak opened this issue Oct 30, 2015 · 12 comments
Closed

Transfer meaningful file and line information on hot code eval #1392

kotarak opened this issue Oct 30, 2015 · 12 comments

Comments

@kotarak
Copy link
Contributor

kotarak commented Oct 30, 2015

Working on a function in a file, hot evaling it in the repl server and testing it immediately is a very fast way of working. Unfortunately the file and line information is not kept during hot eval. In case of an exception you get rather useless location information.

In VimClojure I implemented said information transfer to the backend and it worked rather well for debugging. I simply proxied the reader during eval and also set the compiler location specific Vars.

cf. make-reader and with-repl*

Is there a chance to have this implemented in cider also? And if yes, where should I start?

PS: I know that the location info of code below said function might get of out sync. I consider this less annoying than having no info at all during debug. And it can be easily fixed by hot eval if necessary.

@bbatsov
Copy link
Member

bbatsov commented Oct 30, 2015

This was (finally) added in nREPL 0.2.11, so you just have to start using it (together with the latest CIDER snapshot which sends this data to nREPL).

@bbatsov
Copy link
Member

bbatsov commented Oct 30, 2015

Details here 2c24aaa

@bbatsov
Copy link
Member

bbatsov commented Oct 30, 2015

You might also take a look here #1389 (comment)

@Malabarba
Copy link
Member

Maybe I misunderstood this, but I think @kotarak was asking for something slightly different.
I think he is evaluating stuff on the REPL buffer, and just wants any previous line/col/file information to be preserved. If that's the case then:

  1. @kotarak: you may want to try using C-M-x instead of using the repl to redefine stuff.
  2. @bbatsov: a lot of people prefer the repl buffer, and I imagine it probably screws up with line/col/file information (since the repl knows nothing about those). It might be useful if repl evaluation didn't try to set this information (so as to avoid overriding a previous good value).

@bbatsov
Copy link
Member

bbatsov commented Oct 30, 2015

It might be useful if repl evaluation didn't try to set this information (so as to avoid overriding a previous good value)

I'm pretty sure if you don't set anything it's just set to nil, so if we're to add some special handling in the REPL it should probably take into account the original metadata and reuse it. Btw, we can also do something pretty wild and treat the REPL buffer as file name - this would allow us to jump back to definition in the REPL itself. :-)

@kotarak
Copy link
Contributor Author

kotarak commented Oct 30, 2015

Aside from other possible improvements, my point was actually switching between repl and file. I attached a picture, which illustrates my problem. Notice how the second call to work.in/progress yields useless non-information regarding location after editing the function and hot evaling it via cider-eval-defun-at-point.

argh

@bbatsov
Copy link
Member

bbatsov commented Oct 30, 2015

This definitely works differently with the current snapshot and nREPL 0.2.11.

@kotarak
Copy link
Contributor Author

kotarak commented Oct 30, 2015

Great! :D

@Malabarba
Copy link
Member

Ok, then it sounds like Bozhidar had it right. :-)

Btw, we can also do something pretty wild and treat the REPL buffer as file name - this would allow us to jump back to definition in the REPL itself. :-)

I'd be cool with this too. And it probably wouldn't involve any changes on the clojure side.

@bbatsov
Copy link
Member

bbatsov commented Nov 1, 2015

I'd be cool with this too. And it probably wouldn't involve any changes on the clojure side.

Yep, I believe this can be implemented entirely in the EL portion of the code.

@johngit22
Copy link

I am not certain of what VIM CLOSURE is, thanks. Please explain..a light explanation will do.

@kotarak
Copy link
Contributor Author

kotarak commented Nov 2, 2015

VimClojure is a Clojure plugin for Vim, which I maintained for 5 years. It provided a state-of-the-art Clojure environment since 2008. Even nowadays I would be perfectly happy with it.

@bbatsov bbatsov closed this as completed in a4b34d8 Nov 3, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants