Struct emacs::Env

source ·
pub struct Env { /* private fields */ }
Expand description

Main point of interaction with the Lisp runtime.

Implementations§

source§

impl Env

Public APIs.

source

pub fn intern(&self, name: &str) -> Result<Value<'_>>

source

pub fn type_of<'e>(&'e self, value: Value<'e>) -> Result<Value<'_>>

source

pub fn is_not_nil<'e>(&'e self, value: Value<'e>) -> bool

👎Deprecated since 0.10.0: Please use value.is_not_nil() instead
source

pub fn eq<'e>(&'e self, a: Value<'e>, b: Value<'e>) -> bool

👎Deprecated since 0.10.0: Please use value1.eq(value2) instead
source

pub fn cons<'e, A, B>(&'e self, car: A, cdr: B) -> Result<Value<'_>>
where A: IntoLisp<'e>, B: IntoLisp<'e>,

source

pub fn list<'e, A>(&'e self, args: A) -> Result<Value<'_>>
where A: IntoLispArgs<'e>,

source

pub fn provide(&self, name: &str) -> Result<Value<'_>>

source

pub fn message<T: AsRef<str>>(&self, text: T) -> Result<Value<'_>>

source§

impl Env

source

pub unsafe fn make_user_ptr( &self, fin: emacs_finalizer_function, ptr: *mut c_void ) -> Result<Value<'_>>

Creates and returns a user-ptr object that wraps the raw pointer ptr. When the object is garbage-collected, fin will be called with ptr as the only argument. If fin is None, no finalization will be done.

In general, prefer the user-ptr supported provided by the defun attr macro. Use this function only for special user-ptr types, such as newtypes wrapping opaque pointers.

§Safety

The pointer must be valid until the finalizer is called. The finalizer itself must finalize the pointer in a safe manner.

source§

impl Env

source

pub fn make_vector<'e, T: IntoLisp<'e>>( &'e self, length: usize, init: T ) -> Result<Vector<'_>>

source

pub fn vector<'e, A: IntoLispArgs<'e>>(&'e self, args: A) -> Result<Value<'_>>

source§

impl Env

source

pub fn define_error<'e, N, P>( &'e self, name: N, message: &str, parents: P ) -> Result<Value<'e>>
where N: IntoLispSymbol<'e>, P: IntoLispArgs<'e>,

Defines a new Lisp error signal. This is the equivalent of the Lisp function’s define-error.

The error name can be either a string, a Value, or a GlobalRef.

source

pub fn signal<'e, S, D, T>(&'e self, symbol: S, data: D) -> Result<T>
where S: IntoLispSymbol<'e>, D: IntoLispArgs<'e>,

Signals a Lisp error. This is the equivalent of the Lisp function’s signal.

source§

impl Env

source

pub fn call<'e, F, A>(&'e self, func: F, args: A) -> Result<Value<'_>>
where F: IntoLispCallable<'e>, A: IntoLispArgs<'e>,

Calls a Lisp function, passing the given arguments.

  • func should be a string, or a Lisp’s callable Value (in which case func.call is preferable). An error is signaled otherwise.
  • args should be an array/slice of Value, or a tuple of different types, each implementing IntoLisp.
§Examples
#[defun]
fn listify_vec(vector: Vector) -> Result<Value> {
    let env = vector.value().env;
    let mut args = vec![];
    for elem in vector {
        args.push(elem)
    }
    env.call("list", &args)
}
source

pub unsafe fn call_unprotected<'e, F, A>( &'e self, func: F, args: A ) -> Result<Value<'_>>
where F: IntoLispCallable<'e>, A: IntoLispArgs<'e>,

Like call, except that the returned Value is not protected against Emacs GC’s bug #31238, which caused issue #2.

§Safety

This can be used as an optimization, in situations when the returned Value is unused, or when its usage is shorter than the lifespan of the underlying Lisp object.

Trait Implementations§

source§

impl Debug for Env

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Drop for Env

source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl !Freeze for Env

§

impl !RefUnwindSafe for Env

§

impl !Send for Env

§

impl !Sync for Env

§

impl Unpin for Env

§

impl UnwindSafe for Env

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.