More redvault_el prototyping
This commit is contained in:
parent
78f89dcd8b
commit
f1eda67c1e
5 changed files with 68 additions and 13 deletions
15
Cargo.lock
generated
15
Cargo.lock
generated
|
@ -170,9 +170,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "anyhow"
|
name = "anyhow"
|
||||||
version = "1.0.89"
|
version = "1.0.94"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "86fdf8605db99b54d3cd748a44c6d04df638eb5dafb219b135d0149bd0db01f6"
|
checksum = "c1fd03a028ef38ba2276dce7e33fcd6369c158a1bca17946c4b1b701891c1ff7"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"backtrace",
|
"backtrace",
|
||||||
]
|
]
|
||||||
|
@ -2374,6 +2374,10 @@ dependencies = [
|
||||||
"byteorder",
|
"byteorder",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "garnix"
|
||||||
|
version = "0.1.1"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "gdk"
|
name = "gdk"
|
||||||
version = "0.18.0"
|
version = "0.18.0"
|
||||||
|
@ -6156,8 +6160,10 @@ dependencies = [
|
||||||
name = "redvault_el_rs"
|
name = "redvault_el_rs"
|
||||||
version = "0.1.1"
|
version = "0.1.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"anyhow",
|
||||||
"emacs",
|
"emacs",
|
||||||
"emacs-rs-module",
|
"emacs-rs-module",
|
||||||
|
"tokio",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -8148,9 +8154,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tokio"
|
name = "tokio"
|
||||||
version = "1.40.0"
|
version = "1.42.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "e2b070231665d27ad9ec9b8df639893f46727666c6767db40317fbe920a5d998"
|
checksum = "5cec9b21b0450273377fc97bd4c33a8acffc8c996c987a7c5b319a0083707551"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"backtrace",
|
"backtrace",
|
||||||
"bytes",
|
"bytes",
|
||||||
|
@ -8161,6 +8167,7 @@ dependencies = [
|
||||||
"signal-hook-registry",
|
"signal-hook-registry",
|
||||||
"socket2",
|
"socket2",
|
||||||
"tokio-macros",
|
"tokio-macros",
|
||||||
|
"tracing",
|
||||||
"windows-sys 0.52.0",
|
"windows-sys 0.52.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ lto = "fat"
|
||||||
panic = "abort"
|
panic = "abort"
|
||||||
|
|
||||||
[workspace]
|
[workspace]
|
||||||
members = ["llama_forge_rs", "leptos_stub", "frozen_llama", "llama_proxy_man", "redvault_el_rs"]
|
members = ["llama_forge_rs", "frozen_llama", "llama_proxy_man", "redvault_el_rs", "garnix"]
|
||||||
resolver = "2"
|
resolver = "2"
|
||||||
|
|
||||||
[workspace.package]
|
[workspace.package]
|
||||||
|
|
|
@ -13,8 +13,10 @@ edition.workspace = true
|
||||||
crate-type = ["cdylib"]
|
crate-type = ["cdylib"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
anyhow = "1.0.93"
|
||||||
emacs = "0.19"
|
emacs = "0.19"
|
||||||
emacs-rs-module = { version = "0.19.0" }
|
emacs-rs-module = { version = "0.19.0" }
|
||||||
|
tokio = { version = "1.41.1", features = ["full", "tracing"] }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
emacs-rs-module = { version = "0.19.0" }
|
emacs-rs-module = { version = "0.19.0" }
|
||||||
|
|
|
@ -3,12 +3,20 @@
|
||||||
## Hot reload for dev
|
## Hot reload for dev
|
||||||
```elisp
|
```elisp
|
||||||
|
|
||||||
(module-load "~/code/redvault-ai/target/release/deps/libemacs_rs_module-9ad53dadcc38727d.so")
|
(module-load "/home/tristand/code/redvault-ai/target/release/deps/libemacs_rs_module-9ad53dadcc38727d.so")
|
||||||
|
|
||||||
|
|
||||||
(defun hotreload-el-rs ()
|
(defun hotreload-el-rs ()
|
||||||
(interactive)
|
(interactive)
|
||||||
(rs-module/load "~/code/redvault-ai/target/debug/libredvault_el_rs.so")
|
(rs-module/load "/home/tristand/code/redvault-ai/target/release/libredvault_el_rs.so"))
|
||||||
|
|
||||||
|
|
||||||
|
(defun el-res-say-hello-2 ()
|
||||||
|
(interactive)
|
||||||
|
(asd/say-hello "Asd"))
|
||||||
|
|
||||||
|
(defun el-res-say-hello ()
|
||||||
|
(interactive)
|
||||||
(redvault-el-rs/say-hello "Asd"))
|
(redvault-el-rs/say-hello "Asd"))
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
|
@ -1,11 +1,36 @@
|
||||||
use emacs::{defun, Env, IntoLisp, Result, Value};
|
use emacs::{defun, Env, IntoLisp, Result, Value};
|
||||||
|
use std::sync::Once;
|
||||||
|
use std::sync::OnceLock;
|
||||||
|
use tokio::runtime::{Builder, Runtime};
|
||||||
|
|
||||||
// Emacs won't load the module without this.
|
// Emacs won't load the module without this.
|
||||||
emacs::plugin_is_GPL_compatible!();
|
emacs::plugin_is_GPL_compatible!();
|
||||||
|
|
||||||
|
// Global static runtime that's lazily initialized
|
||||||
|
static RUNTIME: OnceLock<Runtime> = OnceLock::new();
|
||||||
|
|
||||||
|
// Initialization function for the Emacs module
|
||||||
|
fn initialize_tokio_runtime() -> &'static Runtime {
|
||||||
|
RUNTIME.get_or_init(|| {
|
||||||
|
Builder::new_multi_thread()
|
||||||
|
.enable_all()
|
||||||
|
.worker_threads(4) // Adjust number of worker threads as needed
|
||||||
|
.build()
|
||||||
|
.expect("Failed to create Tokio runtime")
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// Register the initialization hook that Emacs will call when it loads the module.
|
// Register the initialization hook that Emacs will call when it loads the module.
|
||||||
#[emacs::module(separator = "/")]
|
#[emacs::module(separator = "/")]
|
||||||
fn init(env: &Env) -> Result<Value<'_>> {
|
fn init(env: &Env) -> Result<Value<'_>> {
|
||||||
|
let runtime = initialize_tokio_runtime();
|
||||||
|
|
||||||
|
// Spawn a task without blocking
|
||||||
|
runtime.spawn(async {
|
||||||
|
// Your async code here
|
||||||
|
println!("Running an async task");
|
||||||
|
});
|
||||||
|
|
||||||
env.message("Test loading!")?;
|
env.message("Test loading!")?;
|
||||||
|
|
||||||
env.message("Done loading!")
|
env.message("Done loading!")
|
||||||
|
@ -26,11 +51,24 @@ fn say_hello(env: &Env, name: String) -> Result<Value<'_>> {
|
||||||
// env.message(&format!("Helloo Broooooooo, {}!", name))
|
// env.message(&format!("Helloo Broooooooo, {}!", name))
|
||||||
env.call(
|
env.call(
|
||||||
"message",
|
"message",
|
||||||
[format!("Henlo whatup, {}!", name).as_str().into_lisp(env)?],
|
[format!("Henlo whatsup, {}!!!!", name)
|
||||||
)
|
.as_str()
|
||||||
|
.into_lisp(env)?],
|
||||||
|
)?;
|
||||||
|
RUNTIME
|
||||||
|
.get()
|
||||||
|
.ok_or_else(|| anyhow::anyhow!("No runtime"))?
|
||||||
|
.spawn(async {
|
||||||
|
for _i in 1..5 {
|
||||||
|
println!("A");
|
||||||
|
std::thread::sleep(std::time::Duration::from_millis(1000));
|
||||||
|
println!("B");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
().into_lisp(env)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[defun]
|
// #[defun]
|
||||||
fn open_test_overlay(_env: &Env) -> Result<Value<'_>> {
|
// fn open_test_overlay(_env: &Env) -> Result<Value<'_>> {
|
||||||
todo!()
|
// todo!()
|
||||||
}
|
// }
|
||||||
|
|
Loading…
Add table
Reference in a new issue