Skip to content

Conversation

expez
Copy link
Member

@expez expez commented Nov 26, 2015

Any valid symbol can be used to name an ns. The current regexp would fail
to parse symbols ending in certain characters, e.g. +.

This closes clojure-emacs/cider#1433

@@ -1009,7 +1009,7 @@ nil."
(one-or-more (any whitespace "\n")))
;; why is this here? oh (in-ns 'foo) or (ns+ :user)
(zero-or-one (any ":'"))
(group (one-or-more (not (any "()\"" whitespace))) word-end)))
(group (one-or-more (not (any "()\"" whitespace))) symbol-end)))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure how correct our symbol definition is. If memory serves - not very correct. This change definitely requires unit tests illustrating it actually solves something.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Our symbol definition is inherited from elisp so it's at least better than using the word definition. I can't think of any notable differences in clojure's and elisp's notion of what a symbol is.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem is that I tried using symbol instead of word semantics when I inherited the mode and everything broke, therefore my reservations... Using symbol semantics is the reasonable thing to do for pretty much everything, but I really think something was fucked up regarding them (don't remember what). I recall lisp-mode's code was full of word references itself, which was odd.

At any rate - a few unit tests won't hurt.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAICT, that regexp should be just (1+ (any symbol word)). But you're the voice of experience here @bbatsov.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That sounds reasonable. But on a general note @expez is right that there should be fewer word checks and symbols checks, as we're talking about symbols here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. I agree too.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Btw, most of this word stuff predates me becoming the maintainer of clojure-mode. I always wanted to redo it (and unify the regex syntax used in clojure-mode), but never had the time to do.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAICT, that regexp should be just (1+ (any symbol word)).

Correction, what I wrote is not valid rx. It would have to be (1+ (or (syntax word) (syntax symbol)))

@expez
Copy link
Member Author

expez commented Nov 30, 2015

  • Updated the regexp to match @Malabarba suggestion.
  • Moved the inline, commented out tests, into a test file
  • Removed duplicate tests
  • Expanded tests to cover the change made here
  • Cleaned up a comment slightly

@expez
Copy link
Member Author

expez commented Nov 30, 2015

Actually, I've restored the regexp to my first suggestion, because

(group (one-or-more (or (syntax symbol) (syntax word))))

fails on namespaces like this:

"(ns #^{:bar true} foo)"

@Malabarba
Copy link
Member

Ideally, each of those tests would also check that (equal "foo" (match-string 4 s)).
But other than that it looks dandy. 👍

@bbatsov
Copy link
Member

bbatsov commented Nov 30, 2015

Apart from @Malabarba's suggestion - a changelog entry would be nice. No other remarks from me.

P.S. We should turn more comments into specs. :-)

@expez expez force-pushed the update-ns-regexp branch 6 times, most recently from 7a277dd to 01568a3 Compare December 1, 2015 13:03
Any valid symbol can be used to name an ns.  The current regexp would fail
to parse symbols ending in certain characters, e.g. `+`.

This closes clojure-emacs/cider#1433
@expez
Copy link
Member Author

expez commented Dec 1, 2015

Aright let's go

bbatsov added a commit that referenced this pull request Dec 1, 2015
Make the ns regexp more permissive
@bbatsov bbatsov merged commit 20b0b34 into clojure-emacs:master Dec 1, 2015
@bbatsov
Copy link
Member

bbatsov commented Dec 1, 2015

👍

@expez expez deleted the update-ns-regexp branch December 1, 2015 14:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ns endswith '+' failed when using cider-repl-set-ns
3 participants