From 815bc387ec1436fb2fcac00ba8a61207636d0186 Mon Sep 17 00:00:00 2001 From: vemv Date: Sun, 26 May 2024 20:25:23 +0200 Subject: [PATCH 01/23] 5.20.0-snapshot --- clojure-mode.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clojure-mode.el b/clojure-mode.el index 1f23884b..1ff2e882 100644 --- a/clojure-mode.el +++ b/clojure-mode.el @@ -12,7 +12,7 @@ ;; Maintainer: Bozhidar Batsov ;; URL: https://github.com/clojure-emacs/clojure-mode ;; Keywords: languages clojure clojurescript lisp -;; Version: 5.19.0 +;; Version: 5.20.0-snapshot ;; Package-Requires: ((emacs "25.1")) ;; This file is not part of GNU Emacs. From 4ed6d606e345be4e4b015a5ac04460456240ec29 Mon Sep 17 00:00:00 2001 From: Bozhidar Batsov Date: Mon, 27 May 2024 07:29:34 +0200 Subject: [PATCH 02/23] Tweak some changelog entries --- CHANGELOG.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 22ba816f..b5ef88a7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,8 +7,8 @@ ### Bugs fixed * Fix `clojure-align` when called from `clojure-ts-mode` major mode buffers. -* [#671](https://github.com/clojure-emacs/clojure-mode/issues/671): Syntax highlighting for digits after the first in `%` args. (e.g. `%10`) -- [#680](https://github.com/clojure-emacs/clojure-mode/issues/680): Change syntax class of ASCII control characters to punctuation, fixing situations where carriage returns were being interpreted as symbols +* [#671](https://github.com/clojure-emacs/clojure-mode/issues/671): Syntax highlighting for digits after the first in `%` args. (e.g. `%10`). +* [#680](https://github.com/clojure-emacs/clojure-mode/issues/680): Change syntax class of ASCII control characters to punctuation, fixing situations where carriage returns were being interpreted as symbols. # Changes @@ -41,7 +41,6 @@ ### Bugs fixed * [#656](https://github.com/clojure-emacs/clojure-mode/issues/656): Fix clojure-find-ns when ns form is preceded by other forms. - * [#593](https://github.com/clojure-emacs/clojure-mode/issues/593): Fix clojure-find-ns when ns form is preceded by whitespace or inside comment form. ## 5.16.2 (2023-08-23) From 9c2f9677819510ec70e03d68a68a99e6d04175ca Mon Sep 17 00:00:00 2001 From: Bozhidar Batsov Date: Mon, 27 May 2024 07:34:03 +0200 Subject: [PATCH 03/23] Tweak a few more changelog entries --- CHANGELOG.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b5ef88a7..b5198123 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,7 @@ ### Bugs fixed * Fix `clojure-align` when called from `clojure-ts-mode` major mode buffers. -* [#671](https://github.com/clojure-emacs/clojure-mode/issues/671): Syntax highlighting for digits after the first in `%` args. (e.g. `%10`). +* [#671](https://github.com/clojure-emacs/clojure-mode/issues/671): Syntax highlighting for digits after the first in `%` args. (e.g. `%10`) * [#680](https://github.com/clojure-emacs/clojure-mode/issues/680): Change syntax class of ASCII control characters to punctuation, fixing situations where carriage returns were being interpreted as symbols. # Changes @@ -40,14 +40,14 @@ ### Bugs fixed -* [#656](https://github.com/clojure-emacs/clojure-mode/issues/656): Fix clojure-find-ns when ns form is preceded by other forms. -* [#593](https://github.com/clojure-emacs/clojure-mode/issues/593): Fix clojure-find-ns when ns form is preceded by whitespace or inside comment form. +* [#656](https://github.com/clojure-emacs/clojure-mode/issues/656): Fix `clojure-find-ns` when ns form is preceded by other forms. +* [#593](https://github.com/clojure-emacs/clojure-mode/issues/593): Fix `clojure-find-ns` when ns form is preceded by whitespace or inside comment form. ## 5.16.2 (2023-08-23) ### Changes -* `clojure-find-ns`: add an option to never raise errors, returning nil instead on unparseable ns forms. +* `clojure-find-ns`: add an option to never raise errors, returning `nil` instead on unparseable ns forms. ## 5.16.1 (2023-06-26) @@ -71,7 +71,7 @@ * [#581](https://github.com/clojure-emacs/clojure-mode/issues/581): Fix font locking not working for keywords starting with a number. * [#377](https://github.com/clojure-emacs/clojure-mode/issues/377): Fix everything starting with the prefix `def` being highlighted as a definition form. Now definition forms are enumerated explicitly in the font-locking code, like all other forms. -* [#638](https://github.com/clojure-emacs/clojure-mode/pull/638): Fix imenu with Clojure code in string or comment. +* [#638](https://github.com/clojure-emacs/clojure-mode/pull/638): Fix `imenu` with Clojure code in string or comment. ## 5.15.1 (2022-07-30) From 59888c84b61081e9b0085e388f55132925a66e7a Mon Sep 17 00:00:00 2001 From: Xiyue Deng Date: Mon, 3 Jun 2024 02:35:25 -0700 Subject: [PATCH 04/23] Don't use custom logic to find source directory of clojure-mode.el * Or this will prevent buttercup tests from working with installed clojure-mode under ELPA directories. * A bit more background: in Debian there is autopkgtest which tests the installed package. dh-elpa enables a mode that runs the same ERT or Buttercup tests against the installed package instead of the source tree. In this case, it will let the tests pass during build phase, but autopkgtest will fail as this custom code will still try to locate the source code which will no longer be available. * I have tested under Debian sbuild that removing the code will let the buttercup tests pass under autopkgtest, but not sure whether this is still required for Eldev to work. --- test/utils/test-helper.el | 7 ------- 1 file changed, 7 deletions(-) diff --git a/test/utils/test-helper.el b/test/utils/test-helper.el index e7894f04..af5273a2 100644 --- a/test/utils/test-helper.el +++ b/test/utils/test-helper.el @@ -25,13 +25,6 @@ (message "Running tests on Emacs %s" emacs-version) -(let* ((current-file (if load-in-progress load-file-name (buffer-file-name))) - (source-directory (locate-dominating-file current-file "Eldev")) - ;; Do not load outdated byte code for tests - (load-prefer-newer t)) - ;; Load the file under test - (load (expand-file-name "clojure-mode" source-directory))) - (defmacro with-clojure-buffer (text &rest body) "Create a temporary buffer, insert TEXT, switch to clojure-mode and evaluate BODY." (declare (indent 1)) From 63356ee3bd6903e7b17822022f5a6ded2512b979 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fredrik=20Vaeng=20R=C3=B8tnes?= Date: Mon, 25 Nov 2024 12:23:05 +0100 Subject: [PATCH 05/23] Relax regexp for clojure-find-def to recognize more complex metadata on vars (#682) --- CHANGELOG.md | 4 +++ clojure-mode.el | 2 +- test/clojure-mode-util-test.el | 45 ++++++++++++++++++++++++++++++++++ 3 files changed, 50 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b5198123..f4cbb8e3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## master (unreleased) +### Bugs fixed + +* [cider#3758](https://github.com/clojure-emacs/cider/issues/3758): Improve regexp for clojure-find-def to recognize more complex metadata on vars + ## 5.19.0 (2024-05-26) ### Bugs fixed diff --git a/clojure-mode.el b/clojure-mode.el index 1ff2e882..2281065f 100644 --- a/clojure-mode.el +++ b/clojure-mode.el @@ -2270,7 +2270,7 @@ renaming a namespace." ;; Any whitespace "[ \r\n\t]*" ;; Possibly type or metadata - "\\(?:#?^\\(?:{[^}]*}\\|\\(?:\\sw\\|\\s_\\)+\\)[ \r\n\t]*\\)*" + "\\(?:#?^\\(?:{[^}]*}+\\|\\(?:\\sw\\|\\s_\\)+\\)[ \r\n\t]*\\)*" ;; Symbol name "\\(\\(?:\\sw\\|\\s_\\)+\\)")) diff --git a/test/clojure-mode-util-test.el b/test/clojure-mode-util-test.el index 78a2ac17..f1895b67 100644 --- a/test/clojure-mode-util-test.el +++ b/test/clojure-mode-util-test.el @@ -331,6 +331,51 @@ {:nested (in|c x)})" (clojure-toggle-ignore-defun))) +(describe "clojure-find-def" + (it "should recognize def and defn" + (with-clojure-buffer-point + "(def foo 1)| + (defn bar [x y z] z)" + (expect (clojure-find-def) :to-equal '("def" "foo"))) + (with-clojure-buffer-point + "(def foo 1) + (defn bar |[x y z] z)" + (expect (clojure-find-def) :to-equal '("defn" "bar"))) + (with-clojure-buffer-point + "(def foo 1) + (defn ^:private bar |[x y z] z)" + (expect (clojure-find-def) :to-equal '("defn" "bar"))) + (with-clojure-buffer-point + "(defn |^{:doc \"A function\"} foo [] 1) + (defn ^:private bar 2)" + (expect (clojure-find-def) :to-equal '("defn" "foo")))) + (it "should recognize deftest, with or without metadata added to the var" + (with-clojure-buffer-point + "|(deftest ^{:a 1} simple-metadata) + (deftest ^{:a {}} complex-metadata) + (deftest no-metadata)" + (expect (clojure-find-def) :to-equal '("deftest" "simple-metadata"))) + (with-clojure-buffer-point + "(deftest ^{:a 1} |simple-metadata) + (deftest ^{:a {}} complex-metadata) + (deftest no-metadata)" + (expect (clojure-find-def) :to-equal '("deftest" "simple-metadata"))) + (with-clojure-buffer-point + "(deftest ^{:a 1} simple-metadata) + (deftest ^{:a {}} |complex-metadata) + (deftest no-metadata)" + (expect (clojure-find-def) :to-equal '("deftest" "complex-metadata"))) + (with-clojure-buffer-point + "(deftest ^{:a 1} simple-metadata) + (deftest ^{:|a {}} complex-metadata) + (deftest no-metadata)" + (expect (clojure-find-def) :to-equal '("deftest" "complex-metadata"))) + (with-clojure-buffer-point + "(deftest ^{:a 1} simple-metadata) + (deftest ^{:a {}} complex-metadata) + (deftest |no-metadata)" + (expect (clojure-find-def) :to-equal '("deftest" "no-metadata"))))) + (provide 'clojure-mode-util-test) ;;; clojure-mode-util-test.el ends here From 740ca698b02725a6506aad873ff080c51982e5e7 Mon Sep 17 00:00:00 2001 From: Jeff Valk Date: Mon, 9 Dec 2024 10:51:05 -0500 Subject: [PATCH 06/23] Restore outline-regexp pattern for top-level forms Multiple alternate patterns were previously removed from outline-regexp in b1ea6de. The pattern restored in this commit is needed to enable top-level forms to participate in outline-minor-mode. Adding this pattern back in does not undo the fix intended in b1ea6de. --- CHANGELOG.md | 1 + clojure-mode.el | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f4cbb8e3..5e78866c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ ### Bugs fixed * [cider#3758](https://github.com/clojure-emacs/cider/issues/3758): Improve regexp for clojure-find-def to recognize more complex metadata on vars +* [#684](https://github.com/clojure-emacs/clojure-mode/issues/684): Restore `outline-regexp` pattern to permit outline handling of top-level forms. ## 5.19.0 (2024-05-26) diff --git a/clojure-mode.el b/clojure-mode.el index 2281065f..e6f7e185 100644 --- a/clojure-mode.el +++ b/clojure-mode.el @@ -625,7 +625,7 @@ replacement for `cljr-expand-let`." (add-to-list 'imenu-generic-expression '(nil clojure-match-next-def 0)) (setq-local indent-tabs-mode nil) (setq-local paragraph-ignore-fill-prefix t) - (setq-local outline-regexp ";;;;* ") + (setq-local outline-regexp ";;;;* \\|(") ; comments and top-level forms (setq-local outline-level 'lisp-outline-level) (setq-local comment-start ";") (setq-local comment-start-skip ";+ *") From 76630045fb5b1660c91e2ab960f5636f4d567c47 Mon Sep 17 00:00:00 2001 From: Sophie Bosio Date: Thu, 5 Dec 2024 16:35:52 +0100 Subject: [PATCH 07/23] Recognize hyphen or end of comment --- clojure-mode.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clojure-mode.el b/clojure-mode.el index e6f7e185..a70ad39c 100644 --- a/clojure-mode.el +++ b/clojure-mode.el @@ -2266,7 +2266,7 @@ renaming a namespace." (defconst clojure-def-type-and-name-regex (concat "(\\(?:\\(?:\\sw\\|\\s_\\)+/\\)?" ;; Declaration - "\\(def\\(?:\\sw\\|\\s_\\)*\\)\\>" + "\\(def\\(?:\\sw\\|\\s_\\)*\\(?:-\\|\\>\\)\\)" ;; Any whitespace "[ \r\n\t]*" ;; Possibly type or metadata From 497727a1305dc29efcc273f6985ace2f5b08b27f Mon Sep 17 00:00:00 2001 From: Sophie Bosio Date: Thu, 5 Dec 2024 16:36:45 +0100 Subject: [PATCH 08/23] Add tests --- test/clojure-mode-util-test.el | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/test/clojure-mode-util-test.el b/test/clojure-mode-util-test.el index f1895b67..c372cffc 100644 --- a/test/clojure-mode-util-test.el +++ b/test/clojure-mode-util-test.el @@ -374,7 +374,21 @@ "(deftest ^{:a 1} simple-metadata) (deftest ^{:a {}} complex-metadata) (deftest |no-metadata)" - (expect (clojure-find-def) :to-equal '("deftest" "no-metadata"))))) + (expect (clojure-find-def) :to-equal '("deftest" "no-metadata")))) + (it "should recognize defn-" + (with-clojure-buffer-point + "(def foo 1) + (defn- bar |[x y z] z) + (def bar 2)" + (expect (clojure-find-def) :to-equal '("defn-" "bar"))) + (with-clojure-buffer-point + "(def foo 1) + (defn- ^:private bar |[x y z] z)" + (expect (clojure-find-def) :to-equal '("defn-" "bar"))) + (with-clojure-buffer-point + "(defn- |^{:doc \"A function\"} foo [] 1) + (defn- ^:private bar 2)" + (expect (clojure-find-def) :to-equal '("defn-" "foo"))))) (provide 'clojure-mode-util-test) From 06a01df8fc6a3478cfb90181444aa0a720bdcd4a Mon Sep 17 00:00:00 2001 From: Sophie Bosio Date: Thu, 5 Dec 2024 17:10:38 +0100 Subject: [PATCH 09/23] Also test for `def-n-` --- test/clojure-mode-util-test.el | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test/clojure-mode-util-test.el b/test/clojure-mode-util-test.el index c372cffc..fb68fa7c 100644 --- a/test/clojure-mode-util-test.el +++ b/test/clojure-mode-util-test.el @@ -388,7 +388,11 @@ (with-clojure-buffer-point "(defn- |^{:doc \"A function\"} foo [] 1) (defn- ^:private bar 2)" - (expect (clojure-find-def) :to-equal '("defn-" "foo"))))) + (expect (clojure-find-def) :to-equal '("defn-" "foo"))) + (with-clojure-buffer-point + "(def-n- |^{:doc \"A function\"} foo [] 1) + (defn- ^:private bar 2)" + (expect (clojure-find-def) :to-equal '("def-n-" "foo"))))) (provide 'clojure-mode-util-test) From bdcc372ba6f2eba9f9ca285433fd531b763ab04f Mon Sep 17 00:00:00 2001 From: Sophie Bosio Date: Tue, 10 Dec 2024 20:04:31 +0100 Subject: [PATCH 10/23] Split `def...-` test into new `it` group --- test/clojure-mode-util-test.el | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/clojure-mode-util-test.el b/test/clojure-mode-util-test.el index fb68fa7c..c7b47e3c 100644 --- a/test/clojure-mode-util-test.el +++ b/test/clojure-mode-util-test.el @@ -375,7 +375,7 @@ (deftest ^{:a {}} complex-metadata) (deftest |no-metadata)" (expect (clojure-find-def) :to-equal '("deftest" "no-metadata")))) - (it "should recognize defn-" + (it "should recognize defn-, with or without metadata" (with-clojure-buffer-point "(def foo 1) (defn- bar |[x y z] z) @@ -388,7 +388,8 @@ (with-clojure-buffer-point "(defn- |^{:doc \"A function\"} foo [] 1) (defn- ^:private bar 2)" - (expect (clojure-find-def) :to-equal '("defn-" "foo"))) + (expect (clojure-find-def) :to-equal '("defn-" "foo")))) + (it "should recognize def...-, with or without metadata" (with-clojure-buffer-point "(def-n- |^{:doc \"A function\"} foo [] 1) (defn- ^:private bar 2)" From 4528e876e5294e29dd0fb6f17d6331cb401d58ef Mon Sep 17 00:00:00 2001 From: Sophie Bosio Date: Tue, 10 Dec 2024 20:24:44 +0100 Subject: [PATCH 11/23] Add more `def...-` tests, with and without metadata --- test/clojure-mode-util-test.el | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/test/clojure-mode-util-test.el b/test/clojure-mode-util-test.el index c7b47e3c..be708c39 100644 --- a/test/clojure-mode-util-test.el +++ b/test/clojure-mode-util-test.el @@ -390,10 +390,39 @@ (defn- ^:private bar 2)" (expect (clojure-find-def) :to-equal '("defn-" "foo")))) (it "should recognize def...-, with or without metadata" + (with-clojure-buffer-point + "(def foo 1) + (def- bar| 5) + (def baz 2)" + (expect (clojure-find-def) :to-equal '("def-" "bar"))) + (with-clojure-buffer-point + "(def foo 1) + (deftest- bar |[x y z] z) + (def baz 2)" + (expect (clojure-find-def) :to-equal '("deftest-" "bar"))) + (with-clojure-buffer-point + "(def foo 1) + (defxyz- bar| 5) + (def baz 2)" + (expect (clojure-find-def) :to-equal '("defxyz-" "bar"))) + (with-clojure-buffer-point + "(def foo 1) + (defn-n- bar| [x y z] z) + (def baz 2)" + (expect (clojure-find-def) :to-equal '("defn-n-" "bar"))) + (with-clojure-buffer-point + "(def foo 1) + (defn-n- ^:private bar |[x y z] z)" + (expect (clojure-find-def) :to-equal '("defn-n-" "bar"))) (with-clojure-buffer-point "(def-n- |^{:doc \"A function\"} foo [] 1) - (defn- ^:private bar 2)" - (expect (clojure-find-def) :to-equal '("def-n-" "foo"))))) + (def- ^:private bar 2)" + (expect (clojure-find-def) :to-equal '("def-n-" "foo"))) + (with-clojure-buffer-point + "(def foo 1) + (defn-n- ^{:|a {}} complex-metadata |[x y z] z) + (def bar 2)" + (expect (clojure-find-def) :to-equal '("defn-n-" "complex-metadata"))))) (provide 'clojure-mode-util-test) From 60ec48579e549b6272b50743c7f743a76751e068 Mon Sep 17 00:00:00 2001 From: Sophie Bosio Date: Tue, 10 Dec 2024 20:09:13 +0100 Subject: [PATCH 12/23] Add test case with complex metadata --- test/clojure-mode-util-test.el | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/test/clojure-mode-util-test.el b/test/clojure-mode-util-test.el index be708c39..d905fc70 100644 --- a/test/clojure-mode-util-test.el +++ b/test/clojure-mode-util-test.el @@ -388,7 +388,12 @@ (with-clojure-buffer-point "(defn- |^{:doc \"A function\"} foo [] 1) (defn- ^:private bar 2)" - (expect (clojure-find-def) :to-equal '("defn-" "foo")))) + (expect (clojure-find-def) :to-equal '("defn-" "foo"))) + (with-clojure-buffer-point + "(def foo 1) + (defn- ^{:|a {}} complex-metadata |[x y z] z) + (def bar 2)" + (expect (clojure-find-def) :to-equal '("defn-" "complex-metadata")))) (it "should recognize def...-, with or without metadata" (with-clojure-buffer-point "(def foo 1) From eabe29b076fff19db552d36d4babaa36ecf0b704 Mon Sep 17 00:00:00 2001 From: Sophie Bosio Date: Tue, 10 Dec 2024 20:31:46 +0100 Subject: [PATCH 13/23] Update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5e78866c..b4645400 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ * [cider#3758](https://github.com/clojure-emacs/cider/issues/3758): Improve regexp for clojure-find-def to recognize more complex metadata on vars * [#684](https://github.com/clojure-emacs/clojure-mode/issues/684): Restore `outline-regexp` pattern to permit outline handling of top-level forms. +* Improve regexp for clojure-find-def to recognize `defn-` and other declarations on the form `def...-`. ## 5.19.0 (2024-05-26) From b766094aea28bdc7b44ce1960d96434fe7d1d9cf Mon Sep 17 00:00:00 2001 From: Bozhidar Batsov Date: Sun, 6 Apr 2025 18:43:28 +0300 Subject: [PATCH 14/23] Update the bug report template --- .github/{ISSUE_TEMPLATE.md => ISSUE_TEMPLATE/bug_report.md} | 6 ++++++ 1 file changed, 6 insertions(+) rename .github/{ISSUE_TEMPLATE.md => ISSUE_TEMPLATE/bug_report.md} (88%) diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE/bug_report.md similarity index 88% rename from .github/ISSUE_TEMPLATE.md rename to .github/ISSUE_TEMPLATE/bug_report.md index 421e8683..dcf8bb8e 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -1,3 +1,9 @@ +--- +name: Bug Report +about: Report an issue with clojure-mode you've discovered. +labels: [bug] +--- + *Use the template below when reporting bugs. Please, make sure that you're running the latest stable clojure-mode and that the problem you're reporting hasn't been reported (and potentially fixed) already.* From 62506769058beb1d32bbb1c916a2796169441d2c Mon Sep 17 00:00:00 2001 From: Bozhidar Batsov Date: Tue, 27 May 2025 11:08:05 +0300 Subject: [PATCH 15/23] Remove dead code --- clojure-mode.el | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/clojure-mode.el b/clojure-mode.el index a70ad39c..202bd4da 100644 --- a/clojure-mode.el +++ b/clojure-mode.el @@ -542,16 +542,6 @@ ENDP and DELIM." "\\_<\\(?:'+\\|#\\)") (line-beginning-position))))) -(defconst clojure--collection-tag-regexp "#\\(::[a-zA-Z0-9._-]*\\|:?\\([a-zA-Z0-9._-]+/\\)?[a-zA-Z0-9._-]+\\)" - "Collection reader macro tag regexp. -It is intended to check for 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.") - -(make-obsolete-variable 'clojure--collection-tag-regexp nil "5.12.0") -(make-obsolete 'clojure-no-space-after-tag 'clojure-space-for-delimiter-p "5.12.0") - (declare-function paredit-open-curly "ext:paredit" t t) (declare-function paredit-close-curly "ext:paredit" t t) (declare-function paredit-convolute-sexp "ext:paredit") From d87d13a13f2e4ad070c0d4307a252084dbb2ba53 Mon Sep 17 00:00:00 2001 From: Bozhidar Batsov Date: Tue, 27 May 2025 11:09:23 +0300 Subject: [PATCH 16/23] Add clojuredart and jank support --- CHANGELOG.md | 4 ++++ clojure-mode.el | 14 ++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b4645400..2afde305 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,10 @@ * [#684](https://github.com/clojure-emacs/clojure-mode/issues/684): Restore `outline-regexp` pattern to permit outline handling of top-level forms. * Improve regexp for clojure-find-def to recognize `defn-` and other declarations on the form `def...-`. +### New features + +* Add `clojuredart-mode` and `jank-mode`, derived from `clojure-mode`. + ## 5.19.0 (2024-05-26) ### Bugs fixed diff --git a/clojure-mode.el b/clojure-mode.el index 202bd4da..2a5f13dd 100644 --- a/clojure-mode.el +++ b/clojure-mode.el @@ -3310,12 +3310,26 @@ With universal argument \\[universal-argument], act on the \"top-level\" form." \\{clojurec-mode-map}") +;;;###autoload +(define-derived-mode clojuredart-mode clojure-mode "ClojureDart[TS]" + "Major mode for editing Clojure Dart code. + +\\{clojuredart-mode-map}") + +;;;###autoload +(define-derived-mode jank-mode clojure-mode "Jank[TS]" + "Major mode for editing Jank code. + +\\{jank-mode-map}") + ;;;###autoload (progn (add-to-list 'auto-mode-alist '("\\.\\(clj\\|cljd\\|dtm\\|edn\\|lpy\\)\\'" . clojure-mode)) (add-to-list 'auto-mode-alist '("\\.cljc\\'" . clojurec-mode)) (add-to-list 'auto-mode-alist '("\\.cljs\\'" . clojurescript-mode)) + (add-to-list 'auto-mode-alist '("\\.cljd\\'" . clojuredart-mode)) + (add-to-list 'auto-mode-alist '("\\.jank\\'" . jank-mode)) ;; boot build scripts are Clojure source files (add-to-list 'auto-mode-alist '("\\(?:build\\|profile\\)\\.boot\\'" . clojure-mode)) ;; babashka scripts are Clojure source files From ded18dde634e6b1c0cfbef5e8589ca4a1ccbcc7e Mon Sep 17 00:00:00 2001 From: Bozhidar Batsov Date: Tue, 27 May 2025 11:10:08 +0300 Subject: [PATCH 17/23] Tweak a couple of changelog entries --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2afde305..cf27260a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,9 +4,9 @@ ### Bugs fixed -* [cider#3758](https://github.com/clojure-emacs/cider/issues/3758): Improve regexp for clojure-find-def to recognize more complex metadata on vars +* [cider#3758](https://github.com/clojure-emacs/cider/issues/3758): Improve regexp for `clojure-find-def` to recognize more complex metadata on vars. * [#684](https://github.com/clojure-emacs/clojure-mode/issues/684): Restore `outline-regexp` pattern to permit outline handling of top-level forms. -* Improve regexp for clojure-find-def to recognize `defn-` and other declarations on the form `def...-`. +* Improve regexp for `clojure-find-def` to recognize `defn-` and other declarations on the form `def...-`. ### New features From a2331ace618c039734b960ba76ffe2c2d2b6775b Mon Sep 17 00:00:00 2001 From: Bozhidar Batsov Date: Tue, 27 May 2025 11:20:01 +0300 Subject: [PATCH 18/23] Add joker-mode --- CHANGELOG.md | 2 +- clojure-mode.el | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cf27260a..57a511c4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,7 +10,7 @@ ### New features -* Add `clojuredart-mode` and `jank-mode`, derived from `clojure-mode`. +* Add `clojuredart-mode`, `joker-mode` and `jank-mode`, derived from `clojure-mode`. ## 5.19.0 (2024-05-26) diff --git a/clojure-mode.el b/clojure-mode.el index 2a5f13dd..464f74e4 100644 --- a/clojure-mode.el +++ b/clojure-mode.el @@ -3311,17 +3311,23 @@ With universal argument \\[universal-argument], act on the \"top-level\" form." \\{clojurec-mode-map}") ;;;###autoload -(define-derived-mode clojuredart-mode clojure-mode "ClojureDart[TS]" +(define-derived-mode clojuredart-mode clojure-mode "ClojureDart" "Major mode for editing Clojure Dart code. \\{clojuredart-mode-map}") ;;;###autoload -(define-derived-mode jank-mode clojure-mode "Jank[TS]" +(define-derived-mode jank-mode clojure-mode "Jank" "Major mode for editing Jank code. \\{jank-mode-map}") +;;;###autoload +(define-derived-mode joker-mode clojure-mode "Joker" + "Major mode for editing Joker code. + +\\{joker-mode-map}") + ;;;###autoload (progn (add-to-list 'auto-mode-alist @@ -3330,6 +3336,7 @@ With universal argument \\[universal-argument], act on the \"top-level\" form." (add-to-list 'auto-mode-alist '("\\.cljs\\'" . clojurescript-mode)) (add-to-list 'auto-mode-alist '("\\.cljd\\'" . clojuredart-mode)) (add-to-list 'auto-mode-alist '("\\.jank\\'" . jank-mode)) + (add-to-list 'auto-mode-alist '("\\.joke\\'" . joker-mode)) ;; boot build scripts are Clojure source files (add-to-list 'auto-mode-alist '("\\(?:build\\|profile\\)\\.boot\\'" . clojure-mode)) ;; babashka scripts are Clojure source files From f95f04c8fd1a377b59d7341db3b05d8a51f6aec7 Mon Sep 17 00:00:00 2001 From: Bozhidar Batsov Date: Tue, 27 May 2025 11:26:16 +0300 Subject: [PATCH 19/23] Mention the new modes in the docs --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 1862db14..7f60239b 100644 --- a/README.md +++ b/README.md @@ -50,6 +50,9 @@ The `clojure-mode` package actually bundles together several major modes: * `clojure-mode` is a major mode for editing Clojure code * `clojurescript-mode` is a major mode for editing ClojureScript code * `clojurec-mode` is a major mode for editing `.cljc` source files +* `clojuredart-mode` is a major mode for editing ClojureDart `.cljd` source files +* `jank-mode` is a major mode for editing Jank `.jank` source files +* `joker-mode` is a major mode for editing Joker `.joke` source files All the major modes derive from `clojure-mode` and provide more or less the same functionality. Differences can be found mostly in the font-locking - From d336db623e7ae8cffff50aaaea3f1b05cc4ccecb Mon Sep 17 00:00:00 2001 From: Bozhidar Batsov Date: Tue, 27 May 2025 11:40:23 +0300 Subject: [PATCH 20/23] Release 5.20 --- CHANGELOG.md | 10 ++++++---- README.md | 2 +- clojure-mode.el | 4 ++-- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 57a511c4..51077f9e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,16 +2,18 @@ ## master (unreleased) +## 5.20.0 (2025-05-27) + +### New features + +* Add `clojuredart-mode`, `joker-mode` and `jank-mode`, derived from `clojure-mode`. + ### Bugs fixed * [cider#3758](https://github.com/clojure-emacs/cider/issues/3758): Improve regexp for `clojure-find-def` to recognize more complex metadata on vars. * [#684](https://github.com/clojure-emacs/clojure-mode/issues/684): Restore `outline-regexp` pattern to permit outline handling of top-level forms. * Improve regexp for `clojure-find-def` to recognize `defn-` and other declarations on the form `def...-`. -### New features - -* Add `clojuredart-mode`, `joker-mode` and `jank-mode`, derived from `clojure-mode`. - ## 5.19.0 (2024-05-26) ### Bugs fixed diff --git a/README.md b/README.md index 7f60239b..24d154a4 100644 --- a/README.md +++ b/README.md @@ -620,7 +620,7 @@ An extensive changelog is available [here](CHANGELOG.md). ## License -Copyright © 2007-2024 Jeffrey Chu, Lennart Staflin, Phil Hagelberg, Bozhidar +Copyright © 2007-2025 Jeffrey Chu, Lennart Staflin, Phil Hagelberg, Bozhidar Batsov, Artur Malabarba, Magnar Sveen and [contributors][]. Distributed under the GNU General Public License; type C-h C-c to view it. diff --git a/clojure-mode.el b/clojure-mode.el index 464f74e4..c3d950ce 100644 --- a/clojure-mode.el +++ b/clojure-mode.el @@ -1,7 +1,7 @@ ;;; clojure-mode.el --- Major mode for Clojure code -*- lexical-binding: t; -*- ;; Copyright © 2007-2013 Jeffrey Chu, Lennart Staflin, Phil Hagelberg -;; Copyright © 2013-2024 Bozhidar Batsov, Artur Malabarba, Magnar Sveen +;; Copyright © 2013-2025 Bozhidar Batsov, Artur Malabarba, Magnar Sveen ;; ;; Authors: Jeffrey Chu ;; Lennart Staflin @@ -12,7 +12,7 @@ ;; Maintainer: Bozhidar Batsov ;; URL: https://github.com/clojure-emacs/clojure-mode ;; Keywords: languages clojure clojurescript lisp -;; Version: 5.20.0-snapshot +;; Version: 5.20.0 ;; Package-Requires: ((emacs "25.1")) ;; This file is not part of GNU Emacs. From 095b36f836c4581ab8651438dec9c346af44e6d8 Mon Sep 17 00:00:00 2001 From: Bozhidar Batsov Date: Tue, 27 May 2025 13:22:55 +0300 Subject: [PATCH 21/23] Remove kofi and liberapay --- .github/FUNDING.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml index 24e86434..718dd0d1 100644 --- a/.github/FUNDING.yml +++ b/.github/FUNDING.yml @@ -2,7 +2,5 @@ github: bbatsov patreon: bbatsov -ko_fi: bbatsov open_collective: cider -liberapay: bbatsov custom: https://www.paypal.me/bbatsov From 3238096e7637205ac109fe6b28d7a088848d2f15 Mon Sep 17 00:00:00 2001 From: Bozhidar Batsov Date: Tue, 27 May 2025 14:16:41 +0300 Subject: [PATCH 22/23] Improve the markup of the README --- README.md | 80 +++++++++++++++++++++++++++++++++---------------------- 1 file changed, 48 insertions(+), 32 deletions(-) diff --git a/README.md b/README.md index 24d154a4..f8ce6bf4 100644 --- a/README.md +++ b/README.md @@ -11,13 +11,13 @@ highlighting), indentation, navigation and refactoring support for the [Clojure(Script) programming language](https://clojure.org). ------------ - -**This documentation tracks the `master` branch of `clojure-mode`. Some of -the features and settings discussed here might not be available in -older releases (including the current stable release). Please, consult -the relevant git tag (e.g. [5.19.0](https://github.com/clojure-emacs/clojure-mode/tree/v5.19.0)) if you need documentation for a -specific `clojure-mode` release.** +> [!IMPORTANT] +> +> This documentation tracks the `master` branch of `clojure-mode`. Some of the +> features and settings discussed here might not be available in older releases +> (including the current stable release). Please, consult the relevant git tag +> (e.g. [5.20.0](https://github.com/clojure-emacs/clojure-mode/tree/v5.20.0)) if +> you need documentation for a specific `clojure-mode` release. ## Installation @@ -47,12 +47,12 @@ If the installation doesn't work try refreshing the package list: The `clojure-mode` package actually bundles together several major modes: -* `clojure-mode` is a major mode for editing Clojure code -* `clojurescript-mode` is a major mode for editing ClojureScript code -* `clojurec-mode` is a major mode for editing `.cljc` source files -* `clojuredart-mode` is a major mode for editing ClojureDart `.cljd` source files -* `jank-mode` is a major mode for editing Jank `.jank` source files -* `joker-mode` is a major mode for editing Joker `.joke` source files +- `clojure-mode` is a major mode for editing Clojure code +- `clojurescript-mode` is a major mode for editing ClojureScript code +- `clojurec-mode` is a major mode for editing `.cljc` source files +- `clojuredart-mode` is a major mode for editing ClojureDart `.cljd` source files +- `jank-mode` is a major mode for editing Jank `.jank` source files +- `joker-mode` is a major mode for editing Joker `.joke` source files All the major modes derive from `clojure-mode` and provide more or less the same functionality. Differences can be found mostly in the font-locking - @@ -140,14 +140,16 @@ The indentation of function forms is configured by the variable 2) ``` -**Note:** Prior to clojure-mode 5.10, the configuration options for `clojure-indent-style` used to be -keywords, but now they are symbols. Keywords will still be supported at least until clojure-mode 6. +> [!NOTE] +> +> Prior to clojure-mode 5.10, the configuration options for `clojure-indent-style` used to be +> keywords, but now they are symbols. Keywords will still be supported at least until clojure-mode 6. #### Indentation of keywords Similarly we have the `clojure-indent-keyword-style`, which works in the following way: -* `always-align` (default) - All +- `always-align` (default) - All args are vertically aligned with the first arg in case (A), and vertically aligned with the function name in case (B). @@ -159,7 +161,7 @@ Similarly we have the `clojure-indent-keyword-style`, which works in the followi [bar.baz]) ``` -* `always-indent` - All args are indented like a macro body. +- `always-indent` - All args are indented like a macro body. ``` clojure (:require [foo.bar] @@ -169,7 +171,7 @@ Similarly we have the `clojure-indent-keyword-style`, which works in the followi 0) ``` -* `align-arguments` - Case (A) is indented like `always-align`, and +- `align-arguments` - Case (A) is indented like `always-align`, and case (B) is indented like a macro body. ``` clojure @@ -288,7 +290,11 @@ You can change this behaviour like this: You might also want to change `comment-add` to 0 in that way, so that Emacs comment functions (e.g. `comment-region`) would use `;` by default instead of `;;`. -**Note:** Check out [this section](https://guide.clojure.style/#comments) of the Clojure style guide to understand better the semantics of the different comment levels and why `clojure-mode` treats them differently by default. +> [!TIP] +> +> Check out [this section](https://guide.clojure.style/#comments) of the Clojure +> style guide to understand better the semantics of the different comment levels +> and why `clojure-mode` treats them differently by default. ### Vertical alignment @@ -315,9 +321,11 @@ happen whenever you select some code and hit `TAB`. ### Font-locking -`clojure-mode` features static font-locking (syntax highlighting) that you can extend yourself -if needed. As typical for Emacs, it's based on regular expressions. You can find -the default font-locking rules in `clojure-font-lock-keywords`. Here's how you can add font-locking for built-in Clojure functions and vars: +`clojure-mode` features static font-locking (syntax highlighting) that you can +extend yourself if needed. As typical for Emacs, it's based on regular +expressions. You can find the default font-locking rules in +`clojure-font-lock-keywords`. Here's how you can add font-locking for built-in +Clojure functions and vars: ``` el (defvar clojure-built-in-vars @@ -360,9 +368,12 @@ var a symbol resolves to). That's why `clojure-mode`'s font-locking defaults are conservative and minimalistic. Precise font-locking requires additional data that can obtained from a running -REPL (that's how CIDER's [dynamic font-locking](https://docs.cider.mx/cider/config/syntax_highlighting.html) works) or from static code analysis. +REPL (that's how CIDER's [dynamic +font-locking](https://docs.cider.mx/cider/config/syntax_highlighting.html) +works) or from static code analysis. -When it comes to non built-in definitions, `clojure-mode` needs to be manually instructed how to handle the docstrings and highlighting. Here's an example: +When it comes to non built-in definitions, `clojure-mode` needs to be manually +instructed how to handle the docstrings and highlighting. Here's an example: ``` emacs-lisp (put '>defn 'clojure-doc-string-elt 2) @@ -373,7 +384,9 @@ When it comes to non built-in definitions, `clojure-mode` needs to be manually i 1 font-lock-keyword-face))) ``` -**Note:** The `clojure-doc-string-elt` attribute is processed by the function `clojure-font-lock-syntactic-face-function`. +> [!NOTE] +> +> The `clojure-doc-string-elt` attribute is processed by the function `clojure-font-lock-syntactic-face-function`. ## Refactoring support @@ -481,7 +494,7 @@ without affecting the namespace declaration. ## Related packages -* [clojure-mode-extra-font-locking][] provides additional font-locking +- [clojure-mode-extra-font-locking][] provides additional font-locking for built-in methods and macros. The font-locking is pretty imprecise, because it doesn't take namespaces into account and it won't font-lock a function at all possible positions in a sexp, but @@ -502,9 +515,9 @@ plenty of incorrect font-locking. CIDER users should avoid this package, as CIDER does its own dynamic font-locking, which is namespace-aware and doesn't produce almost any false positives. -* [clj-refactor][] provides refactoring support. +- [clj-refactor][] provides additional refactoring support. -* Enabling `CamelCase` support for editing commands(like +- Enabling `CamelCase` support for editing commands (like `forward-word`, `backward-word`, etc) in `clojure-mode` is quite useful since we often have to deal with Java class and method names. The built-in Emacs minor mode `subword-mode` provides such @@ -514,7 +527,7 @@ functionality: (add-hook 'clojure-mode-hook #'subword-mode) ``` -* The use of [paredit][] when editing Clojure (or any other Lisp) code +- The use of [paredit][] when editing Clojure (or any other Lisp) code is highly recommended. It helps ensure the structure of your forms is not compromised and offers a number of operations that work on code structure at a higher level than just characters and words. To enable @@ -524,7 +537,7 @@ it for Clojure buffers: (add-hook 'clojure-mode-hook #'paredit-mode) ``` -* [smartparens][] is an excellent +- [smartparens][] is an excellent (newer) alternative to paredit. Many Clojure hackers have adopted it recently and you might want to give it a try as well. To enable `smartparens` use the following code: @@ -533,7 +546,7 @@ it for Clojure buffers: (add-hook 'clojure-mode-hook #'smartparens-strict-mode) ``` -* [RainbowDelimiters][] is a +- [RainbowDelimiters][] is a minor mode which highlights parentheses, brackets, and braces according to their depth. Each successive level is highlighted in a different color. This makes it easy to spot matching delimiters, @@ -545,7 +558,7 @@ it for Clojure buffers: (add-hook 'clojure-mode-hook #'rainbow-delimiters-mode) ``` -* [aggressive-indent-mode][] automatically adjust the indentation of your code, +- [aggressive-indent-mode][] automatically adjust the indentation of your code, while you're writing it. Using it together with `clojure-mode` is highly recommended. Provided you've already installed `aggressive-indent-mode` you can enable it like this: @@ -554,6 +567,9 @@ enable it like this: (add-hook 'clojure-mode-hook #'aggressive-indent-mode) ``` +Note that it might cause performance issues if you're dealing with large +Clojure source files. + ## REPL Interaction One of the fundamental aspects of Lisps in general, and Clojure in From 28dc02114ae70db6bb68d537ea77985f272120bc Mon Sep 17 00:00:00 2001 From: Bozhidar Batsov Date: Wed, 28 May 2025 09:10:40 +0300 Subject: [PATCH 23/23] Reflow a couple of paragraphs --- README.md | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index f8ce6bf4..4845bbd3 100644 --- a/README.md +++ b/README.md @@ -613,22 +613,30 @@ experience negatively. ### General Issues -`clojure-mode` derives a lot of functionality directly from `lisp-mode` (an Emacs major mode for Common Lisp), which -simplified the initial implementation, but also made it harder to implement -certain functionality. Down the road it'd be nice to fully decouple `clojure-mode` -from `lisp-mode`. +`clojure-mode` derives a lot of functionality directly from `lisp-mode` (an +Emacs major mode for Common Lisp), which simplified the initial implementation, +but also made it harder to implement certain functionality. Down the road it'd +be nice to fully decouple `clojure-mode` from `lisp-mode`. See [this ticket](https://github.com/clojure-emacs/clojure-mode/issues/270) for a bit more details. ### Indentation Performance -`clojure-mode`'s indentation engine is a bit slow. You can speed things up significantly by disabling `clojure-use-backtracking-indent`, but this will break the indentation of complex forms like `deftype`, `defprotocol`, `reify`, `letfn`, etc. +`clojure-mode`'s indentation engine is a bit slow. You can speed things up +significantly by disabling `clojure-use-backtracking-indent`, but this will +break the indentation of complex forms like `deftype`, `defprotocol`, `reify`, +`letfn`, etc. -We should look into ways to optimize the performance of the backtracking indentation logic. See [this ticket](https://github.com/clojure-emacs/clojure-mode/issues/606) for more details. +We should look into ways to optimize the performance of the backtracking +indentation logic. See [this ticket](https://github.com/clojure-emacs/clojure-mode/issues/606) for more +details. ### Font-locking Implementation -As mentioned [above](https://github.com/clojure-emacs/clojure-mode#font-locking), the font-locking is implemented in terms of regular expressions which makes it both slow and inaccurate. +As mentioned +[above](https://github.com/clojure-emacs/clojure-mode#font-locking), the +font-locking is implemented in terms of regular expressions which makes it both +slow and inaccurate. ## Changelog