summaryrefslogtreecommitdiff
path: root/plugins/modelines/modeline-parser.c
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/modelines/modeline-parser.c')
-rw-r--r--plugins/modelines/modeline-parser.c74
1 files changed, 37 insertions, 37 deletions
diff --git a/plugins/modelines/modeline-parser.c b/plugins/modelines/modeline-parser.c
index c66c1ed5..3f347a7b 100644
--- a/plugins/modelines/modeline-parser.c
+++ b/plugins/modelines/modeline-parser.c
@@ -63,7 +63,7 @@ typedef struct _ModelineOptions
GtkWrapMode wrap_mode;
gboolean display_right_margin;
guint right_margin_position;
-
+
ModelineSet set;
} ModelineOptions;
@@ -94,7 +94,7 @@ modeline_parser_shutdown ()
if (kate_languages != NULL)
g_hash_table_destroy (kate_languages);
-
+
vim_languages = NULL;
emacs_languages = NULL;
kate_languages = NULL;
@@ -225,7 +225,7 @@ skip_whitespaces (gchar **s)
}
/* Parse vi(m) modelines.
- * Vi(m) modelines looks like this:
+ * Vi(m) modelines looks like this:
* - first form: [text]{white}{vi:|vim:|ex:}[white]{options}
* - second form: [text]{white}{vi:|vim:|ex:}[white]se[t] {options}:[text]
* They can happen on the three first or last lines.
@@ -290,7 +290,7 @@ parse_vim_modeline (gchar *s,
{
g_free (options->language_id);
options->language_id = get_language_id_vim (value->str);
-
+
options->set |= MODELINE_SET_LANGUAGE;
}
else if (strcmp (key->str, "et") == 0 ||
@@ -303,7 +303,7 @@ parse_vim_modeline (gchar *s,
strcmp (key->str, "tabstop") == 0)
{
intval = atoi (value->str);
-
+
if (intval)
{
options->tab_width = intval;
@@ -314,7 +314,7 @@ parse_vim_modeline (gchar *s,
strcmp (key->str, "shiftwidth") == 0)
{
intval = atoi (value->str);
-
+
if (intval)
{
options->indent_width = intval;
@@ -330,15 +330,15 @@ parse_vim_modeline (gchar *s,
else if (strcmp (key->str, "textwidth") == 0)
{
intval = atoi (value->str);
-
+
if (intval)
{
options->right_margin_position = intval;
options->display_right_margin = TRUE;
-
+
options->set |= MODELINE_SET_SHOW_RIGHT_MARGIN |
MODELINE_SET_RIGHT_MARGIN_POSITION;
-
+
}
}
}
@@ -407,13 +407,13 @@ parse_emacs_modeline (gchar *s,
{
g_free (options->language_id);
options->language_id = get_language_id_emacs (value->str);
-
+
options->set |= MODELINE_SET_LANGUAGE;
}
else if (strcmp (key->str, "tab-width") == 0)
{
intval = atoi (value->str);
-
+
if (intval)
{
options->tab_width = intval;
@@ -423,7 +423,7 @@ parse_emacs_modeline (gchar *s,
else if (strcmp (key->str, "indent-offset") == 0)
{
intval = atoi (value->str);
-
+
if (intval)
{
options->indent_width = intval;
@@ -434,14 +434,14 @@ parse_emacs_modeline (gchar *s,
{
intval = strcmp (value->str, "nil") == 0;
options->insert_spaces = intval;
-
+
options->set |= MODELINE_SET_INSERT_SPACES;
}
else if (strcmp (key->str, "autowrap") == 0)
{
intval = strcmp (value->str, "nil") != 0;
options->wrap_mode = intval ? GTK_WRAP_WORD : GTK_WRAP_NONE;
-
+
options->set |= MODELINE_SET_WRAP_MODE;
}
}
@@ -505,13 +505,13 @@ parse_kate_modeline (gchar *s,
{
g_free (options->language_id);
options->language_id = get_language_id_kate (value->str);
-
+
options->set |= MODELINE_SET_LANGUAGE;
}
else if (strcmp (key->str, "tab-width") == 0)
{
intval = atoi (value->str);
-
+
if (intval)
{
options->tab_width = intval;
@@ -540,17 +540,17 @@ parse_kate_modeline (gchar *s,
options->wrap_mode = intval ? GTK_WRAP_WORD : GTK_WRAP_NONE;
- options->set |= MODELINE_SET_WRAP_MODE;
+ options->set |= MODELINE_SET_WRAP_MODE;
}
else if (strcmp (key->str, "word-wrap-column") == 0)
{
intval = atoi (value->str);
-
+
if (intval)
{
options->right_margin_position = intval;
options->display_right_margin = TRUE;
-
+
options->set |= MODELINE_SET_RIGHT_MARGIN_POSITION |
MODELINE_SET_SHOW_RIGHT_MARGIN;
}
@@ -612,7 +612,7 @@ check_previous (GtkSourceView *view,
ModelineSet set)
{
GtkSourceBuffer *buffer = GTK_SOURCE_BUFFER (gtk_text_view_get_buffer (GTK_TEXT_VIEW (view)));
-
+
/* Do not restore default when this is the first time */
if (!previous)
return FALSE;
@@ -649,7 +649,7 @@ check_previous (GtkSourceView *view,
case MODELINE_SET_LANGUAGE:
{
GtkSourceLanguage *language = gtk_source_buffer_get_language (buffer);
-
+
return (language == NULL && previous->language_id == NULL) ||
(language != NULL && g_strcmp0 (gtk_source_language_get_id (language),
previous->language_id) == 0);
@@ -675,7 +675,7 @@ modeline_parser_apply_modeline (GtkSourceView *view)
GtkTextBuffer *buffer;
GtkTextIter iter, liter;
gint line_count;
-
+
options.language_id = NULL;
options.set = MODELINE_SET_NONE;
@@ -758,7 +758,7 @@ modeline_parser_apply_modeline (GtkSourceView *view)
}
}
- ModelineOptions *previous = g_object_get_data (G_OBJECT (buffer),
+ ModelineOptions *previous = g_object_get_data (G_OBJECT (buffer),
MODELINE_OPTIONS_DATA_KEY);
/* Apply the options we got from modelines and restore defaults if
@@ -774,17 +774,17 @@ modeline_parser_apply_modeline (GtkSourceView *view)
(view,
pluma_prefs_manager_get_insert_spaces ());
}
-
+
if (has_option (&options, MODELINE_SET_TAB_WIDTH))
{
gtk_source_view_set_tab_width (view, options.tab_width);
}
else if (check_previous (view, previous, MODELINE_SET_TAB_WIDTH))
{
- gtk_source_view_set_tab_width (view,
+ gtk_source_view_set_tab_width (view,
pluma_prefs_manager_get_tabs_size ());
}
-
+
if (has_option (&options, MODELINE_SET_INDENT_WIDTH))
{
gtk_source_view_set_indent_width (view, options.indent_width);
@@ -793,37 +793,37 @@ modeline_parser_apply_modeline (GtkSourceView *view)
{
gtk_source_view_set_indent_width (view, -1);
}
-
+
if (has_option (&options, MODELINE_SET_WRAP_MODE))
{
gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (view), options.wrap_mode);
}
else if (check_previous (view, previous, MODELINE_SET_WRAP_MODE))
{
- gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (view),
+ gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (view),
pluma_prefs_manager_get_wrap_mode ());
}
-
+
if (has_option (&options, MODELINE_SET_RIGHT_MARGIN_POSITION))
{
gtk_source_view_set_right_margin_position (view, options.right_margin_position);
}
else if (check_previous (view, previous, MODELINE_SET_RIGHT_MARGIN_POSITION))
{
- gtk_source_view_set_right_margin_position (view,
+ gtk_source_view_set_right_margin_position (view,
pluma_prefs_manager_get_right_margin_position ());
}
-
+
if (has_option (&options, MODELINE_SET_SHOW_RIGHT_MARGIN))
{
gtk_source_view_set_show_right_margin (view, options.display_right_margin);
}
else if (check_previous (view, previous, MODELINE_SET_SHOW_RIGHT_MARGIN))
{
- gtk_source_view_set_show_right_margin (view,
+ gtk_source_view_set_show_right_margin (view,
pluma_prefs_manager_get_display_right_margin ());
}
-
+
if (previous)
{
*previous = options;
@@ -834,13 +834,13 @@ modeline_parser_apply_modeline (GtkSourceView *view)
previous = g_slice_new (ModelineOptions);
*previous = options;
previous->language_id = g_strdup (options.language_id);
-
- g_object_set_data_full (G_OBJECT (buffer),
- MODELINE_OPTIONS_DATA_KEY,
+
+ g_object_set_data_full (G_OBJECT (buffer),
+ MODELINE_OPTIONS_DATA_KEY,
previous,
(GDestroyNotify)free_modeline_options);
}
-
+
g_free (options.language_id);
}