From: Caleb Ristvedt <caleb.ristvedt@cune.org>
To: 35644@debbugs.gnu.org
Subject: bug#35644: emacs module support doesn't work
Date: Wed, 08 May 2019 21:16:48 -0500 [thread overview]
Message-ID: <87o94cid7z.fsf@cune.org> (raw)
While attempting to package libegit2
(https://github.com/magit/libegit2), I found that any attempt at loading
a dynamic module from emacs would seemingly work (it returns t), but not
actually work: no module api functions invoked from C seem to have any
effect, including defining functions and printing messages. Here's an
example
-------------------------------
#include <stdio.h>
#include <stdlib.h>
#include <emacs-module.h>
int plugin_is_GPL_compatible;
static emacs_value
hello(emacs_env *env, ptrdiff_t nargs, emacs_value args[], void *data)
{
const char str[] = "Hello Emacs";
return env->make_string(env, str, sizeof(str) - 1);
}
/* Module init function. */
int
emacs_module_init(struct emacs_runtime *ert)
{
emacs_env *env = ert->get_environment(ert);
emacs_value hellofn = env->make_function(env, 0, 0, hello, "return hello string", NULL);
// Bind NAME to FUN.
// (defalias 'hello-c '(lambda () "Hello Emacs"))
emacs_value defalias_sym = env->intern(env, "defalias");
emacs_value hello_sym = env->intern(env, "hello-c");
emacs_value defalias_args[] = { hello_sym, hellofn };
env->funcall(env, defalias_sym, 2, defalias_args);
// Provide FEATURE to Emacs.
// (provide 'hello-core)
emacs_value feature_sym = env->intern(env, "hello-module");
emacs_value provide_sym = env->intern(env, "provide");
emacs_value provide_args[] = { feature_sym };
env->funcall(env, provide_sym, 1, provide_args);
char message[] = "TEST MESSAGE!";
emacs_value message_str = env->make_string(env, message, sizeof(message) - 1);
emacs_value message_sym = env->intern(env, "message");
emacs_value message_args[] = {message_str};
// spam a bit just to be sure
env->funcall(env, message_sym, 1, message_args);
env->funcall(env, message_sym, 1, message_args);
env->funcall(env, message_sym, 1, message_args);
return 0;
}
-------------------------------
Assuming the above file is named emacs-module-test.c:
-------------------------------
$ gcc -fPIC -shared emacs-module-test.c -o hello-module.so
$ emacs -Q -L . --batch -l hello-module --eval "(message (hello-c))"
=> Symbol's function definition is void: hello-c
-------------------------------
As far as I can tell, this should work. Our emacs is built with
'--with-modules', and 'MODULES' is in system-configuration-features. Any
idea what's going wrong?
- reepca
next reply other threads:[~2019-05-09 2:18 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-09 2:16 Caleb Ristvedt [this message]
2020-03-10 16:52 ` bug#35644: emacs module support doesn't work mike
2020-03-11 5:55 ` Caleb Ristvedt
2020-03-20 19:06 ` Marius Bakke
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://guix.gnu.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87o94cid7z.fsf@cune.org \
--to=caleb.ristvedt@cune.org \
--cc=35644@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/guix.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).