mirror of
https://github.com/rkd77/elinks.git
synced 2025-01-03 14:57:44 -05:00
commit
2a0748d533
@ -1,6 +1,6 @@
|
||||
Installation:
|
||||
|
||||
You'll need internal-hooks.scm and user-hooks.scm in $HOME/.elinks
|
||||
You'll need hooks.scm and user-hooks.scm in $HOME/.elinks
|
||||
|
||||
I used Guile 1.5.6, in case that matters.
|
||||
|
||||
|
@ -59,10 +59,10 @@ init_guile(struct module *module)
|
||||
if (!path) return;
|
||||
|
||||
if (file_can_read(path)) {
|
||||
/* Load ~/.elinks/internal-hooks.scm. */
|
||||
/* Load ~/.elinks/hooks.scm. */
|
||||
scm_c_primitive_load_path(path);
|
||||
|
||||
/* internal-hooks.scm should have created a new module (elinks
|
||||
/* hooks.scm should have created a new module (elinks
|
||||
* internal). Let's remember it, even though I haven't figured
|
||||
* out how to use it directly yet... */
|
||||
internal_module = scm_current_module();
|
||||
|
@ -65,14 +65,14 @@ script_hook_goto_url(va_list ap, void *data)
|
||||
if (*url == NULL || !*url[0]) return EVENT_HOOK_STATUS_NEXT;
|
||||
|
||||
proc = get_guile_hook("%goto-url-hook");
|
||||
if (SCM_FALSEP(proc)) return EVENT_HOOK_STATUS_NEXT;
|
||||
if (scm_is_false(proc)) return EVENT_HOOK_STATUS_NEXT;
|
||||
|
||||
x = scm_call_1(SCM_VARIABLE_REF(proc), scm_makfrom0str(*url));
|
||||
x = scm_call_1(SCM_VARIABLE_REF(proc), scm_from_locale_string(*url));
|
||||
|
||||
if (SCM_STRINGP(x)) {
|
||||
if (scm_is_string(x)) {
|
||||
unsigned char *new_url;
|
||||
|
||||
new_url = stracpy(SCM_STRING_UCHARS(x));
|
||||
new_url = stracpy((unsigned char *)scm_to_locale_string(x));
|
||||
if (new_url) {
|
||||
mem_free_set(url, new_url);
|
||||
}
|
||||
@ -96,15 +96,14 @@ script_hook_follow_url(va_list ap, void *data)
|
||||
if (*url == NULL || !*url[0]) return EVENT_HOOK_STATUS_NEXT;
|
||||
|
||||
proc = get_guile_hook("%follow-url-hook");
|
||||
if (SCM_FALSEP(proc)) return EVENT_HOOK_STATUS_NEXT;
|
||||
if (scm_is_false(proc)) return EVENT_HOOK_STATUS_NEXT;
|
||||
|
||||
x = scm_call_1(SCM_VARIABLE_REF(proc), scm_makfrom0str(*url));
|
||||
x = scm_call_1(SCM_VARIABLE_REF(proc), scm_from_locale_string(*url));
|
||||
|
||||
if (SCM_STRINGP(x)) {
|
||||
if (scm_is_string(x)) {
|
||||
unsigned char *new_url;
|
||||
|
||||
new_url = memacpy(SCM_STRING_UCHARS(x),
|
||||
SCM_STRING_LENGTH(x) + 1);
|
||||
new_url = stracpy((unsigned char *)scm_to_locale_string(x));
|
||||
if (new_url) {
|
||||
mem_free_set(url, new_url);
|
||||
}
|
||||
@ -121,7 +120,7 @@ script_hook_pre_format_html(va_list ap, void *data)
|
||||
struct session *ses = va_arg(ap, struct session *);
|
||||
struct cache_entry *cached = va_arg(ap, struct cache_entry *);
|
||||
struct fragment *fragment = get_cache_fragment(cached);
|
||||
unsigned char *url = struri(cached->uri);
|
||||
unsigned char *url = struri(cached->uri), *frag;
|
||||
int len;
|
||||
SCM proc;
|
||||
SCM x;
|
||||
@ -131,15 +130,15 @@ script_hook_pre_format_html(va_list ap, void *data)
|
||||
if (!cached->length || !*fragment->data) return EVENT_HOOK_STATUS_NEXT;
|
||||
|
||||
proc = get_guile_hook("%pre-format-html-hook");
|
||||
if (SCM_FALSEP(proc)) return EVENT_HOOK_STATUS_NEXT;
|
||||
if (scm_is_false(proc)) return EVENT_HOOK_STATUS_NEXT;
|
||||
|
||||
x = scm_call_2(SCM_VARIABLE_REF(proc), scm_makfrom0str(url),
|
||||
scm_mem2string(fragment->data, fragment->length));
|
||||
x = scm_call_2(SCM_VARIABLE_REF(proc), scm_from_locale_string(url),
|
||||
scm_from_locale_stringn(fragment->data, fragment->length));
|
||||
|
||||
if (!SCM_STRINGP(x)) return EVENT_HOOK_STATUS_NEXT;
|
||||
if (!scm_is_string(x)) return EVENT_HOOK_STATUS_NEXT;
|
||||
|
||||
len = SCM_STRING_LENGTH(x);
|
||||
add_fragment(cached, 0, SCM_STRING_UCHARS(x), len);
|
||||
frag = (unsigned char *)scm_to_locale_stringn(x, &len);
|
||||
add_fragment(cached, 0, frag, len);
|
||||
normalize_cache_entry(cached, len);
|
||||
|
||||
return EVENT_HOOK_STATUS_NEXT;
|
||||
@ -157,15 +156,15 @@ script_hook_get_proxy(va_list ap, void *data)
|
||||
SCM proc = get_guile_hook("%get-proxy-hook");
|
||||
SCM x;
|
||||
|
||||
if (SCM_FALSEP(proc)) return EVENT_HOOK_STATUS_NEXT;
|
||||
if (scm_is_false(proc)) return EVENT_HOOK_STATUS_NEXT;
|
||||
|
||||
x = scm_call_1(SCM_VARIABLE_REF(proc), scm_makfrom0str(url));
|
||||
x = scm_call_1(SCM_VARIABLE_REF(proc), scm_from_locale_string(url));
|
||||
|
||||
evhook_use_params(retval && url);
|
||||
|
||||
if (SCM_STRINGP(x)) {
|
||||
mem_free_set(retval, memacpy(SCM_STRING_UCHARS(x), SCM_STRING_LENGTH(x)+1));
|
||||
} else if (SCM_NULLP(x)) {
|
||||
if (scm_is_string(x)) {
|
||||
mem_free_set(retval, stracpy(scm_to_locale_string(x)));
|
||||
} else if (scm_is_null(x)) {
|
||||
mem_free_set(retval, NULL);
|
||||
}
|
||||
|
||||
@ -177,7 +176,7 @@ script_hook_quit(va_list ap, void *data)
|
||||
{
|
||||
SCM proc = get_guile_hook("%quit-hook");
|
||||
|
||||
if (SCM_FALSEP(proc)) return EVENT_HOOK_STATUS_NEXT;
|
||||
if (scm_is_false(proc)) return EVENT_HOOK_STATUS_NEXT;
|
||||
|
||||
scm_call_0(SCM_VARIABLE_REF(proc));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user