Skip to content

Instantly share code, notes, and snippets.

@nonsequitur
Created September 7, 2009 17:24
Show Gist options
  • Save nonsequitur/182461 to your computer and use it in GitHub Desktop.
Save nonsequitur/182461 to your computer and use it in GitHub Desktop.
~/src/swank-clojure/swank/commands/basic.clj:299
The following function is used in slime-edit-definition.
It blows up on namespace 'user' and thus thwarts jumping to
definitions in the user namespace.
(defn- namespace-to-path [ns]
(let [#^String ns-str (name (ns-name ns))]
(-> ns-str
(.substring 0 (.lastIndexOf ns-str ".")) <------ 'user' contains no '.'
(.replace \- \_)
(.replace \. \/))))
My amateurish fix:
(defn- namespace-to-path [ns]
(let [#^String ns-str (name (ns-name ns))]
(let [last-dot (.lastIndexOf ns-str ".")]
(when (pos? last-dot)
(-> ns-str
(.substring 0 last-dot)
(.replace \- \_)
(.replace \. \/))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment