Initial commit of the HEAD branch of the ELinks CVS repository, as of
[elinks/images.git] / src / scripting / guile / core.c
blobb81a537de6326db08fa8245923b5565321b75fbb
1 /* Guile interface (scripting engine) */
2 /* $Id: core.c,v 1.21 2005/06/13 00:43:29 jonas Exp $ */
4 #ifdef HAVE_CONFIG_H
5 #include "config.h"
6 #endif
8 #include <libguile.h>
10 #include "elinks.h"
12 #include "config/home.h"
13 #include "main/module.h"
14 #include "scripting/guile/core.h"
15 #include "scripting/guile/hooks.h"
16 #include "util/error.h"
17 #include "util/file.h"
18 #include "util/string.h"
22 * Bindings
25 /* static SCM c_current_url(void) */
26 /* { */
27 /* struct view_state *vs; */
29 /* if (have_location(ses) && (vs = ses ? &cur_loc(ses)->vs : 0)) */
30 /* return scm_makfrom0str(struri(vs->uri)); */
31 /* else */
32 /* return SCM_BOOL_F; */
33 /* } */
34 /* c_current_link */
35 /* c_current_title */
36 /* c_current_document */
37 /* c_current_document_formatted */
38 /* c_bind_key */
39 /* c_xdialog */
42 void
43 init_guile(struct module *module)
45 SCM user_module;
46 SCM internal_module;
47 unsigned char *path;
49 scm_init_guile();
51 if (!elinks_home) return;
53 /* Remember the current module. */
54 user_module = scm_current_module();
56 path = straconcat(elinks_home, "internal-hooks.scm", NULL);
57 if (!path) return;
59 if (file_can_read(path)) {
60 /* Load ~/.elinks/internal-hooks.scm. */
61 scm_c_primitive_load_path(path);
63 /* internal-hooks.scm should have created a new module (elinks
64 * internal). Let's remember it, even though I haven't figured
65 * out how to use it directly yet... */
66 internal_module = scm_current_module();
68 /* Return to the user module, import bindings from (elinks
69 * internal), then load ~/.elinks/user-hooks.scm. */
70 scm_set_current_module(user_module);
72 /* FIXME: better way? i want to use internal_module directly */
73 scm_c_use_module("elinks internal");
76 mem_free(path);
78 path = straconcat(elinks_home, "user-hooks.scm", NULL);
79 if (!path) return;
80 if (file_can_read(path))
81 scm_c_primitive_load_path(path);
82 mem_free(path);