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

inf-clojure-eval-last-sexp should respect current namespace of a file evaluating from #205

Open
Inc0n opened this issue Nov 12, 2022 · 2 comments

Comments

@Inc0n
Copy link
Contributor

Inc0n commented Nov 12, 2022

Steps to reproduce the problem

Have a script with (ns <namespace> ...) at the top.
Define some variables with filler values.
Run C-x C-e on one of the variables.
The inf-clojure repl will report

Syntax error compiling at (REPL:0:0).
Unable to resolve symbol: <variable name> in this context

## Make C-x C-e respecet the file namespace it was triggered from

This will be convenient to have.

Environment & Version information

Clojure CLI version 1.11.1.1189

inf-clojure version information

3.2.1

Lein/Boot version

clojure-cli

Emacs version

28.1

Operating system

Mac Monterey M1

@dpsutton
Copy link
Contributor

I'm not sure that I want this. A fundamental value proposition of inf-clojure to me is that it is dead simple and works with a standard repl. To me, I have a regular repl and inf-clojure sends simple commands. Adding this changes this assumption, and makes the client more complicated and opaque.

I'm not 100% opposed, and I would like to see what the VS Code extension Clover does in this instance.

@Inc0n
Copy link
Contributor Author

Inc0n commented Nov 13, 2022

Fair enough.
Here is the extension that requires cider-current-ns from CIDER to work.

(defun inf-clojure-eval-last-sexp-in-ns ()
	(interactive)
	(inf-clojure-eval-string
	 (format "(binding [*ns* (find-ns '%s)] (eval '%s))"
			 (cider-current-ns)
			 (buffer-substring
			  (save-excursion (backward-sexp) (point))
			  (point)))))

Here is a link for some more ways to get this to work (instead of using binding).
https://stackoverflow.com/questions/7684656/clojure-eval-code-in-different-namespace

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

2 participants