Skip to content

Commit

Permalink
[Fix clojure-emacs#471] Added support for tagged maps
Browse files Browse the repository at this point in the history
  • Loading branch information
emosesSfdc committed Mar 11, 2018
1 parent 633331f commit 1d03f00
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
* Consider `deps.edn` a project root.

### Changes
Expand Down
13 changes: 8 additions & 5 deletions clojure-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -443,8 +443,8 @@ listed in `clojure-omit-space-between-tag-and-delimiters', this
function returns t.
This allows you to write things like #db/id[:db.part/user]
without inserting a space between the tag and the opening
bracket.
and #::my-ns{:some \"map\"} without inserting a space between
the tag and the opening bracket.
See `paredit-space-for-delimiter-predicates' for the meaning of
ENDP and DELIMITER."
Expand All @@ -454,7 +454,7 @@ ENDP and DELIMITER."
(save-excursion
(let ((orig-point (point)))
(not (and (re-search-backward
"#\\([a-zA-Z0-9._-]+/\\)?[a-zA-Z0-9._-]+"
clojure--collection-tag-regexp
(line-beginning-position)
t)
(= orig-point (match-end 0)))))))))
Expand Down Expand Up @@ -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)
)

(defsubst clojure-in-docstring-p ()
"Check whether point is in a docstring."
Expand Down Expand Up @@ -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._-]+\\)"
"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."))

(defconst clojure-font-lock-keywords
(eval-when-compile
Expand Down
14 changes: 14 additions & 0 deletions test/clojure-mode-syntax-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,20 @@
(backward-prefix-chars)
(should (bobp)))))


(ert-deftest clojure-allowed-collection-tags ()
(dolist (tag '("#::ns" "#:ns" "#ns" "#:f.q/ns" "#f.q/ns" "#::"))
(with-temp-buffer
(clojure-mode)
(insert tag)
(should-not (clojure-no-space-after-tag nil ?{))))
(dolist (tag '("#$:" "#/f" "#:/f" "#::f.q/ns" "::ns" "::" "#f:ns"))
(with-temp-buffer
(clojure-mode)
(insert tag)
(should (clojure-no-space-after-tag nil ?{)))))


(def-refactor-test test-paragraph-fill-within-comments
"
;; Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt
Expand Down

0 comments on commit 1d03f00

Please sign in to comment.