Skip to content

Indent "let", "when" and "while" as function form if not at start #497

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

Merged
merged 5 commits into from
Jan 5, 2019

Conversation

Macroz
Copy link
Contributor

@Macroz Macroz commented Nov 17, 2018

"let", "when" and "while" are considered to be a macro form normally:

(when foo
  bar)

Also you can introduce macros that start with "let", "when" or "while" that
will be indented like macro forms:

(when-foo-bar
  1
  2
  3)

But when "let", "when" and "while" are not in the beginning of a symbol they are
now threated as function forms:

(foo-when-bar 1
              2
              3)

Before submitting a PR mark the checkboxes for the items you've done (if you
think a checkbox does not apply, then leave it unchecked):

  • The commits are consistent with our contribution guidelines.
  • You've added tests (if possible) to cover your change(s). Bugfix, indentation, and font-lock tests are extremely important!
  • You've run M-x checkdoc and fixed any warnings in the code you've written.
  • You've updated the changelog (if adding/changing user-visible functionality).
  • You've updated the readme (if adding/changing user-visible functionality).

Thanks!

"let", "when" and "while" are considered to be a macro form normally:

(when foo
  bar)

Also you can introduce macros that start with "let", "when" or "while" that
will be indented like macro forms:

(when-foo-bar
  1
  2
  3)

But when "let", "when" and "while" are not in the beginning of a symbol they are
now threated as function forms:

(foo-when-bar 1
              2
              3)
clojure-mode.el Outdated
@@ -1304,7 +1304,7 @@ symbol properties."
'clojure-indent-function)
(get (intern-soft (match-string 1 function-name))
'clojure-backtracking-indent)))
(when (string-match (rx (or "let" "when" "while") (syntax symbol))
(when (string-match (rx string-start (or "let" "when" "while") (syntax symbol))
Copy link
Member

Choose a reason for hiding this comment

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

I guess it's also worth adding some explanations in the code here, as to what it's aiming to achieve. You should also check if this won't break if-let.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Are the new explanations something you had in mind?

I also added tests for if-let case and fixed it.

@bbatsov bbatsov merged commit 88c78bf into clojure-emacs:master Jan 5, 2019
@bbatsov
Copy link
Member

bbatsov commented Jan 5, 2019

Thanks!

@Macroz Macroz deleted the let-when-while-indentation branch January 5, 2019 09:18
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