Skip to content

Fix incorrect indentation of namespaced map #513

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

Closed
wants to merge 3 commits into from

Conversation

poernahi
Copy link

Fix Incorrect Indentation of Namespaced Map Literal

Please refer to #511 for bug description.

  • 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).

@@ -1947,7 +1947,7 @@ Returns a list pair, e.g. (\"defn\" \"abc\") or (\"deftest\" \"some-test\")."
\"Non-logical\" sexp are ^metadata and #reader.macros."
(comment-normalize-vars)
(comment-forward (point-max))
(looking-at-p "\\^\\|#[[:alpha:]]"))
(looking-at-p "\\^\\|#:?:?[[:alpha:]]"))
Copy link
Member

Choose a reason for hiding this comment

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

What's this supposed to match?

Copy link
Member

Choose a reason for hiding this comment

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

(it seems to me like 0-2 :, but I think this can be expressed better with a different qualifier). I also don't see tests with ::.

Copy link
Member

Choose a reason for hiding this comment

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

At least not in the first test.

Copy link
Author

Choose a reason for hiding this comment

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

What's this supposed to match?

^metadata or
#reader-macro or
#:ns-unqualified-reader-macro or
#::namespaced-qualified-reader-macro

Yes, it can be expressed as #:{0,2}

The test case uses #::ns, but I did not write cases for each permutation.

Copy link
Member

Choose a reason for hiding this comment

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

Btw, there's a small problem with the regexp now - something like ^:: will also match. Probably it should be tightened.

Copy link
Member

Choose a reason for hiding this comment

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

And I'd really use :\{0,2\} instead of :?:?.

(clojure-mode)
(clojure-backward-logical-sexp 1)
(should (looking-at-p "#:name/space{:k v}"))
(insert " #::ns {:k v}")
Copy link
Member

Choose a reason for hiding this comment

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

Why is there are space here between the namespace and the map?

Copy link
Author

Choose a reason for hiding this comment

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

Both #:ns {:k v} and #:ns{:k v} are valid syntax and has the same meaning. Also, I have not seen any guideline that prefers one style over the other.

Reference:
https://dev.clojure.org/jira/browse/CLJ-1910?focusedCommentId=42834&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-42834

Copy link
Member

Choose a reason for hiding this comment

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

Got it. I thought usually it was the form without the space.

@bbatsov
Copy link
Member

bbatsov commented Mar 11, 2019

Apart from the failing build (which might be some random Travis failure looking at it), this change needs a changelog entry.

@poernahi
Copy link
Author

Updated changelog.

The CI failure looks like build environment related. I'm not too familiar with it though..

@bbatsov
Copy link
Member

bbatsov commented Mar 11, 2019

You need to rebase on top of master for the new CircleCI to kick in. On your current branch its config is missing.

@poernahi
Copy link
Author

Done, checks passed.

@@ -103,6 +103,14 @@ values of customisable variables."
(cond
|x)")

(check-indentation cond-indentation-with-namespaced-map
"
(cond-> #:a{:b 1}
Copy link
Member

Choose a reason for hiding this comment

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

Don't forget to add here a test with ::.

@bbatsov
Copy link
Member

bbatsov commented Mar 12, 2019

Great! Please, address the small feedback I've added and we're good to go.

@bbatsov
Copy link
Member

bbatsov commented Mar 20, 2019

@poernahi ping :-)

@bbatsov
Copy link
Member

bbatsov commented Apr 24, 2019

@poernahi Ping 2 :-)

@bbatsov
Copy link
Member

bbatsov commented Jul 9, 2019

@anthonygalea Can I ask you to pick this one up and just update the tests for buttercup?

@anthonygalea anthonygalea mentioned this pull request Jul 9, 2019
@bbatsov
Copy link
Member

bbatsov commented Jul 9, 2019

Superseded by #533.

@bbatsov bbatsov closed this Jul 9, 2019
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