Handle emacs' "-*- langname -*-"
This commit is contained in:
parent
aca8f50d41
commit
db5bfe2d81
@ -646,7 +646,7 @@ moo_edit_get_editor (MooEdit *doc)
|
||||
|
||||
|
||||
typedef void (*SetVarFunc) (MooEdit *edit,
|
||||
char *name,
|
||||
const char *name,
|
||||
char *val);
|
||||
|
||||
static void
|
||||
@ -735,7 +735,7 @@ parse_kate_mode_string (MooEdit *edit,
|
||||
|
||||
static void
|
||||
set_emacs_var (MooEdit *edit,
|
||||
char *name,
|
||||
const char *name,
|
||||
char *val)
|
||||
{
|
||||
if (!g_ascii_strcasecmp (name, "mode"))
|
||||
@ -768,6 +768,15 @@ static void
|
||||
parse_emacs_mode_string (MooEdit *edit,
|
||||
char *string)
|
||||
{
|
||||
MooLangMgr *mgr;
|
||||
|
||||
g_strstrip (string);
|
||||
|
||||
mgr = moo_editor_get_lang_mgr (edit->priv->editor);
|
||||
|
||||
if (_moo_lang_mgr_find_lang (mgr, string))
|
||||
set_emacs_var (edit, "mode", string);
|
||||
else
|
||||
parse_mode_string (edit, string, ":", set_emacs_var);
|
||||
}
|
||||
|
||||
|
@ -202,13 +202,33 @@ string_list_free (GSList *list)
|
||||
MooLang *
|
||||
moo_lang_mgr_get_lang (MooLangMgr *mgr,
|
||||
const char *name)
|
||||
{
|
||||
MooLang *lang;
|
||||
|
||||
g_return_val_if_fail (MOO_IS_LANG_MGR (mgr), NULL);
|
||||
|
||||
if (!name)
|
||||
return NULL;
|
||||
|
||||
lang = _moo_lang_mgr_find_lang (mgr, name);
|
||||
|
||||
if (!lang)
|
||||
g_warning ("could not find language '%s'", name);
|
||||
|
||||
return lang;
|
||||
}
|
||||
|
||||
MooLang *
|
||||
_moo_lang_mgr_find_lang (MooLangMgr *mgr,
|
||||
const char *name)
|
||||
{
|
||||
char *id;
|
||||
LangInfo *info;
|
||||
|
||||
g_return_val_if_fail (MOO_IS_LANG_MGR (mgr), NULL);
|
||||
g_return_val_if_fail (name != NULL, NULL);
|
||||
|
||||
if (!name || !strcmp (name, MOO_LANG_NONE))
|
||||
if (!strcmp (name, MOO_LANG_NONE))
|
||||
return NULL;
|
||||
|
||||
if (!g_ascii_strcasecmp (name, "c++"))
|
||||
@ -217,11 +237,8 @@ moo_lang_mgr_get_lang (MooLangMgr *mgr,
|
||||
read_langs (mgr);
|
||||
id = _moo_lang_id_from_name (name);
|
||||
info = get_lang_info (mgr, id, FALSE);
|
||||
|
||||
if (!info)
|
||||
g_warning ("could not find language '%s'", name);
|
||||
|
||||
g_free (id);
|
||||
|
||||
return info ? info->lang : NULL;
|
||||
}
|
||||
|
||||
|
@ -42,6 +42,9 @@ GSList *moo_lang_mgr_get_available_langs (MooLangMgr *mgr);
|
||||
/* list must be freed together with content */
|
||||
GSList *moo_lang_mgr_get_sections (MooLangMgr *mgr);
|
||||
|
||||
MooLang *_moo_lang_mgr_find_lang (MooLangMgr *mgr,
|
||||
const char *name);
|
||||
|
||||
MooTextStyleScheme *_moo_lang_mgr_get_active_scheme (MooLangMgr *mgr);
|
||||
void _moo_lang_mgr_set_active_scheme (MooLangMgr *mgr,
|
||||
const char *scheme_name);
|
||||
|
Loading…
x
Reference in New Issue
Block a user