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

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

[nongnu] elpa/clojure-mode 1dc343fe67: Fix clojure-find-ns for ns forms


From: ELPA Syncer
Subject: [nongnu] elpa/clojure-mode 1dc343fe67: Fix clojure-find-ns for ns forms preceded by whitespace (#661)
Date: Thu, 7 Sep 2023 03:59:12 -0400 (EDT)

branch: elpa/clojure-mode
commit 1dc343fe67c1b7b858df6250bfc500eca6823940
Author: p4v4n <pavan.mantha99@gmail.com>
Commit: vemv <vemv@users.noreply.github.com>

    Fix clojure-find-ns for ns forms preceded by whitespace (#661)
    
    Closes https://github.com/clojure-emacs/clojure-mode/issues/593
---
 CHANGELOG.md                   |  4 ++++
 clojure-mode.el                |  6 +++---
 test/clojure-mode-util-test.el | 17 +++++++++++++++++
 3 files changed, 24 insertions(+), 3 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 27aed4f369..6a4b3eb71e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,6 +6,10 @@
 
 * Improve support for multiple forms in the same line by replacing 
`beginning-of-defun` fn.
 
+### Bugs fixed
+
+* [#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
diff --git a/clojure-mode.el b/clojure-mode.el
index 0d2b613e88..43030a1d07 100644
--- a/clojure-mode.el
+++ b/clojure-mode.el
@@ -2125,7 +2125,7 @@ content) are considered part of the preceding sexp."
 (make-obsolete-variable 'clojure-namespace-name-regex 
'clojure-namespace-regexp "5.12.0")
 
 (defconst clojure-namespace-regexp
-  (rx line-start "(" (? "clojure.core/") (or "in-ns" "ns" "ns+") symbol-end))
+  (rx line-start (zero-or-more whitespace) "(" (? "clojure.core/") (or "in-ns" 
"ns" "ns+") symbol-end))
 
 (defcustom clojure-cache-ns nil
   "Whether to cache the results of `clojure-find-ns'.
@@ -2153,7 +2153,7 @@ DIRECTION is `forward' or `backward'."
           (save-match-data
             (goto-char end)
             (clojure-forward-logical-sexp)
-            (unless (or (clojure--in-string-p) (clojure--in-comment-p))
+            (unless (or (clojure--in-string-p) (clojure--in-comment-p) 
(clojure-top-level-form-p "comment"))
               (setq candidate (string-remove-prefix "'" (thing-at-point 
'symbol))))))))
     candidate))
 
@@ -3224,7 +3224,7 @@ With universal argument \\[universal-argument], act on 
the \"top-level\" form."
     (beginning-of-defun-raw)
     (clojure--toggle-ignore-next-sexp)))
 
-
+
 ;;; ClojureScript
 (defconst clojurescript-font-lock-keywords
   (eval-when-compile
diff --git a/test/clojure-mode-util-test.el b/test/clojure-mode-util-test.el
index a35babbed3..3f6e2de74a 100644
--- a/test/clojure-mode-util-test.el
+++ b/test/clojure-mode-util-test.el
@@ -82,6 +82,23 @@
       (expect (clojure-find-ns) :to-equal "foo"))
     (with-clojure-buffer "(ns ^:bar ^:baz foo)"
       (expect (clojure-find-ns) :to-equal "foo")))
+  (it "should find namespaces with spaces before ns form"
+    (with-clojure-buffer "  (ns foo)"
+      (expect (clojure-find-ns) :to-equal "foo")))
+  (it "should skip namespaces within any comment forms"
+    (with-clojure-buffer "(comment
+      (ns foo))"
+      (expect (clojure-find-ns) :to-equal nil))
+    (with-clojure-buffer " (ns foo)
+     (comment
+      (ns bar))"
+      (expect (clojure-find-ns) :to-equal "foo"))
+    (with-clojure-buffer " (comment
+      (ns foo))
+     (ns bar)
+    (comment
+      (ns baz))"
+      (expect (clojure-find-ns) :to-equal "bar")))
   (it "should find namespace declarations with nested metadata and docstrings"
     (with-clojure-buffer "(ns ^{:bar true} foo)"
       (expect (clojure-find-ns) :to-equal "foo"))



reply via email to

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