Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
bbatsov opened this issue May 3, 2021 · 2 comments · Fixed by #661
Closed

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

bbatsov opened this issue May 3, 2021 · 2 comments · Fixed by #661

Comments

@bbatsov
Copy link
Member

bbatsov commented May 3, 2021

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

jogo3000 added a commit to jogo3000/clojure-mode that referenced this issue May 5, 2021
…eded by ws

Problem was that the regexp here expected (ns form to start right in the
beginning of the line. I added zero or more whitespace in the beginning which
corrects the issue.

Adds also a unit test which covers the issue.
@jogo3000
Copy link

jogo3000 commented May 5, 2021

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

@mizlan
Copy link

mizlan commented May 20, 2021

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.

@vemv vemv closed this as completed in #661 Sep 7, 2023
vemv pushed a commit that referenced this issue Sep 7, 2023
kommen pushed a commit to kommen/clojure-ts-mode that referenced this issue Oct 30, 2024
kommen pushed a commit to kommen/clojure-ts-mode that referenced this issue Oct 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants