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

clomacs-httpd-start FileNotFoundException on Windows 10 #11

Open
kirill-gerasimenko opened this issue Jan 2, 2018 · 6 comments
Open

Comments

@kirill-gerasimenko
Copy link

Hi,

I'm having troubles starting http server using (clomacs-httpd-start):

Debugger entered--Lisp error: (error "FileNotFoundException Could not locate clomacs__init.class or clomacs.clj on classpath.  clojure.lang.RT.load (RT.java:456)
")
  signal(error ("FileNotFoundException Could not locate clomacs__init.class or clomacs.clj on classpath.  clojure.lang.RT.load (RT.java:456)\n"))
  error("FileNotFoundException Could not locate clomacs__init.class or clomacs.clj on classpath.  clojure.lang.RT.load (RT.java:456)\n")
  clomacs-get-result((dict "status" ("eval-error" "done" "state") "ex" "class java.io.FileNotFoundException" "id" "11" "root-ex" "class java.io.FileNotFoundException" "session" "5933c6ef-b53c-4e22-9264-87d6a3825e1a" "err" "FileNotFoundException Could not locate clomacs__init.class or clomacs.clj on classpath.  clojure.lang.RT.load (RT.java:456)\n" "changed-namespaces" (dict) "repl-type" "clj") :value :string nil)
  clomacs-require((quote clomacs))
  clomacs-httpd-start()
  eval((clomacs-httpd-start) nil)
  elisp--eval-last-sexp(nil)

I'm doing some Clojure with clomacs and it's working fine (I'm able to call Clojure functions from Elisp), but I wanted to use callbacks from Clojure to Emacs and have this issue.

I have Windows 10, Java 1.8, Emacs 25.3.1, Spacemacs.

If you need more information please let me know.

Thanks!
Kirill

@kostafey
Copy link
Member

kostafey commented Jan 2, 2018

Hello! It's very new experimental possibility and not well-documented yet.
Please, add [clomacs "0.0.3-SNAPSHOT"] to your project.clj :dependencies.
Then terminate your REPL (if running) and try again.

@kostafey
Copy link
Member

kostafey commented Jan 3, 2018

Furthermore if you develop your own Elisp-Clojure Emacs extension, you should add library info to all related clomacs-defun wrapped functions.

(require 'clomacs)

(clomacs-defun your-libname-set-emacs-connection
               clomacs/set-emacs-connection
               :lib-name "your-libname")
(clomacs-defun your-libname-close-emacs-connection
               clomacs/close-emacs-connection
               :lib-name "your-libname")
(clomacs-defun your-libname-require
               clojure.core/require
               :lib-name "your-libname")

(defun your-libname-httpd-start ()
  (cl-flet ((clomacs-set-emacs-connection 'your-libname-set-emacs-connection)
            (clomacs-require 'your-libname-require))
    (clomacs-httpd-start)))

(defun your-libname-httpd-stop ()
  (cl-flet ((clomacs-close-emacs-connection 'your-libname-close-emacs-connection)
            (clomacs-require 'your-libname-require))
    (clomacs-httpd-stop)))

@kirill-gerasimenko
Copy link
Author

Thanks! I'll try what you've suggested and let you know the results!

So what you are saying is that I should include such code as above in my elisp part of the plugin, then start httpd server with such custom function your-libname-httpd-start from emacs config and things should work properly? (of course after adding dependency in project.clj).

@kostafey
Copy link
Member

kostafey commented Jan 14, 2018

Yep. But beware, anytime you run (your-libname-httpd-start), nREPL server will start too (of not yet) to be sent Emacs http server parameters (host & port) to Clojure side.
If you don't want to run (your-libname-httpd-start) in the time you load .emacs with your lib required, you can use :httpd-starter parameter for clomacs-defun
See complete example here:
https://github.com/kostafey/cm-test/blob/master/src/elisp/cm-test.el#L39
https://github.com/kostafey/cm-test/blob/master/src/clj/cm_test/core.clj#L10

In this example, when you run (cm-test-strong-emacs-version) at the first time, both nREPL server and Emacs http server will start, then Clojure side code will ask Emacs about its version, add some markdown marking chars to version string and return the result to Emacs side.

@MalloZup
Copy link

MalloZup commented Aug 5, 2019

autogenerated with https://github.com/MalloZup/doghub: issue inactive since 450 days. Please update the issue or close it

@kostafey
Copy link
Member

kostafey commented Aug 5, 2019

TODO: Update README.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants