mirror of
https://github.com/djcb/mu.git
synced 2024-06-27 07:35:16 +02:00
* update mu-guile for other changes
This commit is contained in:
parent
c9d4111915
commit
2c92018484
|
@ -27,7 +27,7 @@
|
||||||
|
|
||||||
void
|
void
|
||||||
mu_guile_error (const char *func_name, int status,
|
mu_guile_error (const char *func_name, int status,
|
||||||
const char *fmt, SCM args)
|
const char *fmt, SCM args)
|
||||||
{
|
{
|
||||||
scm_error_scm (scm_from_locale_symbol ("MuError"),
|
scm_error_scm (scm_from_locale_symbol ("MuError"),
|
||||||
scm_from_utf8_string (func_name ? func_name : "<nameless>"),
|
scm_from_utf8_string (func_name ? func_name : "<nameless>"),
|
||||||
|
@ -37,15 +37,14 @@ mu_guile_error (const char *func_name, int status,
|
||||||
|
|
||||||
void
|
void
|
||||||
mu_guile_g_error (const char *func_name, GError *err)
|
mu_guile_g_error (const char *func_name, GError *err)
|
||||||
{
|
{
|
||||||
scm_error_scm (scm_from_locale_symbol ("MuError"),
|
scm_error_scm (scm_from_locale_symbol ("MuError"),
|
||||||
scm_from_utf8_string (func_name),
|
scm_from_utf8_string (func_name),
|
||||||
scm_from_utf8_string (err->message),
|
scm_from_utf8_string (err ? err->message : "error"),
|
||||||
SCM_UNDEFINED, SCM_UNDEFINED);
|
SCM_UNDEFINED, SCM_UNDEFINED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
mu_guile_init (void)
|
mu_guile_init (void)
|
||||||
{
|
{
|
||||||
|
@ -57,8 +56,8 @@ mu_guile_init (void)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* backward compat for pre-2.x guile - note, this will fail miserably
|
* backward compat for pre-2.x guile - note, this will fail miserably
|
||||||
* if you don't use a UTF8 locale
|
* if you don't use a UTF8 locale
|
||||||
*/
|
*/
|
||||||
#if HAVE_PRE2_GUILE
|
#if HAVE_PRE2_GUILE
|
||||||
|
|
||||||
SCM
|
SCM
|
||||||
|
|
|
@ -29,13 +29,21 @@ static MuQuery*
|
||||||
get_query (void)
|
get_query (void)
|
||||||
{
|
{
|
||||||
MuQuery *query;
|
MuQuery *query;
|
||||||
|
MuStore *store;
|
||||||
GError *err;
|
GError *err;
|
||||||
|
|
||||||
err = NULL;
|
err = NULL;
|
||||||
query = mu_query_new (mu_runtime_path(MU_RUNTIME_PATH_XAPIANDB), &err);
|
store = mu_store_new_read_only (mu_runtime_path(MU_RUNTIME_PATH_XAPIANDB),
|
||||||
if (err) {
|
&err);
|
||||||
|
query = store ? mu_query_new (store, &err) : NULL;
|
||||||
|
|
||||||
|
if (store)
|
||||||
|
mu_store_unref (store);
|
||||||
|
|
||||||
|
if (!query) {
|
||||||
mu_guile_g_error ("<internal error>", err);
|
mu_guile_g_error ("<internal error>", err);
|
||||||
g_error_free (err);
|
if (err)
|
||||||
|
g_error_free (err);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,8 +56,8 @@ get_query_iter (MuQuery *query, const char* expr)
|
||||||
{
|
{
|
||||||
MuMsgIter *iter;
|
MuMsgIter *iter;
|
||||||
GError *err;
|
GError *err;
|
||||||
|
|
||||||
err = NULL;
|
err = NULL;
|
||||||
iter = mu_query_run (query, expr,
|
iter = mu_query_run (query, expr,
|
||||||
FALSE, MU_MSG_FIELD_ID_NONE, TRUE, &err);
|
FALSE, MU_MSG_FIELD_ID_NONE, TRUE, &err);
|
||||||
if (err) {
|
if (err) {
|
||||||
|
@ -57,7 +65,7 @@ get_query_iter (MuQuery *query, const char* expr)
|
||||||
g_error_free (err);
|
g_error_free (err);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return iter;
|
return iter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,16 +75,9 @@ call_func (SCM FUNC, MuMsgIter *iter, const char* func_name)
|
||||||
{
|
{
|
||||||
SCM msgsmob;
|
SCM msgsmob;
|
||||||
MuMsg *msg;
|
MuMsg *msg;
|
||||||
GError *err;
|
|
||||||
|
msg = mu_msg_iter_get_msg_floating (iter); /* don't unref */
|
||||||
err = NULL;
|
|
||||||
msg = mu_msg_iter_get_msg (iter, &err);
|
|
||||||
if (err) {
|
|
||||||
mu_guile_g_error (func_name, err);
|
|
||||||
g_error_free (err);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
msgsmob = mu_guile_msg_to_scm (mu_msg_ref(msg));
|
msgsmob = mu_guile_msg_to_scm (mu_msg_ref(msg));
|
||||||
scm_call_1 (FUNC, msgsmob);
|
scm_call_1 (FUNC, msgsmob);
|
||||||
}
|
}
|
||||||
|
@ -96,13 +97,13 @@ SCM_DEFINE (store_foreach, "mu:store:for-each", 1, 1, 0,
|
||||||
SCM_ASSERT (scm_procedure_p (FUNC), FUNC, SCM_ARG1, FUNC_NAME);
|
SCM_ASSERT (scm_procedure_p (FUNC), FUNC, SCM_ARG1, FUNC_NAME);
|
||||||
SCM_ASSERT (scm_is_string (EXPR) || EXPR == SCM_UNSPECIFIED,
|
SCM_ASSERT (scm_is_string (EXPR) || EXPR == SCM_UNSPECIFIED,
|
||||||
EXPR, SCM_ARG2, FUNC_NAME);
|
EXPR, SCM_ARG2, FUNC_NAME);
|
||||||
|
|
||||||
query = get_query ();
|
query = get_query ();
|
||||||
if (!query)
|
if (!query)
|
||||||
return SCM_UNSPECIFIED;
|
return SCM_UNSPECIFIED;
|
||||||
|
|
||||||
expr = SCM_UNBNDP(EXPR) ? NULL : scm_to_utf8_string(EXPR);
|
expr = SCM_UNBNDP(EXPR) ? NULL : scm_to_utf8_string(EXPR);
|
||||||
|
|
||||||
iter = get_query_iter (query, expr);
|
iter = get_query_iter (query, expr);
|
||||||
if (!iter)
|
if (!iter)
|
||||||
return SCM_UNSPECIFIED;
|
return SCM_UNSPECIFIED;
|
||||||
|
@ -111,7 +112,7 @@ SCM_DEFINE (store_foreach, "mu:store:for-each", 1, 1, 0,
|
||||||
call_func (FUNC, iter, FUNC_NAME);
|
call_func (FUNC, iter, FUNC_NAME);
|
||||||
++count;
|
++count;
|
||||||
}
|
}
|
||||||
|
|
||||||
mu_query_destroy (query);
|
mu_query_destroy (query);
|
||||||
|
|
||||||
return scm_from_int (count);
|
return scm_from_int (count);
|
||||||
|
@ -121,7 +122,7 @@ SCM_DEFINE (store_foreach, "mu:store:for-each", 1, 1, 0,
|
||||||
|
|
||||||
void*
|
void*
|
||||||
mu_guile_store_init (void *data)
|
mu_guile_store_init (void *data)
|
||||||
{
|
{
|
||||||
#include "mu-guile-store.x"
|
#include "mu-guile-store.x"
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user