ubolonton / emacs-module-rs

Rust binding and tools for Emacs's dynamic modules
336 stars 22 forks source link

Use selected region as input to function #45

Closed pierwill closed 2 years ago

pierwill commented 2 years ago

For instance, in this example

    // Define a function callable by Lisp code.
    #[defun]
    fn say_hello(env: &Env, name: String) -> Result<Value<'_>> {
        env.message(&format!("Hello, {}!", name))
    }

I'd like to be able to run this code in Emacs with a highlighted region used as the value of name. Is this possible?

pierwill commented 2 years ago

After some thought, it's really not hard to do the last bit in Elisp:

(defun say-hello (beg end)
 (interactive "r")
 (myemacsrust-say-hello (buffer-substring beg end)))