scicloj / notespace

using your namespace as a notebook
Eclipse Public License 2.0
148 stars 10 forks source link

Notespace assumes any source files will live under `src` directory #50

Open jonadelson opened 3 years ago

jonadelson commented 3 years ago

I was trying to make a mixed java/clojure project in which the java files would be under src/main/java and the clojure files would be under src/main/clojure and found that Notespace assumes that any namespaces would be in the src directory. I'm not sure if this is really an issue but was wondering if you recommended some workaround. Also, really love the library!

daslu commented 3 years ago

Hi @jonadelson, thanks!

Following your comment, I now deployed a small change that allows configuring the source base path.

(notespace.api/update-config
  #(assoc % :source-base-path "src/main/clojure"))

should make it work in your case.

Does it seem to work?

jonadelson commented 3 years ago

Thanks for such a quick response! It seems to work, but I did accidentally stumble on one issue.

Everything works fine if I run the following namespace by first evaluating the forms in the comment and then using the notespace/eval-this-notespace emacs command.

(comment
  (notespace.api/init-with-browser)
  (notespace.api/update-config
    #(assoc % :source-base-path "src/main/clojure"))
)

(+ 1 2)

However, the following seems to hang after evaluating the comment forms and running the notespace/eval-this-notespace emacs command.

(comment
  (notespace.api/init-with-browser)
  (notespace.api/update-config
    #(assoc % :source-base-path "src/main/clojure"))
)

(notespace.api/update-config
  #(assoc % :source-base-path "src/main/clojure"))

(+ 1 2)

I'm not sure if this is a legitimate problem or a misunderstanding of the library on my part. Thanks.

daslu commented 3 years ago

Thanks @jonadelson !

In general, notespace API function calls are not recommended to be part of the notespace itself, but rather live inside comments (or be called from the REPL by some other method).

For some of the API functions, this may result in an infinite loop (for example, when the function is trying to evaluate the note that contains itself).

In the case of this function, I am not sure why this hangs. It seems like a good idea to understand that, so let us leave the issue open for now.