emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/clojure-mode 63356ee3bd: Relax regexp for clojure-find-def


From: ELPA Syncer
Subject: [nongnu] elpa/clojure-mode 63356ee3bd: Relax regexp for clojure-find-def to recognize more complex metadata on vars (#682)
Date: Mon, 25 Nov 2024 06:59:34 -0500 (EST)

branch: elpa/clojure-mode
commit 63356ee3bd6903e7b17822022f5a6ded2512b979
Author: Fredrik Vaeng Røtnes <frwdrik@gmail.com>
Commit: GitHub <noreply@github.com>

    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 b51981235f..f4cbb8e351 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 1ff2e8822d..2281065ff4 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 78a2ac170a..f1895b6746 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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]