mirror of https://github.com/djcb/mu.git
* mu-guile-util: remove guile 1.8 backward compat stuff
This commit is contained in:
parent
9d6d33be2a
commit
489fd3fcf4
|
@ -16,7 +16,13 @@
|
|||
** Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
**
|
||||
*/
|
||||
|
||||
#include <mu-runtime.h>
|
||||
#include <glib-object.h>
|
||||
|
||||
#include "mu-guile-util.h"
|
||||
#include "mu-guile-msg.h"
|
||||
|
||||
|
||||
SCM
|
||||
mu_guile_util_error (const char *func_name, int status,
|
||||
|
@ -40,116 +46,3 @@ mu_guile_util_g_error (const char *func_name, GError *err)
|
|||
|
||||
return SCM_UNSPECIFIED;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#include <mu-runtime.h>
|
||||
#include <glib-object.h>
|
||||
|
||||
#include "mu-guile-util.h"
|
||||
#include "mu-guile-msg.h"
|
||||
|
||||
struct _GuileConfig {
|
||||
const char *muhome;
|
||||
char *msgpath;
|
||||
};
|
||||
typedef struct _GuileConfig GuileConfig;
|
||||
|
||||
|
||||
static GuileConfig*
|
||||
guile_config_new (int *argcp, char ***argvp)
|
||||
{
|
||||
GOptionContext *octx;
|
||||
GuileConfig *opts = g_new0 (GuileConfig, 1);
|
||||
GOptionEntry entries[] = {
|
||||
{"muhome", 0, 0, G_OPTION_ARG_FILENAME, &opts->muhome,
|
||||
"specify an alternative mu directory", NULL},
|
||||
{"msg", 0, 0, G_OPTION_ARG_FILENAME, &opts->msgpath,
|
||||
"specify path to a message to load as mu:current-msg)", NULL},
|
||||
{NULL, 0, 0, G_OPTION_ARG_NONE, NULL, NULL, NULL}/* sentinel */
|
||||
};
|
||||
|
||||
octx = g_option_context_new ("- mu guile options");
|
||||
g_option_context_add_main_entries (octx, entries, "mu guile");
|
||||
|
||||
if (!g_option_context_parse (octx, argcp, argvp, NULL)) {
|
||||
g_option_context_free (octx);
|
||||
g_printerr ("mu guile: error in options\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (opts->msgpath)
|
||||
opts->msgpath = mu_util_dir_expand (opts->msgpath);
|
||||
|
||||
g_option_context_free (octx);
|
||||
|
||||
return opts;
|
||||
}
|
||||
|
||||
static void
|
||||
guile_config_destroy (GuileConfig *conf)
|
||||
{
|
||||
g_free (conf->msgpath);
|
||||
g_free (conf);
|
||||
}
|
||||
|
||||
|
||||
|
||||
gboolean
|
||||
mu_guile_util_run (int *argcp, char **argvp[])
|
||||
{
|
||||
GuileConfig *opts;
|
||||
|
||||
#ifdef HAVE_PRE2_GUILE
|
||||
g_warning ("Note: mu guile will not function properly unless you are using a"
|
||||
"UTF-8 locale.");
|
||||
#endif /* HAVE_PRE2_GUILE */
|
||||
|
||||
opts = guile_config_new (argcp, argvp);
|
||||
if (!opts)
|
||||
goto error;
|
||||
|
||||
if (!mu_runtime_init (opts->muhome /* NULL is okay */,
|
||||
"mu-guile"))
|
||||
goto error;
|
||||
|
||||
/* FIXME: mu_guile_init (); /\* initialize mu guile modules *\/ */
|
||||
|
||||
if (opts->msgpath) {
|
||||
if (!(gboolean)scm_with_guile
|
||||
((MuGuileFunc*)&mu_guile_msg_load_current,
|
||||
opts->msgpath))
|
||||
goto error;
|
||||
}
|
||||
|
||||
scm_shell (*argcp, *argvp);
|
||||
|
||||
mu_runtime_uninit ();
|
||||
guile_config_destroy (opts);
|
||||
|
||||
return TRUE;
|
||||
error:
|
||||
guile_config_destroy (opts);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* backward compat for pre-2.x guile - note, this will fail miserably
|
||||
* if you don't use a UTF8 locale
|
||||
*/
|
||||
#if HAVE_PRE2_GUILE
|
||||
|
||||
SCM
|
||||
scm_from_utf8_string (const char* str)
|
||||
{
|
||||
return scm_from_locale_string (str);
|
||||
}
|
||||
|
||||
char*
|
||||
scm_to_utf8_string (SCM scm)
|
||||
{
|
||||
return scm_to_locale_string (scm);
|
||||
}
|
||||
#endif /*HAVE_PRE2_GUILE*/
|
||||
|
|
|
@ -21,11 +21,6 @@
|
|||
#define __MU_GUILE_UTIL_H__
|
||||
|
||||
#include <libguile.h>
|
||||
|
||||
#if HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif /*HAVE_CONFIG_H*/
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
@ -61,13 +56,6 @@ SCM mu_guile_util_error (const char *func_name, int status,
|
|||
*/
|
||||
SCM mu_guile_util_g_error (const char *func_name, GError *err);
|
||||
|
||||
|
||||
/* compatibility functions for guile 1.8 */
|
||||
#if HAVE_PRE2_GUILE
|
||||
SCM scm_from_utf8_string (const char* str);
|
||||
char* scm_to_utf8_string (SCM scm);
|
||||
#endif /*HAVE_PRE2_GUILE*/
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /*__MU_GUILE_UTIL_H__*/
|
||||
|
|
Loading…
Reference in New Issue