Comments (8)
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:
- https://github.com/kostafey/ejc-sql/blob/877200ddc082acc275445a736abd9a70bd9189b4/ejc-interaction.el#L23
- https://github.com/kostafey/ejc-sql/blob/877200ddc082acc275445a736abd9a70bd9189b4/ejc-sql.el#L399
from clomacs.
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).
from clomacs.
@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
.
from clomacs.
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.
from clomacs.
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!
from clomacs.
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.
from clomacs.
Thanks Very Much! @kostafey
:)
I start ( screenshot right side codes).
(org-babel-load-file "~/CLOM/README.org")
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
👍
from clomacs.
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.
from clomacs.
Related Issues (13)
- nrepl not found HOT 1
- Passing escaped substrings HOT 1
- clomacs-httpd-start FileNotFoundException on Windows 10 HOT 6
- cdr: Wrong type argument: arrayp, ("clojure-test") HOT 2
- Create clomacs server HOT 2
- Try README CLJ call Elisp function demo error HOT 1
- Passing map to clojure via alist HOT 6
- Adding babashka as runtime HOT 3
- Async call-type example
- Error: Symbol’s function definition is void: clomacs-doc HOT 2
- void variable clomacs--doc HOT 13
- Warning msg when installing in spacemacs and the dependent package (ejc-sql) fails to install HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from clomacs.