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

Define command to run -main #1174

Merged
merged 1 commit into from
Jun 30, 2015
Merged

Define command to run -main #1174

merged 1 commit into from
Jun 30, 2015

Conversation

Malabarba
Copy link
Member

Fix #1011.

Something like this?
Not sure where to bind it.

"Run -main or FUNCTION, prompting for its namespace if necessary.
With a prefix argument, prompt for function to run instead of -main."
(interactive (list (when current-prefix-arg (read-string "Function name: "))))
(-when-let (response (nrepl-sync-request:eval
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's be better to move this inlined code to a simple middleware op.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which middleware would you put it in? info? ns?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But Idk... Isn't this a little narrow for a middleware?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd put it in ns. Middleware shouldn't be complex - it should just get some work done. The problem with evaluating strings is twofold:

  1. The meaning of the code is obscured by implementation details
  2. Even simple code can be problematic (in your case you're not using FQ names, which means that in some namespaces this code will misbehave)

@Malabarba
Copy link
Member Author

All added. Along with clojure-emacs/cider-nrepl#221

(let* ((completions (mapcar #'cider--var-namespace vars))
(def (or (car cider--namespace-history)
(car completions))))
(format "(#'%s/-main)"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Btw, shouldn't this cover the option of function being used?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops. :-)

@Malabarba
Copy link
Member Author

Tests added and name fixed.

bbatsov added a commit that referenced this pull request Jun 30, 2015
Define command to run -main
@bbatsov bbatsov merged commit 1709246 into clojure-emacs:master Jun 30, 2015
@bbatsov
Copy link
Member

bbatsov commented Jun 30, 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

Successfully merging this pull request may close these issues.

2 participants