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

Enhance move-to-let to add or augment :let binding when in macros that support it #1732

Open
justone opened this issue Dec 4, 2023 · 2 comments
Labels
enhancement New feature or request good first issue Good for newcomers
Projects

Comments

@justone
Copy link

justone commented Dec 4, 2023

Is your feature request related to a problem? Please describe.

When using for, there are times where I want to move an expression to the :let

For instance, starting with this:

(for [x [1 2 3 4]]
  (* 2 x))

I would like to end up with this:

(for [x [1 2 3 4]
      :let [a (* 2 x)]]
  a)

However, running move-to-let results in this:

(for [x [1 2 3 4]]
  (let [a (* 2 x)]
    a))

Describe the solution you'd like

When a move-to-let action is performed inside a for macro, it should create (or add to) the :let section of the macro binding instead of introducing a standalone let block.

Describe alternatives you've considered

I usually run the move-to-let and then use editor commands to copy/paste the resulting block into the :let.

Additional context

This would also apply to doseq, as it also supports a :let binding.

@justone justone added the enhancement New feature or request label Dec 4, 2023
@justone
Copy link
Author

justone commented Dec 4, 2023

This might also apply to introduce-let.

@ericdallo ericdallo added this to Low priority in clojure-lsp via automation Dec 4, 2023
@ericdallo ericdallo added the good first issue Good for newcomers label Dec 4, 2023
@danielhvs
Copy link
Contributor

I suggest making it separate.
Keep introduce let
Add introduce :let
It's more flexible IMHO

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
clojure-lsp
Low priority
Development

No branches or pull requests

3 participants