Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ jobs:
- name: Lint the project
run: make lint

- name: Check the indentation
run: make indent

test:
runs-on: ubuntu-latest
# continue-on-error: ${{matrix.emacs_version == 'snapshot'}}
Expand Down
14 changes: 14 additions & 0 deletions .markdownlint-cli2.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
config:
default: true

line-length:
line_length: 100
code_blocks: false
tables: false

no-duplicate-heading:
allow_different_nesting: true

no-inline-html: false

first-line-heading: false
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

<!-- Entries are one line per item, so the line-length rule doesn't fit this file. -->
<!-- markdownlint-disable MD013 -->

## main (unreleased)

- Fix indentation of namespaced maps in `fixed` indentation style.
Expand Down
27 changes: 27 additions & 0 deletions Eldev
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,30 @@
`(:or ,eldev-standard-excludes "./clojure-mode-tests/*"))
(setf eldev-lint-ignored-fileset
`(:or ,eldev-lint-ignored-fileset "./clojure-mode-tests/*"))

(defvar clojure-ts-mode-indent-check-fix nil
"Whether `eldev indent' should rewrite the misindented files.")

(eldev-defcommand clojure-ts-mode-indent-check-command (&rest parameters)
"Check that every Emacs Lisp source file of the project is indented the way
Emacs would indent it. Pass `--fix' to reindent the offenders in place
instead of only reporting them."
:command indent
:category testing
(when parameters
(signal 'eldev-wrong-command-usage `(t "Unexpected command parameters")))
(eldev-load-project-dependencies 'test)
(load (expand-file-name "test/indent-check.el" eldev-project-dir) nil t)
(unless (zerop (clojure-ts-mode-indent-check clojure-ts-mode-indent-check-fix))
(unless clojure-ts-mode-indent-check-fix
(signal 'eldev-error `("Some files are misindented; run `eldev indent --fix'")))))

(eldev-defbooloptions clojure-ts-mode-indent-check-do-fix
clojure-ts-mode-indent-check-just-check
clojure-ts-mode-indent-check-fix
("Reindent the misindented files in place"
:options (--fix))
("Only report the misindented lines"
:options (--check)
:hidden-if :default)
:for-command indent)
8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: clean compile lint test all
.PHONY: clean compile lint indent test all
.DEFAULT_GOAL := all

clean:
Expand All @@ -7,11 +7,15 @@ clean:
lint: clean
eldev lint -c

# Checks that the sources are indented the way Emacs would indent them.
indent:
eldev indent

# Checks for byte-compilation warnings.
compile: clean
eldev -dtT compile --warnings-as-errors

test: clean
eldev -dtT -p test

all: clean compile lint test
all: clean compile lint indent test
8 changes: 4 additions & 4 deletions test/clojure-ts-mode-cycling-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,14 @@
(clojure-ts-cycle-privacy))

(when-refactoring-it "should also work from the beginning of a sexp"
"(defn- add [a b]
"(defn- add [a b]
(+ a b))"

"(defn add [a b]
"(defn add [a b]
(+ a b))"

(backward-sexp)
(clojure-ts-cycle-privacy))
(backward-sexp)
(clojure-ts-cycle-privacy))

(when-refactoring-it "should use metadata when clojure-use-metadata-for-privacy is set to true"
"(defn add [a b]
Expand Down
20 changes: 10 additions & 10 deletions test/clojure-ts-mode-fill-paragraph-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@
\"This is a very long docstring that should be reformatted using fill-paragraph function.\"
[]
(pringln \"Hello world\"))"
(goto-char 40)
(prog-fill-reindent-defun)
(expect (buffer-substring-no-properties (point-min) (point-max))
:to-equal
"(ns foo)
(goto-char 40)
(prog-fill-reindent-defun)
(expect (buffer-substring-no-properties (point-min) (point-max))
:to-equal
"(ns foo)

(defn hello-world
\"This is a very long docstring that should be reformatted using
Expand All @@ -50,11 +50,11 @@
(with-clojure-ts-buffer "(ns foo)

;; This is a very long comment that should be reformatted using fill-paragraph function."
(goto-char 20)
(prog-fill-reindent-defun)
(expect (buffer-substring-no-properties (point-min) (point-max))
:to-equal
"(ns foo)
(goto-char 20)
(prog-fill-reindent-defun)
(expect (buffer-substring-no-properties (point-min) (point-max))
:to-equal
"(ns foo)

;; This is a very long comment that should be reformatted using
;; fill-paragraph function."))))
Expand Down
38 changes: 21 additions & 17 deletions test/clojure-ts-mode-font-lock-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
Assumes the current buffer is already fontified."
(let ((start-face (get-text-property start 'face))
(all-faces (cl-loop for i from start to end collect (get-text-property
i 'face))))
i 'face))))
(if (cl-every (lambda (face) (equal face start-face)) all-faces)
start-face
'various-faces)))
Expand Down Expand Up @@ -152,14 +152,14 @@ DESCRIPTION is the description of the spec."
("(deftest a (is (= 1 1)))" ("deftest" font-lock-keyword-face))


;; TODO: copied from clojure-mode, but failing
;; ("(defne [x y])" (2 6 font-lock-keyword-face))
;; ("(defnm a b)" (2 6 font-lock-keyword-face))
;; ("(defnu)" (2 6 font-lock-keyword-face))
;; ("(defnc [a])" (2 6 font-lock-keyword-face))
;; ("(defna)" (2 6 font-lock-keyword-face))
;; ("(deftask a)" (2 8 font-lock-keyword-face))
;; ("(defstate a :start \"b\" :stop \"c\")" (2 9 font-lock-keyword-face))
;; TODO: copied from clojure-mode, but failing
;; ("(defne [x y])" (2 6 font-lock-keyword-face))
;; ("(defnm a b)" (2 6 font-lock-keyword-face))
;; ("(defnu)" (2 6 font-lock-keyword-face))
;; ("(defnc [a])" (2 6 font-lock-keyword-face))
;; ("(defna)" (2 6 font-lock-keyword-face))
;; ("(deftask a)" (2 8 font-lock-keyword-face))
;; ("(defstate a :start \"b\" :stop \"c\")" (2 9 font-lock-keyword-face))

)

Expand Down Expand Up @@ -351,8 +351,9 @@ DESCRIPTION is the description of the spec."
(when-fontifying-it "should highlight keywords"
(":foo" ("foo" clojure-ts-keyword-face))
("::foo" ("foo" clojure-ts-keyword-face))
(":my.ns/bar" ("my.ns" font-lock-type-face)
("bar" clojure-ts-keyword-face))))
(":my.ns/bar"
("my.ns" font-lock-type-face)
("bar" clojure-ts-keyword-face))))

;;;; Strings

Expand All @@ -370,10 +371,12 @@ DESCRIPTION is the description of the spec."
(";;; heading" (";;; heading" font-lock-comment-face)))

(when-fontifying-it "should highlight discard expressions"
("#_foo" ("#_" font-lock-comment-delimiter-face)
("foo" font-lock-comment-face))
("#_(+ 1 2)" ("#_" font-lock-comment-delimiter-face)
("(+ 1 2)" font-lock-comment-face)))
("#_foo"
("#_" font-lock-comment-delimiter-face)
("foo" font-lock-comment-face))
("#_(+ 1 2)"
("#_" font-lock-comment-delimiter-face)
("(+ 1 2)" font-lock-comment-face)))

(it "should highlight comment macro name as delimiter"
(with-fontified-clojure-ts-buffer "(comment (+ 1 2))"
Expand Down Expand Up @@ -453,8 +456,9 @@ DESCRIPTION is the description of the spec."

(describe "regex-highlighting"
(when-fontifying-it "should highlight regex literals"
("#\"pattern\"" ("#" font-lock-punctuation-face)
("pattern" font-lock-regexp-face))))
("#\"pattern\""
("#" font-lock-punctuation-face)
("pattern" font-lock-regexp-face))))

;;;; Builtin macros

Expand Down
50 changes: 25 additions & 25 deletions test/clojure-ts-mode-indentation-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,17 @@ represents the expected position of point.
DESCRIPTION is a string with the description of the spec."
(declare (indent 1))
`(it ,description
(let* ((after ,after)
(expected-cursor-pos (1+ (clojure-ts--s-index-of "|" after)))
(expected-state (delete ?| after)))
(with-clojure-ts-buffer ,before
(goto-char (point-min))
(search-forward "|")
(delete-char -1)
(font-lock-ensure)
(indent-according-to-mode)
(expect (buffer-string) :to-equal expected-state)
(expect (point) :to-equal expected-cursor-pos)))))
(let* ((after ,after)
(expected-cursor-pos (1+ (clojure-ts--s-index-of "|" after)))
(expected-state (delete ?| after)))
(with-clojure-ts-buffer ,before
(goto-char (point-min))
(search-forward "|")
(delete-char -1)
(font-lock-ensure)
(indent-according-to-mode)
(expect (buffer-string) :to-equal expected-state)
(expect (point) :to-equal expected-cursor-pos)))))



Expand Down Expand Up @@ -698,7 +698,7 @@ DESCRIPTION is a string with the description of the spec."
(with-clojure-ts-buffer-point "
(let [a-long-name 10
b |20])"
(call-interactively #'clojure-ts-align)
(call-interactively #'clojure-ts-align)
(expect (buffer-string) :to-equal "
(let [a-long-name 10
b 20])"))
Expand All @@ -713,7 +713,7 @@ b |20])"
:a #long \"1234\"
:b {:this \"is\"
:nested \"map\"}}])"
(call-interactively #'clojure-ts-align)
(call-interactively #'clojure-ts-align)
(expect (buffer-string) :to-equal "
(let [^long my-map {:hello \"World\" ;Hello
:foo
Expand All @@ -730,7 +730,7 @@ b |20])"
|123 \"Hello\"
99999 \"World\"
234 nil)"
(call-interactively #'clojure-ts-align)
(call-interactively #'clojure-ts-align)
(expect (buffer-string) :to-equal "
(condp = 2
123 \"Hello\"
Expand All @@ -741,7 +741,7 @@ b |20])"
(with-clojure-ts-buffer-point "
#?(:clj 2
|:cljs 2)"
(call-interactively #'clojure-ts-align)
(call-interactively #'clojure-ts-align)
(expect (buffer-string) :to-equal "
#?(:clj 2
:cljs 2)")))
Expand All @@ -750,16 +750,16 @@ b |20])"
(with-clojure-ts-buffer-point "
#?(:clj 2
|:cljs 2)"
(setq-local clojure-ts-align-reader-conditionals t)
(setq-local clojure-ts-align-reader-conditionals t)
(call-interactively #'clojure-ts-align)
(expect (buffer-string) :to-equal "
#?(:clj 2
:cljs 2)")))

(it "should remove extra commas"
(with-clojure-ts-buffer-point "{|:a 2, ,:c 4}"
(call-interactively #'clojure-ts-align)
(expect (buffer-string) :to-equal "{:a 2, :c 4}"))))
(call-interactively #'clojure-ts-align)
(expect (buffer-string) :to-equal "{:a 2, :c 4}"))))

(describe "clojure-ts-align-forms-automatically"
;; Copied from `clojure-mode'
Expand Down Expand Up @@ -826,29 +826,29 @@ b |20])"
"
{c d
:this-is-a-form b}"
"
"
{c d
:this-is b}"
"
"
{c d
:this b}"
"
"
{c d
:a b}"

"
"
(let [c d
this-is-a-form b])"

"
"
(let [c d
this-is b])"

"
"
(let [c d
this b])"

"
"
(let [c d
a b])")

Expand Down
2 changes: 1 addition & 1 deletion test/clojure-ts-mode-util-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@
(in-ns 'foo3)
|
(ns foo4)"
(expect (clojure-ts-find-ns) :to-equal "foo3"))
(expect (clojure-ts-find-ns) :to-equal "foo3"))
(with-clojure-ts-buffer "(ns foo)
(ns-unmap *ns* 'map)
(ns.misleading 1 2 3)"
Expand Down
Loading
Loading