clojure-mode icon indicating copy to clipboard operation
clojure-mode copied to clipboard

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

Open bbatsov opened this issue 4 years ago • 2 comments

See https://github.com/clojure-emacs/cider/issues/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

bbatsov avatar May 03 '21 18:05 bbatsov

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))

jogo3000 avatar May 05 '21 16:05 jogo3000

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.

mizlan avatar May 20 '21 19:05 mizlan