clojure-emacs/clojure-mode

clojure-find-ns breaks if the ns form is preceded by whitespace

bbatsov opened this issue · 2 comments

See clojure-emacs/cider#3009

Expected behavior

clojure-find-ns should handle properly an ns form with preceding whitespace.

Actual behavior

It returns nil.

Steps to reproduce the problem

  (ns foo.bar)

(defn foo [] :bar)

Try evaluating the defn form.

Environment & Version information

clojure-mode version

clojure-mode (version 5.10.0)

Emacs version

26.3

Operating system

Ubuntu 20.04

I tried to fix this issue by altering the regex to allow whitespace before the ns form. However, @yuhan0 quickly pointed out that this approach may cause unexpected behaviour when ns form is inside a comment block for example.

For example

(ns the-actual-ns) 

(comment
  (ns not-the-real-one))

I tried to fix this issue by altering the regex to allow whitespace before the ns form. However, @yuhan0 quickly pointed out that this approach may cause unexpected behaviour when ns form is inside a comment block for example.

For example

(ns the-actual-ns) 

(comment
  (ns not-the-real-one))

How relevant is this problem? What if the buffer contained the following:

(comment
(ns not-the-real-one))

note the lack of whitespace.