Closed PlumpMath closed 2 years ago
Can you write this fantastic project as a lumo? . This project Fantastic.
https://practicalli.github.io/clojurescript/quickstart/self-hosted-clojurescript.html
Above link very fast. Would be more cool dynamic loading modules.
hanks.
@PlumpMath any suggestions about API?
What do you think about, e.g. :backend
parameter
(clomacs-defun get-property System/getProperty :backend :cljs)
with a default value of :clj
.
When I was a kid, I read the Macro command book of autocad 10? 11? book (dos version) to be good at computers. Why did I think it was such a humble macro system? . today, I feeling.. recently I've been windows remove and setting up my computer... with guix os, exwm, org-mode... and I've memoried your clomacs Project! . I've been thinking that we can now save all of our moments as a card macro on the keyboard. If you combine the backend(all language) interoping elisp. of this great project with elisp to store all of our moments, we will be able to catch every moment of memory that we have on the keyboard day of day life. Thanks! human alien. :) oh Thanks!
@kostafey
There are currently src and project.clj in the home directory.
I want to work with only one nREPL on when the emacs boot up.
I used to work with a cursor-nREPL turned on with the command below. I'm looking at the og-babel emacs-lisp block With clomacs. Two and three... NREPL is running.. I don't want to increase the cider.
(require 'clomacs) (clomacs-launch-nrepl nil t) ; not currently operational.
You know how I work, and you've created the function below. Thank you. previous function (clomacs-launch-nrepl).. There was an error in clomacs-launch-nrepl, so I looked up the code. I need four factors.
for the new generation (clomacs-jack-in-cljs fn.) <---? I think we can solve it with the above function, I'm not sure how to use it. I don't know the complicated elisp. How can I get clomacs-cider to work with one nREPL?
Thank you.
Ok, could you explain to me more about your desired workflow?
Clomacs
is made to be a wrapper of Elisp to Clojure calls and vice versa.
So, if you want to call some Clojure code from Elisp, you should create a wrapper:
(clomacs-defun get-property System/getProperty)
Then you can operate with get-property
as ordinary Elisp function.
If cider-current-connection
exists, then
(get-property "java.version")
will return the result immediately. If not, it will start nREPL and evaluated after process started.
If you want to see the result of this evaluation add nrepl-ready-callback
param (literally on nREPL started and Clojure function evaluated hook, do with this function evaluation result):
(clomacs-defun get-property2
System/getProperty
:nrepl-ready-callback (lambda (result)
(message "nREPL started, property value : %s" result)))
Here get-property2
will operate the same way as get-property
does for "REPL already started" case, but will echo the message after nREPL starts when it called without nREPL already started.
If you want to call a chain of wrapped functions, e.g.:
(message "Running Java %s on %s system"
(get-property "java.version")
(get-property "os.arch"))
you must be sure that nREPL is already running. If not, clomacs
will start 2 nREPLs (!!!), each one for every get-property
calls. To avoid this, please use clomacs-with-nrepl
.
(clomacs-with-nrepl nil
(lambda ()
(message "Running Java %s on %s system"
(get-property "java.version")
(get-property "os.arch"))))
This function makes sure, nREPL started and then evaluates it's lambda
as callback.
So, actual clomacs
functions to use are: clomacs-defun
and clomacs-with-nrepl
.
You are not expected to use clomacs-launch-nrepl
or clomacs-jack-in-cljs
directly.
If you need to start nREPL for ClojureScript, please add :backend :cljs
key parameters for clomacs-defun
and clomacs-with-nrepl
calls, e.g.:
(clomacs-defun get-property3
System/getProperty
:backend :cljs)
The most expected use case is to create a dedicated leiningen
project for your Elisp+Clojure mixed Emacs extenstion and eval all functions in it's REPL. The name of project passed by :lib-name
parameter for clomacs-defun
macro and first parameter for clomacs-with-nrepl
function.
See more full-fledged actual examples here:
Thanks Very Much! @kostafey :)
I start ( screenshot right side codes).
Previously on this code alone, "(require 'clomacs) (clomacs-launch-nrepl nil t)" So I use nREPL load... static-project(CLOM) code. It was shared to README.org (org-babels).
Of course, I elisp code was also first (provide 'CLOM) by README.org. emacs read the follow first. (NAME change cm-test to CLOM;;; and lib-name/namespace clomacs to CLOM https://github.com/kostafey/cm-test/blob/master/src/elisp/cm-test.el Those .elisp codes are Picked up from your other repository cm-test project.
Then emacs had all the REPL codes shared.
Thanks @kostafey :+1:
I've added org-mode Babel experiments file to cm-test project: https://raw.githubusercontent.com/kostafey/cm-test/master/org-sandbox.org
The exception you see here: No such var...
in this case actually means that it's namespace hasn't required yet. To accomplish that you can require it manually (e.g. via clomacs-require
):
#+begin_src emacs-lisp :noweb yes
(require 'clomacs)
(clomacs-defun cm-test-md-to-html-wrapper
cm-test.core/my-md-to-html-string)
(clomacs-with-nrepl nil
(lambda ()
(clomacs-require `'cm-test.core)
(message (cm-test-md-to-html-wrapper "# Hello, World!"))))
#+end_src
But the most straightforward way is to use :namespace
parameter for run require in macros:
#+begin_src clojure
(ns cm-test.core)
(use 'clomacs)
(defn add [x] (+ 1 x))
(add 2)
#+end_src
#+begin_src emacs-lisp :noweb yes
(require 'clomacs)
(clomacs-defun cm-test-md-to-html-wrapper
my-md-to-html-string
:namespace cm-test.core)
(clomacs-defun cm-test-add
add
:namespace cm-test.core)
(clomacs-with-nrepl nil
(lambda ()
(message (cm-test-md-to-html-wrapper "# Hello, World %s times!")
(cm-test-add 2))))
#+end_src
Furthermore, please note, that this org-mode file shoud be located in your Clojure project folder with cm-test.core
namespace.
If not, you should pass :lib-name
parameter to clomacs-defun
and to clomacs-with-nrepl
as a first argument. This lib-name is a Emacs Lisp library file which ends with (provide '<lib-name>)
and is available in Emacs load-path
. This Elisp file sould be located in your Clojure project which namespaces you use in clomacs-defun
(s).
I'm putting together the clomacs lein project in my job project, so the org-mode can't... because I'm so busy in a hurry job-project. I'll try it later and leave comments if it goes well. Thank you very much for making it.
Thanks E.T. uncle.
when
Thanks :)) E.T. uncle good day!