A prelude for writing Emacs dynamic modules

When writing an Emacs dynamic module for Xapian1, I found that calling Lisp functions in a dynamic module is painfully tedious. For example, the equivalent of

(define-error 'xeft-error "Generic Xeft error" 'error)

is

emacs_value Qdefine_error = env->intern (env, "define-error");
emacs_value Qxeft_error = env->intern (env, "xeft-error");
emacs_value Qerror = env->intern (env, "error");
char **text = "Generic Xeft error";
emacs_value message = env->make_string (env, text , strlen (text));
emacs_value args[] = {Qxeft_error, message, Qerror};
int nargs = 3;
env->funcall (env, Qdefine_error, nargs, args);

Even though we usually only write a little Lisp for defining the exposed functions and errors in a dynamic module, this is too much. Naturally I wrote some wrappers. With my wrappers, I can write the following instead:

emp_funcall (env, "define-error", 3,
             emp_intern (env, "xeft-error"),
             emp_build_string (env, "Generic Xeft error"),
             emp_intern (env, "error"));

I put these wrappers together into emacs-module-prelude. Currently it provides these functions:

You can find it at emacs-module-prelude. I can’t say that I’m a seasoned C programmer so use at your own risk. Corrections are very welcome.

For my note-searching package: Xeft.