~ubuntu-branches/ubuntu/feisty/elinks/feisty-updates

« back to all changes in this revision

Viewing changes to src/scripting/guile/core.c

  • Committer: Bazaar Package Importer
  • Author(s): Peter Gervai
  • Date: 2004-01-21 22:13:45 UTC
  • Revision ID: james.westby@ubuntu.com-20040121221345-ju33hai1yhhqt6kn
Tags: upstream-0.9.1
ImportĀ upstreamĀ versionĀ 0.9.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Guile interface (scripting engine) */
 
2
/* $Id: core.c,v 1.12 2003/12/21 06:55:16 miciah Exp $ */
 
3
 
 
4
#ifdef HAVE_CONFIG_H
 
5
#include "config.h"
 
6
#endif
 
7
 
 
8
#ifdef HAVE_GUILE
 
9
 
 
10
#include <libguile.h>
 
11
 
 
12
#include "elinks.h"
 
13
 
 
14
#include "lowlevel/home.h"
 
15
#include "modules/module.h"
 
16
#include "scripting/guile/core.h"
 
17
#include "scripting/guile/hooks.h"
 
18
#include "scripting/scripting.h"
 
19
#include "util/error.h"
 
20
#include "util/string.h"
 
21
 
 
22
 
 
23
/*
 
24
 * Bindings
 
25
 */
 
26
 
 
27
/* static SCM c_current_url(void) */
 
28
/* { */
 
29
/*      struct view_state *vs; */
 
30
 
 
31
/*      if (have_location(ses) && (vs = ses ? &cur_loc(ses)->vs : 0)) */
 
32
/*              return scm_makfrom0str(vs->url); */
 
33
/*      else */
 
34
/*              return SCM_BOOL_F; */
 
35
/* } */
 
36
/* c_current_link */
 
37
/* c_current_title */
 
38
/* c_current_document */
 
39
/* c_current_document_formatted */
 
40
/* c_bind_key */
 
41
/* c_xdialog */
 
42
 
 
43
 
 
44
static void
 
45
init_guile(struct module *module)
 
46
{
 
47
        SCM user_module;
 
48
        SCM internal_module;
 
49
        unsigned char *path;
 
50
 
 
51
        scm_init_guile();
 
52
 
 
53
        if (!elinks_home) return;
 
54
 
 
55
        /* Remember the current module. */
 
56
        user_module = scm_current_module();
 
57
 
 
58
        /* Load ~/.elinks/internal-hooks.scm. */
 
59
        path = straconcat(elinks_home, "internal-hooks.scm", NULL);
 
60
        if (!path) return;
 
61
        scm_c_primitive_load_path(path);
 
62
        mem_free(path);
 
63
 
 
64
        /* internal-hooks.scm should have created a new module (elinks
 
65
         * internal).  Let's remember it, even though I haven't
 
66
         * figured out how to use it directly yet...
 
67
         */
 
68
        internal_module = scm_current_module();
 
69
 
 
70
        /* Return to the user module, import bindings from (elinks
 
71
         * internal), then load ~/.elinks/user-hooks.scm.
 
72
         */
 
73
        scm_set_current_module(user_module);
 
74
        scm_c_use_module("elinks internal"); /* XXX: better way? i want to use internal_module directly */
 
75
        path = straconcat(elinks_home, "user-hooks.scm", NULL);
 
76
        if (!path) return;
 
77
        scm_c_primitive_load_path(path);
 
78
        mem_free(path);
 
79
}
 
80
 
 
81
 
 
82
struct module guile_scripting_module = struct_module(
 
83
        /* name: */             "Guile",
 
84
        /* options: */          NULL,
 
85
        /* events: */           guile_scripting_hooks,
 
86
        /* submodules: */       NULL,
 
87
        /* data: */             NULL,
 
88
        /* init: */             init_guile,
 
89
        /* done: */             NULL
 
90
);
 
91
 
 
92
#endif /* HAVE_GUILE */