Skip to content

[Fix #471] Added support for tagged maps #472

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 1 commit into from
Mar 12, 2018

Conversation

emoses
Copy link
Contributor

@emoses emoses commented Mar 11, 2018

Updated clojure-no-space-after-tag to support tagged maps with autoresolved namespaces, such as #::{:foo "bar"} and #::my-ns{:foo "bar"}. This is new reader syntax added in Clojure 1.9

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):

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

Thanks!

@emoses
Copy link
Contributor Author

emoses commented Mar 11, 2018

CI failed on a test, on only a couple versions, and I don't think I changed anything that would affect it. Do you have any suggestions as to why it broke?

CHANGELOG.md Outdated
@@ -10,6 +10,7 @@
* New interactive command `clojure-cycle-not`.
* New defcustom `clojure-comment-regexp` for font-locking `#_` or `#_` AND `(comment)` sexps.
* [#459](https://github.com/clojure-emacs/clojure-mode/issues/459): Add font-locking for new built-ins added in Clojure 1.9.
* [#471](https://github.com/clojure-emacs/clojure-mode/pull/471): Support tagged maps, new in Clojure 1.9
Copy link
Member

Choose a reason for hiding this comment

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

I think the link is not correct - looks like a pull request link, not an issue link. Also, I guess you meant to say this adds support for Paredit, right?

This sentence should end with a ., btw.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It doesn't add support for paredit, it fixes the existing support.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, yeah. I meant that what you wrote could be interpreted as the addition of some broader set of functionality for namespaced maps, so I wanted the entry to be more specific.

Btw, @benedekfazekas, that's a nice idea for a simple refactoring - making a map namespaced/unnamespaced.

clojure-mode.el Outdated
@@ -521,7 +521,8 @@ replacement for `cljr-expand-let`."
(setq-local clojure-expected-ns-function #'clojure-expected-ns)
(setq-local parse-sexp-ignore-comments t)
(setq-local prettify-symbols-alist clojure--prettify-symbols-alist)
(setq-local open-paren-in-column-0-is-defun-start nil))
(setq-local open-paren-in-column-0-is-defun-start nil)
Copy link
Member

Choose a reason for hiding this comment

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

Not sure why you changed this, probably accidentally.

clojure-mode.el Outdated
@@ -733,7 +734,9 @@ definition of 'macros': URL `http://git.io/vRGLD'.")
(concat "[^" clojure--sym-forbidden-1st-chars "][^" clojure--sym-forbidden-rest-chars "]*")
"A regexp matching a Clojure symbol or namespace alias.
Matches the rule `clojure--sym-forbidden-1st-chars' followed by
any number of matches of `clojure--sym-forbidden-rest-chars'."))
any number of matches of `clojure--sym-forbidden-rest-chars'.")
(defconst clojure--collection-tag-regexp "#\\(::[a-zA-Z0-9._-]*\\|:?\\([a-zA-Z0-9._-]+/\\)?[a-zA-Z0-9._-]+\\)"
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 move this before its usage, and remove that leading indentation.

clojure-mode.el Outdated
any number of matches of `clojure--sym-forbidden-rest-chars'."))
any number of matches of `clojure--sym-forbidden-rest-chars'.")
(defconst clojure--collection-tag-regexp "#\\(::[a-zA-Z0-9._-]*\\|:?\\([a-zA-Z0-9._-]+/\\)?[a-zA-Z0-9._-]+\\)"
"Allowed strings that can come before a collection literal (e.g. '[]' or '{}'), as reader macro tags. This includes #fully.qualified/my-ns[:kw val] and #::my-ns{:kw val} as of Clojure 1.9."))
Copy link
Member

Choose a reason for hiding this comment

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

The first sentence should be on a life of its own.

(with-temp-buffer
(clojure-mode)
(insert tag)
(should-not (clojure-no-space-after-tag nil ?{))))
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't you add some comparison in that should-not?

(with-temp-buffer
(clojure-mode)
(insert tag)
(should (clojure-no-space-after-tag nil ?{)))))
Copy link
Member

Choose a reason for hiding this comment

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

Same here.

@emoses
Copy link
Contributor Author

emoses commented Mar 12, 2018 via email

@bbatsov
Copy link
Member

bbatsov commented Mar 12, 2018

Got it. I guess we should have named it clojure-insert-space-after-tag-p to show this better. Anyways I'll take a look at the test failures when I can.

@bbatsov bbatsov merged commit 1fdb3cd into clojure-emacs:master Mar 12, 2018
@bbatsov
Copy link
Member

bbatsov commented Mar 12, 2018

Thanks for working on this! I really appreciate it! 🙇

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.

3 participants