Index: src/project.c
===================================================================
--- src/project.c	(revision 2039)
+++ src/project.c	(working copy)
@@ -47,7 +47,7 @@
 
 static struct
 {
-	gchar *project_file_path; // in UTF-8
+    gchar *project_file_path; // in UTF-8
 } local_prefs = {NULL};
 
 
@@ -56,13 +56,13 @@
 // simple struct to keep references to the elements of the properties dialog
 typedef struct _PropertyDialogElements
 {
-	GtkWidget *dialog;
-	GtkWidget *name;
-	GtkWidget *description;
-	GtkWidget *file_name;
-	GtkWidget *base_path;
-	GtkWidget *run_cmd;
-	GtkWidget *patterns;
+    GtkWidget *dialog;
+    GtkWidget *name;
+    GtkWidget *description;
+    GtkWidget *file_name;
+    GtkWidget *base_path;
+    GtkWidget *run_cmd;
+    GtkWidget *patterns;
 } PropertyDialogElements;
 
 
@@ -87,404 +87,419 @@
 
 void project_new()
 {
-	GtkWidget *vbox;
-	GtkWidget *table;
-	GtkWidget *image;
-	GtkWidget *button;
-	GtkWidget *bbox;
-	GtkWidget *label;
-	GtkTooltips *tooltips = GTK_TOOLTIPS(lookup_widget(app->window, "tooltips"));
-	PropertyDialogElements *e;
-	gint response;
+    GtkWidget *vbox;
+    GtkWidget *table;
+    GtkWidget *image;
+    GtkWidget *button;
+    GtkWidget *bbox;
+    GtkWidget *label;
+    GtkTooltips *tooltips = GTK_TOOLTIPS(lookup_widget(app->window, "tooltips"));
+    PropertyDialogElements *e;
+    gint response;
 
-	if (! close_open_project()) return;
+    if (! close_open_project()) return;
 
-	g_return_if_fail(app->project == NULL);
+    g_return_if_fail(app->project == NULL);
 
-	e = g_new0(PropertyDialogElements, 1);
-	e->dialog = gtk_dialog_new_with_buttons(_("New Project"), GTK_WINDOW(app->window),
-										 GTK_DIALOG_DESTROY_WITH_PARENT,
-										 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, NULL);
+    e = g_new0(PropertyDialogElements, 1);
+    e->dialog = gtk_dialog_new_with_buttons(_("New Project"), GTK_WINDOW(app->window),
+                                         GTK_DIALOG_DESTROY_WITH_PARENT,
+                                         GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, NULL);
 
-	gtk_widget_set_name(e->dialog, "GeanyDialogProject");
-	bbox = gtk_hbox_new(FALSE, 0);
-	button = gtk_button_new();
-	image = gtk_image_new_from_stock("gtk-new", GTK_ICON_SIZE_BUTTON);
-	label = gtk_label_new_with_mnemonic(_("C_reate"));
-	gtk_box_pack_start(GTK_BOX(bbox), image, FALSE, FALSE, 3);
-	gtk_box_pack_start(GTK_BOX(bbox), label, FALSE, FALSE, 3);
-	gtk_container_add(GTK_CONTAINER(button), bbox);
-	gtk_dialog_add_action_widget(GTK_DIALOG(e->dialog), button, GTK_RESPONSE_OK);
+    gtk_widget_set_name(e->dialog, "GeanyDialogProject");
+    bbox = gtk_hbox_new(FALSE, 0);
+    button = gtk_button_new();
+    image = gtk_image_new_from_stock("gtk-new", GTK_ICON_SIZE_BUTTON);
+    label = gtk_label_new_with_mnemonic(_("C_reate"));
+    gtk_box_pack_start(GTK_BOX(bbox), image, FALSE, FALSE, 3);
+    gtk_box_pack_start(GTK_BOX(bbox), label, FALSE, FALSE, 3);
+    gtk_container_add(GTK_CONTAINER(button), bbox);
+    gtk_dialog_add_action_widget(GTK_DIALOG(e->dialog), button, GTK_RESPONSE_OK);
 
-	vbox = ui_dialog_vbox_new(GTK_DIALOG(e->dialog));
+    vbox = ui_dialog_vbox_new(GTK_DIALOG(e->dialog));
 
-	entries_modified = FALSE;
+    entries_modified = FALSE;
 
-	table = gtk_table_new(3, 2, FALSE);
-	gtk_table_set_row_spacings(GTK_TABLE(table), 5);
-	gtk_table_set_col_spacings(GTK_TABLE(table), 10);
+    table = gtk_table_new(3, 2, FALSE);
+    gtk_table_set_row_spacings(GTK_TABLE(table), 5);
+    gtk_table_set_col_spacings(GTK_TABLE(table), 10);
 
-	label = gtk_label_new(_("Name:"));
-	gtk_misc_set_alignment(GTK_MISC(label), 1, 0);
+    label = gtk_label_new(_("Name:"));
+    gtk_misc_set_alignment(GTK_MISC(label), 1, 0);
 
-	e->name = gtk_entry_new();
-	gtk_entry_set_max_length(GTK_ENTRY(e->name), MAX_NAME_LEN);
+    e->name = gtk_entry_new();
+    gtk_entry_set_max_length(GTK_ENTRY(e->name), MAX_NAME_LEN);
 
-	ui_table_add_row(GTK_TABLE(table), 0, label, e->name, NULL);
+    ui_table_add_row(GTK_TABLE(table), 0, label, e->name, NULL);
 
-	label = gtk_label_new(_("Filename:"));
-	gtk_misc_set_alignment(GTK_MISC(label), 1, 0);
+    label = gtk_label_new(_("Filename:"));
+    gtk_misc_set_alignment(GTK_MISC(label), 1, 0);
 
-	e->file_name = gtk_entry_new();
-	gtk_entry_set_width_chars(GTK_ENTRY(e->file_name), 30);
-	button = gtk_button_new();
-	g_signal_connect((gpointer) button, "clicked",
-				G_CALLBACK(on_file_save_button_clicked), e->file_name);
-	image = gtk_image_new_from_stock("gtk-open", GTK_ICON_SIZE_BUTTON);
-	gtk_container_add(GTK_CONTAINER(button), image);
-	bbox = gtk_hbox_new(FALSE, 6);
-	gtk_box_pack_start_defaults(GTK_BOX(bbox), e->file_name);
-	gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0);
+    e->file_name = gtk_entry_new();
+    gtk_entry_set_width_chars(GTK_ENTRY(e->file_name), 30);
+    button = gtk_button_new();
+    g_signal_connect((gpointer) button, "clicked",
+                G_CALLBACK(on_file_save_button_clicked), e->file_name);
+    image = gtk_image_new_from_stock("gtk-open", GTK_ICON_SIZE_BUTTON);
+    gtk_container_add(GTK_CONTAINER(button), image);
+    bbox = gtk_hbox_new(FALSE, 6);
+    gtk_box_pack_start_defaults(GTK_BOX(bbox), e->file_name);
+    gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0);
 
-	ui_table_add_row(GTK_TABLE(table), 1, label, bbox, NULL);
+    ui_table_add_row(GTK_TABLE(table), 1, label, bbox, NULL);
 
-	label = gtk_label_new(_("Base path:"));
-	gtk_misc_set_alignment(GTK_MISC(label), 1, 0);
+    label = gtk_label_new(_("Base path:"));
+    gtk_misc_set_alignment(GTK_MISC(label), 1, 0);
 
-	e->base_path = gtk_entry_new();
-	gtk_tooltips_set_tip(tooltips, e->base_path,
-		_("Base directory of all files that make up the project. "
-		"This can be a new path, or an existing directory tree absolute "
-		"or relative to the project filename."), NULL);
-	bbox = ui_path_box_new(_("Choose Project Base Path"),
-		GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER, GTK_ENTRY(e->base_path));
+    e->base_path = gtk_entry_new();
+    gtk_tooltips_set_tip(tooltips, e->base_path,
+        _("Base directory of all files that make up the project. "
+        "This can be a new path, or an existing directory tree absolute "
+        "or relative to the project filename."), NULL);
+    bbox = ui_path_box_new(_("Choose Project Base Path"),
+        GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER, GTK_ENTRY(e->base_path));
 
-	ui_table_add_row(GTK_TABLE(table), 2, label, bbox, NULL);
+    ui_table_add_row(GTK_TABLE(table), 2, label, bbox, NULL);
 
-	gtk_container_add(GTK_CONTAINER(vbox), table);
+    gtk_container_add(GTK_CONTAINER(vbox), table);
 
-	// signals
-	g_signal_connect((gpointer) e->name, "changed", G_CALLBACK(on_name_entry_changed), e);
-	// run the callback manually to initialise the base_path and file_name fields
-	on_name_entry_changed(GTK_EDITABLE(e->name), e);
+    // signals
+    g_signal_connect((gpointer) e->name, "changed", G_CALLBACK(on_name_entry_changed), e);
+    // run the callback manually to initialise the base_path and file_name fields
+    on_name_entry_changed(GTK_EDITABLE(e->name), e);
 
-	g_signal_connect((gpointer) e->file_name, "changed", G_CALLBACK(on_entries_changed), e);
-	g_signal_connect((gpointer) e->base_path, "changed", G_CALLBACK(on_entries_changed), e);
+    g_signal_connect((gpointer) e->file_name, "changed", G_CALLBACK(on_entries_changed), e);
+    g_signal_connect((gpointer) e->base_path, "changed", G_CALLBACK(on_entries_changed), e);
 
-	gtk_widget_show_all(e->dialog);
+    gtk_widget_show_all(e->dialog);
 
-	retry:
-	response = gtk_dialog_run(GTK_DIALOG(e->dialog));
-	if (response == GTK_RESPONSE_OK)
-		if (! update_config(e))
-			goto retry;
+    retry:
+    response = gtk_dialog_run(GTK_DIALOG(e->dialog));
+    if (response == GTK_RESPONSE_OK)
+        if (! update_config(e))
+            goto retry;
 
-	gtk_widget_destroy(e->dialog);
-	g_free(e);
+    gtk_widget_destroy(e->dialog);
+    g_free(e);
 }
 
 
 #ifndef G_OS_WIN32
 static void run_open_dialog(GtkDialog *dialog)
 {
-	gint response;
+    gint response;
 
-	retry:
-	response = gtk_dialog_run(dialog);
+    retry:
+    response = gtk_dialog_run(dialog);
 
-	if (response == GTK_RESPONSE_ACCEPT)
-	{
-		gchar *filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
+    if (response == GTK_RESPONSE_ACCEPT)
+    {
+        gchar *filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
 
-		// try to load the config
-		if (! project_load_file(filename))
-		{
-			gchar *utf8_filename = utils_get_utf8_from_locale(filename);
+        // try to load the config
+        if (! project_load_file(filename))
+        {
+            gchar *utf8_filename = utils_get_utf8_from_locale(filename);
 
-			SHOW_ERR1(_("Project file \"%s\" could not be loaded."), utf8_filename);
-			gtk_widget_grab_focus(GTK_WIDGET(dialog));
-			g_free(utf8_filename);
-			g_free(filename);
-			goto retry;
-		}
-		g_free(filename);
-	}
+            SHOW_ERR1(_("Project file \"%s\" could not be loaded."), utf8_filename);
+            gtk_widget_grab_focus(GTK_WIDGET(dialog));
+            g_free(utf8_filename);
+            g_free(filename);
+            goto retry;
+        }
+        g_free(filename);
+    }
 }
 #endif
 
 
 void project_open()
 {
-	const gchar *dir = local_prefs.project_file_path;
+    const gchar *dir = local_prefs.project_file_path;
 #ifdef G_OS_WIN32
-	gchar *file;
+    gchar *file;
 #else
-	GtkWidget *dialog;
-	GtkFileFilter *filter;
-	gchar *locale_path;
+    GtkWidget *dialog;
+    GtkFileFilter *filter;
+    gchar *locale_path;
 #endif
-	if (! close_open_project()) return;
+    if (! close_open_project()) return;
 
 #ifdef G_OS_WIN32
-	file = win32_show_project_open_dialog(_("Open Project"), dir, FALSE);
-	if (file != NULL)
-	{
-		load_config(file);
-		g_free(file);
-	}
+    file = win32_show_project_open_dialog(_("Open Project"), dir, FALSE);
+    if (file != NULL)
+    {
+        load_config(file);
+        g_free(file);
+    }
 #else
 
-	dialog = gtk_file_chooser_dialog_new(_("Open Project"), GTK_WINDOW(app->window),
-			GTK_FILE_CHOOSER_ACTION_OPEN,
-			GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
-			GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, NULL);
-	gtk_widget_set_name(dialog, "GeanyDialogProject");
+    dialog = gtk_file_chooser_dialog_new(_("Open Project"), GTK_WINDOW(app->window),
+            GTK_FILE_CHOOSER_ACTION_OPEN,
+            GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+            GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, NULL);
+    gtk_widget_set_name(dialog, "GeanyDialogProject");
 
-	// set default Open, so pressing enter can open multiple files
-	gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_ACCEPT);
-	gtk_window_set_destroy_with_parent(GTK_WINDOW(dialog), TRUE);
-	gtk_window_set_skip_taskbar_hint(GTK_WINDOW(dialog), TRUE);
-	gtk_window_set_type_hint(GTK_WINDOW(dialog), GDK_WINDOW_TYPE_HINT_DIALOG);
-	gtk_window_set_transient_for(GTK_WINDOW(dialog), GTK_WINDOW(app->window));
-	gtk_file_chooser_set_select_multiple(GTK_FILE_CHOOSER(dialog), TRUE);
+    // set default Open, so pressing enter can open multiple files
+    gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_ACCEPT);
+    gtk_window_set_destroy_with_parent(GTK_WINDOW(dialog), TRUE);
+    gtk_window_set_skip_taskbar_hint(GTK_WINDOW(dialog), TRUE);
+    gtk_window_set_type_hint(GTK_WINDOW(dialog), GDK_WINDOW_TYPE_HINT_DIALOG);
+    gtk_window_set_transient_for(GTK_WINDOW(dialog), GTK_WINDOW(app->window));
+    gtk_file_chooser_set_select_multiple(GTK_FILE_CHOOSER(dialog), TRUE);
 
-	// add FileFilters
-	filter = gtk_file_filter_new();
-	gtk_file_filter_set_name(filter, _("All files"));
-	gtk_file_filter_add_pattern(filter, "*");
-	gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialog), filter);
-	filter = gtk_file_filter_new();
-	gtk_file_filter_set_name(filter, _("Project files"));
-	gtk_file_filter_add_pattern(filter, "*." GEANY_PROJECT_EXT);
-	gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialog), filter);
-	gtk_file_chooser_set_filter(GTK_FILE_CHOOSER(dialog), filter);
+    // add FileFilters
+    filter = gtk_file_filter_new();
+    gtk_file_filter_set_name(filter, _("All files"));
+    gtk_file_filter_add_pattern(filter, "*");
+    gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialog), filter);
+    filter = gtk_file_filter_new();
+    gtk_file_filter_set_name(filter, _("Project files"));
+    gtk_file_filter_add_pattern(filter, "*." GEANY_PROJECT_EXT);
+    gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialog), filter);
+    gtk_file_chooser_set_filter(GTK_FILE_CHOOSER(dialog), filter);
 
-	locale_path = utils_get_locale_from_utf8(dir);
-	if (g_file_test(locale_path, G_FILE_TEST_EXISTS) &&
-		g_file_test(locale_path, G_FILE_TEST_IS_DIR))
-	{
-		gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog), locale_path);
-	}
-	g_free(locale_path);
+    locale_path = utils_get_locale_from_utf8(dir);
+    if (g_file_test(locale_path, G_FILE_TEST_EXISTS) &&
+        g_file_test(locale_path, G_FILE_TEST_IS_DIR))
+    {
+        gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog), locale_path);
+    }
+    g_free(locale_path);
 
-	gtk_widget_show_all(dialog);
-	run_open_dialog(GTK_DIALOG(dialog));
-	gtk_widget_destroy(GTK_WIDGET(dialog));
+    gtk_widget_show_all(dialog);
+    run_open_dialog(GTK_DIALOG(dialog));
+    gtk_widget_destroy(GTK_WIDGET(dialog));
 #endif
+    configuration_open_files(); // Load the session files into the tabs
 }
 
 
 // Called when opening, closing and updating projects.
 static void update_ui()
 {
-	ui_set_window_title(-1);
-	build_menu_update(-1);
+    ui_set_window_title(-1);
+    build_menu_update(-1);
 }
 
+void project_save()
+{
+    g_return_if_fail(app->project != NULL);
+    
+    write_config();
+    
+    ui_set_statusbar(TRUE, _("Project \"%s\" saved."), app->project->name);
+}
 
 void project_close()
 {
-	g_return_if_fail(app->project != NULL);
+    gint i, max = gtk_notebook_get_n_pages(GTK_NOTEBOOK(app->notebook));
+    g_return_if_fail(app->project != NULL);
 
-	/// TODO handle open project files
+    /// TODO handle open project files
+   
+    ui_set_statusbar(TRUE, _("Project \"%s\" closed."), app->project->name);
 
-	write_config();
-	ui_set_statusbar(TRUE, _("Project \"%s\" closed."), app->project->name);
+    g_free(app->project->name);
+    g_free(app->project->description);
+    g_free(app->project->file_name);
+    g_free(app->project->base_path);
+    g_free(app->project->run_cmd);
 
-	g_free(app->project->name);
-	g_free(app->project->description);
-	g_free(app->project->file_name);
-	g_free(app->project->base_path);
-	g_free(app->project->run_cmd);
+    g_free(app->project);
+    app->project = NULL;
 
-	g_free(app->project);
-	app->project = NULL;
+    for(i = 0; i < max; i++)
+        if (! document_remove(0))
+            break;
+            
+    tm_workspace_update(TM_WORK_OBJECT(app->tm_workspace), TRUE, TRUE, FALSE);
 
-	update_ui();
+    update_ui();
 }
 
 
 void project_properties()
 {
-	GtkWidget *vbox;
-	GtkWidget *table;
-	GtkWidget *image;
-	GtkWidget *button;
-	GtkWidget *bbox;
-	GtkWidget *label;
-	GtkWidget *swin;
-	GtkTooltips *tooltips = GTK_TOOLTIPS(lookup_widget(app->window, "tooltips"));
-	PropertyDialogElements *e = g_new(PropertyDialogElements, 1);
-	GeanyProject *p = app->project;
-	gint response;
+    GtkWidget *vbox;
+    GtkWidget *table;
+    GtkWidget *image;
+    GtkWidget *button;
+    GtkWidget *bbox;
+    GtkWidget *label;
+    GtkWidget *swin;
+    GtkTooltips *tooltips = GTK_TOOLTIPS(lookup_widget(app->window, "tooltips"));
+    PropertyDialogElements *e = g_new(PropertyDialogElements, 1);
+    GeanyProject *p = app->project;
+    gint response;
 
-	g_return_if_fail(app->project != NULL);
+    g_return_if_fail(app->project != NULL);
 
-	e->dialog = gtk_dialog_new_with_buttons(_("Project Properties"), GTK_WINDOW(app->window),
-										 GTK_DIALOG_DESTROY_WITH_PARENT,
-										 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, NULL);
-	gtk_dialog_add_buttons(GTK_DIALOG(e->dialog), GTK_STOCK_OK, GTK_RESPONSE_OK, NULL);
-	gtk_widget_set_name(e->dialog, "GeanyDialogProject");
+    e->dialog = gtk_dialog_new_with_buttons(_("Project Properties"), GTK_WINDOW(app->window),
+                                         GTK_DIALOG_DESTROY_WITH_PARENT,
+                                         GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, NULL);
+    gtk_dialog_add_buttons(GTK_DIALOG(e->dialog), GTK_STOCK_OK, GTK_RESPONSE_OK, NULL);
+    gtk_widget_set_name(e->dialog, "GeanyDialogProject");
 
-	vbox = ui_dialog_vbox_new(GTK_DIALOG(e->dialog));
+    vbox = ui_dialog_vbox_new(GTK_DIALOG(e->dialog));
 
-	entries_modified = FALSE;
+    entries_modified = FALSE;
 
-	table = gtk_table_new(6, 2, FALSE);
-	gtk_table_set_row_spacings(GTK_TABLE(table), 5);
-	gtk_table_set_col_spacings(GTK_TABLE(table), 10);
+    table = gtk_table_new(6, 2, FALSE);
+    gtk_table_set_row_spacings(GTK_TABLE(table), 5);
+    gtk_table_set_col_spacings(GTK_TABLE(table), 10);
 
-	label = gtk_label_new(_("Name:"));
-	gtk_table_attach(GTK_TABLE(table), label, 0, 1, 0, 1,
-					(GtkAttachOptions) (GTK_FILL),
-					(GtkAttachOptions) (0), 0, 0);
-	gtk_misc_set_alignment(GTK_MISC(label), 1, 0);
+    label = gtk_label_new(_("Name:"));
+    gtk_table_attach(GTK_TABLE(table), label, 0, 1, 0, 1,
+                    (GtkAttachOptions) (GTK_FILL),
+                    (GtkAttachOptions) (0), 0, 0);
+    gtk_misc_set_alignment(GTK_MISC(label), 1, 0);
 
-	e->name = gtk_entry_new();
-	gtk_entry_set_max_length(GTK_ENTRY(e->name), MAX_NAME_LEN);
-	gtk_table_attach(GTK_TABLE(table), e->name, 1, 2, 0, 1,
-					(GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
-					(GtkAttachOptions) (0), 0, 0);
+    e->name = gtk_entry_new();
+    gtk_entry_set_max_length(GTK_ENTRY(e->name), MAX_NAME_LEN);
+    gtk_table_attach(GTK_TABLE(table), e->name, 1, 2, 0, 1,
+                    (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
+                    (GtkAttachOptions) (0), 0, 0);
 
-	label = gtk_label_new(_("Filename:"));
-	gtk_table_attach(GTK_TABLE(table), label, 0, 1, 1, 2,
-					(GtkAttachOptions) (GTK_FILL),
-					(GtkAttachOptions) (0), 0, 0);
-	gtk_misc_set_alignment(GTK_MISC(label), 1, 0);
+    label = gtk_label_new(_("Filename:"));
+    gtk_table_attach(GTK_TABLE(table), label, 0, 1, 1, 2,
+                    (GtkAttachOptions) (GTK_FILL),
+                    (GtkAttachOptions) (0), 0, 0);
+    gtk_misc_set_alignment(GTK_MISC(label), 1, 0);
 
-	e->file_name = gtk_entry_new();
-	gtk_editable_set_editable(GTK_EDITABLE(e->file_name), FALSE);	// read-only
-	gtk_table_attach(GTK_TABLE(table), e->file_name, 1, 2, 1, 2,
-					(GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
-					(GtkAttachOptions) (0), 0, 0);
+    e->file_name = gtk_entry_new();
+    gtk_editable_set_editable(GTK_EDITABLE(e->file_name), FALSE);   // read-only
+    gtk_table_attach(GTK_TABLE(table), e->file_name, 1, 2, 1, 2,
+                    (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
+                    (GtkAttachOptions) (0), 0, 0);
 
-	label = gtk_label_new(_("Description:"));
-	gtk_table_attach(GTK_TABLE(table), label, 0, 1, 2, 3,
-					(GtkAttachOptions) (GTK_FILL),
-					(GtkAttachOptions) (GTK_FILL), 0, 0);
-	gtk_misc_set_alignment(GTK_MISC(label), 1, 0);
+    label = gtk_label_new(_("Description:"));
+    gtk_table_attach(GTK_TABLE(table), label, 0, 1, 2, 3,
+                    (GtkAttachOptions) (GTK_FILL),
+                    (GtkAttachOptions) (GTK_FILL), 0, 0);
+    gtk_misc_set_alignment(GTK_MISC(label), 1, 0);
 
-	e->description = gtk_text_view_new();
-	gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(e->description), GTK_WRAP_WORD);
-	swin = gtk_scrolled_window_new(NULL, NULL);
-	gtk_widget_set_size_request(swin, 250, 80);
-	gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(swin),
-				GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
-	gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(swin), GTK_WIDGET(e->description));
-	gtk_table_attach(GTK_TABLE(table), swin, 1, 2, 2, 3,
-					(GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
-					(GtkAttachOptions) (0), 0, 0);
+    e->description = gtk_text_view_new();
+    gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(e->description), GTK_WRAP_WORD);
+    swin = gtk_scrolled_window_new(NULL, NULL);
+    gtk_widget_set_size_request(swin, 250, 80);
+    gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(swin),
+                GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+    gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(swin), GTK_WIDGET(e->description));
+    gtk_table_attach(GTK_TABLE(table), swin, 1, 2, 2, 3,
+                    (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
+                    (GtkAttachOptions) (0), 0, 0);
 
-	label = gtk_label_new(_("Base path:"));
-	gtk_table_attach(GTK_TABLE(table), label, 0, 1, 3, 4,
-					(GtkAttachOptions) (GTK_FILL),
-					(GtkAttachOptions) (0), 0, 0);
-	gtk_misc_set_alignment(GTK_MISC(label), 1, 0);
+    label = gtk_label_new(_("Base path:"));
+    gtk_table_attach(GTK_TABLE(table), label, 0, 1, 3, 4,
+                    (GtkAttachOptions) (GTK_FILL),
+                    (GtkAttachOptions) (0), 0, 0);
+    gtk_misc_set_alignment(GTK_MISC(label), 1, 0);
 
-	e->base_path = gtk_entry_new();
-	gtk_tooltips_set_tip(tooltips, e->base_path,
-		_("Base directory of all files that make up the project. "
-		"This can be a new path, or an existing directory tree absolute "
-		"or relative to the project filename."), NULL);
-	bbox = ui_path_box_new(_("Choose Project Base Path"),
-		GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER, GTK_ENTRY(e->base_path));
-	gtk_table_attach(GTK_TABLE(table), bbox, 1, 2, 3, 4,
-					(GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
-					(GtkAttachOptions) (0), 0, 0);
+    e->base_path = gtk_entry_new();
+    gtk_tooltips_set_tip(tooltips, e->base_path,
+        _("Base directory of all files that make up the project. "
+        "This can be a new path, or an existing directory tree absolute "
+        "or relative to the project filename."), NULL);
+    bbox = ui_path_box_new(_("Choose Project Base Path"),
+        GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER, GTK_ENTRY(e->base_path));
+    gtk_table_attach(GTK_TABLE(table), bbox, 1, 2, 3, 4,
+                    (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
+                    (GtkAttachOptions) (0), 0, 0);
 
-	label = gtk_label_new(_("Run command:"));
-	gtk_table_attach(GTK_TABLE(table), label, 0, 1, 4, 5,
-					(GtkAttachOptions) (GTK_FILL),
-					(GtkAttachOptions) (0), 0, 0);
-	gtk_misc_set_alignment(GTK_MISC(label), 1, 0);
+    label = gtk_label_new(_("Run command:"));
+    gtk_table_attach(GTK_TABLE(table), label, 0, 1, 4, 5,
+                    (GtkAttachOptions) (GTK_FILL),
+                    (GtkAttachOptions) (0), 0, 0);
+    gtk_misc_set_alignment(GTK_MISC(label), 1, 0);
 
-	e->run_cmd = gtk_entry_new();
-	gtk_tooltips_set_tip(tooltips, e->run_cmd,
-		_("Command-line to run in the project base directory. "
-		"Options can be appended to the command. "
-		"Leave blank to use the default run command."), NULL);
-	button = gtk_button_new();
-	g_signal_connect((gpointer) button, "clicked",
-				G_CALLBACK(on_file_open_button_clicked), e->run_cmd);
-	image = gtk_image_new_from_stock("gtk-open", GTK_ICON_SIZE_BUTTON);
-	gtk_container_add(GTK_CONTAINER(button), image);
-	bbox = gtk_hbox_new(FALSE, 6);
-	gtk_box_pack_start_defaults(GTK_BOX(bbox), e->run_cmd);
-	gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0);
-	gtk_table_attach(GTK_TABLE(table), bbox, 1, 2, 4, 5,
-					(GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
-					(GtkAttachOptions) (0), 0, 0);
+    e->run_cmd = gtk_entry_new();
+    gtk_tooltips_set_tip(tooltips, e->run_cmd,
+        _("Command-line to run in the project base directory. "
+        "Options can be appended to the command. "
+        "Leave blank to use the default run command."), NULL);
+    button = gtk_button_new();
+    g_signal_connect((gpointer) button, "clicked",
+                G_CALLBACK(on_file_open_button_clicked), e->run_cmd);
+    image = gtk_image_new_from_stock("gtk-open", GTK_ICON_SIZE_BUTTON);
+    gtk_container_add(GTK_CONTAINER(button), image);
+    bbox = gtk_hbox_new(FALSE, 6);
+    gtk_box_pack_start_defaults(GTK_BOX(bbox), e->run_cmd);
+    gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0);
+    gtk_table_attach(GTK_TABLE(table), bbox, 1, 2, 4, 5,
+                    (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
+                    (GtkAttachOptions) (0), 0, 0);
 
 #if 0
-	label = gtk_label_new(_("File patterns:"));
-	// <small>Separate multiple patterns by a new line</small>
-	gtk_table_attach(GTK_TABLE(table), label, 0, 1, 5, 6,
-					(GtkAttachOptions) (GTK_FILL),
-					(GtkAttachOptions) (GTK_FILL), 0, 0);
-	gtk_misc_set_alignment(GTK_MISC(label), 1, 0);
+    label = gtk_label_new(_("File patterns:"));
+    // <small>Separate multiple patterns by a new line</small>
+    gtk_table_attach(GTK_TABLE(table), label, 0, 1, 5, 6,
+                    (GtkAttachOptions) (GTK_FILL),
+                    (GtkAttachOptions) (GTK_FILL), 0, 0);
+    gtk_misc_set_alignment(GTK_MISC(label), 1, 0);
 
-	e->patterns = gtk_text_view_new();
-	swin = gtk_scrolled_window_new(NULL, NULL);
-	gtk_widget_set_size_request(swin, -1, 80);
-	gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(swin),
-				GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
-	gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(swin), GTK_WIDGET(e->patterns));
-	gtk_table_attach(GTK_TABLE(table), swin, 1, 2, 5, 6,
-					(GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
-					(GtkAttachOptions) (0), 0, 0);
+    e->patterns = gtk_text_view_new();
+    swin = gtk_scrolled_window_new(NULL, NULL);
+    gtk_widget_set_size_request(swin, -1, 80);
+    gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(swin),
+                GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+    gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(swin), GTK_WIDGET(e->patterns));
+    gtk_table_attach(GTK_TABLE(table), swin, 1, 2, 5, 6,
+                    (GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
+                    (GtkAttachOptions) (0), 0, 0);
 #endif
 
-	gtk_container_add(GTK_CONTAINER(vbox), table);
+    gtk_container_add(GTK_CONTAINER(vbox), table);
 
-	// fill the elements with the appropriate data
-	gtk_entry_set_text(GTK_ENTRY(e->name), p->name);
+    // fill the elements with the appropriate data
+    gtk_entry_set_text(GTK_ENTRY(e->name), p->name);
 
-	if (p->description != NULL)
-	{	// set text
-		GtkTextBuffer *buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(e->description));
-		gtk_text_buffer_set_text(buffer, p->description, -1);
-	}
+    if (p->description != NULL)
+    {   // set text
+        GtkTextBuffer *buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(e->description));
+        gtk_text_buffer_set_text(buffer, p->description, -1);
+    }
 
 #if 0
-	if (p->file_patterns != NULL)
-	{	// set the file patterns
-		gint i;
-		gint len = g_strv_length(p->file_patterns);
-		GtkTextBuffer *buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(e->patterns));
-		GString *str = g_string_sized_new(len * 4);
+    if (p->file_patterns != NULL)
+    {   // set the file patterns
+        gint i;
+        gint len = g_strv_length(p->file_patterns);
+        GtkTextBuffer *buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(e->patterns));
+        GString *str = g_string_sized_new(len * 4);
 
-		for (i = 0; i < len; i++)
-		{
-			if (p->file_patterns[i] != NULL)
-			{
-				g_string_append(str, p->file_patterns[i]);
-				g_string_append_c(str, '\n');
-			}
-		}
-		gtk_text_buffer_set_text(buffer, str->str, -1);
-		g_string_free(str, TRUE);
-	}
+        for (i = 0; i < len; i++)
+        {
+            if (p->file_patterns[i] != NULL)
+            {
+                g_string_append(str, p->file_patterns[i]);
+                g_string_append_c(str, '\n');
+            }
+        }
+        gtk_text_buffer_set_text(buffer, str->str, -1);
+        g_string_free(str, TRUE);
+    }
 #endif
 
-	gtk_entry_set_text(GTK_ENTRY(e->file_name), p->file_name);
-	gtk_entry_set_text(GTK_ENTRY(e->base_path), p->base_path);
-	if (p->run_cmd != NULL)
-		gtk_entry_set_text(GTK_ENTRY(e->run_cmd), p->run_cmd);
+    gtk_entry_set_text(GTK_ENTRY(e->file_name), p->file_name);
+    gtk_entry_set_text(GTK_ENTRY(e->base_path), p->base_path);
+    if (p->run_cmd != NULL)
+        gtk_entry_set_text(GTK_ENTRY(e->run_cmd), p->run_cmd);
 
-	gtk_widget_show_all(e->dialog);
+    gtk_widget_show_all(e->dialog);
 
-	retry:
-	response = gtk_dialog_run(GTK_DIALOG(e->dialog));
-	if (response == GTK_RESPONSE_OK)
-	{
-		if (! update_config(e))
-			goto retry;
-		// successfully updated properties
-		update_ui();
-	}
+    retry:
+    response = gtk_dialog_run(GTK_DIALOG(e->dialog));
+    if (response == GTK_RESPONSE_OK)
+    {
+        if (! update_config(e))
+            goto retry;
+        // successfully updated properties
+        update_ui();
+    }
 
-	gtk_widget_destroy(e->dialog);
-	g_free(e);
+    gtk_widget_destroy(e->dialog);
+    g_free(e);
 }
 
 
@@ -493,20 +508,20 @@
  * and TRUE if we can go ahead */
 static gboolean close_open_project()
 {
-	if (app->project != NULL)
-	{
-		if (dialogs_show_question_full(NULL, GTK_STOCK_OK, GTK_STOCK_CANCEL,
-			_("Do you want to close it before proceeding?"),
-			_("The '%s' project is already open. "), app->project->name))
-		{
-			project_close();
-			return TRUE;
-		}
-		else
-			return FALSE;
-	}
-	else
-		return TRUE;
+    if (app->project != NULL)
+    {
+        if (dialogs_show_question_full(NULL, GTK_STOCK_OK, GTK_STOCK_CANCEL,
+            _("Do you want to close it before proceeding?"),
+            _("The '%s' project is already open. "), app->project->name))
+        {
+            project_close();
+            return TRUE;
+        }
+        else
+            return FALSE;
+    }
+    else
+        return TRUE;
 }
 
 
@@ -514,174 +529,174 @@
  * Returns: FALSE if the user needs to change any data. */
 static gboolean update_config(const PropertyDialogElements *e)
 {
-	const gchar *name, *file_name, *base_path;
-	gchar *locale_filename;
-	gint name_len;
-	gboolean new_project = FALSE;
-	GeanyProject *p;
+    const gchar *name, *file_name, *base_path;
+    gchar *locale_filename;
+    gint name_len;
+    gboolean new_project = FALSE;
+    GeanyProject *p;
 
-	g_return_val_if_fail(e != NULL, TRUE);
+    g_return_val_if_fail(e != NULL, TRUE);
 
-	name = gtk_entry_get_text(GTK_ENTRY(e->name));
-	name_len = strlen(name);
-	if (name_len == 0)
-	{
-		SHOW_ERR(_("The specified project name is too short."));
-		gtk_widget_grab_focus(e->name);
-		return FALSE;
-	}
-	else if (name_len > MAX_NAME_LEN)
-	{
-		SHOW_ERR1(_("The specified project name is too long (max. %d characters)."), MAX_NAME_LEN);
-		gtk_widget_grab_focus(e->name);
-		return FALSE;
-	}
+    name = gtk_entry_get_text(GTK_ENTRY(e->name));
+    name_len = strlen(name);
+    if (name_len == 0)
+    {
+        SHOW_ERR(_("The specified project name is too short."));
+        gtk_widget_grab_focus(e->name);
+        return FALSE;
+    }
+    else if (name_len > MAX_NAME_LEN)
+    {
+        SHOW_ERR1(_("The specified project name is too long (max. %d characters)."), MAX_NAME_LEN);
+        gtk_widget_grab_focus(e->name);
+        return FALSE;
+    }
 
-	file_name = gtk_entry_get_text(GTK_ENTRY(e->file_name));
-	if (strlen(file_name) == 0)
-	{
-		SHOW_ERR(_("You have specified an invalid project filename."));
-		gtk_widget_grab_focus(e->file_name);
-		return FALSE;
-	}
+    file_name = gtk_entry_get_text(GTK_ENTRY(e->file_name));
+    if (strlen(file_name) == 0)
+    {
+        SHOW_ERR(_("You have specified an invalid project filename."));
+        gtk_widget_grab_focus(e->file_name);
+        return FALSE;
+    }
 
-	// finally test whether the given project file can be written
-	locale_filename = utils_get_locale_from_utf8(file_name);
-	if (utils_write_file(file_name, "") != 0)
-	{
-		SHOW_ERR(_("Project file could not be written."));
-		gtk_widget_grab_focus(e->file_name);
-		return FALSE;
-	}
+    // finally test whether the given project file can be written
+    locale_filename = utils_get_locale_from_utf8(file_name);
+    if (utils_write_file(file_name, "") != 0)
+    {
+        SHOW_ERR(_("Project file could not be written."));
+        gtk_widget_grab_focus(e->file_name);
+        return FALSE;
+    }
 
-	base_path = gtk_entry_get_text(GTK_ENTRY(e->base_path));
-	if (NZV(base_path))
-	{	// check whether the given directory actually exists
-		gchar *locale_path = utils_get_locale_from_utf8(base_path);
+    base_path = gtk_entry_get_text(GTK_ENTRY(e->base_path));
+    if (NZV(base_path))
+    {   // check whether the given directory actually exists
+        gchar *locale_path = utils_get_locale_from_utf8(base_path);
 
-		if (! g_path_is_absolute(locale_path))
-		{	// relative base path, so add base dir of project file name
-			gchar *dir = g_path_get_dirname(locale_filename);
-			setptr(locale_path, g_strconcat(dir, G_DIR_SEPARATOR_S, locale_path, NULL));
-			g_free(dir);
-		}
+        if (! g_path_is_absolute(locale_path))
+        {   // relative base path, so add base dir of project file name
+            gchar *dir = g_path_get_dirname(locale_filename);
+            setptr(locale_path, g_strconcat(dir, G_DIR_SEPARATOR_S, locale_path, NULL));
+            g_free(dir);
+        }
 
-		if (! g_file_test(locale_path, G_FILE_TEST_IS_DIR))
-		{
-			if (dialogs_show_question_full(NULL, GTK_STOCK_OK, GTK_STOCK_CANCEL,
-				_("Create the project's base path directory?"),
-				_("The path \"%s\" does not exist."),
-				base_path))
-			{
-				utils_mkdir(locale_path, TRUE);
-			}
-			else
-			{
-				g_free(locale_path);
-				gtk_widget_grab_focus(e->base_path);
-				return FALSE;
-			}
-		}
-		g_free(locale_path);
-	}
-	g_free(locale_filename);
+        if (! g_file_test(locale_path, G_FILE_TEST_IS_DIR))
+        {
+            if (dialogs_show_question_full(NULL, GTK_STOCK_OK, GTK_STOCK_CANCEL,
+                _("Create the project's base path directory?"),
+                _("The path \"%s\" does not exist."),
+                base_path))
+            {
+                utils_mkdir(locale_path, TRUE);
+            }
+            else
+            {
+                g_free(locale_path);
+                gtk_widget_grab_focus(e->base_path);
+                return FALSE;
+            }
+        }
+        g_free(locale_path);
+    }
+    g_free(locale_filename);
 
-	if (app->project == NULL)
-	{
-		app->project = g_new0(GeanyProject, 1);
-		new_project = TRUE;
-	}
-	p = app->project;
+    if (app->project == NULL)
+    {
+        app->project = g_new0(GeanyProject, 1);
+        new_project = TRUE;
+    }
+    p = app->project;
 
-	if (p->name != NULL) g_free(p->name);
-	p->name = g_strdup(name);
+    if (p->name != NULL) g_free(p->name);
+    p->name = g_strdup(name);
 
-	if (p->file_name != NULL) g_free(p->file_name);
-	p->file_name = g_strdup(file_name);
+    if (p->file_name != NULL) g_free(p->file_name);
+    p->file_name = g_strdup(file_name);
 
-	if (p->base_path != NULL) g_free(p->base_path);
-	p->base_path = g_strdup(NZV(base_path) ? base_path : "./"); // use "." if base_path is empty
+    if (p->base_path != NULL) g_free(p->base_path);
+    p->base_path = g_strdup(NZV(base_path) ? base_path : "./"); // use "." if base_path is empty
 
-	if (! new_project)	// save properties specific fields
-	{
-		GtkTextIter start, end;
-		//gchar *tmp;
-		GtkTextBuffer *buffer;
+    if (! new_project)  // save properties specific fields
+    {
+        GtkTextIter start, end;
+        //gchar *tmp;
+        GtkTextBuffer *buffer;
 
-		if (p->run_cmd != NULL) g_free(p->run_cmd);
-		p->run_cmd = g_strdup(gtk_entry_get_text(GTK_ENTRY(e->run_cmd)));
+        if (p->run_cmd != NULL) g_free(p->run_cmd);
+        p->run_cmd = g_strdup(gtk_entry_get_text(GTK_ENTRY(e->run_cmd)));
 
-		// get and set the project description
-		buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(e->description));
-		gtk_text_buffer_get_start_iter(buffer, &start);
-		gtk_text_buffer_get_end_iter(buffer, &end);
-		g_free(p->description);
-		p->description = gtk_text_buffer_get_text(buffer, &start, &end, FALSE);
+        // get and set the project description
+        buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(e->description));
+        gtk_text_buffer_get_start_iter(buffer, &start);
+        gtk_text_buffer_get_end_iter(buffer, &end);
+        g_free(p->description);
+        p->description = gtk_text_buffer_get_text(buffer, &start, &end, FALSE);
 
 #if 0
-		// get and set the project file patterns
-		buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(e->patterns));
-		gtk_text_buffer_get_start_iter(buffer, &start);
-		gtk_text_buffer_get_end_iter(buffer, &end);
-		tmp = gtk_text_buffer_get_text(buffer, &start, &end, FALSE);
-		g_strfreev(p->file_patterns);
-		p->file_patterns = g_strsplit(tmp, "\n", -1);
-		g_free(tmp);
+        // get and set the project file patterns
+        buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(e->patterns));
+        gtk_text_buffer_get_start_iter(buffer, &start);
+        gtk_text_buffer_get_end_iter(buffer, &end);
+        tmp = gtk_text_buffer_get_text(buffer, &start, &end, FALSE);
+        g_strfreev(p->file_patterns);
+        p->file_patterns = g_strsplit(tmp, "\n", -1);
+        g_free(tmp);
 #endif
-	}
-	write_config();
-	if (new_project)
-		ui_set_statusbar(TRUE, _("Project \"%s\" created."), p->name);
-	else
-		ui_set_statusbar(TRUE, _("Project \"%s\" saved."), p->name);
+    }
+    write_config();
+    if (new_project)
+        ui_set_statusbar(TRUE, _("Project \"%s\" created."), p->name);
+    else
+        ui_set_statusbar(TRUE, _("Project \"%s\" saved."), p->name);
 
-	return TRUE;
+    return TRUE;
 }
 
 
 #ifndef G_OS_WIN32
 static void run_dialog(GtkWidget *dialog, GtkWidget *entry)
 {
-	// set filename in the file chooser dialog
-	const gchar *utf8_filename = gtk_entry_get_text(GTK_ENTRY(entry));
-	gchar *locale_filename = utils_get_locale_from_utf8(utf8_filename);
+    // set filename in the file chooser dialog
+    const gchar *utf8_filename = gtk_entry_get_text(GTK_ENTRY(entry));
+    gchar *locale_filename = utils_get_locale_from_utf8(utf8_filename);
 
-	if (g_path_is_absolute(locale_filename))
-	{
-		if (g_file_test(locale_filename, G_FILE_TEST_EXISTS))
-			gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(dialog), utf8_filename);
-		else // if the file doesn't yet exist, use at least the current directory
-		{
-			gchar *locale_dir = g_path_get_dirname(locale_filename);
-			gchar *name = g_path_get_basename(utf8_filename);
+    if (g_path_is_absolute(locale_filename))
+    {
+        if (g_file_test(locale_filename, G_FILE_TEST_EXISTS))
+            gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(dialog), utf8_filename);
+        else // if the file doesn't yet exist, use at least the current directory
+        {
+            gchar *locale_dir = g_path_get_dirname(locale_filename);
+            gchar *name = g_path_get_basename(utf8_filename);
 
-			if (g_file_test(locale_dir, G_FILE_TEST_EXISTS))
-				gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog), locale_dir);
-			gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(dialog), name);
+            if (g_file_test(locale_dir, G_FILE_TEST_EXISTS))
+                gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog), locale_dir);
+            gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(dialog), name);
 
-			g_free(name);
-			g_free(locale_dir);
-		}
-	}
-	else
-	if (gtk_file_chooser_get_action(GTK_FILE_CHOOSER(dialog)) != GTK_FILE_CHOOSER_ACTION_OPEN)
-	{
-		gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(dialog), utf8_filename);
-	}
-	g_free(locale_filename);
+            g_free(name);
+            g_free(locale_dir);
+        }
+    }
+    else
+    if (gtk_file_chooser_get_action(GTK_FILE_CHOOSER(dialog)) != GTK_FILE_CHOOSER_ACTION_OPEN)
+    {
+        gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(dialog), utf8_filename);
+    }
+    g_free(locale_filename);
 
-	// run it
-	if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT)
-	{
-		gchar *filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
-		gchar *tmp_utf8_filename = utils_get_utf8_from_locale(filename);
+    // run it
+    if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT)
+    {
+        gchar *filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
+        gchar *tmp_utf8_filename = utils_get_utf8_from_locale(filename);
 
-		gtk_entry_set_text(GTK_ENTRY(entry), tmp_utf8_filename);
+        gtk_entry_set_text(GTK_ENTRY(entry), tmp_utf8_filename);
 
-		g_free(tmp_utf8_filename);
-		g_free(filename);
-	}
-	gtk_widget_destroy(dialog);
+        g_free(tmp_utf8_filename);
+        g_free(filename);
+    }
+    gtk_widget_destroy(dialog);
 }
 #endif
 
@@ -689,28 +704,28 @@
 static void on_file_save_button_clicked(GtkButton *button, GtkWidget *entry)
 {
 #ifdef G_OS_WIN32
-	gchar *path = win32_show_project_open_dialog(_("Choose Project Filename"),
-						gtk_entry_get_text(GTK_ENTRY(entry)), TRUE);
-	if (path != NULL)
-	{
-		gtk_entry_set_text(GTK_ENTRY(entry), path);
-		g_free(path);
-	}
+    gchar *path = win32_show_project_open_dialog(_("Choose Project Filename"),
+                        gtk_entry_get_text(GTK_ENTRY(entry)), TRUE);
+    if (path != NULL)
+    {
+        gtk_entry_set_text(GTK_ENTRY(entry), path);
+        g_free(path);
+    }
 #else
-	GtkWidget *dialog;
+    GtkWidget *dialog;
 
-	// initialise the dialog
-	dialog = gtk_file_chooser_dialog_new(_("Choose Project Filename"), NULL,
-					GTK_FILE_CHOOSER_ACTION_SAVE,
-					GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
-					GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT, NULL);
-	gtk_widget_set_name(dialog, "GeanyDialogProject");
-	gtk_window_set_destroy_with_parent(GTK_WINDOW(dialog), TRUE);
-	gtk_window_set_skip_taskbar_hint(GTK_WINDOW(dialog), TRUE);
-	gtk_window_set_type_hint(GTK_WINDOW(dialog), GDK_WINDOW_TYPE_HINT_DIALOG);
-	gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_ACCEPT);
+    // initialise the dialog
+    dialog = gtk_file_chooser_dialog_new(_("Choose Project Filename"), NULL,
+                    GTK_FILE_CHOOSER_ACTION_SAVE,
+                    GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+                    GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT, NULL);
+    gtk_widget_set_name(dialog, "GeanyDialogProject");
+    gtk_window_set_destroy_with_parent(GTK_WINDOW(dialog), TRUE);
+    gtk_window_set_skip_taskbar_hint(GTK_WINDOW(dialog), TRUE);
+    gtk_window_set_type_hint(GTK_WINDOW(dialog), GDK_WINDOW_TYPE_HINT_DIALOG);
+    gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_ACCEPT);
 
-	run_dialog(dialog, entry);
+    run_dialog(dialog, entry);
 #endif
 }
 
@@ -718,28 +733,28 @@
 static void on_file_open_button_clicked(GtkButton *button, GtkWidget *entry)
 {
 #ifdef G_OS_WIN32
-	gchar *path = win32_show_project_open_dialog(_("Choose Project Run Command"),
-						gtk_entry_get_text(GTK_ENTRY(entry)), FALSE);
-	if (path != NULL)
-	{
-		gtk_entry_set_text(GTK_ENTRY(entry), path);
-		g_free(path);
-	}
+    gchar *path = win32_show_project_open_dialog(_("Choose Project Run Command"),
+                        gtk_entry_get_text(GTK_ENTRY(entry)), FALSE);
+    if (path != NULL)
+    {
+        gtk_entry_set_text(GTK_ENTRY(entry), path);
+        g_free(path);
+    }
 #else
-	GtkWidget *dialog;
+    GtkWidget *dialog;
 
-	// initialise the dialog
-	dialog = gtk_file_chooser_dialog_new(_("Choose Project Run Command"), NULL,
-					GTK_FILE_CHOOSER_ACTION_OPEN,
-					GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
-					GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, NULL);
-	gtk_widget_set_name(dialog, "GeanyDialog");
-	gtk_window_set_destroy_with_parent(GTK_WINDOW(dialog), TRUE);
-	gtk_window_set_skip_taskbar_hint(GTK_WINDOW(dialog), TRUE);
-	gtk_window_set_type_hint(GTK_WINDOW(dialog), GDK_WINDOW_TYPE_HINT_DIALOG);
-	gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_ACCEPT);
+    // initialise the dialog
+    dialog = gtk_file_chooser_dialog_new(_("Choose Project Run Command"), NULL,
+                    GTK_FILE_CHOOSER_ACTION_OPEN,
+                    GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+                    GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, NULL);
+    gtk_widget_set_name(dialog, "GeanyDialog");
+    gtk_window_set_destroy_with_parent(GTK_WINDOW(dialog), TRUE);
+    gtk_window_set_skip_taskbar_hint(GTK_WINDOW(dialog), TRUE);
+    gtk_window_set_type_hint(GTK_WINDOW(dialog), GDK_WINDOW_TYPE_HINT_DIALOG);
+    gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_ACCEPT);
 
-	run_dialog(dialog, entry);
+    run_dialog(dialog, entry);
 #endif
 }
 
@@ -747,62 +762,62 @@
 /* sets the project base path and the project file name according to the project name */
 static void on_name_entry_changed(GtkEditable *editable, PropertyDialogElements *e)
 {
-	gchar *base_path;
-	gchar *file_name;
-	gchar *name;
-	const gchar *project_dir = local_prefs.project_file_path;
+    gchar *base_path;
+    gchar *file_name;
+    gchar *name;
+    const gchar *project_dir = local_prefs.project_file_path;
 
-	if (entries_modified)
-		return;
+    if (entries_modified)
+        return;
 
-	name = gtk_editable_get_chars(editable, 0, -1);
-	if (name != NULL && strlen(name) > 0)
-	{
-		base_path = g_strconcat(project_dir, G_DIR_SEPARATOR_S,
-			name, G_DIR_SEPARATOR_S, NULL);
-		file_name = g_strconcat(project_dir, G_DIR_SEPARATOR_S,
-			name, "." GEANY_PROJECT_EXT, NULL);
-	}
-	else
-	{
-		base_path = g_strconcat(project_dir, G_DIR_SEPARATOR_S, NULL);
-		file_name = g_strconcat(project_dir, G_DIR_SEPARATOR_S, NULL);
-	}
-	g_free(name);
+    name = gtk_editable_get_chars(editable, 0, -1);
+    if (name != NULL && strlen(name) > 0)
+    {
+        base_path = g_strconcat(project_dir, G_DIR_SEPARATOR_S,
+            name, G_DIR_SEPARATOR_S, NULL);
+        file_name = g_strconcat(project_dir, G_DIR_SEPARATOR_S,
+            name, "." GEANY_PROJECT_EXT, NULL);
+    }
+    else
+    {
+        base_path = g_strconcat(project_dir, G_DIR_SEPARATOR_S, NULL);
+        file_name = g_strconcat(project_dir, G_DIR_SEPARATOR_S, NULL);
+    }
+    g_free(name);
 
-	gtk_entry_set_text(GTK_ENTRY(e->base_path), base_path);
-	gtk_entry_set_text(GTK_ENTRY(e->file_name), file_name);
+    gtk_entry_set_text(GTK_ENTRY(e->base_path), base_path);
+    gtk_entry_set_text(GTK_ENTRY(e->file_name), file_name);
 
-	entries_modified = FALSE;
+    entries_modified = FALSE;
 
-	g_free(base_path);
-	g_free(file_name);
+    g_free(base_path);
+    g_free(file_name);
 }
 
 
 static void on_entries_changed(GtkEditable *editable, PropertyDialogElements *e)
 {
-	entries_modified = TRUE;
+    entries_modified = TRUE;
 }
 
 
 gboolean project_load_file(const gchar *locale_file_name)
 {
-	g_return_val_if_fail(locale_file_name != NULL, FALSE);
+    g_return_val_if_fail(locale_file_name != NULL, FALSE);
 
-	if (load_config(locale_file_name))
-	{
-		ui_set_statusbar(TRUE, _("Project \"%s\" opened."), app->project->name);
-		return TRUE;
-	}
-	else
-	{
-		gchar *utf8_filename = utils_get_utf8_from_locale(locale_file_name);
+    if (load_config(locale_file_name))
+    {
+        ui_set_statusbar(TRUE, _("Project \"%s\" opened."), app->project->name);
+        return TRUE;
+    }
+    else
+    {
+        gchar *utf8_filename = utils_get_utf8_from_locale(locale_file_name);
 
-		ui_set_statusbar(TRUE, _("Project file \"%s\" could not be loaded."), utf8_filename);
-		g_free(utf8_filename);
-	}
-	return FALSE;
+        ui_set_statusbar(TRUE, _("Project file \"%s\" could not be loaded."), utf8_filename);
+        g_free(utf8_filename);
+    }
+    return FALSE;
 }
 
 
@@ -812,73 +827,79 @@
  * The filename is expected in the locale encoding. */
 static gboolean load_config(const gchar *filename)
 {
-	GKeyFile *config;
-	GeanyProject *p;
+    GKeyFile *config;
+    GeanyProject *p;
 
-	// there should not be an open project
-	g_return_val_if_fail(app->project == NULL && filename != NULL, FALSE);
+    // there should not be an open project
+    g_return_val_if_fail(app->project == NULL && filename != NULL, FALSE);
 
-	config = g_key_file_new();
-	if (! g_key_file_load_from_file(config, filename, G_KEY_FILE_KEEP_COMMENTS, NULL))
-	{
-		g_key_file_free(config);
-		return FALSE;
-	}
+    config = g_key_file_new();
+    if (! g_key_file_load_from_file(config, filename, G_KEY_FILE_KEEP_COMMENTS, NULL))
+    {
+        g_key_file_free(config);
+        return FALSE;
+    }
 
-	p = app->project = g_new0(GeanyProject, 1);
+    p = app->project = g_new0(GeanyProject, 1);
 
-	p->name = utils_get_setting_string(config, "project", "name", GEANY_STRING_UNTITLED);
-	p->description = utils_get_setting_string(config, "project", "description", "");
-	p->file_name = utils_get_utf8_from_locale(filename);
-	p->base_path = utils_get_setting_string(config, "project", "base_path", "");
-	p->run_cmd = utils_get_setting_string(config, "project", "run_cmd", "");
-	p->file_patterns = g_key_file_get_string_list(config, "project", "file_patterns", NULL, NULL);
+    p->name = utils_get_setting_string(config, "project", "name", GEANY_STRING_UNTITLED);
+    p->description = utils_get_setting_string(config, "project", "description", "");
+    p->file_name = utils_get_utf8_from_locale(filename);
+    p->base_path = utils_get_setting_string(config, "project", "base_path", "");
+    p->run_cmd = utils_get_setting_string(config, "project", "run_cmd", "");
+    p->file_patterns = g_key_file_get_string_list(config, "project", "file_patterns", NULL, NULL);
 
-	g_key_file_free(config);
+    // fetch session files too
+    load_session_files(config);
 
-	update_ui();
-	return TRUE;
+    g_key_file_free(config);
+
+    update_ui();
+    return TRUE;
 }
 
 
 // Returns: TRUE if project file was written successfully.
 static gboolean write_config()
 {
-	GeanyProject *p;
-	GKeyFile *config;
-	gchar *filename;
-	gchar *data;
-	gboolean ret = FALSE;
+    GeanyProject *p;
+    GKeyFile *config;
+    gchar *filename;
+    gchar *data;
+    gboolean ret = FALSE;
 
-	g_return_val_if_fail(app->project != NULL, FALSE);
+    g_return_val_if_fail(app->project != NULL, FALSE);
 
-	p = app->project;
+    p = app->project;
 
-	config = g_key_file_new();
-	// try to load an existing config to keep manually added comments
-	filename = utils_get_locale_from_utf8(p->file_name);
-	g_key_file_load_from_file(config, filename, G_KEY_FILE_KEEP_COMMENTS, NULL);
+    config = g_key_file_new();
+    // try to load an existing config to keep manually added comments
+    filename = utils_get_locale_from_utf8(p->file_name);
+    g_key_file_load_from_file(config, filename, G_KEY_FILE_KEEP_COMMENTS, NULL);
 
-	g_key_file_set_string(config, "project", "name", p->name);
-	g_key_file_set_string(config, "project", "base_path", p->base_path);
+    g_key_file_set_string(config, "project", "name", p->name);
+    g_key_file_set_string(config, "project", "base_path", p->base_path);
 
-	if (p->description)
-		g_key_file_set_string(config, "project", "description", p->description);
-	if (p->run_cmd)
-		g_key_file_set_string(config, "project", "run_cmd", p->run_cmd);
-	if (p->file_patterns)
-		g_key_file_set_string_list(config, "project", "file_patterns",
-			(const gchar**) p->file_patterns, g_strv_length(p->file_patterns));
+    if (p->description)
+        g_key_file_set_string(config, "project", "description", p->description);
+    if (p->run_cmd)
+        g_key_file_set_string(config, "project", "run_cmd", p->run_cmd);
+    if (p->file_patterns)
+        g_key_file_set_string_list(config, "project", "file_patterns",
+            (const gchar**) p->file_patterns, g_strv_length(p->file_patterns));
 
-	// write the file
-	data = g_key_file_to_data(config, NULL, NULL);
-	ret = (utils_write_file(filename, data) == 0);
+    // Store the session files into the project too
+    save_session_files(config);
 
-	g_free(data);
-	g_free(filename);
-	g_key_file_free(config);
+    // write the file
+    data = g_key_file_to_data(config, NULL, NULL);
+    ret = (utils_write_file(filename, data) == 0);
 
-	return ret;
+    g_free(data);
+    g_free(filename);
+    g_key_file_free(config);
+
+    return ret;
 }
 
 
@@ -889,79 +910,78 @@
  * The returned string should be freed when no longer needed. */
 gchar *project_get_make_dir()
 {
-	if (app->project != NULL && NZV(app->project->base_path))
-	{
-		if (g_path_is_absolute(app->project->base_path))
-			return g_strdup(app->project->base_path);
-		else
-		{	// build base_path out of project file name's dir and base_path
-			gchar *path;
-			gchar *dir = g_path_get_dirname(app->project->file_name);
+    if (app->project != NULL && NZV(app->project->base_path))
+    {
+        if (g_path_is_absolute(app->project->base_path))
+            return g_strdup(app->project->base_path);
+        else
+        {   // build base_path out of project file name's dir and base_path
+            gchar *path;
+            gchar *dir = g_path_get_dirname(app->project->file_name);
 
-			path = g_strconcat(dir, G_DIR_SEPARATOR_S, app->project->base_path, NULL);
-			g_free(dir);
-			return path;
-		}
-	}
-	else
-		return NULL;
+            path = g_strconcat(dir, G_DIR_SEPARATOR_S, app->project->base_path, NULL);
+            g_free(dir);
+            return path;
+        }
+    }
+    else
+        return NULL;
 }
 
 
 void project_save_prefs(GKeyFile *config)
 {
-	GeanyProject *project = app->project;
+    GeanyProject *project = app->project;
 
-	if (cl_options.load_session)
-	{
-		gchar *utf8_filename = (project == NULL) ? "" : project->file_name;
+    if (cl_options.load_session)
+    {
+        gchar *utf8_filename = (project == NULL) ? "" : project->file_name;
 
-		g_key_file_set_string(config, "project", "session_file", utf8_filename);
-	}
-	g_key_file_set_string(config, "project", "project_file_path",
-		NVL(local_prefs.project_file_path, ""));
+        g_key_file_set_string(config, "project", "session_file", utf8_filename);
+    }
+    g_key_file_set_string(config, "project", "project_file_path",
+        NVL(local_prefs.project_file_path, ""));
 }
 
 
 void project_load_prefs(GKeyFile *config)
 {
-	if (cl_options.load_session)
-	{
-		g_return_if_fail(project_prefs.session_file == NULL);
-		project_prefs.session_file = utils_get_setting_string(config, "project",
-			"session_file", "");
-	}
-	local_prefs.project_file_path = utils_get_setting_string(config, "project",
-		"project_file_path", NULL);
-	if (local_prefs.project_file_path == NULL)
-	{
-		local_prefs.project_file_path = g_strconcat(GEANY_HOME_DIR,
-			G_DIR_SEPARATOR_S, PROJECT_DIR, NULL);
-	}
+    if (cl_options.load_session)
+    {
+        g_return_if_fail(project_prefs.session_file == NULL);
+        project_prefs.session_file = utils_get_setting_string(config, "project",
+            "session_file", "");
+    }
+    local_prefs.project_file_path = utils_get_setting_string(config, "project",
+        "project_file_path", NULL);
+    if (local_prefs.project_file_path == NULL)
+    {
+        local_prefs.project_file_path = g_strconcat(GEANY_HOME_DIR,
+            G_DIR_SEPARATOR_S, PROJECT_DIR, NULL);
+    }
 }
 
-
 /* Initialize project-related preferences in the Preferences dialog. */
 void project_setup_prefs()
 {
-	GtkWidget *path_entry = lookup_widget(ui_widgets.prefs_dialog, "project_file_path_entry");
-	GtkWidget *path_btn = lookup_widget(ui_widgets.prefs_dialog, "project_file_path_button");
+    GtkWidget *path_entry = lookup_widget(ui_widgets.prefs_dialog, "project_file_path_entry");
+    GtkWidget *path_btn = lookup_widget(ui_widgets.prefs_dialog, "project_file_path_button");
 
-	g_return_if_fail(local_prefs.project_file_path != NULL);
-	gtk_entry_set_text(GTK_ENTRY(path_entry), local_prefs.project_file_path);
-	ui_setup_open_button_callback(path_btn, NULL,
-		GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER, GTK_ENTRY(path_entry));
+    g_return_if_fail(local_prefs.project_file_path != NULL);
+    gtk_entry_set_text(GTK_ENTRY(path_entry), local_prefs.project_file_path);
+    ui_setup_open_button_callback(path_btn, NULL,
+        GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER, GTK_ENTRY(path_entry));
 }
 
 
 /* Update project-related preferences after using the Preferences dialog. */
 void project_apply_prefs()
 {
-	GtkWidget *path_entry = lookup_widget(ui_widgets.prefs_dialog, "project_file_path_entry");
-	const gchar *str;
+    GtkWidget *path_entry = lookup_widget(ui_widgets.prefs_dialog, "project_file_path_entry");
+    const gchar *str;
 
-	str = gtk_entry_get_text(GTK_ENTRY(path_entry));
-	setptr(local_prefs.project_file_path, g_strdup(str));
+    str = gtk_entry_get_text(GTK_ENTRY(path_entry));
+    setptr(local_prefs.project_file_path, g_strdup(str));
 }
 
 
Index: src/project.h
===================================================================
--- src/project.h	(revision 2039)
+++ src/project.h	(working copy)
@@ -29,21 +29,21 @@
 /* structure for representing a project. */
 struct _GeanyProject
 {
-	gchar *name; 			// the name of the project
-	gchar *description; 	// short description of the project
+    gchar *name;            // the name of the project
+    gchar *description;     // short description of the project
 
-	gchar *file_name; 		// where the project file is stored (in UTF-8)
+    gchar *file_name;       // where the project file is stored (in UTF-8)
 
-	gchar *base_path;		// base path of the project directory (in UTF-8, maybe relative)
-	gchar *run_cmd; 		// project run command (in UTF-8)
-	// ...					// fields for build process(run arguments and so on) should be added
+    gchar *base_path;       // base path of the project directory (in UTF-8, maybe relative)
+    gchar *run_cmd;         // project run command (in UTF-8)
+    // ...                  // fields for build process(run arguments and so on) should be added
 
-	gchar **file_patterns;	// array of filename extension patterns
+    gchar **file_patterns;  // array of filename extension patterns
 };
 
 typedef struct
 {
-	gchar *session_file;
+    gchar *session_file;
 } ProjectPrefs;
 
 extern ProjectPrefs project_prefs;
@@ -53,6 +53,8 @@
 
 void project_open();
 
+void project_save();
+
 void project_close();
 
 void project_properties();
Index: src/keyfile.c
===================================================================
--- src/keyfile.c	(revision 2039)
+++ src/keyfile.c	(working copy)
@@ -62,718 +62,730 @@
 
 static void save_recent_files(GKeyFile *config)
 {
-	gchar **recent_files = g_new0(gchar*, prefs.mru_length + 1);
-	guint i;
+    gchar **recent_files = g_new0(gchar*, prefs.mru_length + 1);
+    guint i;
 
-	for (i = 0; i < prefs.mru_length; i++)
-	{
-		if (! g_queue_is_empty(ui_prefs.recent_queue))
-		{
-			// copy the values, this is necessary when this function is called from the
-			// preferences dialog or when quitting is canceled to keep the queue intact
-			recent_files[i] = g_strdup(g_queue_peek_nth(ui_prefs.recent_queue, i));
-		}
-		else
-		{
-			recent_files[i] = NULL;
-			break;
-		}
-	}
-	// There is a bug in GTK2.6 g_key_file_set_string_list, we must NULL terminate.
-	recent_files[prefs.mru_length] = NULL;
-	g_key_file_set_string_list(config, "files", "recent_files",
-				(const gchar**)recent_files, prefs.mru_length);
-	g_strfreev(recent_files);
+    for (i = 0; i < prefs.mru_length; i++)
+    {
+        if (! g_queue_is_empty(ui_prefs.recent_queue))
+        {
+            // copy the values, this is necessary when this function is called from the
+            // preferences dialog or when quitting is canceled to keep the queue intact
+            recent_files[i] = g_strdup(g_queue_peek_nth(ui_prefs.recent_queue, i));
+        }
+        else
+        {
+            recent_files[i] = NULL;
+            break;
+        }
+    }
+    // There is a bug in GTK2.6 g_key_file_set_string_list, we must NULL terminate.
+    recent_files[prefs.mru_length] = NULL;
+    g_key_file_set_string_list(config, "files", "recent_files",
+                (const gchar**)recent_files, prefs.mru_length);
+    g_strfreev(recent_files);
 }
 
 
-static void save_session_files(GKeyFile *config)
+void save_session_files(GKeyFile *config)
 {
-	gint idx, npage;
-	gchar *tmp;
-	gchar entry[14];
-	guint i = 0, j = 0, max;
+    gint idx, npage;
+    gchar *tmp;
+    gchar entry[14];
+    guint i = 0, j = 0, max;
 
-	if (! cl_options.load_session)
-		return;
+    if (! cl_options.load_session)
+        return;
 
-	npage = gtk_notebook_get_current_page(GTK_NOTEBOOK(app->notebook));
-	g_key_file_set_integer(config, "files", "current_page", npage);
+    npage = gtk_notebook_get_current_page(GTK_NOTEBOOK(app->notebook));
+    g_key_file_set_integer(config, "files", "current_page", npage);
 
-	// store the filenames to reopen them the next time
-	max = gtk_notebook_get_n_pages(GTK_NOTEBOOK(app->notebook));
-	for (i = 0; i < max; i++)
-	{
-		idx = document_get_n_idx(i);
-		if (idx >= 0 && doc_list[idx].file_name)
-		{
-			gchar *fname;
-			filetype *ft = doc_list[idx].file_type;
+    // store the filenames to reopen them the next time
+    max = gtk_notebook_get_n_pages(GTK_NOTEBOOK(app->notebook));
+    for (i = 0; i < max; i++)
+    {
+        idx = document_get_n_idx(i);
+        if (idx >= 0 && doc_list[idx].file_name)
+        {
+            gchar *fname;
+            filetype *ft = doc_list[idx].file_type;
 
-			if (ft == NULL)	// can happen when saving a new file when quitting
-				ft = filetypes[GEANY_FILETYPES_ALL];
-			g_snprintf(entry, 13, "FILE_NAME_%d", j);
-			fname = g_strdup_printf("%d:%d:%s", sci_get_current_position(doc_list[idx].sci),
-				ft->uid, doc_list[idx].file_name);
-			g_key_file_set_string(config, "files", entry, fname);
-			g_free(fname);
-			j++;
-		}
-	}
-	// if open filenames less than saved session files, delete existing entries in the list
-	i = j;
-	while (TRUE)
-	{
-		g_snprintf(entry, 13, "FILE_NAME_%d", i);
-		tmp = g_key_file_get_string(config, "files", entry, NULL);
-		if (tmp == NULL)
-		{
-			break;
-		}
-		else
-		{
-			g_key_file_remove_key(config, "files", entry, NULL);
-			g_free(tmp);
-			i++;
-		}
-	}
+            if (ft == NULL) // can happen when saving a new file when quitting
+                ft = filetypes[GEANY_FILETYPES_ALL];
+            g_snprintf(entry, 13, "FILE_NAME_%d", j);
+            fname = g_strdup_printf("%d:%d:%s", sci_get_current_position(doc_list[idx].sci),
+                ft->uid, doc_list[idx].file_name);
+            g_key_file_set_string(config, "files", entry, fname);
+            g_free(fname);
+            j++;
+        }
+    }
+    // if open filenames less than saved session files, delete existing entries in the list
+    i = j;
+    while (TRUE)
+    {
+        g_snprintf(entry, 13, "FILE_NAME_%d", i);
+        tmp = g_key_file_get_string(config, "files", entry, NULL);
+        if (tmp == NULL)
+        {
+            break;
+        }
+        else
+        {
+            g_key_file_remove_key(config, "files", entry, NULL);
+            g_free(tmp);
+            i++;
+        }
+    }
 }
 
 
 static void save_dialog_prefs(GKeyFile *config)
 {
-	/* Some of the key names are not consistent, but this is for backwards compatibility */
+    /* Some of the key names are not consistent, but this is for backwards compatibility */
 
-	// general
-	g_key_file_set_boolean(config, PACKAGE, "pref_main_load_session", prefs.load_session);
-	g_key_file_set_boolean(config, PACKAGE, "load_plugins", prefs.load_plugins);
-	g_key_file_set_boolean(config, PACKAGE, "pref_main_save_winpos", prefs.save_winpos);
-	g_key_file_set_boolean(config, PACKAGE, "pref_main_confirm_exit", prefs.confirm_exit);
-	g_key_file_set_boolean(config, PACKAGE, "pref_main_suppress_search_dialogs", prefs.suppress_search_dialogs);
-	g_key_file_set_boolean(config, PACKAGE, "pref_main_suppress_status_messages", prefs.suppress_status_messages);
-	g_key_file_set_boolean(config, PACKAGE, "switch_msgwin_pages", prefs.switch_msgwin_pages);
-	g_key_file_set_boolean(config, PACKAGE, "beep_on_errors", prefs.beep_on_errors);
-	g_key_file_set_boolean(config, PACKAGE, "auto_focus", prefs.auto_focus);
-	g_key_file_set_string(config, PACKAGE, "default_open_path", prefs.default_open_path);
+    // general
+    g_key_file_set_boolean(config, PACKAGE, "pref_main_load_session", prefs.load_session);
+    g_key_file_set_boolean(config, PACKAGE, "load_plugins", prefs.load_plugins);
+    g_key_file_set_boolean(config, PACKAGE, "pref_main_save_winpos", prefs.save_winpos);
+    g_key_file_set_boolean(config, PACKAGE, "pref_main_confirm_exit", prefs.confirm_exit);
+    g_key_file_set_boolean(config, PACKAGE, "pref_main_suppress_search_dialogs", prefs.suppress_search_dialogs);
+    g_key_file_set_boolean(config, PACKAGE, "pref_main_suppress_status_messages", prefs.suppress_status_messages);
+    g_key_file_set_boolean(config, PACKAGE, "switch_msgwin_pages", prefs.switch_msgwin_pages);
+    g_key_file_set_boolean(config, PACKAGE, "beep_on_errors", prefs.beep_on_errors);
+    g_key_file_set_boolean(config, PACKAGE, "auto_focus", prefs.auto_focus);
+    g_key_file_set_string(config, PACKAGE, "default_open_path", prefs.default_open_path);
 
-	// interface
-	g_key_file_set_boolean(config, PACKAGE, "sidebar_symbol_visible", prefs.sidebar_symbol_visible);
-	g_key_file_set_boolean(config, PACKAGE, "sidebar_openfiles_visible", prefs.sidebar_openfiles_visible);
-	g_key_file_set_boolean(config, PACKAGE, "sidebar_openfiles_fullpath", prefs.sidebar_openfiles_fullpath);
-	g_key_file_set_string(config, PACKAGE, "editor_font", prefs.editor_font);
-	g_key_file_set_string(config, PACKAGE, "tagbar_font", prefs.tagbar_font);
-	g_key_file_set_string(config, PACKAGE, "msgwin_font", prefs.msgwin_font);
-	g_key_file_set_boolean(config, PACKAGE, "show_notebook_tabs", prefs.show_notebook_tabs);
-	g_key_file_set_boolean(config, PACKAGE, "show_tab_cross", prefs.show_tab_cross);
-	g_key_file_set_boolean(config, PACKAGE, "tab_order_ltr", prefs.tab_order_ltr);
-	g_key_file_set_integer(config, PACKAGE, "tab_pos_editor", prefs.tab_pos_editor);
-	g_key_file_set_integer(config, PACKAGE, "tab_pos_msgwin", prefs.tab_pos_msgwin);
-	g_key_file_set_integer(config, PACKAGE, "tab_pos_sidebar", prefs.tab_pos_sidebar);
+    // interface
+    g_key_file_set_boolean(config, PACKAGE, "sidebar_symbol_visible", prefs.sidebar_symbol_visible);
+    g_key_file_set_boolean(config, PACKAGE, "sidebar_openfiles_visible", prefs.sidebar_openfiles_visible);
+    g_key_file_set_boolean(config, PACKAGE, "sidebar_openfiles_fullpath", prefs.sidebar_openfiles_fullpath);
+    g_key_file_set_string(config, PACKAGE, "editor_font", prefs.editor_font);
+    g_key_file_set_string(config, PACKAGE, "tagbar_font", prefs.tagbar_font);
+    g_key_file_set_string(config, PACKAGE, "msgwin_font", prefs.msgwin_font);
+    g_key_file_set_boolean(config, PACKAGE, "show_notebook_tabs", prefs.show_notebook_tabs);
+    g_key_file_set_boolean(config, PACKAGE, "show_tab_cross", prefs.show_tab_cross);
+    g_key_file_set_boolean(config, PACKAGE, "tab_order_ltr", prefs.tab_order_ltr);
+    g_key_file_set_integer(config, PACKAGE, "tab_pos_editor", prefs.tab_pos_editor);
+    g_key_file_set_integer(config, PACKAGE, "tab_pos_msgwin", prefs.tab_pos_msgwin);
+    g_key_file_set_integer(config, PACKAGE, "tab_pos_sidebar", prefs.tab_pos_sidebar);
 
-	// display
-	g_key_file_set_boolean(config, PACKAGE, "show_indent_guide", editor_prefs.show_indent_guide);
-	g_key_file_set_boolean(config, PACKAGE, "show_white_space", editor_prefs.show_white_space);
-	g_key_file_set_boolean(config, PACKAGE, "show_line_endings", editor_prefs.show_line_endings);
-	g_key_file_set_boolean(config, PACKAGE, "show_markers_margin", editor_prefs.show_markers_margin);
-	g_key_file_set_boolean(config, PACKAGE, "show_linenumber_margin", editor_prefs.show_linenumber_margin);
-	g_key_file_set_integer(config, PACKAGE, "long_line_type", editor_prefs.long_line_type);
-	g_key_file_set_integer(config, PACKAGE, "long_line_column", editor_prefs.long_line_column);
-	g_key_file_set_string(config, PACKAGE, "long_line_color", editor_prefs.long_line_color);
+    // display
+    g_key_file_set_boolean(config, PACKAGE, "show_indent_guide", editor_prefs.show_indent_guide);
+    g_key_file_set_boolean(config, PACKAGE, "show_white_space", editor_prefs.show_white_space);
+    g_key_file_set_boolean(config, PACKAGE, "show_line_endings", editor_prefs.show_line_endings);
+    g_key_file_set_boolean(config, PACKAGE, "show_markers_margin", editor_prefs.show_markers_margin);
+    g_key_file_set_boolean(config, PACKAGE, "show_linenumber_margin", editor_prefs.show_linenumber_margin);
+    g_key_file_set_integer(config, PACKAGE, "long_line_type", editor_prefs.long_line_type);
+    g_key_file_set_integer(config, PACKAGE, "long_line_column", editor_prefs.long_line_column);
+    g_key_file_set_string(config, PACKAGE, "long_line_color", editor_prefs.long_line_color);
 
-	// editor
-	g_key_file_set_integer(config, PACKAGE, "autocompletion_max_height", editor_prefs.autocompletion_max_height);
-	g_key_file_set_boolean(config, PACKAGE, "use_folding", editor_prefs.folding);
-	g_key_file_set_boolean(config, PACKAGE, "unfold_all_children", editor_prefs.unfold_all_children);
-	g_key_file_set_integer(config, PACKAGE, "indent_mode", editor_prefs.indent_mode);
-	g_key_file_set_integer(config, PACKAGE, "check_detect_indent", editor_prefs.detect_tab_mode);
-	g_key_file_set_boolean(config, PACKAGE, "use_indicators", editor_prefs.use_indicators);
-	g_key_file_set_boolean(config, PACKAGE, "line_breaking", editor_prefs.line_wrapping);
-	g_key_file_set_boolean(config, PACKAGE, "auto_close_xml_tags", editor_prefs.auto_close_xml_tags);
-	g_key_file_set_boolean(config, PACKAGE, "auto_complete_constructs", editor_prefs.auto_complete_constructs);
-	g_key_file_set_boolean(config, PACKAGE, "auto_complete_symbols", editor_prefs.auto_complete_symbols);
-	g_key_file_set_integer(config, PACKAGE, "pref_editor_tab_width", editor_prefs.tab_width);
-	g_key_file_set_boolean(config, PACKAGE, "pref_editor_use_tabs", editor_prefs.use_tabs);
-	g_key_file_set_boolean(config, PACKAGE, "pref_editor_disable_dnd", editor_prefs.disable_dnd);
-	g_key_file_set_boolean(config, PACKAGE, "pref_editor_smart_home_key", editor_prefs.smart_home_key);
-	g_key_file_set_boolean(config, PACKAGE, "pref_editor_newline_strip", editor_prefs.newline_strip);
+    // editor
+    g_key_file_set_integer(config, PACKAGE, "autocompletion_max_height", editor_prefs.autocompletion_max_height);
+    g_key_file_set_boolean(config, PACKAGE, "use_folding", editor_prefs.folding);
+    g_key_file_set_boolean(config, PACKAGE, "unfold_all_children", editor_prefs.unfold_all_children);
+    g_key_file_set_integer(config, PACKAGE, "indent_mode", editor_prefs.indent_mode);
+    g_key_file_set_integer(config, PACKAGE, "check_detect_indent", editor_prefs.detect_tab_mode);
+    g_key_file_set_boolean(config, PACKAGE, "use_indicators", editor_prefs.use_indicators);
+    g_key_file_set_boolean(config, PACKAGE, "line_breaking", editor_prefs.line_wrapping);
+    g_key_file_set_boolean(config, PACKAGE, "auto_close_xml_tags", editor_prefs.auto_close_xml_tags);
+    g_key_file_set_boolean(config, PACKAGE, "auto_complete_constructs", editor_prefs.auto_complete_constructs);
+    g_key_file_set_boolean(config, PACKAGE, "auto_complete_symbols", editor_prefs.auto_complete_symbols);
+    g_key_file_set_integer(config, PACKAGE, "pref_editor_tab_width", editor_prefs.tab_width);
+    g_key_file_set_boolean(config, PACKAGE, "pref_editor_use_tabs", editor_prefs.use_tabs);
+    g_key_file_set_boolean(config, PACKAGE, "pref_editor_disable_dnd", editor_prefs.disable_dnd);
+    g_key_file_set_boolean(config, PACKAGE, "pref_editor_smart_home_key", editor_prefs.smart_home_key);
+    g_key_file_set_boolean(config, PACKAGE, "pref_editor_newline_strip", editor_prefs.newline_strip);
 
-	// files
-	g_key_file_set_string(config, PACKAGE, "pref_editor_default_new_encoding", encodings[prefs.default_new_encoding].charset);
-	if (prefs.default_open_encoding == -1)
-		g_key_file_set_string(config, PACKAGE, "pref_editor_default_open_encoding", "none");
-	else
-		g_key_file_set_string(config, PACKAGE, "pref_editor_default_open_encoding", encodings[prefs.default_open_encoding].charset);
-	g_key_file_set_boolean(config, PACKAGE, "pref_editor_new_line", prefs.final_new_line);
-	g_key_file_set_boolean(config, PACKAGE, "pref_editor_replace_tabs", prefs.replace_tabs);
-	g_key_file_set_boolean(config, PACKAGE, "pref_editor_trail_space", prefs.strip_trailing_spaces);
-	g_key_file_set_integer(config, PACKAGE, "mru_length", prefs.mru_length);
+    // files
+    g_key_file_set_string(config, PACKAGE, "pref_editor_default_new_encoding", encodings[prefs.default_new_encoding].charset);
+    if (prefs.default_open_encoding == -1)
+        g_key_file_set_string(config, PACKAGE, "pref_editor_default_open_encoding", "none");
+    else
+        g_key_file_set_string(config, PACKAGE, "pref_editor_default_open_encoding", encodings[prefs.default_open_encoding].charset);
+    g_key_file_set_boolean(config, PACKAGE, "pref_editor_new_line", prefs.final_new_line);
+    g_key_file_set_boolean(config, PACKAGE, "pref_editor_replace_tabs", prefs.replace_tabs);
+    g_key_file_set_boolean(config, PACKAGE, "pref_editor_trail_space", prefs.strip_trailing_spaces);
+    g_key_file_set_integer(config, PACKAGE, "mru_length", prefs.mru_length);
 
-	// toolbar
-	g_key_file_set_boolean(config, PACKAGE, "pref_toolbar_show", prefs.toolbar_visible);
-	g_key_file_set_boolean(config, PACKAGE, "pref_toolbar_show_search", prefs.toolbar_show_search);
-	g_key_file_set_boolean(config, PACKAGE, "pref_toolbar_show_goto", prefs.toolbar_show_goto);
-	g_key_file_set_boolean(config, PACKAGE, "pref_toolbar_show_zoom", prefs.toolbar_show_zoom);
-	g_key_file_set_boolean(config, PACKAGE, "pref_toolbar_show_undo", prefs.toolbar_show_undo);
-	g_key_file_set_boolean(config, PACKAGE, "pref_toolbar_show_navigation", prefs.toolbar_show_navigation);
-	g_key_file_set_boolean(config, PACKAGE, "pref_toolbar_show_compile", prefs.toolbar_show_compile);
-	g_key_file_set_boolean(config, PACKAGE, "pref_toolbar_show_colour", prefs.toolbar_show_colour);
-	g_key_file_set_boolean(config, PACKAGE, "pref_toolbar_show_fileops", prefs.toolbar_show_fileops);
-	g_key_file_set_boolean(config, PACKAGE, "pref_toolbar_show_quit", prefs.toolbar_show_quit);
-	g_key_file_set_integer(config, PACKAGE, "pref_toolbar_icon_style", prefs.toolbar_icon_style);
-	g_key_file_set_integer(config, PACKAGE, "pref_toolbar_icon_size", prefs.toolbar_icon_size);
+    // toolbar
+    g_key_file_set_boolean(config, PACKAGE, "pref_toolbar_show", prefs.toolbar_visible);
+    g_key_file_set_boolean(config, PACKAGE, "pref_toolbar_show_search", prefs.toolbar_show_search);
+    g_key_file_set_boolean(config, PACKAGE, "pref_toolbar_show_goto", prefs.toolbar_show_goto);
+    g_key_file_set_boolean(config, PACKAGE, "pref_toolbar_show_zoom", prefs.toolbar_show_zoom);
+    g_key_file_set_boolean(config, PACKAGE, "pref_toolbar_show_undo", prefs.toolbar_show_undo);
+    g_key_file_set_boolean(config, PACKAGE, "pref_toolbar_show_navigation", prefs.toolbar_show_navigation);
+    g_key_file_set_boolean(config, PACKAGE, "pref_toolbar_show_compile", prefs.toolbar_show_compile);
+    g_key_file_set_boolean(config, PACKAGE, "pref_toolbar_show_colour", prefs.toolbar_show_colour);
+    g_key_file_set_boolean(config, PACKAGE, "pref_toolbar_show_fileops", prefs.toolbar_show_fileops);
+    g_key_file_set_boolean(config, PACKAGE, "pref_toolbar_show_quit", prefs.toolbar_show_quit);
+    g_key_file_set_integer(config, PACKAGE, "pref_toolbar_icon_style", prefs.toolbar_icon_style);
+    g_key_file_set_integer(config, PACKAGE, "pref_toolbar_icon_size", prefs.toolbar_icon_size);
 
-	// templates
-	g_key_file_set_string(config, PACKAGE, "pref_template_developer", prefs.template_developer);
-	g_key_file_set_string(config, PACKAGE, "pref_template_company", prefs.template_company);
-	g_key_file_set_string(config, PACKAGE, "pref_template_mail", prefs.template_mail);
-	g_key_file_set_string(config, PACKAGE, "pref_template_initial", prefs.template_initial);
-	g_key_file_set_string(config, PACKAGE, "pref_template_version", prefs.template_version);
+    // templates
+    g_key_file_set_string(config, PACKAGE, "pref_template_developer", prefs.template_developer);
+    g_key_file_set_string(config, PACKAGE, "pref_template_company", prefs.template_company);
+    g_key_file_set_string(config, PACKAGE, "pref_template_mail", prefs.template_mail);
+    g_key_file_set_string(config, PACKAGE, "pref_template_initial", prefs.template_initial);
+    g_key_file_set_string(config, PACKAGE, "pref_template_version", prefs.template_version);
 
-	// tools settings
-	g_key_file_set_string(config, "tools", "make_cmd", prefs.tools_make_cmd ? prefs.tools_make_cmd : "");
-	g_key_file_set_string(config, "tools", "term_cmd", prefs.tools_term_cmd ? prefs.tools_term_cmd : "");
-	g_key_file_set_string(config, "tools", "browser_cmd", prefs.tools_browser_cmd ? prefs.tools_browser_cmd : "");
-	g_key_file_set_string(config, "tools", "print_cmd", prefs.tools_print_cmd ? prefs.tools_print_cmd : "");
-	g_key_file_set_string(config, "tools", "grep_cmd", prefs.tools_grep_cmd ? prefs.tools_grep_cmd : "");
-	g_key_file_set_string(config, PACKAGE, "context_action_cmd", prefs.context_action_cmd);
+    // tools settings
+    g_key_file_set_string(config, "tools", "make_cmd", prefs.tools_make_cmd ? prefs.tools_make_cmd : "");
+    g_key_file_set_string(config, "tools", "term_cmd", prefs.tools_term_cmd ? prefs.tools_term_cmd : "");
+    g_key_file_set_string(config, "tools", "browser_cmd", prefs.tools_browser_cmd ? prefs.tools_browser_cmd : "");
+    g_key_file_set_string(config, "tools", "print_cmd", prefs.tools_print_cmd ? prefs.tools_print_cmd : "");
+    g_key_file_set_string(config, "tools", "grep_cmd", prefs.tools_grep_cmd ? prefs.tools_grep_cmd : "");
+    g_key_file_set_string(config, PACKAGE, "context_action_cmd", prefs.context_action_cmd);
 
-	// VTE
+    // VTE
 #ifdef HAVE_VTE
-	g_key_file_set_boolean(config, "VTE", "load_vte", vte_info.load_vte);
-	if (vte_info.load_vte && vc != NULL)
-	{
-		gchar *tmp_string;
+    g_key_file_set_boolean(config, "VTE", "load_vte", vte_info.load_vte);
+    if (vte_info.load_vte && vc != NULL)
+    {
+        gchar *tmp_string;
 
-		g_key_file_set_string(config, "VTE", "emulation", vc->emulation);
-		g_key_file_set_string(config, "VTE", "font", vc->font);
-		g_key_file_set_boolean(config, "VTE", "scroll_on_key", vc->scroll_on_key);
-		g_key_file_set_boolean(config, "VTE", "scroll_on_out", vc->scroll_on_out);
-		g_key_file_set_boolean(config, "VTE", "ignore_menu_bar_accel", vc->ignore_menu_bar_accel);
-		g_key_file_set_boolean(config, "VTE", "follow_path", vc->follow_path);
-		g_key_file_set_boolean(config, "VTE", "run_in_vte", vc->run_in_vte);
-		g_key_file_set_integer(config, "VTE", "scrollback_lines", vc->scrollback_lines);
-		g_key_file_set_string(config, "VTE", "font", vc->font);
-		g_key_file_set_string(config, "VTE", "shell", vc->shell);
-		tmp_string = utils_get_hex_from_color(vc->colour_fore);
-		g_key_file_set_string(config, "VTE", "colour_fore", tmp_string);
-		g_free(tmp_string);
-		tmp_string = utils_get_hex_from_color(vc->colour_back);
-		g_key_file_set_string(config, "VTE", "colour_back", tmp_string);
-		g_free(tmp_string);
-		vte_get_working_directory();	// refresh vte_info.dir
-		g_key_file_set_string(config, "VTE", "last_dir", vte_info.dir);
-	}
+        g_key_file_set_string(config, "VTE", "emulation", vc->emulation);
+        g_key_file_set_string(config, "VTE", "font", vc->font);
+        g_key_file_set_boolean(config, "VTE", "scroll_on_key", vc->scroll_on_key);
+        g_key_file_set_boolean(config, "VTE", "scroll_on_out", vc->scroll_on_out);
+        g_key_file_set_boolean(config, "VTE", "ignore_menu_bar_accel", vc->ignore_menu_bar_accel);
+        g_key_file_set_boolean(config, "VTE", "follow_path", vc->follow_path);
+        g_key_file_set_boolean(config, "VTE", "run_in_vte", vc->run_in_vte);
+        g_key_file_set_integer(config, "VTE", "scrollback_lines", vc->scrollback_lines);
+        g_key_file_set_string(config, "VTE", "font", vc->font);
+        g_key_file_set_string(config, "VTE", "shell", vc->shell);
+        tmp_string = utils_get_hex_from_color(vc->colour_fore);
+        g_key_file_set_string(config, "VTE", "colour_fore", tmp_string);
+        g_free(tmp_string);
+        tmp_string = utils_get_hex_from_color(vc->colour_back);
+        g_key_file_set_string(config, "VTE", "colour_back", tmp_string);
+        g_free(tmp_string);
+        vte_get_working_directory();    // refresh vte_info.dir
+        g_key_file_set_string(config, "VTE", "last_dir", vte_info.dir);
+    }
 #endif
 }
 
 
 static void save_ui_prefs(GKeyFile *config)
 {
-	g_key_file_set_boolean(config, PACKAGE, "sidebar_visible", ui_prefs.sidebar_visible);
-	g_key_file_set_boolean(config, PACKAGE, "statusbar_visible", prefs.statusbar_visible);
-	g_key_file_set_boolean(config, PACKAGE, "msgwindow_visible", ui_prefs.msgwindow_visible);
-	g_key_file_set_boolean(config, PACKAGE, "fullscreen", ui_prefs.fullscreen);
+    g_key_file_set_boolean(config, PACKAGE, "sidebar_visible", ui_prefs.sidebar_visible);
+    g_key_file_set_boolean(config, PACKAGE, "statusbar_visible", prefs.statusbar_visible);
+    g_key_file_set_boolean(config, PACKAGE, "msgwindow_visible", ui_prefs.msgwindow_visible);
+    g_key_file_set_boolean(config, PACKAGE, "fullscreen", ui_prefs.fullscreen);
 
-	// get the text from the scribble textview
-	{
-		GtkTextBuffer *buffer;
-		GtkTextIter start, end;
+    // get the text from the scribble textview
+    {
+        GtkTextBuffer *buffer;
+        GtkTextIter start, end;
 
-		buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(lookup_widget(app->window, "textview_scribble")));
-		gtk_text_buffer_get_bounds(buffer, &start, &end);
-		scribble_text = gtk_text_buffer_get_text(buffer, &start, &end, FALSE);
-		g_key_file_set_string(config, PACKAGE, "scribble_text", scribble_text);
-		g_free(scribble_text);
-	}
+        buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(lookup_widget(app->window, "textview_scribble")));
+        gtk_text_buffer_get_bounds(buffer, &start, &end);
+        scribble_text = gtk_text_buffer_get_text(buffer, &start, &end, FALSE);
+        g_key_file_set_string(config, PACKAGE, "scribble_text", scribble_text);
+        g_free(scribble_text);
+    }
 
-	if (prefs.save_winpos)
-	{
-		g_key_file_set_integer(config, PACKAGE, "treeview_position",
-				gtk_paned_get_position(GTK_PANED(lookup_widget(app->window, "hpaned1"))));
-		g_key_file_set_integer(config, PACKAGE, "msgwindow_position",
-				gtk_paned_get_position(GTK_PANED(lookup_widget(app->window, "vpaned1"))));
-	}
+    if (prefs.save_winpos)
+    {
+        g_key_file_set_integer(config, PACKAGE, "treeview_position",
+                gtk_paned_get_position(GTK_PANED(lookup_widget(app->window, "hpaned1"))));
+        g_key_file_set_integer(config, PACKAGE, "msgwindow_position",
+                gtk_paned_get_position(GTK_PANED(lookup_widget(app->window, "vpaned1"))));
+    }
 
-	if (prefs.save_winpos && ! ui_prefs.fullscreen)
-	{
-		gtk_window_get_position(GTK_WINDOW(app->window), &ui_prefs.geometry[0], &ui_prefs.geometry[1]);
-		gtk_window_get_size(GTK_WINDOW(app->window), &ui_prefs.geometry[2], &ui_prefs.geometry[3]);
-		if (gdk_window_get_state(app->window->window) & GDK_WINDOW_STATE_MAXIMIZED)
-			ui_prefs.geometry[4] = 1;
-		else
-			ui_prefs.geometry[4] = 0;
+    if (prefs.save_winpos && ! ui_prefs.fullscreen)
+    {
+        gtk_window_get_position(GTK_WINDOW(app->window), &ui_prefs.geometry[0], &ui_prefs.geometry[1]);
+        gtk_window_get_size(GTK_WINDOW(app->window), &ui_prefs.geometry[2], &ui_prefs.geometry[3]);
+        if (gdk_window_get_state(app->window->window) & GDK_WINDOW_STATE_MAXIMIZED)
+            ui_prefs.geometry[4] = 1;
+        else
+            ui_prefs.geometry[4] = 0;
 
-		g_key_file_set_integer_list(config, PACKAGE, "geometry", ui_prefs.geometry, 5);
-	}
+        g_key_file_set_integer_list(config, PACKAGE, "geometry", ui_prefs.geometry, 5);
+    }
 
-	g_key_file_set_string(config, PACKAGE, "custom_date_format", ui_prefs.custom_date_format);
-	if (ui_prefs.custom_commands != NULL)
-	{
-		g_key_file_set_string_list(config, PACKAGE, "custom_commands",
-				(const gchar**) ui_prefs.custom_commands, g_strv_length(ui_prefs.custom_commands));
-	}
+    g_key_file_set_string(config, PACKAGE, "custom_date_format", ui_prefs.custom_date_format);
+    if (ui_prefs.custom_commands != NULL)
+    {
+        g_key_file_set_string_list(config, PACKAGE, "custom_commands",
+                (const gchar**) ui_prefs.custom_commands, g_strv_length(ui_prefs.custom_commands));
+    }
 
-	// search
-	g_key_file_set_string(config, "search", "fif_extra_options", search_prefs.fif_extra_options ? search_prefs.fif_extra_options : "");
+    // search
+    g_key_file_set_string(config, "search", "fif_extra_options", search_prefs.fif_extra_options ? search_prefs.fif_extra_options : "");
 }
 
 
 // hidden prefs (don't overwrite them so users can edit them manually)
 #define write_hidden_pref_boolean(conf, pkg, key, val) \
-		if (! g_key_file_has_key((conf), (pkg), (key), NULL)) \
-			g_key_file_set_boolean((conf), (pkg), (key), (val));
+        if (! g_key_file_has_key((conf), (pkg), (key), NULL)) \
+            g_key_file_set_boolean((conf), (pkg), (key), (val));
 
 static void save_hidden_prefs(GKeyFile *config)
 {
-	write_hidden_pref_boolean(config, PACKAGE, "show_editor_scrollbars", editor_prefs.show_scrollbars);
-	write_hidden_pref_boolean(config, PACKAGE, "use_tab_to_indent", editor_prefs.use_tab_to_indent);
-	write_hidden_pref_boolean(config, PACKAGE, "brace_match_ltgt", editor_prefs.brace_match_ltgt);
-	write_hidden_pref_boolean(config, PACKAGE, "use_gtk_word_boundaries", editor_prefs.use_gtk_word_boundaries);
-	write_hidden_pref_boolean(config, PACKAGE, "auto_complete_whilst_editing", editor_prefs.auto_complete_whilst_editing);
+    write_hidden_pref_boolean(config, PACKAGE, "show_editor_scrollbars", editor_prefs.show_scrollbars);
+    write_hidden_pref_boolean(config, PACKAGE, "use_tab_to_indent", editor_prefs.use_tab_to_indent);
+    write_hidden_pref_boolean(config, PACKAGE, "brace_match_ltgt", editor_prefs.brace_match_ltgt);
+    write_hidden_pref_boolean(config, PACKAGE, "use_gtk_word_boundaries", editor_prefs.use_gtk_word_boundaries);
+    write_hidden_pref_boolean(config, PACKAGE, "auto_complete_whilst_editing", editor_prefs.auto_complete_whilst_editing);
 #ifdef HAVE_VTE
-	if (vte_info.have_vte)
-		write_hidden_pref_boolean(config, "VTE", "enable_bash_keys", vc->enable_bash_keys);
+    if (vte_info.have_vte)
+        write_hidden_pref_boolean(config, "VTE", "enable_bash_keys", vc->enable_bash_keys);
 #endif
 }
 
 
 void configuration_save()
 {
-	GKeyFile *config = g_key_file_new();
-	gchar *configfile = g_strconcat(app->configdir, G_DIR_SEPARATOR_S, "geany.conf", NULL);
-	gchar *data;
+    GKeyFile *config = g_key_file_new();
+    gchar *configfile = g_strconcat(app->configdir, G_DIR_SEPARATOR_S, "geany.conf", NULL);
+    gchar *data;
 
-	g_key_file_load_from_file(config, configfile, G_KEY_FILE_NONE, NULL);
+    g_key_file_load_from_file(config, configfile, G_KEY_FILE_NONE, NULL);
 
-	save_dialog_prefs(config);
-	save_hidden_prefs(config);
-	save_ui_prefs(config);
-	project_save_prefs(config);	// save project filename, etc.
-	save_recent_files(config);
-	save_session_files(config);
+    save_dialog_prefs(config);
+    save_hidden_prefs(config);
+    save_ui_prefs(config);
+    project_save_prefs(config); // save project filename, etc.
+    save_recent_files(config);
+    if( app->project )
+        project_save();
+    else
+        save_session_files(config);
 
-	// write the file
-	data = g_key_file_to_data(config, NULL, NULL);
-	utils_write_file(configfile, data);
-	g_free(data);
+    // write the file
+    data = g_key_file_to_data(config, NULL, NULL);
+    utils_write_file(configfile, data);
+    g_free(data);
 
-	g_key_file_free(config);
-	g_free(configfile);
+    g_key_file_free(config);
+    g_free(configfile);
 }
 
-
-static void load_file_lists(GKeyFile *config)
+/**
+ * Load session list from the given keyfile, and store it in the global
+ * session_files variable for later file loading
+ * */
+void load_session_files(GKeyFile *config)
 {
-	gchar **recent_files;
-	guint i;
-	gsize len = 0;
-	gboolean have_session_files;
-	gchar entry[14];
-	gchar *tmp_string;
-	GError *error = NULL;
+    gchar **recent_files;
+    guint i;
+    gsize len = 0;
+    gboolean have_session_files;
+    gchar entry[14];
+    gchar *tmp_string;
+    GError *error = NULL;
 
-	session_notebook_page = utils_get_setting_integer(config, "files", "current_page", -1);
+    session_notebook_page = utils_get_setting_integer(config, "files", "current_page", -1);
 
-	recent_files = g_key_file_get_string_list(config, "files", "recent_files", &len, NULL);
-	if (recent_files != NULL)
-	{
-		for (i = 0; (i < len) && (i < prefs.mru_length); i++)
-		{
-			gchar *filename = g_strdup(recent_files[i]);
-			g_queue_push_tail(ui_prefs.recent_queue, filename);
-		}
-	}
-	g_strfreev(recent_files);
+    recent_files = g_key_file_get_string_list(config, "files", "recent_files", &len, NULL);
+    if (recent_files != NULL)
+    {
+        for (i = 0; (i < len) && (i < prefs.mru_length); i++)
+        {
+            gchar *filename = g_strdup(recent_files[i]);
+            g_queue_push_tail(ui_prefs.recent_queue, filename);
+        }
+    }
+    g_strfreev(recent_files);
 
-	session_files = g_ptr_array_new();
-	have_session_files = TRUE;
-	i = 0;
-	while (have_session_files)
-	{
-		g_snprintf(entry, 13, "FILE_NAME_%d", i);
-		tmp_string = g_key_file_get_string(config, "files", entry, &error);
-		if (! tmp_string || error)
-		{
-			g_error_free(error);
-			error = NULL;
-			have_session_files = FALSE;
-		}
-		g_ptr_array_add(session_files, tmp_string);
-		i++;
-	}
+    // The project may load another list, than the main setting
+    if( session_files )
+        g_ptr_array_free(session_files, TRUE);
+
+    session_files = g_ptr_array_new();
+    have_session_files = TRUE;
+    i = 0;
+    while (have_session_files)
+    {
+        g_snprintf(entry, 13, "FILE_NAME_%d", i);
+        tmp_string = g_key_file_get_string(config, "files", entry, &error);
+        if (! tmp_string || error)
+        {
+            g_error_free(error);
+            error = NULL;
+            have_session_files = FALSE;
+        }
+        g_ptr_array_add(session_files, tmp_string);
+        i++;
+    }
 }
 
 
 #define GEANY_GET_SETTING(propertyname, value, default_value) \
-	if (g_object_class_find_property( \
-		G_OBJECT_GET_CLASS(G_OBJECT(gtk_settings_get_default())), propertyname)) \
-			g_object_get(G_OBJECT(gtk_settings_get_default()), propertyname, &value, \
-				NULL); \
-	else \
-		value = default_value;
+    if (g_object_class_find_property( \
+        G_OBJECT_GET_CLASS(G_OBJECT(gtk_settings_get_default())), propertyname)) \
+            g_object_get(G_OBJECT(gtk_settings_get_default()), propertyname, &value, \
+                NULL); \
+    else \
+        value = default_value;
 
 static void load_dialog_prefs(GKeyFile *config)
 {
-	gchar *tmp_string, *tmp_string2;
-	const gchar *default_charset = NULL;
+    gchar *tmp_string, *tmp_string2;
+    const gchar *default_charset = NULL;
 
-	// general
-	prefs.confirm_exit = utils_get_setting_boolean(config, PACKAGE, "pref_main_confirm_exit", FALSE);
-	prefs.suppress_search_dialogs = utils_get_setting_boolean(config, PACKAGE, "pref_main_suppress_search_dialogs", FALSE);
-	prefs.suppress_status_messages = utils_get_setting_boolean(config, PACKAGE, "pref_main_suppress_status_messages", FALSE);
-	prefs.load_session = utils_get_setting_boolean(config, PACKAGE, "pref_main_load_session", TRUE);
-	prefs.load_plugins = utils_get_setting_boolean(config, PACKAGE, "load_plugins", TRUE);
-	prefs.save_winpos = utils_get_setting_boolean(config, PACKAGE, "pref_main_save_winpos", TRUE);
-	prefs.beep_on_errors = utils_get_setting_boolean(config, PACKAGE, "beep_on_errors", TRUE);
-	prefs.switch_msgwin_pages = utils_get_setting_boolean(config, PACKAGE, "switch_msgwin_pages", FALSE);
-	prefs.auto_focus = utils_get_setting_boolean(config, PACKAGE, "auto_focus", FALSE);
-	prefs.default_open_path = utils_get_setting_string(config, PACKAGE, "default_open_path", "");
+    // general
+    prefs.confirm_exit = utils_get_setting_boolean(config, PACKAGE, "pref_main_confirm_exit", FALSE);
+    prefs.suppress_search_dialogs = utils_get_setting_boolean(config, PACKAGE, "pref_main_suppress_search_dialogs", FALSE);
+    prefs.suppress_status_messages = utils_get_setting_boolean(config, PACKAGE, "pref_main_suppress_status_messages", FALSE);
+    prefs.load_session = utils_get_setting_boolean(config, PACKAGE, "pref_main_load_session", TRUE);
+    prefs.load_plugins = utils_get_setting_boolean(config, PACKAGE, "load_plugins", TRUE);
+    prefs.save_winpos = utils_get_setting_boolean(config, PACKAGE, "pref_main_save_winpos", TRUE);
+    prefs.beep_on_errors = utils_get_setting_boolean(config, PACKAGE, "beep_on_errors", TRUE);
+    prefs.switch_msgwin_pages = utils_get_setting_boolean(config, PACKAGE, "switch_msgwin_pages", FALSE);
+    prefs.auto_focus = utils_get_setting_boolean(config, PACKAGE, "auto_focus", FALSE);
+    prefs.default_open_path = utils_get_setting_string(config, PACKAGE, "default_open_path", "");
 
-	// interface
-	prefs.tab_pos_editor = utils_get_setting_integer(config, PACKAGE, "tab_pos_editor", GTK_POS_TOP);
-	prefs.tab_pos_msgwin = utils_get_setting_integer(config, PACKAGE, "tab_pos_msgwin",GTK_POS_LEFT);
-	prefs.tab_pos_sidebar = utils_get_setting_integer(config, PACKAGE, "tab_pos_sidebar", GTK_POS_TOP);
-	prefs.sidebar_symbol_visible = utils_get_setting_boolean(config, PACKAGE, "sidebar_symbol_visible", TRUE);
-	prefs.sidebar_openfiles_visible = utils_get_setting_boolean(config, PACKAGE, "sidebar_openfiles_visible", TRUE);
-	prefs.sidebar_openfiles_fullpath = utils_get_setting_boolean(config, PACKAGE, "sidebar_openfiles_fullpath", FALSE);
-	prefs.statusbar_visible = utils_get_setting_boolean(config, PACKAGE, "statusbar_visible", TRUE);
-	prefs.tab_order_ltr = utils_get_setting_boolean(config, PACKAGE, "tab_order_ltr", TRUE);
-	prefs.show_notebook_tabs = utils_get_setting_boolean(config, PACKAGE, "show_notebook_tabs", TRUE);
-	prefs.show_tab_cross = utils_get_setting_boolean(config, PACKAGE, "show_tab_cross", TRUE);
-	prefs.editor_font = utils_get_setting_string(config, PACKAGE, "editor_font", GEANY_DEFAULT_FONT_EDITOR);
-	prefs.tagbar_font = utils_get_setting_string(config, PACKAGE, "tagbar_font", GEANY_DEFAULT_FONT_SYMBOL_LIST);
-	prefs.msgwin_font = utils_get_setting_string(config, PACKAGE, "msgwin_font", GEANY_DEFAULT_FONT_MSG_WINDOW);
+    // interface
+    prefs.tab_pos_editor = utils_get_setting_integer(config, PACKAGE, "tab_pos_editor", GTK_POS_TOP);
+    prefs.tab_pos_msgwin = utils_get_setting_integer(config, PACKAGE, "tab_pos_msgwin",GTK_POS_LEFT);
+    prefs.tab_pos_sidebar = utils_get_setting_integer(config, PACKAGE, "tab_pos_sidebar", GTK_POS_TOP);
+    prefs.sidebar_symbol_visible = utils_get_setting_boolean(config, PACKAGE, "sidebar_symbol_visible", TRUE);
+    prefs.sidebar_openfiles_visible = utils_get_setting_boolean(config, PACKAGE, "sidebar_openfiles_visible", TRUE);
+    prefs.sidebar_openfiles_fullpath = utils_get_setting_boolean(config, PACKAGE, "sidebar_openfiles_fullpath", FALSE);
+    prefs.statusbar_visible = utils_get_setting_boolean(config, PACKAGE, "statusbar_visible", TRUE);
+    prefs.tab_order_ltr = utils_get_setting_boolean(config, PACKAGE, "tab_order_ltr", TRUE);
+    prefs.show_notebook_tabs = utils_get_setting_boolean(config, PACKAGE, "show_notebook_tabs", TRUE);
+    prefs.show_tab_cross = utils_get_setting_boolean(config, PACKAGE, "show_tab_cross", TRUE);
+    prefs.editor_font = utils_get_setting_string(config, PACKAGE, "editor_font", GEANY_DEFAULT_FONT_EDITOR);
+    prefs.tagbar_font = utils_get_setting_string(config, PACKAGE, "tagbar_font", GEANY_DEFAULT_FONT_SYMBOL_LIST);
+    prefs.msgwin_font = utils_get_setting_string(config, PACKAGE, "msgwin_font", GEANY_DEFAULT_FONT_MSG_WINDOW);
 
-	// display, editor
-	editor_prefs.long_line_type = utils_get_setting_integer(config, PACKAGE, "long_line_type", 0);
-	editor_prefs.long_line_color = utils_get_setting_string(config, PACKAGE, "long_line_color", "#C2EBC2");
-	editor_prefs.long_line_column = utils_get_setting_integer(config, PACKAGE, "long_line_column", 72);
-	editor_prefs.autocompletion_max_height = utils_get_setting_integer(config, PACKAGE, "autocompletion_max_height", GEANY_MAX_AUTOCOMPLETE_HEIGHT);
-	editor_prefs.line_wrapping = utils_get_setting_boolean(config, PACKAGE, "line_breaking", FALSE); // default is off for better performance
-	editor_prefs.indent_mode = utils_get_setting_integer(config, PACKAGE, "indent_mode", INDENT_CURRENTCHARS);
-	editor_prefs.detect_tab_mode = utils_get_setting_integer(config, PACKAGE, "check_detect_indent", FALSE);
-	editor_prefs.use_tab_to_indent = utils_get_setting_boolean(config, PACKAGE, "use_tab_to_indent", FALSE);
-	editor_prefs.use_indicators = utils_get_setting_boolean(config, PACKAGE, "use_indicators", TRUE);
-	editor_prefs.show_indent_guide = utils_get_setting_boolean(config, PACKAGE, "show_indent_guide", FALSE);
-	editor_prefs.show_white_space = utils_get_setting_boolean(config, PACKAGE, "show_white_space", FALSE);
-	editor_prefs.show_line_endings = utils_get_setting_boolean(config, PACKAGE, "show_line_endings", FALSE);
-	editor_prefs.auto_close_xml_tags = utils_get_setting_boolean(config, PACKAGE, "auto_close_xml_tags", TRUE);
-	editor_prefs.auto_complete_constructs = utils_get_setting_boolean(config, PACKAGE, "auto_complete_constructs", TRUE);
-	editor_prefs.auto_complete_symbols = utils_get_setting_boolean(config, PACKAGE, "auto_complete_symbols", TRUE);
-	editor_prefs.folding = utils_get_setting_boolean(config, PACKAGE, "use_folding", TRUE);
-	editor_prefs.unfold_all_children = utils_get_setting_boolean(config, PACKAGE, "unfold_all_children", FALSE);
-	editor_prefs.show_scrollbars = utils_get_setting_boolean(config, PACKAGE, "show_editor_scrollbars", TRUE);
-	editor_prefs.show_markers_margin = utils_get_setting_boolean(config, PACKAGE, "show_markers_margin", TRUE);
-	editor_prefs.show_linenumber_margin = utils_get_setting_boolean(config, PACKAGE, "show_linenumber_margin", TRUE);
-	editor_prefs.brace_match_ltgt = utils_get_setting_boolean(config, PACKAGE, "brace_match_ltgt", FALSE);
-	editor_prefs.tab_width = utils_get_setting_integer(config, PACKAGE, "pref_editor_tab_width", 4);
-	editor_prefs.use_tabs = utils_get_setting_boolean(config, PACKAGE, "pref_editor_use_tabs", TRUE);
-	editor_prefs.disable_dnd = utils_get_setting_boolean(config, PACKAGE, "pref_editor_disable_dnd", FALSE);
-	editor_prefs.smart_home_key = utils_get_setting_boolean(config, PACKAGE, "pref_editor_smart_home_key", TRUE);
-	editor_prefs.newline_strip = utils_get_setting_boolean(config, PACKAGE, "pref_editor_newline_strip", FALSE);
-	editor_prefs.use_gtk_word_boundaries = utils_get_setting_boolean(config, PACKAGE, "use_gtk_word_boundaries", TRUE);
-	editor_prefs.auto_complete_whilst_editing = utils_get_setting_boolean(config, PACKAGE, "auto_complete_whilst_editing", FALSE);
+    // display, editor
+    editor_prefs.long_line_type = utils_get_setting_integer(config, PACKAGE, "long_line_type", 0);
+    editor_prefs.long_line_color = utils_get_setting_string(config, PACKAGE, "long_line_color", "#C2EBC2");
+    editor_prefs.long_line_column = utils_get_setting_integer(config, PACKAGE, "long_line_column", 72);
+    editor_prefs.autocompletion_max_height = utils_get_setting_integer(config, PACKAGE, "autocompletion_max_height", GEANY_MAX_AUTOCOMPLETE_HEIGHT);
+    editor_prefs.line_wrapping = utils_get_setting_boolean(config, PACKAGE, "line_breaking", FALSE); // default is off for better performance
+    editor_prefs.indent_mode = utils_get_setting_integer(config, PACKAGE, "indent_mode", INDENT_CURRENTCHARS);
+    editor_prefs.detect_tab_mode = utils_get_setting_integer(config, PACKAGE, "check_detect_indent", FALSE);
+    editor_prefs.use_tab_to_indent = utils_get_setting_boolean(config, PACKAGE, "use_tab_to_indent", FALSE);
+    editor_prefs.use_indicators = utils_get_setting_boolean(config, PACKAGE, "use_indicators", TRUE);
+    editor_prefs.show_indent_guide = utils_get_setting_boolean(config, PACKAGE, "show_indent_guide", FALSE);
+    editor_prefs.show_white_space = utils_get_setting_boolean(config, PACKAGE, "show_white_space", FALSE);
+    editor_prefs.show_line_endings = utils_get_setting_boolean(config, PACKAGE, "show_line_endings", FALSE);
+    editor_prefs.auto_close_xml_tags = utils_get_setting_boolean(config, PACKAGE, "auto_close_xml_tags", TRUE);
+    editor_prefs.auto_complete_constructs = utils_get_setting_boolean(config, PACKAGE, "auto_complete_constructs", TRUE);
+    editor_prefs.auto_complete_symbols = utils_get_setting_boolean(config, PACKAGE, "auto_complete_symbols", TRUE);
+    editor_prefs.folding = utils_get_setting_boolean(config, PACKAGE, "use_folding", TRUE);
+    editor_prefs.unfold_all_children = utils_get_setting_boolean(config, PACKAGE, "unfold_all_children", FALSE);
+    editor_prefs.show_scrollbars = utils_get_setting_boolean(config, PACKAGE, "show_editor_scrollbars", TRUE);
+    editor_prefs.show_markers_margin = utils_get_setting_boolean(config, PACKAGE, "show_markers_margin", TRUE);
+    editor_prefs.show_linenumber_margin = utils_get_setting_boolean(config, PACKAGE, "show_linenumber_margin", TRUE);
+    editor_prefs.brace_match_ltgt = utils_get_setting_boolean(config, PACKAGE, "brace_match_ltgt", FALSE);
+    editor_prefs.tab_width = utils_get_setting_integer(config, PACKAGE, "pref_editor_tab_width", 4);
+    editor_prefs.use_tabs = utils_get_setting_boolean(config, PACKAGE, "pref_editor_use_tabs", TRUE);
+    editor_prefs.disable_dnd = utils_get_setting_boolean(config, PACKAGE, "pref_editor_disable_dnd", FALSE);
+    editor_prefs.smart_home_key = utils_get_setting_boolean(config, PACKAGE, "pref_editor_smart_home_key", TRUE);
+    editor_prefs.newline_strip = utils_get_setting_boolean(config, PACKAGE, "pref_editor_newline_strip", FALSE);
+    editor_prefs.use_gtk_word_boundaries = utils_get_setting_boolean(config, PACKAGE, "use_gtk_word_boundaries", TRUE);
+    editor_prefs.auto_complete_whilst_editing = utils_get_setting_boolean(config, PACKAGE, "auto_complete_whilst_editing", FALSE);
 
-	// Files
-	// use current locale encoding as default for new files (should be UTF-8 in most cases)
-	g_get_charset(&default_charset);
-	tmp_string = utils_get_setting_string(config, PACKAGE, "pref_editor_default_new_encoding",
-		default_charset);
-	if (tmp_string)
-	{
-		const GeanyEncoding *enc = encodings_get_from_charset(tmp_string);
-		if (enc != NULL)
-			prefs.default_new_encoding = enc->idx;
-		else
-			prefs.default_new_encoding = GEANY_ENCODING_UTF_8;
+    // Files
+    // use current locale encoding as default for new files (should be UTF-8 in most cases)
+    g_get_charset(&default_charset);
+    tmp_string = utils_get_setting_string(config, PACKAGE, "pref_editor_default_new_encoding",
+        default_charset);
+    if (tmp_string)
+    {
+        const GeanyEncoding *enc = encodings_get_from_charset(tmp_string);
+        if (enc != NULL)
+            prefs.default_new_encoding = enc->idx;
+        else
+            prefs.default_new_encoding = GEANY_ENCODING_UTF_8;
 
-		g_free(tmp_string);
-	}
-	tmp_string = utils_get_setting_string(config, PACKAGE, "pref_editor_default_open_encoding",
-		"none");
-	if (tmp_string)
-	{
-		const GeanyEncoding *enc = encodings_get_from_charset(tmp_string);
-		if (enc != NULL)
-			prefs.default_open_encoding = enc->idx;
-		else
-			prefs.default_open_encoding = -1;
+        g_free(tmp_string);
+    }
+    tmp_string = utils_get_setting_string(config, PACKAGE, "pref_editor_default_open_encoding",
+        "none");
+    if (tmp_string)
+    {
+        const GeanyEncoding *enc = encodings_get_from_charset(tmp_string);
+        if (enc != NULL)
+            prefs.default_open_encoding = enc->idx;
+        else
+            prefs.default_open_encoding = -1;
 
-		g_free(tmp_string);
-	}
-	prefs.replace_tabs = utils_get_setting_boolean(config, PACKAGE, "pref_editor_replace_tabs", FALSE);
-	prefs.final_new_line = utils_get_setting_boolean(config, PACKAGE, "pref_editor_new_line", TRUE);
-	prefs.strip_trailing_spaces = utils_get_setting_boolean(config, PACKAGE, "pref_editor_trail_space", FALSE);
-	prefs.mru_length = utils_get_setting_integer(config, PACKAGE, "mru_length", GEANY_DEFAULT_MRU_LENGTH);
+        g_free(tmp_string);
+    }
+    prefs.replace_tabs = utils_get_setting_boolean(config, PACKAGE, "pref_editor_replace_tabs", FALSE);
+    prefs.final_new_line = utils_get_setting_boolean(config, PACKAGE, "pref_editor_new_line", TRUE);
+    prefs.strip_trailing_spaces = utils_get_setting_boolean(config, PACKAGE, "pref_editor_trail_space", FALSE);
+    prefs.mru_length = utils_get_setting_integer(config, PACKAGE, "mru_length", GEANY_DEFAULT_MRU_LENGTH);
 
-	// toolbar
-	prefs.toolbar_visible = utils_get_setting_boolean(config, PACKAGE, "pref_toolbar_show", TRUE);
-	prefs.toolbar_show_search = utils_get_setting_boolean(config, PACKAGE, "pref_toolbar_show_search", TRUE);
-	prefs.toolbar_show_goto = utils_get_setting_boolean(config, PACKAGE, "pref_toolbar_show_goto", TRUE);
-	prefs.toolbar_show_zoom = utils_get_setting_boolean(config, PACKAGE, "pref_toolbar_show_zoom", FALSE);
-	prefs.toolbar_show_compile = utils_get_setting_boolean(config, PACKAGE, "pref_toolbar_show_compile", TRUE);
-	prefs.toolbar_show_undo = utils_get_setting_boolean(config, PACKAGE, "pref_toolbar_show_undo", FALSE);
-	prefs.toolbar_show_navigation = utils_get_setting_boolean(config, PACKAGE, "pref_toolbar_show_navigation", TRUE);
-	prefs.toolbar_show_colour = utils_get_setting_boolean(config, PACKAGE, "pref_toolbar_show_colour", TRUE);
-	prefs.toolbar_show_fileops = utils_get_setting_boolean(config, PACKAGE, "pref_toolbar_show_fileops", TRUE);
-	prefs.toolbar_show_quit = utils_get_setting_boolean(config, PACKAGE, "pref_toolbar_show_quit", TRUE);
-	{
-		GtkIconSize tb_iconsize;
-		GtkToolbarStyle tb_style;
-		GEANY_GET_SETTING("gtk-toolbar-style", tb_style, GTK_TOOLBAR_ICONS);
-		GEANY_GET_SETTING("gtk-toolbar-icon-size", tb_iconsize, GTK_ICON_SIZE_LARGE_TOOLBAR);
-		prefs.toolbar_icon_style = utils_get_setting_integer(config, PACKAGE, "pref_toolbar_icon_style", tb_style);
-		prefs.toolbar_icon_size = utils_get_setting_integer(config, PACKAGE, "pref_toolbar_icon_size", tb_iconsize);
-	}
+    // toolbar
+    prefs.toolbar_visible = utils_get_setting_boolean(config, PACKAGE, "pref_toolbar_show", TRUE);
+    prefs.toolbar_show_search = utils_get_setting_boolean(config, PACKAGE, "pref_toolbar_show_search", TRUE);
+    prefs.toolbar_show_goto = utils_get_setting_boolean(config, PACKAGE, "pref_toolbar_show_goto", TRUE);
+    prefs.toolbar_show_zoom = utils_get_setting_boolean(config, PACKAGE, "pref_toolbar_show_zoom", FALSE);
+    prefs.toolbar_show_compile = utils_get_setting_boolean(config, PACKAGE, "pref_toolbar_show_compile", TRUE);
+    prefs.toolbar_show_undo = utils_get_setting_boolean(config, PACKAGE, "pref_toolbar_show_undo", FALSE);
+    prefs.toolbar_show_navigation = utils_get_setting_boolean(config, PACKAGE, "pref_toolbar_show_navigation", TRUE);
+    prefs.toolbar_show_colour = utils_get_setting_boolean(config, PACKAGE, "pref_toolbar_show_colour", TRUE);
+    prefs.toolbar_show_fileops = utils_get_setting_boolean(config, PACKAGE, "pref_toolbar_show_fileops", TRUE);
+    prefs.toolbar_show_quit = utils_get_setting_boolean(config, PACKAGE, "pref_toolbar_show_quit", TRUE);
+    {
+        GtkIconSize tb_iconsize;
+        GtkToolbarStyle tb_style;
+        GEANY_GET_SETTING("gtk-toolbar-style", tb_style, GTK_TOOLBAR_ICONS);
+        GEANY_GET_SETTING("gtk-toolbar-icon-size", tb_iconsize, GTK_ICON_SIZE_LARGE_TOOLBAR);
+        prefs.toolbar_icon_style = utils_get_setting_integer(config, PACKAGE, "pref_toolbar_icon_style", tb_style);
+        prefs.toolbar_icon_size = utils_get_setting_integer(config, PACKAGE, "pref_toolbar_icon_size", tb_iconsize);
+    }
 
-	// VTE
+    // VTE
 #ifdef HAVE_VTE
-	vte_info.load_vte = utils_get_setting_boolean(config, "VTE", "load_vte", TRUE);
-	if (vte_info.load_vte)
-	{
-		struct passwd *pw = getpwuid(getuid());
-		gchar *shell = (pw != NULL) ? pw->pw_shell : "/bin/sh";
+    vte_info.load_vte = utils_get_setting_boolean(config, "VTE", "load_vte", TRUE);
+    if (vte_info.load_vte)
+    {
+        struct passwd *pw = getpwuid(getuid());
+        gchar *shell = (pw != NULL) ? pw->pw_shell : "/bin/sh";
 
-		vc = g_new0(VteConfig, 1);
-		vte_info.dir = utils_get_setting_string(config, "VTE", "last_dir", NULL);
-		if ((vte_info.dir == NULL || utils_str_equal(vte_info.dir, "")) && pw != NULL)
-			// last dir is not set, fallback to user's home directory
-			vte_info.dir = g_strdup(pw->pw_dir);
-		else if (vte_info.dir == NULL && pw == NULL)
-			// fallback to root
-			vte_info.dir = g_strdup("/");
+        vc = g_new0(VteConfig, 1);
+        vte_info.dir = utils_get_setting_string(config, "VTE", "last_dir", NULL);
+        if ((vte_info.dir == NULL || utils_str_equal(vte_info.dir, "")) && pw != NULL)
+            // last dir is not set, fallback to user's home directory
+            vte_info.dir = g_strdup(pw->pw_dir);
+        else if (vte_info.dir == NULL && pw == NULL)
+            // fallback to root
+            vte_info.dir = g_strdup("/");
 
-		vc->emulation = utils_get_setting_string(config, "VTE", "emulation", "xterm");
-		vc->shell = utils_get_setting_string(config, "VTE", "shell", shell);
-		vc->font = utils_get_setting_string(config, "VTE", "font", "Monospace 10");
-		vc->scroll_on_key = utils_get_setting_boolean(config, "VTE", "scroll_on_key", TRUE);
-		vc->scroll_on_out = utils_get_setting_boolean(config, "VTE", "scroll_on_out", TRUE);
-		vc->ignore_menu_bar_accel = utils_get_setting_boolean(config, "VTE", "ignore_menu_bar_accel", FALSE);
-		vc->follow_path = utils_get_setting_boolean(config, "VTE", "follow_path", FALSE);
-		vc->run_in_vte = utils_get_setting_boolean(config, "VTE", "run_in_vte", FALSE);
-		vc->enable_bash_keys = utils_get_setting_boolean(config, "VTE", "enable_bash_keys", TRUE);
-		vc->scrollback_lines = utils_get_setting_integer(config, "VTE", "scrollback_lines", 500);
-		vc->colour_fore = g_new0(GdkColor, 1);
-		vc->colour_back = g_new0(GdkColor, 1);
-		tmp_string = utils_get_setting_string(config, "VTE", "colour_fore", "#ffffff");
-		gdk_color_parse(tmp_string, vc->colour_fore);
-		g_free(tmp_string);
-		tmp_string = utils_get_setting_string(config, "VTE", "colour_back", "#000000");
-		gdk_color_parse(tmp_string, vc->colour_back);
-		g_free(tmp_string);
-	}
+        vc->emulation = utils_get_setting_string(config, "VTE", "emulation", "xterm");
+        vc->shell = utils_get_setting_string(config, "VTE", "shell", shell);
+        vc->font = utils_get_setting_string(config, "VTE", "font", "Monospace 10");
+        vc->scroll_on_key = utils_get_setting_boolean(config, "VTE", "scroll_on_key", TRUE);
+        vc->scroll_on_out = utils_get_setting_boolean(config, "VTE", "scroll_on_out", TRUE);
+        vc->ignore_menu_bar_accel = utils_get_setting_boolean(config, "VTE", "ignore_menu_bar_accel", FALSE);
+        vc->follow_path = utils_get_setting_boolean(config, "VTE", "follow_path", FALSE);
+        vc->run_in_vte = utils_get_setting_boolean(config, "VTE", "run_in_vte", FALSE);
+        vc->enable_bash_keys = utils_get_setting_boolean(config, "VTE", "enable_bash_keys", TRUE);
+        vc->scrollback_lines = utils_get_setting_integer(config, "VTE", "scrollback_lines", 500);
+        vc->colour_fore = g_new0(GdkColor, 1);
+        vc->colour_back = g_new0(GdkColor, 1);
+        tmp_string = utils_get_setting_string(config, "VTE", "colour_fore", "#ffffff");
+        gdk_color_parse(tmp_string, vc->colour_fore);
+        g_free(tmp_string);
+        tmp_string = utils_get_setting_string(config, "VTE", "colour_back", "#000000");
+        gdk_color_parse(tmp_string, vc->colour_back);
+        g_free(tmp_string);
+    }
 #endif
-	// templates
-	prefs.template_developer = utils_get_setting_string(config, PACKAGE, "pref_template_developer", g_get_real_name());
-	prefs.template_company = utils_get_setting_string(config, PACKAGE, "pref_template_company", "");
-	tmp_string = utils_get_initials(prefs.template_developer);
-	prefs.template_initial = utils_get_setting_string(config, PACKAGE, "pref_template_initial", tmp_string);
-	g_free(tmp_string);
+    // templates
+    prefs.template_developer = utils_get_setting_string(config, PACKAGE, "pref_template_developer", g_get_real_name());
+    prefs.template_company = utils_get_setting_string(config, PACKAGE, "pref_template_company", "");
+    tmp_string = utils_get_initials(prefs.template_developer);
+    prefs.template_initial = utils_get_setting_string(config, PACKAGE, "pref_template_initial", tmp_string);
+    g_free(tmp_string);
 
-	prefs.template_version = utils_get_setting_string(config, PACKAGE, "pref_template_version", "1.0");
+    prefs.template_version = utils_get_setting_string(config, PACKAGE, "pref_template_version", "1.0");
 
-	tmp_string2 = utils_get_hostname();
-	tmp_string = g_strdup_printf("%s@%s", g_get_user_name(), tmp_string2);
-	prefs.template_mail = utils_get_setting_string(config, PACKAGE, "pref_template_mail", tmp_string);
-	g_free(tmp_string);
-	g_free(tmp_string2);
+    tmp_string2 = utils_get_hostname();
+    tmp_string = g_strdup_printf("%s@%s", g_get_user_name(), tmp_string2);
+    prefs.template_mail = utils_get_setting_string(config, PACKAGE, "pref_template_mail", tmp_string);
+    g_free(tmp_string);
+    g_free(tmp_string2);
 
-	// tools
-	tmp_string = g_find_program_in_path(GEANY_DEFAULT_TOOLS_MAKE);
-	prefs.tools_make_cmd = utils_get_setting_string(config, "tools", "make_cmd", tmp_string);
-	g_free(tmp_string);
+    // tools
+    tmp_string = g_find_program_in_path(GEANY_DEFAULT_TOOLS_MAKE);
+    prefs.tools_make_cmd = utils_get_setting_string(config, "tools", "make_cmd", tmp_string);
+    g_free(tmp_string);
 
-	tmp_string = g_find_program_in_path(GEANY_DEFAULT_TOOLS_TERMINAL);
-	prefs.tools_term_cmd = utils_get_setting_string(config, "tools", "term_cmd", tmp_string);
-	g_free(tmp_string);
+    tmp_string = g_find_program_in_path(GEANY_DEFAULT_TOOLS_TERMINAL);
+    prefs.tools_term_cmd = utils_get_setting_string(config, "tools", "term_cmd", tmp_string);
+    g_free(tmp_string);
 
-	tmp_string = g_find_program_in_path(GEANY_DEFAULT_TOOLS_BROWSER);
-	prefs.tools_browser_cmd = utils_get_setting_string(config, "tools", "browser_cmd", tmp_string);
-	g_free(tmp_string);
+    tmp_string = g_find_program_in_path(GEANY_DEFAULT_TOOLS_BROWSER);
+    prefs.tools_browser_cmd = utils_get_setting_string(config, "tools", "browser_cmd", tmp_string);
+    g_free(tmp_string);
 
-	tmp_string2 = g_find_program_in_path(GEANY_DEFAULT_TOOLS_PRINTCMD);
+    tmp_string2 = g_find_program_in_path(GEANY_DEFAULT_TOOLS_PRINTCMD);
 #ifdef G_OS_WIN32
-	// single quote paths on Win32 for g_spawn_command_line_async
-	tmp_string = g_strconcat("'", tmp_string2, "' '%f'", NULL);
+    // single quote paths on Win32 for g_spawn_command_line_async
+    tmp_string = g_strconcat("'", tmp_string2, "' '%f'", NULL);
 #else
-	tmp_string = g_strconcat(tmp_string2, " %f", NULL);
+    tmp_string = g_strconcat(tmp_string2, " %f", NULL);
 #endif
-	prefs.tools_print_cmd = utils_get_setting_string(config, "tools", "print_cmd", tmp_string);
-	g_free(tmp_string);
-	g_free(tmp_string2);
+    prefs.tools_print_cmd = utils_get_setting_string(config, "tools", "print_cmd", tmp_string);
+    g_free(tmp_string);
+    g_free(tmp_string2);
 
-	tmp_string = g_find_program_in_path(GEANY_DEFAULT_TOOLS_GREP);
-	prefs.tools_grep_cmd = utils_get_setting_string(config, "tools", "grep_cmd", tmp_string);
-	g_free(tmp_string);
+    tmp_string = g_find_program_in_path(GEANY_DEFAULT_TOOLS_GREP);
+    prefs.tools_grep_cmd = utils_get_setting_string(config, "tools", "grep_cmd", tmp_string);
+    g_free(tmp_string);
 
-	prefs.context_action_cmd = utils_get_setting_string(config, PACKAGE, "context_action_cmd", "");
+    prefs.context_action_cmd = utils_get_setting_string(config, PACKAGE, "context_action_cmd", "");
 }
 
 
 static void load_ui_prefs(GKeyFile *config)
 {
-	gint *geo;
-	GError *error = NULL;
+    gint *geo;
+    GError *error = NULL;
 
-	ui_prefs.sidebar_visible = utils_get_setting_boolean(config, PACKAGE, "sidebar_visible", TRUE);
-	ui_prefs.msgwindow_visible = utils_get_setting_boolean(config, PACKAGE, "msgwindow_visible", TRUE);
-	ui_prefs.fullscreen = utils_get_setting_boolean(config, PACKAGE, "fullscreen", FALSE);
-	ui_prefs.custom_date_format = utils_get_setting_string(config, PACKAGE, "custom_date_format", "");
-	ui_prefs.custom_commands = g_key_file_get_string_list(config, PACKAGE, "custom_commands", NULL, NULL);
+    ui_prefs.sidebar_visible = utils_get_setting_boolean(config, PACKAGE, "sidebar_visible", TRUE);
+    ui_prefs.msgwindow_visible = utils_get_setting_boolean(config, PACKAGE, "msgwindow_visible", TRUE);
+    ui_prefs.fullscreen = utils_get_setting_boolean(config, PACKAGE, "fullscreen", FALSE);
+    ui_prefs.custom_date_format = utils_get_setting_string(config, PACKAGE, "custom_date_format", "");
+    ui_prefs.custom_commands = g_key_file_get_string_list(config, PACKAGE, "custom_commands", NULL, NULL);
 
-	scribble_text = utils_get_setting_string(config, PACKAGE, "scribble_text",
-				_("Type here what you want, use it as a notice/scratch board"));
+    scribble_text = utils_get_setting_string(config, PACKAGE, "scribble_text",
+                _("Type here what you want, use it as a notice/scratch board"));
 
-	geo = g_key_file_get_integer_list(config, PACKAGE, "geometry", NULL, &error);
-	if (error)
-	{
-		ui_prefs.geometry[0] = -1;
-		g_error_free(error);
-		error = NULL;
-	}
-	else
-	{
-		gint i;
+    geo = g_key_file_get_integer_list(config, PACKAGE, "geometry", NULL, &error);
+    if (error)
+    {
+        ui_prefs.geometry[0] = -1;
+        g_error_free(error);
+        error = NULL;
+    }
+    else
+    {
+        gint i;
 
-		ui_prefs.geometry[0] = geo[0];
-		ui_prefs.geometry[1] = geo[1];
-		ui_prefs.geometry[2] = geo[2];
-		ui_prefs.geometry[3] = geo[3];
-		ui_prefs.geometry[4] = geo[4];
+        ui_prefs.geometry[0] = geo[0];
+        ui_prefs.geometry[1] = geo[1];
+        ui_prefs.geometry[2] = geo[2];
+        ui_prefs.geometry[3] = geo[3];
+        ui_prefs.geometry[4] = geo[4];
 
-		// don't use insane values but when main windows was maximized last time, pos might be
-		// negative at least on Windows for some reason
-		if (ui_prefs.geometry[4] != 1)
-		{
-			for (i = 0; i < 4; i++)
-			{
-				if (ui_prefs.geometry[i] < -1)
-					ui_prefs.geometry[i] = -1;
-			}
-		}
-	}
-	hpan_position = utils_get_setting_integer(config, PACKAGE, "treeview_position", 156);
-	vpan_position = utils_get_setting_integer(config, PACKAGE, "msgwindow_position", (geo) ?
-				(GEANY_MSGWIN_HEIGHT + geo[3] - 440) :
-				(GEANY_MSGWIN_HEIGHT + GEANY_WINDOW_DEFAULT_HEIGHT - 440));
+        // don't use insane values but when main windows was maximized last time, pos might be
+        // negative at least on Windows for some reason
+        if (ui_prefs.geometry[4] != 1)
+        {
+            for (i = 0; i < 4; i++)
+            {
+                if (ui_prefs.geometry[i] < -1)
+                    ui_prefs.geometry[i] = -1;
+            }
+        }
+    }
+    hpan_position = utils_get_setting_integer(config, PACKAGE, "treeview_position", 156);
+    vpan_position = utils_get_setting_integer(config, PACKAGE, "msgwindow_position", (geo) ?
+                (GEANY_MSGWIN_HEIGHT + geo[3] - 440) :
+                (GEANY_MSGWIN_HEIGHT + GEANY_WINDOW_DEFAULT_HEIGHT - 440));
 
-	g_free(geo);
+    g_free(geo);
 
-	// search
-	search_prefs.fif_extra_options = utils_get_setting_string(config, "search", "fif_extra_options", "");
+    // search
+    search_prefs.fif_extra_options = utils_get_setting_string(config, "search", "fif_extra_options", "");
 }
 
 
 gboolean configuration_load()
 {
-	gchar *configfile = g_strconcat(app->configdir, G_DIR_SEPARATOR_S, "geany.conf", NULL);
-	GKeyFile *config = g_key_file_new();
+    gchar *configfile = g_strconcat(app->configdir, G_DIR_SEPARATOR_S, "geany.conf", NULL);
+    GKeyFile *config = g_key_file_new();
 
-	if (! g_file_test(configfile, G_FILE_TEST_IS_REGULAR | G_FILE_TEST_IS_SYMLINK))
-	{	// config file does not (yet) exist, so try to load a global config file which may be
-		// created by distributors
-		geany_debug("No config file found, try to use global configuration.");
-		setptr(configfile, g_strconcat(app->datadir, G_DIR_SEPARATOR_S "geany.conf", NULL));
-	}
+    if (! g_file_test(configfile, G_FILE_TEST_IS_REGULAR | G_FILE_TEST_IS_SYMLINK))
+    {   // config file does not (yet) exist, so try to load a global config file which may be
+        // created by distributors
+        geany_debug("No config file found, try to use global configuration.");
+        setptr(configfile, g_strconcat(app->datadir, G_DIR_SEPARATOR_S "geany.conf", NULL));
+    }
 
-	g_key_file_load_from_file(config, configfile, G_KEY_FILE_NONE, NULL);
+    g_key_file_load_from_file(config, configfile, G_KEY_FILE_NONE, NULL);
 
-	load_dialog_prefs(config);
-	load_ui_prefs(config);
-	project_load_prefs(config);
-	load_file_lists(config);
+    load_dialog_prefs(config);
+    load_ui_prefs(config);
+    project_load_prefs(config);
+    
+    load_session_files(config);
 
-	g_key_file_free(config);
-	g_free(configfile);
-	return TRUE;
+    g_key_file_free(config);
+    g_free(configfile);
+    return TRUE;
 }
 
 
 // open session files
 gboolean configuration_open_files()
 {
-	gint i;
-	guint x, pos, y, len;
-	gboolean ret = FALSE, failure = FALSE;
+    gint i;
+    guint x, pos, y, len;
+    gboolean ret = FALSE, failure = FALSE;
 
-	document_delay_colourise();
+    document_delay_colourise();
 
-	i = prefs.tab_order_ltr ? 0 : (session_files->len - 1);
-	while (TRUE)
-	{
-		gchar *tmp = g_ptr_array_index(session_files, i);
+    i = prefs.tab_order_ltr ? 0 : (session_files->len - 1);
+    while (TRUE)
+    {
+        gchar *tmp = g_ptr_array_index(session_files, i);
 
-		if (tmp && *tmp)
-		{
-			const gchar *file;
-			gchar *locale_filename, **array;
-			gint uid = -1;
-			x = 0;
-			y = 0;
+        if (tmp && *tmp)
+        {
+            const gchar *file;
+            gchar *locale_filename, **array;
+            gint uid = -1;
+            x = 0;
+            y = 0;
 
-			// yes it is :, it should be a ;, but now it is too late to change it
-			array = g_strsplit(tmp, ":", 3);
-			len = g_strv_length(array);
+            // yes it is :, it should be a ;, but now it is too late to change it
+            array = g_strsplit(tmp, ":", 3);
+            len = g_strv_length(array);
 
-			// read position
-			if (len > 0 && array[0]) pos = atoi(array[0]);
-			else pos = 0;
+            // read position
+            if (len > 0 && array[0]) pos = atoi(array[0]);
+            else pos = 0;
 
-			// read filetype (only if there are more than two fields, otherwise we have the old format)
-			if (len > 2 && array[1])
-			{
-				uid = atoi(array[1]);
-				file = array[2];
-			}
-			else file = array[1];
+            // read filetype (only if there are more than two fields, otherwise we have the old format)
+            if (len > 2 && array[1])
+            {
+                uid = atoi(array[1]);
+                file = array[2];
+            }
+            else file = array[1];
 
-			// try to get the locale equivalent for the filename, fallback to filename if error
-			locale_filename = utils_get_locale_from_utf8(file);
+            // try to get the locale equivalent for the filename, fallback to filename if error
+            locale_filename = utils_get_locale_from_utf8(file);
 
-			if (g_file_test(locale_filename, G_FILE_TEST_IS_REGULAR | G_FILE_TEST_IS_SYMLINK))
-			{
-				filetype *ft = filetypes_get_from_uid(uid);
-				document_open_file_full(-1, locale_filename, pos, FALSE, ft, NULL);
-				ret = TRUE;
-			}
-			else
-			{
-				failure = TRUE;
-				geany_debug("Could not find file '%s'.", file);
-			}
+            if (g_file_test(locale_filename, G_FILE_TEST_IS_REGULAR | G_FILE_TEST_IS_SYMLINK))
+            {
+                filetype *ft = filetypes_get_from_uid(uid);
+                document_open_file_full(-1, locale_filename, pos, FALSE, ft, NULL);
+                ret = TRUE;
+            }
+            else
+            {
+                failure = TRUE;
+                geany_debug("Could not find file '%s'.", file);
+            }
 
-			g_strfreev(array);
-			g_free(locale_filename);
-		}
-		g_free(tmp);
+            g_strfreev(array);
+            g_free(locale_filename);
+        }
+        g_free(tmp);
 
-		if (prefs.tab_order_ltr)
-		{
-			i++;
-			if (i >= (gint)session_files->len) break;
-		}
-		else
-		{
-			i--;
-			if (i < 0) break;
-		}
-	}
-	document_colourise_new();
+        if (prefs.tab_order_ltr)
+        {
+            i++;
+            if (i >= (gint)session_files->len) break;
+        }
+        else
+        {
+            i--;
+            if (i < 0) break;
+        }
+    }
+    document_colourise_new();
 
-	g_ptr_array_free(session_files, TRUE);
+    g_ptr_array_free(session_files, TRUE);
+    session_files = NULL;
 
-	if (failure)
-		ui_set_statusbar(TRUE, _("Failed to load one or more session files."));
-	else if (session_notebook_page >= 0)
-	{
-		// exlicitly allow notebook switch page callback to be called for window title,
-		// encoding settings and so other things
-		main_status.opening_session_files = FALSE;
-		gtk_notebook_set_current_page(GTK_NOTEBOOK(app->notebook), session_notebook_page);
-		// reset status to leave in any case with the same state as when entering
-		main_status.opening_session_files = TRUE;
-	}
-	return ret;
+    if (failure)
+        ui_set_statusbar(TRUE, _("Failed to load one or more session files."));
+    else if (session_notebook_page >= 0)
+    {
+        // exlicitly allow notebook switch page callback to be called for window title,
+        // encoding settings and so other things
+        main_status.opening_session_files = FALSE;
+        gtk_notebook_set_current_page(GTK_NOTEBOOK(app->notebook), session_notebook_page);
+        // reset status to leave in any case with the same state as when entering
+        main_status.opening_session_files = TRUE;
+    }
+    return ret;
 }
 
 
@@ -781,29 +793,29 @@
  * realisation of the main window */
 void configuration_apply_settings()
 {
-	if (scribble_text)
-	{	// update the scribble widget, because now it's realized
-		gtk_text_buffer_set_text(
-				gtk_text_view_get_buffer(GTK_TEXT_VIEW(lookup_widget(app->window, "textview_scribble"))),
-				scribble_text, -1);
-	}
-	g_free(scribble_text);
+    if (scribble_text)
+    {   // update the scribble widget, because now it's realized
+        gtk_text_buffer_set_text(
+                gtk_text_view_get_buffer(GTK_TEXT_VIEW(lookup_widget(app->window, "textview_scribble"))),
+                scribble_text, -1);
+    }
+    g_free(scribble_text);
 
-	// set the position of the hpaned and vpaned
-	if (prefs.save_winpos)
-	{
-		gtk_paned_set_position(GTK_PANED(lookup_widget(app->window, "hpaned1")), hpan_position);
-		gtk_paned_set_position(GTK_PANED(lookup_widget(app->window, "vpaned1")), vpan_position);
-	}
+    // set the position of the hpaned and vpaned
+    if (prefs.save_winpos)
+    {
+        gtk_paned_set_position(GTK_PANED(lookup_widget(app->window, "hpaned1")), hpan_position);
+        gtk_paned_set_position(GTK_PANED(lookup_widget(app->window, "vpaned1")), vpan_position);
+    }
 
-	// set fullscreen after initial draw so that returning to normal view is the right size.
-	// fullscreen mode is disabled by default, so act only if it is true
-	if (ui_prefs.fullscreen)
-	{
-		gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(lookup_widget(app->window, "menu_fullscreen1")), TRUE);
-		ui_prefs.fullscreen = TRUE;
-		ui_set_fullscreen();
-	}
+    // set fullscreen after initial draw so that returning to normal view is the right size.
+    // fullscreen mode is disabled by default, so act only if it is true
+    if (ui_prefs.fullscreen)
+    {
+        gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(lookup_widget(app->window, "menu_fullscreen1")), TRUE);
+        ui_prefs.fullscreen = TRUE;
+        ui_set_fullscreen();
+    }
 }
 
 
@@ -816,60 +828,60 @@
 /* Generate the config files in "data/" from defaults */
 void configuration_generate_data_files()
 {
-	gchar *cur_dir, *gen_dir;
+    gchar *cur_dir, *gen_dir;
 
-	cur_dir = g_get_current_dir();
-	gen_dir = g_strconcat(cur_dir, G_DIR_SEPARATOR_S, "data", NULL);
-	g_free(cur_dir);
+    cur_dir = g_get_current_dir();
+    gen_dir = g_strconcat(cur_dir, G_DIR_SEPARATOR_S, "data", NULL);
+    g_free(cur_dir);
 
-	if (! g_file_test(gen_dir, G_FILE_TEST_IS_DIR))
-	{
-		g_print("%s does not exist!\n", gen_dir);
-		return;
-	}
-	g_print("Generating system files in %s:\n", gen_dir);
-	// currently only filetype extensions are auto-generated.
-	generate_filetype_extensions(gen_dir);
-	g_free(gen_dir);
+    if (! g_file_test(gen_dir, G_FILE_TEST_IS_DIR))
+    {
+        g_print("%s does not exist!\n", gen_dir);
+        return;
+    }
+    g_print("Generating system files in %s:\n", gen_dir);
+    // currently only filetype extensions are auto-generated.
+    generate_filetype_extensions(gen_dir);
+    g_free(gen_dir);
 }
 
 
 /* This will write the default settings for the system filetype_extensions.conf */
 static void generate_filetype_extensions(const gchar *output_dir)
 {
-	guint i;
-	gchar *configfile = g_strconcat(output_dir, G_DIR_SEPARATOR_S, "filetype_extensions.conf", NULL);
-	gchar *data, *basename;
-	GKeyFile *config;
+    guint i;
+    gchar *configfile = g_strconcat(output_dir, G_DIR_SEPARATOR_S, "filetype_extensions.conf", NULL);
+    gchar *data, *basename;
+    GKeyFile *config;
 
-	config = g_key_file_new();
-	g_key_file_set_comment(config, NULL, NULL,
-		"*** This file generated by: geany --generate-data-files ***", NULL);
-	// add filetype keys
-	for (i = 0; i < GEANY_MAX_FILE_TYPES; i++)
-	{
-		g_key_file_set_string_list(config, "Extensions", filetypes[i]->name,
-			(const gchar**) filetypes[i]->pattern, g_strv_length(filetypes[i]->pattern));
-	}
-	// add comment
-	g_key_file_set_comment(config, "Extensions", NULL,
-		"Filetype extension configuration file for Geany\n"
-		"Insert as many items as you want, seperate them with a \";\".\n"
-		"See Geany's main documentation for details.", NULL);
+    config = g_key_file_new();
+    g_key_file_set_comment(config, NULL, NULL,
+        "*** This file generated by: geany --generate-data-files ***", NULL);
+    // add filetype keys
+    for (i = 0; i < GEANY_MAX_FILE_TYPES; i++)
+    {
+        g_key_file_set_string_list(config, "Extensions", filetypes[i]->name,
+            (const gchar**) filetypes[i]->pattern, g_strv_length(filetypes[i]->pattern));
+    }
+    // add comment
+    g_key_file_set_comment(config, "Extensions", NULL,
+        "Filetype extension configuration file for Geany\n"
+        "Insert as many items as you want, seperate them with a \";\".\n"
+        "See Geany's main documentation for details.", NULL);
 
-	// write the file
-	g_print("%s: ", __func__);
-	data = g_key_file_to_data(config, NULL, NULL);
-	basename = g_path_get_basename(configfile);
+    // write the file
+    g_print("%s: ", __func__);
+    data = g_key_file_to_data(config, NULL, NULL);
+    basename = g_path_get_basename(configfile);
 
-	if (utils_write_file(configfile, data) == 0)
-		g_print("wrote file %s.\n", basename);
-	else
-		g_print("*** ERROR: error writing file %s\n", basename);
-	g_free(basename);
+    if (utils_write_file(configfile, data) == 0)
+        g_print("wrote file %s.\n", basename);
+    else
+        g_print("*** ERROR: error writing file %s\n", basename);
+    g_free(basename);
 
-	g_free(data);
-	g_key_file_free(config);
+    g_free(data);
+    g_key_file_free(config);
 }
 
 #endif
@@ -877,112 +889,112 @@
 
 void configuration_read_filetype_extensions()
 {
-	guint i;
-	gsize len = 0;
-	gchar *sysconfigfile = g_strconcat(app->datadir, G_DIR_SEPARATOR_S,
-		"filetype_extensions.conf", NULL);
-	gchar *userconfigfile = g_strconcat(app->configdir, G_DIR_SEPARATOR_S,
-		"filetype_extensions.conf", NULL);
-	gchar **list;
-	GKeyFile *sysconfig = g_key_file_new();
-	GKeyFile *userconfig = g_key_file_new();
+    guint i;
+    gsize len = 0;
+    gchar *sysconfigfile = g_strconcat(app->datadir, G_DIR_SEPARATOR_S,
+        "filetype_extensions.conf", NULL);
+    gchar *userconfigfile = g_strconcat(app->configdir, G_DIR_SEPARATOR_S,
+        "filetype_extensions.conf", NULL);
+    gchar **list;
+    GKeyFile *sysconfig = g_key_file_new();
+    GKeyFile *userconfig = g_key_file_new();
 
-	g_key_file_load_from_file(sysconfig, sysconfigfile, G_KEY_FILE_NONE, NULL);
-	g_key_file_load_from_file(userconfig, userconfigfile, G_KEY_FILE_NONE, NULL);
+    g_key_file_load_from_file(sysconfig, sysconfigfile, G_KEY_FILE_NONE, NULL);
+    g_key_file_load_from_file(userconfig, userconfigfile, G_KEY_FILE_NONE, NULL);
 
-	// read the keys
-	for (i = 0; i < GEANY_MAX_FILE_TYPES; i++)
-	{
-		gboolean userset =
-			g_key_file_has_key(userconfig, "Extensions", filetypes[i]->name, NULL);
-		list = g_key_file_get_string_list(
-			(userset) ? userconfig : sysconfig, "Extensions", filetypes[i]->name, &len, NULL);
-		if (list && len > 0)
-		{
-			g_strfreev(filetypes[i]->pattern);
-			filetypes[i]->pattern = list;
-		}
-		else g_strfreev(list);
-	}
+    // read the keys
+    for (i = 0; i < GEANY_MAX_FILE_TYPES; i++)
+    {
+        gboolean userset =
+            g_key_file_has_key(userconfig, "Extensions", filetypes[i]->name, NULL);
+        list = g_key_file_get_string_list(
+            (userset) ? userconfig : sysconfig, "Extensions", filetypes[i]->name, &len, NULL);
+        if (list && len > 0)
+        {
+            g_strfreev(filetypes[i]->pattern);
+            filetypes[i]->pattern = list;
+        }
+        else g_strfreev(list);
+    }
 
-	g_free(sysconfigfile);
-	g_free(userconfigfile);
-	g_key_file_free(sysconfig);
-	g_key_file_free(userconfig);
+    g_free(sysconfigfile);
+    g_free(userconfigfile);
+    g_key_file_free(sysconfig);
+    g_key_file_free(userconfig);
 }
 
 
 void configuration_read_autocompletions()
 {
-	gsize i, j, len = 0, len_keys = 0;
-	gchar *sysconfigfile = g_strconcat(app->datadir, G_DIR_SEPARATOR_S,
-		"autocomplete.conf", NULL);
-	gchar *userconfigfile = g_strconcat(app->configdir, G_DIR_SEPARATOR_S,
-		"autocomplete.conf", NULL);
-	gchar **groups_user, **groups_sys;
-	gchar **keys_user, **keys_sys;
-	gchar *value;
-	GKeyFile *sysconfig = g_key_file_new();
-	GKeyFile *userconfig = g_key_file_new();
-	GHashTable *tmp;
+    gsize i, j, len = 0, len_keys = 0;
+    gchar *sysconfigfile = g_strconcat(app->datadir, G_DIR_SEPARATOR_S,
+        "autocomplete.conf", NULL);
+    gchar *userconfigfile = g_strconcat(app->configdir, G_DIR_SEPARATOR_S,
+        "autocomplete.conf", NULL);
+    gchar **groups_user, **groups_sys;
+    gchar **keys_user, **keys_sys;
+    gchar *value;
+    GKeyFile *sysconfig = g_key_file_new();
+    GKeyFile *userconfig = g_key_file_new();
+    GHashTable *tmp;
 
-	g_key_file_load_from_file(sysconfig, sysconfigfile, G_KEY_FILE_NONE, NULL);
-	g_key_file_load_from_file(userconfig, userconfigfile, G_KEY_FILE_NONE, NULL);
+    g_key_file_load_from_file(sysconfig, sysconfigfile, G_KEY_FILE_NONE, NULL);
+    g_key_file_load_from_file(userconfig, userconfigfile, G_KEY_FILE_NONE, NULL);
 
-	// keys are strings, values are GHashTables, so use g_free and g_hash_table_destroy
-	editor_prefs.auto_completions =
-		g_hash_table_new_full(g_str_hash, g_str_equal, g_free, (GDestroyNotify) g_hash_table_destroy);
+    // keys are strings, values are GHashTables, so use g_free and g_hash_table_destroy
+    editor_prefs.auto_completions =
+        g_hash_table_new_full(g_str_hash, g_str_equal, g_free, (GDestroyNotify) g_hash_table_destroy);
 
-	// first read all globally defined auto completions
-	groups_sys = g_key_file_get_groups(sysconfig, &len);
-	for (i = 0; i < len; i++)
-	{
-		keys_sys = g_key_file_get_keys(sysconfig, groups_sys[i], &len_keys, NULL);
-		// create new hash table for the read section (=> filetype)
-		tmp = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
-		g_hash_table_insert(editor_prefs.auto_completions, g_strdup(groups_sys[i]), tmp);
+    // first read all globally defined auto completions
+    groups_sys = g_key_file_get_groups(sysconfig, &len);
+    for (i = 0; i < len; i++)
+    {
+        keys_sys = g_key_file_get_keys(sysconfig, groups_sys[i], &len_keys, NULL);
+        // create new hash table for the read section (=> filetype)
+        tmp = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
+        g_hash_table_insert(editor_prefs.auto_completions, g_strdup(groups_sys[i]), tmp);
 
-		for (j = 0; j < len_keys; j++)
-		{
-			g_hash_table_insert(tmp, g_strdup(keys_sys[j]),
-						utils_get_setting_string(sysconfig, groups_sys[i], keys_sys[j], ""));
-		}
-		g_strfreev(keys_sys);
-	}
+        for (j = 0; j < len_keys; j++)
+        {
+            g_hash_table_insert(tmp, g_strdup(keys_sys[j]),
+                        utils_get_setting_string(sysconfig, groups_sys[i], keys_sys[j], ""));
+        }
+        g_strfreev(keys_sys);
+    }
 
-	// now read defined completions in user's configuration directory and add / replace them
-	groups_user = g_key_file_get_groups(userconfig, &len);
-	for (i = 0; i < len; i++)
-	{
-		keys_user = g_key_file_get_keys(userconfig, groups_user[i], &len_keys, NULL);
+    // now read defined completions in user's configuration directory and add / replace them
+    groups_user = g_key_file_get_groups(userconfig, &len);
+    for (i = 0; i < len; i++)
+    {
+        keys_user = g_key_file_get_keys(userconfig, groups_user[i], &len_keys, NULL);
 
-		tmp = g_hash_table_lookup(editor_prefs.auto_completions, groups_user[i]);
-		if (tmp == NULL)
-		{	// new key found, create hash table
-			tmp = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
-			g_hash_table_insert(editor_prefs.auto_completions, g_strdup(groups_user[i]), tmp);
-		}
-		for (j = 0; j < len_keys; j++)
-		{
-			value = g_hash_table_lookup(tmp, keys_user[j]);
-			if (value == NULL)
-			{	// value = NULL means the key doesn't yet exist, so insert
-				g_hash_table_insert(tmp, g_strdup(keys_user[j]),
-						utils_get_setting_string(userconfig, groups_user[i], keys_user[j], ""));
-			}
-			else
-			{	// old key and value will be freed by destroy function (g_free)
-				g_hash_table_replace(tmp, g_strdup(keys_user[j]),
-						utils_get_setting_string(userconfig, groups_user[i], keys_user[j], ""));
-			}
-		}
-		g_strfreev(keys_user);
-	}
+        tmp = g_hash_table_lookup(editor_prefs.auto_completions, groups_user[i]);
+        if (tmp == NULL)
+        {   // new key found, create hash table
+            tmp = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
+            g_hash_table_insert(editor_prefs.auto_completions, g_strdup(groups_user[i]), tmp);
+        }
+        for (j = 0; j < len_keys; j++)
+        {
+            value = g_hash_table_lookup(tmp, keys_user[j]);
+            if (value == NULL)
+            {   // value = NULL means the key doesn't yet exist, so insert
+                g_hash_table_insert(tmp, g_strdup(keys_user[j]),
+                        utils_get_setting_string(userconfig, groups_user[i], keys_user[j], ""));
+            }
+            else
+            {   // old key and value will be freed by destroy function (g_free)
+                g_hash_table_replace(tmp, g_strdup(keys_user[j]),
+                        utils_get_setting_string(userconfig, groups_user[i], keys_user[j], ""));
+            }
+        }
+        g_strfreev(keys_user);
+    }
 
-	g_free(sysconfigfile);
-	g_free(userconfigfile);
-	g_strfreev(groups_sys);
-	g_strfreev(groups_user);
-	g_key_file_free(sysconfig);
-	g_key_file_free(userconfig);
+    g_free(sysconfigfile);
+    g_free(userconfigfile);
+    g_strfreev(groups_sys);
+    g_strfreev(groups_user);
+    g_key_file_free(sysconfig);
+    g_key_file_free(userconfig);
 }
Index: src/keyfile.h
===================================================================
--- src/keyfile.h	(revision 2039)
+++ src/keyfile.h	(working copy)
@@ -31,6 +31,9 @@
 
 gboolean configuration_open_files();
 
+void load_session_files(GKeyFile *config);
+void save_session_files(GKeyFile *config);
+
 void configuration_read_filetype_extensions();
 
 void configuration_read_autocompletions();
Index: src/main.c
===================================================================
--- src/main.c	(revision 2039)
+++ src/main.c	(working copy)
@@ -83,8 +83,8 @@
 
 GeanyApp *app;
 
-GeanyStatus	 main_status;
-CommandLineOptions cl_options;	// fields initialised in parse_command_line_options
+GeanyStatus  main_status;
+CommandLineOptions cl_options;  // fields initialised in parse_command_line_options
 
 
 static gboolean want_plugins;
@@ -111,27 +111,27 @@
 // in alphabetical order of short options
 static GOptionEntry entries[] =
 {
-	{ "column", 0, 0, G_OPTION_ARG_INT, &cl_options.goto_column, N_("Set initial column number for the first opened file (useful in conjunction with --line)"), NULL },
-	{ "config", 'c', 0, G_OPTION_ARG_FILENAME, &alternate_config, N_("Use an alternate configuration directory"), NULL },
-	{ "debug", 'd', 0, G_OPTION_ARG_NONE, &debug_mode, N_("Runs in debug mode (means being verbose)"), NULL },
-	{ "ft-names", 0, 0, G_OPTION_ARG_NONE, &ft_names, N_("Print internal filetype names"), NULL },
-	{ "generate-tags", 'g', 0, G_OPTION_ARG_NONE, &generate_tags, N_("Generate global tags file (see documentation)"), NULL },
-	{ "no-preprocessing", 'P', 0, G_OPTION_ARG_NONE, &no_preprocessing, NULL, NULL },
-	{ "generate-data-files", 0, G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_NONE, &generate_datafiles, NULL, NULL },
+    { "column", 0, 0, G_OPTION_ARG_INT, &cl_options.goto_column, N_("Set initial column number for the first opened file (useful in conjunction with --line)"), NULL },
+    { "config", 'c', 0, G_OPTION_ARG_FILENAME, &alternate_config, N_("Use an alternate configuration directory"), NULL },
+    { "debug", 'd', 0, G_OPTION_ARG_NONE, &debug_mode, N_("Runs in debug mode (means being verbose)"), NULL },
+    { "ft-names", 0, 0, G_OPTION_ARG_NONE, &ft_names, N_("Print internal filetype names"), NULL },
+    { "generate-tags", 'g', 0, G_OPTION_ARG_NONE, &generate_tags, N_("Generate global tags file (see documentation)"), NULL },
+    { "no-preprocessing", 'P', 0, G_OPTION_ARG_NONE, &no_preprocessing, NULL, NULL },
+    { "generate-data-files", 0, G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_NONE, &generate_datafiles, NULL, NULL },
 #ifdef HAVE_SOCKET
-	{ "new-instance", 'i', 0, G_OPTION_ARG_NONE, &ignore_socket, N_("Don't open files in a running instance, force opening a new instance"), NULL },
+    { "new-instance", 'i', 0, G_OPTION_ARG_NONE, &ignore_socket, N_("Don't open files in a running instance, force opening a new instance"), NULL },
 #endif
-	{ "line", 'l', 0, G_OPTION_ARG_INT, &cl_options.goto_line, N_("Set initial line number for the first opened file"), NULL },
-	{ "no-msgwin", 'm', 0, G_OPTION_ARG_NONE, &no_msgwin, N_("Don't show message window at startup"), NULL },
-	{ "no-ctags", 'n', 0, G_OPTION_ARG_NONE, &ignore_global_tags, N_("Don't load auto completion data (see documentation)"), NULL },
-	{ "no-plugins", 'p', 0, G_OPTION_ARG_NONE, &no_plugins, N_("Don't load plugins"), NULL },
-	{ "no-session", 's', G_OPTION_FLAG_REVERSE, G_OPTION_ARG_NONE, &cl_options.load_session, N_("don't load the previous session's files"), NULL },
+    { "line", 'l', 0, G_OPTION_ARG_INT, &cl_options.goto_line, N_("Set initial line number for the first opened file"), NULL },
+    { "no-msgwin", 'm', 0, G_OPTION_ARG_NONE, &no_msgwin, N_("Don't show message window at startup"), NULL },
+    { "no-ctags", 'n', 0, G_OPTION_ARG_NONE, &ignore_global_tags, N_("Don't load auto completion data (see documentation)"), NULL },
+    { "no-plugins", 'p', 0, G_OPTION_ARG_NONE, &no_plugins, N_("Don't load plugins"), NULL },
+    { "no-session", 's', G_OPTION_FLAG_REVERSE, G_OPTION_ARG_NONE, &cl_options.load_session, N_("don't load the previous session's files"), NULL },
 #ifdef HAVE_VTE
-	{ "no-terminal", 't', 0, G_OPTION_ARG_NONE, &no_vte, N_("Don't load terminal support"), NULL },
-	{ "vte-lib", 0, 0, G_OPTION_ARG_FILENAME, &lib_vte, N_("Filename of libvte.so"), NULL },
+    { "no-terminal", 't', 0, G_OPTION_ARG_NONE, &no_vte, N_("Don't load terminal support"), NULL },
+    { "vte-lib", 0, 0, G_OPTION_ARG_FILENAME, &lib_vte, N_("Filename of libvte.so"), NULL },
 #endif
-	{ "version", 'v', 0, G_OPTION_ARG_NONE, &show_version, N_("Show version and exit"), NULL },
-	{ NULL, 0, 0, 0, NULL, NULL, NULL }
+    { "version", 'v', 0, G_OPTION_ARG_NONE, &show_version, N_("Show version and exit"), NULL },
+    { NULL, 0, 0, 0, NULL, NULL, NULL }
 };
 
 
@@ -140,14 +140,14 @@
 void geany_debug(gchar const *format, ...)
 {
 #ifndef GEANY_DEBUG
-	if (app != NULL && app->debug_mode)
+    if (app != NULL && app->debug_mode)
 #endif
-	{
-		va_list args;
-		va_start(args, format);
-		g_logv(G_LOG_DOMAIN, G_LOG_LEVEL_INFO, format, args);
-		va_end(args);
-	}
+    {
+        va_list args;
+        va_start(args, format);
+        g_logv(G_LOG_DOMAIN, G_LOG_LEVEL_INFO, format, args);
+        va_end(args);
+    }
 }
 
 /* special things for the initial setup of the checkboxes and related stuff
@@ -155,175 +155,175 @@
  * (all the following code is not perfect but it works for the moment) */
 static void apply_settings(void)
 {
-	ui_update_fold_items();
+    ui_update_fold_items();
 
-	// toolbar, message window and sidebar are by default visible, so don't change it if it is true
-	if (! prefs.toolbar_visible)
-	{
-		app->ignore_callback = TRUE;
-		gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(lookup_widget(app->window, "menu_show_toolbar1")), FALSE);
-		gtk_widget_hide(app->toolbar);
-		app->ignore_callback = FALSE;
-	}
-	if (! ui_prefs.msgwindow_visible)
-	{
-		app->ignore_callback = TRUE;
-		gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(lookup_widget(app->window, "menu_show_messages_window1")), FALSE);
-		gtk_widget_hide(lookup_widget(app->window, "scrolledwindow1"));
-		app->ignore_callback = FALSE;
-	}
-	if (! ui_prefs.sidebar_visible)
-	{
-		app->ignore_callback = TRUE;
-		gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(lookup_widget(app->window, "menu_show_sidebar1")), FALSE);
-		app->ignore_callback = FALSE;
-	}
-	ui_treeviews_show_hide(TRUE);
-	// sets the icon style of the toolbar
-	switch (prefs.toolbar_icon_style)
-	{
-		case GTK_TOOLBAR_BOTH:
-		{
-			//gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(lookup_widget(app->window, "images_and_text1")), TRUE);
-			gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(lookup_widget(ui_widgets.toolbar_menu, "images_and_text2")), TRUE);
-			break;
-		}
-		case GTK_TOOLBAR_ICONS:
-		{
-			//gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(lookup_widget(app->window, "images_only1")), TRUE);
-			gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(lookup_widget(ui_widgets.toolbar_menu, "images_only2")), TRUE);
-			break;
-		}
-		case GTK_TOOLBAR_TEXT:
-		{
-			//gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(lookup_widget(app->window, "text_only1")), TRUE);
-			gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(lookup_widget(ui_widgets.toolbar_menu, "text_only2")), TRUE);
-			break;
-		}
-	}
-	gtk_toolbar_set_style(GTK_TOOLBAR(app->toolbar), prefs.toolbar_icon_style);
+    // toolbar, message window and sidebar are by default visible, so don't change it if it is true
+    if (! prefs.toolbar_visible)
+    {
+        app->ignore_callback = TRUE;
+        gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(lookup_widget(app->window, "menu_show_toolbar1")), FALSE);
+        gtk_widget_hide(app->toolbar);
+        app->ignore_callback = FALSE;
+    }
+    if (! ui_prefs.msgwindow_visible)
+    {
+        app->ignore_callback = TRUE;
+        gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(lookup_widget(app->window, "menu_show_messages_window1")), FALSE);
+        gtk_widget_hide(lookup_widget(app->window, "scrolledwindow1"));
+        app->ignore_callback = FALSE;
+    }
+    if (! ui_prefs.sidebar_visible)
+    {
+        app->ignore_callback = TRUE;
+        gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(lookup_widget(app->window, "menu_show_sidebar1")), FALSE);
+        app->ignore_callback = FALSE;
+    }
+    ui_treeviews_show_hide(TRUE);
+    // sets the icon style of the toolbar
+    switch (prefs.toolbar_icon_style)
+    {
+        case GTK_TOOLBAR_BOTH:
+        {
+            //gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(lookup_widget(app->window, "images_and_text1")), TRUE);
+            gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(lookup_widget(ui_widgets.toolbar_menu, "images_and_text2")), TRUE);
+            break;
+        }
+        case GTK_TOOLBAR_ICONS:
+        {
+            //gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(lookup_widget(app->window, "images_only1")), TRUE);
+            gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(lookup_widget(ui_widgets.toolbar_menu, "images_only2")), TRUE);
+            break;
+        }
+        case GTK_TOOLBAR_TEXT:
+        {
+            //gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(lookup_widget(app->window, "text_only1")), TRUE);
+            gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(lookup_widget(ui_widgets.toolbar_menu, "text_only2")), TRUE);
+            break;
+        }
+    }
+    gtk_toolbar_set_style(GTK_TOOLBAR(app->toolbar), prefs.toolbar_icon_style);
 
-	// sets the icon size of the toolbar, use user preferences (.gtkrc) if not set
-	if (prefs.toolbar_icon_size == GTK_ICON_SIZE_SMALL_TOOLBAR ||
-		prefs.toolbar_icon_size == GTK_ICON_SIZE_LARGE_TOOLBAR)
-	{
-		gtk_toolbar_set_icon_size(GTK_TOOLBAR(app->toolbar), prefs.toolbar_icon_size);
-	}
-	ui_update_toolbar_icons(prefs.toolbar_icon_size);
+    // sets the icon size of the toolbar, use user preferences (.gtkrc) if not set
+    if (prefs.toolbar_icon_size == GTK_ICON_SIZE_SMALL_TOOLBAR ||
+        prefs.toolbar_icon_size == GTK_ICON_SIZE_LARGE_TOOLBAR)
+    {
+        gtk_toolbar_set_icon_size(GTK_TOOLBAR(app->toolbar), prefs.toolbar_icon_size);
+    }
+    ui_update_toolbar_icons(prefs.toolbar_icon_size);
 
-	// line number and markers margin are by default enabled
-	if (! editor_prefs.show_markers_margin)
-	{
-		gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(lookup_widget(app->window, "menu_markers_margin1")), FALSE);
-		editor_prefs.show_markers_margin = FALSE;
-	}
-	if (! editor_prefs.show_linenumber_margin)
-	{
-		gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(lookup_widget(app->window, "menu_linenumber_margin1")), FALSE);
-		editor_prefs.show_linenumber_margin = FALSE;
-	}
+    // line number and markers margin are by default enabled
+    if (! editor_prefs.show_markers_margin)
+    {
+        gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(lookup_widget(app->window, "menu_markers_margin1")), FALSE);
+        editor_prefs.show_markers_margin = FALSE;
+    }
+    if (! editor_prefs.show_linenumber_margin)
+    {
+        gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(lookup_widget(app->window, "menu_linenumber_margin1")), FALSE);
+        editor_prefs.show_linenumber_margin = FALSE;
+    }
 
-	// interprets the saved window geometry
-	if (prefs.save_winpos && ui_prefs.geometry[0] != -1)
-	{
-		gtk_window_move(GTK_WINDOW(app->window), ui_prefs.geometry[0], ui_prefs.geometry[1]);
-		gtk_window_set_default_size(GTK_WINDOW(app->window), ui_prefs.geometry[2], ui_prefs.geometry[3]);
-		if (ui_prefs.geometry[4] == 1)
-			gtk_window_maximize(GTK_WINDOW(app->window));
-	}
+    // interprets the saved window geometry
+    if (prefs.save_winpos && ui_prefs.geometry[0] != -1)
+    {
+        gtk_window_move(GTK_WINDOW(app->window), ui_prefs.geometry[0], ui_prefs.geometry[1]);
+        gtk_window_set_default_size(GTK_WINDOW(app->window), ui_prefs.geometry[2], ui_prefs.geometry[3]);
+        if (ui_prefs.geometry[4] == 1)
+            gtk_window_maximize(GTK_WINDOW(app->window));
+    }
 
-	// hide statusbar if desired
-	if (! prefs.statusbar_visible)
-	{
-		gtk_widget_hide(app->statusbar);
-	}
+    // hide statusbar if desired
+    if (! prefs.statusbar_visible)
+    {
+        gtk_widget_hide(app->statusbar);
+    }
 
-	app->ignore_callback = TRUE;
-	gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(
-				lookup_widget(app->window, "menu_line_breaking1")), editor_prefs.line_wrapping);
-	gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(
-				lookup_widget(app->window, "menu_use_auto_indentation1")),
-				(editor_prefs.indent_mode != INDENT_NONE));
-	app->ignore_callback = FALSE;
+    app->ignore_callback = TRUE;
+    gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(
+                lookup_widget(app->window, "menu_line_breaking1")), editor_prefs.line_wrapping);
+    gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(
+                lookup_widget(app->window, "menu_use_auto_indentation1")),
+                (editor_prefs.indent_mode != INDENT_NONE));
+    app->ignore_callback = FALSE;
 
-	// connect the toolbar dropdown menu for the new button
-	gtk_menu_tool_button_set_menu(GTK_MENU_TOOL_BUTTON(
-			lookup_widget(app->window, "menutoolbutton1")), ui_widgets.new_file_menu);
+    // connect the toolbar dropdown menu for the new button
+    gtk_menu_tool_button_set_menu(GTK_MENU_TOOL_BUTTON(
+            lookup_widget(app->window, "menutoolbutton1")), ui_widgets.new_file_menu);
 
-	// set the tab placements of the notebooks
-	gtk_notebook_set_tab_pos(GTK_NOTEBOOK(app->notebook), prefs.tab_pos_editor);
-	gtk_notebook_set_tab_pos(GTK_NOTEBOOK(msgwindow.notebook), prefs.tab_pos_msgwin);
-	gtk_notebook_set_tab_pos(GTK_NOTEBOOK(app->treeview_notebook), prefs.tab_pos_sidebar);
+    // set the tab placements of the notebooks
+    gtk_notebook_set_tab_pos(GTK_NOTEBOOK(app->notebook), prefs.tab_pos_editor);
+    gtk_notebook_set_tab_pos(GTK_NOTEBOOK(msgwindow.notebook), prefs.tab_pos_msgwin);
+    gtk_notebook_set_tab_pos(GTK_NOTEBOOK(app->treeview_notebook), prefs.tab_pos_sidebar);
 
-	ui_update_toolbar_items();
+    ui_update_toolbar_items();
 
-	// whether to show notebook tabs or not
-	gtk_notebook_set_show_tabs(GTK_NOTEBOOK(app->notebook), prefs.show_notebook_tabs);
+    // whether to show notebook tabs or not
+    gtk_notebook_set_show_tabs(GTK_NOTEBOOK(app->notebook), prefs.show_notebook_tabs);
 }
 
 
 static void main_init(void)
 {
-	// inits
-	app->window				= NULL;
-	app->project			= NULL;
-	ui_widgets.open_fontsel		= NULL;
-	ui_widgets.open_colorsel		= NULL;
-	ui_widgets.open_filesel		= NULL;
-	ui_widgets.save_filesel		= NULL;
-	ui_widgets.prefs_dialog		= NULL;
-	tv.default_tag_tree	= NULL;
-	main_status.main_window_realized= FALSE;
-	prefs.tab_order_ltr		= FALSE;
-	main_status.quitting			= FALSE;
-	app->ignore_callback	= FALSE;
-	app->tm_workspace				= tm_get_workspace(app->configdir);
-	ui_prefs.recent_queue				= g_queue_new();
-	main_status.opening_session_files		= FALSE;
+    // inits
+    app->window             = NULL;
+    app->project            = NULL;
+    ui_widgets.open_fontsel     = NULL;
+    ui_widgets.open_colorsel        = NULL;
+    ui_widgets.open_filesel     = NULL;
+    ui_widgets.save_filesel     = NULL;
+    ui_widgets.prefs_dialog     = NULL;
+    tv.default_tag_tree = NULL;
+    main_status.main_window_realized= FALSE;
+    prefs.tab_order_ltr     = FALSE;
+    main_status.quitting            = FALSE;
+    app->ignore_callback    = FALSE;
+    app->tm_workspace               = tm_get_workspace(app->configdir);
+    ui_prefs.recent_queue               = g_queue_new();
+    main_status.opening_session_files       = FALSE;
 
-	app->window = create_window1();
-	ui_widgets.new_file_menu = gtk_menu_new();
-	ui_widgets.recent_files_toolbar = gtk_menu_new();
-	ui_widgets.recent_files_menuitem = lookup_widget(app->window, "recent_files1");
-	ui_widgets.recent_files_menubar = gtk_menu_new();
-	gtk_menu_item_set_submenu(GTK_MENU_ITEM(ui_widgets.recent_files_menuitem),
-							ui_widgets.recent_files_menubar);
+    app->window = create_window1();
+    ui_widgets.new_file_menu = gtk_menu_new();
+    ui_widgets.recent_files_toolbar = gtk_menu_new();
+    ui_widgets.recent_files_menuitem = lookup_widget(app->window, "recent_files1");
+    ui_widgets.recent_files_menubar = gtk_menu_new();
+    gtk_menu_item_set_submenu(GTK_MENU_ITEM(ui_widgets.recent_files_menuitem),
+                            ui_widgets.recent_files_menubar);
 
-	// store important pointers in the GeanyApp structure
-	app->toolbar = lookup_widget(app->window, "toolbar1");
-	app->treeview_notebook = lookup_widget(app->window, "notebook3");
-	app->notebook = lookup_widget(app->window, "notebook1");
-	app->statusbar = lookup_widget(app->window, "statusbar");
-	app->popup_menu = create_edit_menu1();
-	ui_widgets.toolbar_menu = create_toolbar_popup_menu1();
-	ui_widgets.popup_goto_items[0] = lookup_widget(app->popup_menu, "goto_tag_definition1");
-	ui_widgets.popup_goto_items[1] = lookup_widget(app->popup_menu, "goto_tag_declaration1");
-	ui_widgets.popup_goto_items[2] = lookup_widget(app->popup_menu, "find_usage1");
-	ui_widgets.popup_copy_items[0] = lookup_widget(app->popup_menu, "cut1");
-	ui_widgets.popup_copy_items[1] = lookup_widget(app->popup_menu, "copy1");
-	ui_widgets.popup_copy_items[2] = lookup_widget(app->popup_menu, "delete1");
-	ui_widgets.menu_copy_items[0] = lookup_widget(app->window, "menu_cut1");
-	ui_widgets.menu_copy_items[1] = lookup_widget(app->window, "menu_copy1");
-	ui_widgets.menu_copy_items[2] = lookup_widget(app->window, "menu_delete1");
-	ui_widgets.menu_insert_include_items[0] = lookup_widget(app->popup_menu, "insert_include1");
-	ui_widgets.menu_insert_include_items[1] = lookup_widget(app->window, "insert_include2");
-	ui_widgets.save_buttons[0] = lookup_widget(app->window, "menu_save1");
-	ui_widgets.save_buttons[1] = lookup_widget(app->window, "toolbutton10");
-	ui_widgets.save_buttons[2] = lookup_widget(app->window, "menu_save_all1");
-	ui_widgets.save_buttons[3] = lookup_widget(app->window, "toolbutton22");
-	ui_widgets.redo_items[0] = lookup_widget(app->popup_menu, "redo1");
-	ui_widgets.redo_items[1] = lookup_widget(app->window, "menu_redo2");
-	ui_widgets.redo_items[2] = lookup_widget(app->window, "toolbutton_redo");
-	ui_widgets.undo_items[0] = lookup_widget(app->popup_menu, "undo1");
-	ui_widgets.undo_items[1] = lookup_widget(app->window, "menu_undo2");
-	ui_widgets.undo_items[2] = lookup_widget(app->window, "toolbutton_undo");
+    // store important pointers in the GeanyApp structure
+    app->toolbar = lookup_widget(app->window, "toolbar1");
+    app->treeview_notebook = lookup_widget(app->window, "notebook3");
+    app->notebook = lookup_widget(app->window, "notebook1");
+    app->statusbar = lookup_widget(app->window, "statusbar");
+    app->popup_menu = create_edit_menu1();
+    ui_widgets.toolbar_menu = create_toolbar_popup_menu1();
+    ui_widgets.popup_goto_items[0] = lookup_widget(app->popup_menu, "goto_tag_definition1");
+    ui_widgets.popup_goto_items[1] = lookup_widget(app->popup_menu, "goto_tag_declaration1");
+    ui_widgets.popup_goto_items[2] = lookup_widget(app->popup_menu, "find_usage1");
+    ui_widgets.popup_copy_items[0] = lookup_widget(app->popup_menu, "cut1");
+    ui_widgets.popup_copy_items[1] = lookup_widget(app->popup_menu, "copy1");
+    ui_widgets.popup_copy_items[2] = lookup_widget(app->popup_menu, "delete1");
+    ui_widgets.menu_copy_items[0] = lookup_widget(app->window, "menu_cut1");
+    ui_widgets.menu_copy_items[1] = lookup_widget(app->window, "menu_copy1");
+    ui_widgets.menu_copy_items[2] = lookup_widget(app->window, "menu_delete1");
+    ui_widgets.menu_insert_include_items[0] = lookup_widget(app->popup_menu, "insert_include1");
+    ui_widgets.menu_insert_include_items[1] = lookup_widget(app->window, "insert_include2");
+    ui_widgets.save_buttons[0] = lookup_widget(app->window, "menu_save1");
+    ui_widgets.save_buttons[1] = lookup_widget(app->window, "toolbutton10");
+    ui_widgets.save_buttons[2] = lookup_widget(app->window, "menu_save_all1");
+    ui_widgets.save_buttons[3] = lookup_widget(app->window, "toolbutton22");
+    ui_widgets.redo_items[0] = lookup_widget(app->popup_menu, "redo1");
+    ui_widgets.redo_items[1] = lookup_widget(app->window, "menu_redo2");
+    ui_widgets.redo_items[2] = lookup_widget(app->window, "toolbutton_redo");
+    ui_widgets.undo_items[0] = lookup_widget(app->popup_menu, "undo1");
+    ui_widgets.undo_items[1] = lookup_widget(app->window, "menu_undo2");
+    ui_widgets.undo_items[2] = lookup_widget(app->window, "toolbutton_undo");
 
-	ui_init();
+    ui_init();
 
-	// set widget names for matching with .gtkrc-2.0
-	gtk_widget_set_name(app->window, "GeanyMainWindow");
-	gtk_widget_set_name(ui_widgets.toolbar_menu, "GeanyToolbarMenu");
-	gtk_widget_set_name(app->popup_menu, "GeanyEditMenu");
+    // set widget names for matching with .gtkrc-2.0
+    gtk_widget_set_name(app->window, "GeanyMainWindow");
+    gtk_widget_set_name(ui_widgets.toolbar_menu, "GeanyToolbarMenu");
+    gtk_widget_set_name(app->popup_menu, "GeanyEditMenu");
 }
 
 
@@ -331,537 +331,539 @@
  * N.B. the result should be freed and may contain '/../' or '/./ ' */
 gchar *get_argv_filename(const gchar *filename)
 {
-	gchar *result;
+    gchar *result;
 
-	if (g_path_is_absolute(filename))
-		result = g_strdup(filename);
-	else
-	{
-		// use current dir
-		gchar *cur_dir = g_get_current_dir();
+    if (g_path_is_absolute(filename))
+        result = g_strdup(filename);
+    else
+    {
+        // use current dir
+        gchar *cur_dir = g_get_current_dir();
 
-		result = g_strjoin(
-			G_DIR_SEPARATOR_S, cur_dir, filename, NULL);
-		g_free(cur_dir);
-	}
-	return result;
+        result = g_strjoin(
+            G_DIR_SEPARATOR_S, cur_dir, filename, NULL);
+        g_free(cur_dir);
+    }
+    return result;
 }
 
 
 static void setup_paths()
 {
-	gchar *data_dir;
-	gchar *doc_dir;
+    gchar *data_dir;
+    gchar *doc_dir;
 
-	// set paths
+    // set paths
 #ifdef G_OS_WIN32
-	// take the installation directory(the one where geany.exe is located) as the base for the
-	// documentation and data files
-	gchar *install_dir = g_win32_get_package_installation_directory("geany", NULL);
+    // take the installation directory(the one where geany.exe is located) as the base for the
+    // documentation and data files
+    gchar *install_dir = g_win32_get_package_installation_directory("geany", NULL);
 
-	data_dir = g_strconcat(install_dir, "\\data", NULL); // e.g. C:\Program Files\geany\data
-	doc_dir = g_strconcat(install_dir, "\\doc", NULL);
+    data_dir = g_strconcat(install_dir, "\\data", NULL); // e.g. C:\Program Files\geany\data
+    doc_dir = g_strconcat(install_dir, "\\doc", NULL);
 
-	g_free(install_dir);
+    g_free(install_dir);
 #else
-	data_dir = g_strdup(PACKAGE_DATA_DIR "/" PACKAGE "/"); // e.g. /usr/share/geany
-	doc_dir = g_strdup(PACKAGE_DATA_DIR "/doc/" PACKAGE "/html/");
+    data_dir = g_strdup(PACKAGE_DATA_DIR "/" PACKAGE "/"); // e.g. /usr/share/geany
+    doc_dir = g_strdup(PACKAGE_DATA_DIR "/doc/" PACKAGE "/html/");
 #endif
 
-	// convert path names to locale encoding
-	app->datadir = utils_get_locale_from_utf8(data_dir);
-	app->docdir = utils_get_locale_from_utf8(doc_dir);
+    // convert path names to locale encoding
+    app->datadir = utils_get_locale_from_utf8(data_dir);
+    app->docdir = utils_get_locale_from_utf8(doc_dir);
 
-	g_free(data_dir);
-	g_free(doc_dir);
+    g_free(data_dir);
+    g_free(doc_dir);
 }
 
 
 static void locale_init()
 {
 #ifdef ENABLE_NLS
-	gchar *locale_dir = NULL;
+    gchar *locale_dir = NULL;
 
 #if HAVE_LOCALE_H
-	setlocale(LC_ALL, "");
+    setlocale(LC_ALL, "");
 #endif
 
 #ifdef G_OS_WIN32
-	gchar *install_dir = g_win32_get_package_installation_directory("geany", NULL);
-	// e.g. C:\Program Files\geany\lib\locale
-	locale_dir = g_strconcat(install_dir, "\\lib\\locale", NULL);
-	g_free(install_dir);
+    gchar *install_dir = g_win32_get_package_installation_directory("geany", NULL);
+    // e.g. C:\Program Files\geany\lib\locale
+    locale_dir = g_strconcat(install_dir, "\\lib\\locale", NULL);
+    g_free(install_dir);
 #else
-	locale_dir = g_strdup(PACKAGE_LOCALE_DIR);
+    locale_dir = g_strdup(PACKAGE_LOCALE_DIR);
 #endif
 
-	bindtextdomain(GETTEXT_PACKAGE, locale_dir);
-	bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
-	textdomain(GETTEXT_PACKAGE);
-	g_free(locale_dir);
+    bindtextdomain(GETTEXT_PACKAGE, locale_dir);
+    bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
+    textdomain(GETTEXT_PACKAGE);
+    g_free(locale_dir);
 #endif
 }
 
 
 static void parse_command_line_options(gint *argc, gchar ***argv)
 {
-	GOptionContext *context;
-	GError *error = NULL;
+    GOptionContext *context;
+    GError *error = NULL;
 
-	// first initialise cl_options fields with default values
-	cl_options.load_session = TRUE;
-	cl_options.goto_line = -1;
-	cl_options.goto_column = -1;
+    // first initialise cl_options fields with default values
+    cl_options.load_session = TRUE;
+    cl_options.goto_line = -1;
+    cl_options.goto_column = -1;
 
-	context = g_option_context_new(_("[FILES...]"));
-	g_option_context_add_main_entries(context, entries, GETTEXT_PACKAGE);
-	g_option_group_set_translation_domain(g_option_context_get_main_group(context), GETTEXT_PACKAGE);
-	g_option_context_add_group(context, gtk_get_option_group(TRUE));
-	g_option_context_parse(context, argc, argv, &error);
-	g_option_context_free(context);
+    context = g_option_context_new(_("[FILES...]"));
+    g_option_context_add_main_entries(context, entries, GETTEXT_PACKAGE);
+    g_option_group_set_translation_domain(g_option_context_get_main_group(context), GETTEXT_PACKAGE);
+    g_option_context_add_group(context, gtk_get_option_group(TRUE));
+    g_option_context_parse(context, argc, argv, &error);
+    g_option_context_free(context);
 
-	if (show_version)
-	{
-		printf(PACKAGE " " VERSION " ");
-		printf(_("(built on %s with GTK %d.%d.%d, GLib %d.%d.%d)"),
-				__DATE__, GTK_MAJOR_VERSION, GTK_MINOR_VERSION, GTK_MICRO_VERSION,
-				GLIB_MAJOR_VERSION, GLIB_MINOR_VERSION, GLIB_MICRO_VERSION);
-		printf("\n");
+    if (show_version)
+    {
+        printf(PACKAGE " " VERSION " ");
+        printf(_("(built on %s with GTK %d.%d.%d, GLib %d.%d.%d)"),
+                __DATE__, GTK_MAJOR_VERSION, GTK_MINOR_VERSION, GTK_MICRO_VERSION,
+                GLIB_MAJOR_VERSION, GLIB_MINOR_VERSION, GLIB_MICRO_VERSION);
+        printf("\n");
 
-		exit(0);
-	}
+        exit(0);
+    }
 
 #ifdef GEANY_DEBUG
-	app->debug_mode = TRUE;
-	geany_debug("debug mode built in (can't be disabled)");
+    app->debug_mode = TRUE;
+    geany_debug("debug mode built in (can't be disabled)");
 #else
-	app->debug_mode = debug_mode;
+    app->debug_mode = debug_mode;
 #endif
 
-	if (alternate_config)
-	{
-		geany_debug("alternate config: %s", alternate_config);
-		app->configdir = alternate_config;
-	}
-	else
-		app->configdir = g_strconcat(GEANY_HOME_DIR, G_DIR_SEPARATOR_S, ".", PACKAGE, NULL);
+    if (alternate_config)
+    {
+        geany_debug("alternate config: %s", alternate_config);
+        app->configdir = alternate_config;
+    }
+    else
+        app->configdir = g_strconcat(GEANY_HOME_DIR, G_DIR_SEPARATOR_S, ".", PACKAGE, NULL);
 
 #ifdef GEANY_DEBUG
-	if (generate_datafiles)
-	{
-		filetypes_init_types();
-		configuration_generate_data_files();	// currently only filetype_extensions.conf
-		exit(0);
-	}
+    if (generate_datafiles)
+    {
+        filetypes_init_types();
+        configuration_generate_data_files();    // currently only filetype_extensions.conf
+        exit(0);
+    }
 #endif
-	if (generate_tags)
-	{
-		gboolean ret;
+    if (generate_tags)
+    {
+        gboolean ret;
 
-		filetypes_init_types();
-		configuration_read_filetype_extensions();	// needed for *.lang.tags filetype matching
-		ret = symbols_generate_global_tags(*argc, *argv, ! no_preprocessing);
-		exit(ret);
-	}
+        filetypes_init_types();
+        configuration_read_filetype_extensions();   // needed for *.lang.tags filetype matching
+        ret = symbols_generate_global_tags(*argc, *argv, ! no_preprocessing);
+        exit(ret);
+    }
 
-	if (ft_names)
-	{
-		int i;
+    if (ft_names)
+    {
+        int i;
 
-		printf("Geany's internal filetype names:\n");
-		filetypes_init_types();
-		for (i = 0; i < GEANY_MAX_FILE_TYPES; i++)
-		{
-			printf("%s\n", filetypes[i]->name);
-		}
-		filetypes_free_types();
-		exit(0);
-	}
+        printf("Geany's internal filetype names:\n");
+        filetypes_init_types();
+        for (i = 0; i < GEANY_MAX_FILE_TYPES; i++)
+        {
+            printf("%s\n", filetypes[i]->name);
+        }
+        filetypes_free_types();
+        exit(0);
+    }
 
 #ifdef HAVE_SOCKET
-	socket_info.ignore_socket = ignore_socket;
-	if (ignore_socket)
-		cl_options.load_session = FALSE;
+    socket_info.ignore_socket = ignore_socket;
+    if (ignore_socket)
+        cl_options.load_session = FALSE;
 #endif
 #ifdef HAVE_VTE
-	vte_info.lib_vte = lib_vte;
+    vte_info.lib_vte = lib_vte;
 #endif
-	cl_options.ignore_global_tags = ignore_global_tags;
+    cl_options.ignore_global_tags = ignore_global_tags;
 }
 
 
 // Returns 0 if config dir is OK.
 static gint setup_config_dir()
 {
-	gint mkdir_result = 0;
-	gchar *tmp = app->configdir;
+    gint mkdir_result = 0;
+    gchar *tmp = app->configdir;
 
-	// convert configdir to locale encoding to avoid troubles
-	app->configdir = utils_get_locale_from_utf8(app->configdir);
-	g_free(tmp);
+    // convert configdir to locale encoding to avoid troubles
+    app->configdir = utils_get_locale_from_utf8(app->configdir);
+    g_free(tmp);
 
-	mkdir_result = utils_make_settings_dir();
-	if (mkdir_result != 0)
-	{
-		if (! dialogs_show_question(
-			_("Configuration directory could not be created (%s).\nThere could be some problems "
-			  "using Geany without a configuration directory.\nStart Geany anyway?"),
-			  g_strerror(mkdir_result)))
-		{
-			exit(0);
-		}
-	}
-	return mkdir_result;
+    mkdir_result = utils_make_settings_dir();
+    if (mkdir_result != 0)
+    {
+        if (! dialogs_show_question(
+            _("Configuration directory could not be created (%s).\nThere could be some problems "
+              "using Geany without a configuration directory.\nStart Geany anyway?"),
+              g_strerror(mkdir_result)))
+        {
+            exit(0);
+        }
+    }
+    return mkdir_result;
 }
 
 
 static void signal_cb(gint sig)
 {
-	if (sig == SIGTERM)
-	{
-		on_exit_clicked(NULL, NULL);
-	}
+    if (sig == SIGTERM)
+    {
+        on_exit_clicked(NULL, NULL);
+    }
 }
 
 
 // open files from command line
 static gboolean open_cl_files(gint argc, gchar **argv)
 {
-	gint i;
+    gint i;
 
-	if (argc <= 1) return FALSE;
+    if (argc <= 1) return FALSE;
 
-	document_delay_colourise();
+    document_delay_colourise();
 
-	for(i = 1; i < argc; i++)
-	{
-		gchar *filename = get_argv_filename(argv[i]);
+    for(i = 1; i < argc; i++)
+    {
+        gchar *filename = get_argv_filename(argv[i]);
 
-		if (filename != NULL &&
-			g_file_test(filename, G_FILE_TEST_IS_REGULAR | G_FILE_TEST_IS_SYMLINK))
-		{
-			gint idx;
+        if (filename != NULL &&
+            g_file_test(filename, G_FILE_TEST_IS_REGULAR | G_FILE_TEST_IS_SYMLINK))
+        {
+            gint idx;
 
-			idx = document_open_file(filename, FALSE, NULL, NULL);
-			// add recent file manually because opening_session_files is set
-			if (DOC_IDX_VALID(idx))
-				ui_add_recent_file(doc_list[idx].file_name);
-		}
-		else if (filename != NULL)
-		{	// create new file if it doesn't exist
-			gint idx;
+            idx = document_open_file(filename, FALSE, NULL, NULL);
+            // add recent file manually because opening_session_files is set
+            if (DOC_IDX_VALID(idx))
+                ui_add_recent_file(doc_list[idx].file_name);
+        }
+        else if (filename != NULL)
+        {   // create new file if it doesn't exist
+            gint idx;
 
-			idx = document_new_file(filename, NULL, NULL);
-			if (DOC_IDX_VALID(idx))
-				ui_add_recent_file(doc_list[idx].file_name);
-		}
-		else
-		{
-			gchar *msg = _("Could not find file '%s'.");
+            idx = document_new_file(filename, NULL, NULL);
+            if (DOC_IDX_VALID(idx))
+                ui_add_recent_file(doc_list[idx].file_name);
+        }
+        else
+        {
+            gchar *msg = _("Could not find file '%s'.");
 
-			g_printerr(msg, filename);	// also print to the terminal
-			g_printerr("\n");
-			ui_set_statusbar(TRUE, msg, filename);
-		}
-		g_free(filename);
-	}
-	document_colourise_new();
-	return TRUE;
+            g_printerr(msg, filename);  // also print to the terminal
+            g_printerr("\n");
+            ui_set_statusbar(TRUE, msg, filename);
+        }
+        g_free(filename);
+    }
+    document_colourise_new();
+    return TRUE;
 }
 
 
 static void load_project_file()
 {
-	gchar *locale_filename;
+    gchar *locale_filename;
 
-	g_return_if_fail(project_prefs.session_file != NULL);
+    g_return_if_fail(project_prefs.session_file != NULL);
 
-	locale_filename = utils_get_locale_from_utf8(project_prefs.session_file);
+    locale_filename = utils_get_locale_from_utf8(project_prefs.session_file);
 
-	if (*locale_filename)
-		project_load_file(locale_filename);
+    if (*locale_filename)
+        project_load_file(locale_filename);
 
-	g_free(locale_filename);
-	g_free(project_prefs.session_file);	// no longer needed
+    g_free(locale_filename);
+    g_free(project_prefs.session_file); // no longer needed
 }
 
 
 static void load_settings()
 {
-	configuration_load();
-	// let cmdline options overwrite configuration settings
+    configuration_load();
+    // let cmdline options overwrite configuration settings
 #ifdef HAVE_VTE
-	vte_info.have_vte = (no_vte) ? FALSE : vte_info.load_vte;
+    vte_info.have_vte = (no_vte) ? FALSE : vte_info.load_vte;
 #endif
-	if (no_msgwin) ui_prefs.msgwindow_visible = FALSE;
+    if (no_msgwin) ui_prefs.msgwindow_visible = FALSE;
 
-	want_plugins = prefs.load_plugins && !no_plugins;
+    want_plugins = prefs.load_plugins && !no_plugins;
 }
 
 
 gint main(gint argc, gchar **argv)
 {
-	gint idx;
-	gint config_dir_result;
+    gint idx;
+    gint config_dir_result;
 
-	app = g_new0(GeanyApp, 1);
-	memset(&main_status, 0, sizeof(GeanyStatus));
-	memset(&prefs, 0, sizeof(GeanyPrefs));
-	memset(&ui_prefs, 0, sizeof(UIPrefs));
-	memset(&ui_widgets, 0, sizeof(UIWidgets));
+    app = g_new0(GeanyApp, 1);
+    memset(&main_status, 0, sizeof(GeanyStatus));
+    memset(&prefs, 0, sizeof(GeanyPrefs));
+    memset(&ui_prefs, 0, sizeof(UIPrefs));
+    memset(&ui_widgets, 0, sizeof(UIWidgets));
 
-	setup_paths();
-	locale_init();
-	parse_command_line_options(&argc, &argv);
+    setup_paths();
+    locale_init();
+    parse_command_line_options(&argc, &argv);
 
-	gtk_set_locale();
+    gtk_set_locale();
 
-	signal(SIGTERM, signal_cb);
+    signal(SIGTERM, signal_cb);
 #ifdef G_OS_UNIX
-	// SIGQUIT is used to kill spawned children and we get also this signal, so ignore
-	signal(SIGQUIT, SIG_IGN);
-	// ignore SIGPIPE signal for preventing sudden death of program
-	signal(SIGPIPE, SIG_IGN);
+    // SIGQUIT is used to kill spawned children and we get also this signal, so ignore
+    signal(SIGQUIT, SIG_IGN);
+    // ignore SIGPIPE signal for preventing sudden death of program
+    signal(SIGPIPE, SIG_IGN);
 #endif
 
-	config_dir_result = setup_config_dir();
+    config_dir_result = setup_config_dir();
 #ifdef HAVE_SOCKET
     // check and create (unix domain) socket for remote operation
-	if (! socket_info.ignore_socket)
-	{
-		socket_info.lock_socket = -1;
-		socket_info.lock_socket_tag = 0;
-		socket_info.lock_socket = socket_init(argc, argv);
-		if (socket_info.lock_socket < 0)
-		{
-			// Socket exists
-			if (argc > 1)	// filenames were sent to first instance, so quit
-			{
-				g_free(app->configdir);
-				g_free(app->datadir);
-				g_free(app->docdir);
-				g_free(app);
-				return 0;
-			}
-			// Start a new instance if no command line strings were passed
-			socket_info.ignore_socket = TRUE;
-			cl_options.load_session = FALSE;
-		}
-	}
+    if (! socket_info.ignore_socket)
+    {
+        socket_info.lock_socket = -1;
+        socket_info.lock_socket_tag = 0;
+        socket_info.lock_socket = socket_init(argc, argv);
+        if (socket_info.lock_socket < 0)
+        {
+            // Socket exists
+            if (argc > 1)   // filenames were sent to first instance, so quit
+            {
+                g_free(app->configdir);
+                g_free(app->datadir);
+                g_free(app->docdir);
+                g_free(app);
+                return 0;
+            }
+            // Start a new instance if no command line strings were passed
+            socket_info.ignore_socket = TRUE;
+            cl_options.load_session = FALSE;
+        }
+    }
 #endif
 
-	geany_debug("Geany %s, GTK+ %u.%u.%u, GLib %u.%u.%u",
-		VERSION,
-		gtk_major_version, gtk_minor_version, gtk_micro_version,
-		glib_major_version, glib_minor_version, glib_micro_version);
-	gtk_init(&argc, &argv);
+    geany_debug("Geany %s, GTK+ %u.%u.%u, GLib %u.%u.%u",
+        VERSION,
+        gtk_major_version, gtk_minor_version, gtk_micro_version,
+        glib_major_version, glib_minor_version, glib_micro_version);
+    gtk_init(&argc, &argv);
 
-	// inits
-	main_init();
-	gtk_widget_set_size_request(app->window, GEANY_WINDOW_MINIMAL_WIDTH, GEANY_WINDOW_MINIMAL_HEIGHT);
-	gtk_window_set_default_size(GTK_WINDOW(app->window), GEANY_WINDOW_DEFAULT_WIDTH, GEANY_WINDOW_DEFAULT_HEIGHT);
-	encodings_init();
+    // inits
+    main_init();
+    gtk_widget_set_size_request(app->window, GEANY_WINDOW_MINIMAL_WIDTH, GEANY_WINDOW_MINIMAL_HEIGHT);
+    gtk_window_set_default_size(GTK_WINDOW(app->window), GEANY_WINDOW_DEFAULT_WIDTH, GEANY_WINDOW_DEFAULT_HEIGHT);
+    encodings_init();
 
-	load_settings();
+    load_settings();
 
-	msgwin_init();
-	build_init();
-	search_init();
-	ui_create_insert_menu_items();
-	ui_create_insert_date_menu_items();
-	keybindings_init();
-	tools_create_insert_custom_command_menu_items();
-	notebook_init();
-	filetypes_init();
-	templates_init();
-	navqueue_init();
-	document_init_doclist();
-	treeviews_init();
-	configuration_read_filetype_extensions();
-	configuration_read_autocompletions();
+    msgwin_init();
+    build_init();
+    search_init();
+    ui_create_insert_menu_items();
+    ui_create_insert_date_menu_items();
+    keybindings_init();
+    tools_create_insert_custom_command_menu_items();
+    notebook_init();
+    filetypes_init();
+    templates_init();
+    navqueue_init();
+    document_init_doclist();
+    treeviews_init();
+    configuration_read_filetype_extensions();
+    configuration_read_autocompletions();
 
-	// set window icon
-	{
-		GdkPixbuf *pb;
+    // set window icon
+    {
+        GdkPixbuf *pb;
 
-		pb = ui_new_pixbuf_from_inline(GEANY_IMAGE_LOGO, FALSE);
-		gtk_window_set_icon(GTK_WINDOW(app->window), pb);
-		g_object_unref(pb);	// free our reference
-	}
+        pb = ui_new_pixbuf_from_inline(GEANY_IMAGE_LOGO, FALSE);
+        gtk_window_set_icon(GTK_WINDOW(app->window), pb);
+        g_object_unref(pb); // free our reference
+    }
 
-	// registering some basic events
-	g_signal_connect(G_OBJECT(app->window), "delete_event", G_CALLBACK(on_exit_clicked), NULL);
-	g_signal_connect(G_OBJECT(app->window), "key-press-event", G_CALLBACK(keybindings_got_event), NULL);
-	g_signal_connect(G_OBJECT(app->toolbar), "button-press-event", G_CALLBACK(toolbar_popup_menu), NULL);
-	g_signal_connect(G_OBJECT(lookup_widget(app->window, "textview_scribble")),
-							"motion-notify-event", G_CALLBACK(on_motion_event), NULL);
-	g_signal_connect(G_OBJECT(lookup_widget(app->window, "entry1")),
-							"motion-notify-event", G_CALLBACK(on_motion_event), NULL);
-	g_signal_connect(G_OBJECT(lookup_widget(app->window, "entry_goto_line")),
-							"motion-notify-event", G_CALLBACK(on_motion_event), NULL);
+    // registering some basic events
+    g_signal_connect(G_OBJECT(app->window), "delete_event", G_CALLBACK(on_exit_clicked), NULL);
+    g_signal_connect(G_OBJECT(app->window), "key-press-event", G_CALLBACK(keybindings_got_event), NULL);
+    g_signal_connect(G_OBJECT(app->toolbar), "button-press-event", G_CALLBACK(toolbar_popup_menu), NULL);
+    g_signal_connect(G_OBJECT(lookup_widget(app->window, "textview_scribble")),
+                            "motion-notify-event", G_CALLBACK(on_motion_event), NULL);
+    g_signal_connect(G_OBJECT(lookup_widget(app->window, "entry1")),
+                            "motion-notify-event", G_CALLBACK(on_motion_event), NULL);
+    g_signal_connect(G_OBJECT(lookup_widget(app->window, "entry_goto_line")),
+                            "motion-notify-event", G_CALLBACK(on_motion_event), NULL);
 
 #ifdef HAVE_VTE
-	vte_init();
+    vte_init();
 #endif
-	ui_create_recent_menu();
+    ui_create_recent_menu();
 
-	ui_set_statusbar(TRUE, _("This is Geany %s."), VERSION);
-	if (config_dir_result != 0)
-		ui_set_statusbar(TRUE, _("Configuration directory could not be created (%s)."),
-			g_strerror(config_dir_result));
+    ui_set_statusbar(TRUE, _("This is Geany %s."), VERSION);
+    if (config_dir_result != 0)
+        ui_set_statusbar(TRUE, _("Configuration directory could not be created (%s)."),
+            g_strerror(config_dir_result));
 
-	// apply all configuration options
-	apply_settings();
+    // apply all configuration options
+    apply_settings();
 
 #ifdef HAVE_PLUGINS
-	// load any enabled plugins before we open any documents
-	if (want_plugins)
-		plugins_init();
+    // load any enabled plugins before we open any documents
+    if (want_plugins)
+        plugins_init();
 #endif
 
-	// load any command line files or session files
-	main_status.opening_session_files = TRUE;
-	if (! open_cl_files(argc, argv))
-	{
-		if (prefs.load_session && cl_options.load_session)
-		{
-			load_project_file();
+    // load any command line files or session files
+    main_status.opening_session_files = TRUE;
+    if (! open_cl_files(argc, argv))
+    {
+        if (prefs.load_session && cl_options.load_session)
+        {
+            load_project_file();
 
-			// load session files
-			if (! configuration_open_files())
-			{
-				ui_update_popup_copy_items(-1);
-				ui_update_popup_reundo_items(-1);
-			}
-		}
-	}
-	main_status.opening_session_files = FALSE;
+            // load session files into tabs, as they are found in the session_files variable
+            if (! configuration_open_files())
+            {
+                ui_update_popup_copy_items(-1);
+                ui_update_popup_reundo_items(-1);
+            }
+        }
+    }
+    main_status.opening_session_files = FALSE;
 
-	// open a new file if no other file was opened
-	if (gtk_notebook_get_n_pages(GTK_NOTEBOOK(app->notebook)) == 0)
-		document_new_file(NULL, NULL, NULL);
+    // open a new file if no other file was opened
+    if (gtk_notebook_get_n_pages(GTK_NOTEBOOK(app->notebook)) == 0)
+        document_new_file(NULL, NULL, NULL);
 
-	ui_document_buttons_update();
-	ui_save_buttons_toggle(FALSE);
+    ui_document_buttons_update();
+    ui_save_buttons_toggle(FALSE);
 
-	idx = document_get_cur_idx();
-	gtk_widget_grab_focus(GTK_WIDGET(doc_list[idx].sci));
-	treeviews_select_openfiles_item(idx);
-	build_menu_update(idx);
-	treeviews_update_tag_list(idx, FALSE);
+    idx = document_get_cur_idx();
+    gtk_widget_grab_focus(GTK_WIDGET(doc_list[idx].sci));
+    treeviews_select_openfiles_item(idx);
+    build_menu_update(idx);
+    treeviews_update_tag_list(idx, FALSE);
 
-	// finally realize the window to show the user what we have done
-	gtk_widget_show(app->window);
-	main_status.main_window_realized = TRUE;
+    // finally realize the window to show the user what we have done
+    gtk_widget_show(app->window);
+    main_status.main_window_realized = TRUE;
 
-	configuration_apply_settings();
+    configuration_apply_settings();
 
 #ifdef HAVE_SOCKET
-	// register the callback of socket input
-	if (! socket_info.ignore_socket && socket_info.lock_socket > 0)
-	{
-		socket_info.read_ioc = g_io_channel_unix_new(socket_info.lock_socket);
-		socket_info.lock_socket_tag = g_io_add_watch(socket_info.read_ioc,
-						G_IO_IN|G_IO_PRI|G_IO_ERR, socket_lock_input_cb, app->window);
-	}
+    // register the callback of socket input
+    if (! socket_info.ignore_socket && socket_info.lock_socket > 0)
+    {
+        socket_info.read_ioc = g_io_channel_unix_new(socket_info.lock_socket);
+        socket_info.lock_socket_tag = g_io_add_watch(socket_info.read_ioc,
+                        G_IO_IN|G_IO_PRI|G_IO_ERR, socket_lock_input_cb, app->window);
+    }
 #endif
 
-	//g_timeout_add(0, (GSourceFunc)destroyapp, NULL); // useful for start time tests
-	gtk_main();
-	return 0;
+    //g_timeout_add(0, (GSourceFunc)destroyapp, NULL); // useful for start time tests
+    gtk_main();
+    return 0;
 }
 
 
 void main_quit()
 {
-	geany_debug("Quitting...");
+    geany_debug("Quitting...");
 
 #ifdef HAVE_SOCKET
-	socket_finalize();
+    socket_finalize();
 #endif
 
 #ifdef HAVE_PLUGINS
-	if (want_plugins)
-		plugins_free();
+    if (want_plugins)
+        plugins_free();
 #endif
-	navqueue_free();
-	keybindings_free();
-	filetypes_save_commands();
-	filetypes_free_types();
-	highlighting_free_styles();
-	templates_free_templates();
-	msgwin_finalize();
-	search_finalize();
-	build_finalize();
-	document_finalize();
-	symbols_finalize();
-	editor_finalize();
-	if (app->project != NULL) project_close();
+    if (app->project != NULL)
+        project_close();
+        
+    navqueue_free();
+    keybindings_free();
+    filetypes_save_commands();
+    filetypes_free_types();
+    highlighting_free_styles();
+    templates_free_templates();
+    msgwin_finalize();
+    search_finalize();
+    build_finalize();
+    document_finalize();
+    symbols_finalize();
+    editor_finalize();
 
-	tm_workspace_free(TM_WORK_OBJECT(app->tm_workspace));
-	g_free(app->configdir);
-	g_free(app->datadir);
-	g_free(app->docdir);
-	g_free(prefs.default_open_path);
-	g_free(ui_prefs.custom_date_format);
-	g_free(prefs.editor_font);
-	g_free(prefs.tagbar_font);
-	g_free(prefs.msgwin_font);
-	g_free(editor_prefs.long_line_color);
-	g_free(prefs.context_action_cmd);
-	g_free(prefs.template_developer);
-	g_free(prefs.template_company);
-	g_free(prefs.template_mail);
-	g_free(prefs.template_initial);
-	g_free(prefs.template_version);
-	g_free(prefs.tools_make_cmd);
-	g_free(prefs.tools_term_cmd);
-	g_free(prefs.tools_browser_cmd);
-	g_free(prefs.tools_print_cmd);
-	g_free(prefs.tools_grep_cmd);
-	g_strfreev(ui_prefs.custom_commands);
-	while (! g_queue_is_empty(ui_prefs.recent_queue))
-	{
-		g_free(g_queue_pop_tail(ui_prefs.recent_queue));
-	}
-	g_queue_free(ui_prefs.recent_queue);
+    tm_workspace_free(TM_WORK_OBJECT(app->tm_workspace));
+    g_free(app->configdir);
+    g_free(app->datadir);
+    g_free(app->docdir);
+    g_free(prefs.default_open_path);
+    g_free(ui_prefs.custom_date_format);
+    g_free(prefs.editor_font);
+    g_free(prefs.tagbar_font);
+    g_free(prefs.msgwin_font);
+    g_free(editor_prefs.long_line_color);
+    g_free(prefs.context_action_cmd);
+    g_free(prefs.template_developer);
+    g_free(prefs.template_company);
+    g_free(prefs.template_mail);
+    g_free(prefs.template_initial);
+    g_free(prefs.template_version);
+    g_free(prefs.tools_make_cmd);
+    g_free(prefs.tools_term_cmd);
+    g_free(prefs.tools_browser_cmd);
+    g_free(prefs.tools_print_cmd);
+    g_free(prefs.tools_grep_cmd);
+    g_strfreev(ui_prefs.custom_commands);
+    while (! g_queue_is_empty(ui_prefs.recent_queue))
+    {
+        g_free(g_queue_pop_tail(ui_prefs.recent_queue));
+    }
+    g_queue_free(ui_prefs.recent_queue);
 
-	if (ui_widgets.prefs_dialog && GTK_IS_WIDGET(ui_widgets.prefs_dialog)) gtk_widget_destroy(ui_widgets.prefs_dialog);
-	if (ui_widgets.save_filesel && GTK_IS_WIDGET(ui_widgets.save_filesel)) gtk_widget_destroy(ui_widgets.save_filesel);
-	if (ui_widgets.open_filesel && GTK_IS_WIDGET(ui_widgets.open_filesel)) gtk_widget_destroy(ui_widgets.open_filesel);
-	if (ui_widgets.open_fontsel && GTK_IS_WIDGET(ui_widgets.open_fontsel)) gtk_widget_destroy(ui_widgets.open_fontsel);
-	if (ui_widgets.open_colorsel && GTK_IS_WIDGET(ui_widgets.open_colorsel)) gtk_widget_destroy(ui_widgets.open_colorsel);
-	if (tv.default_tag_tree && GTK_IS_WIDGET(tv.default_tag_tree))
-	{
-		g_object_unref(tv.default_tag_tree);
-		gtk_widget_destroy(tv.default_tag_tree);
-	}
+    if (ui_widgets.prefs_dialog && GTK_IS_WIDGET(ui_widgets.prefs_dialog)) gtk_widget_destroy(ui_widgets.prefs_dialog);
+    if (ui_widgets.save_filesel && GTK_IS_WIDGET(ui_widgets.save_filesel)) gtk_widget_destroy(ui_widgets.save_filesel);
+    if (ui_widgets.open_filesel && GTK_IS_WIDGET(ui_widgets.open_filesel)) gtk_widget_destroy(ui_widgets.open_filesel);
+    if (ui_widgets.open_fontsel && GTK_IS_WIDGET(ui_widgets.open_fontsel)) gtk_widget_destroy(ui_widgets.open_fontsel);
+    if (ui_widgets.open_colorsel && GTK_IS_WIDGET(ui_widgets.open_colorsel)) gtk_widget_destroy(ui_widgets.open_colorsel);
+    if (tv.default_tag_tree && GTK_IS_WIDGET(tv.default_tag_tree))
+    {
+        g_object_unref(tv.default_tag_tree);
+        gtk_widget_destroy(tv.default_tag_tree);
+    }
 #ifdef HAVE_VTE
-	if (vte_info.have_vte) vte_close();
-	g_free(vte_info.lib_vte);
-	g_free(vte_info.dir);
+    if (vte_info.have_vte) vte_close();
+    g_free(vte_info.lib_vte);
+    g_free(vte_info.dir);
 #endif
-	gtk_widget_destroy(app->window);
+    gtk_widget_destroy(app->window);
 
-	// destroy popup menus
-	if (app->popup_menu && GTK_IS_WIDGET(app->popup_menu))
-					gtk_widget_destroy(app->popup_menu);
-	if (ui_widgets.toolbar_menu && GTK_IS_WIDGET(ui_widgets.toolbar_menu))
-					gtk_widget_destroy(ui_widgets.toolbar_menu);
-	if (tv.popup_taglist && GTK_IS_WIDGET(tv.popup_taglist))
-					gtk_widget_destroy(tv.popup_taglist);
-	if (tv.popup_openfiles && GTK_IS_WIDGET(tv.popup_openfiles))
-					gtk_widget_destroy(tv.popup_openfiles);
-	if (msgwindow.popup_status_menu && GTK_IS_WIDGET(msgwindow.popup_status_menu))
-					gtk_widget_destroy(msgwindow.popup_status_menu);
-	if (msgwindow.popup_msg_menu && GTK_IS_WIDGET(msgwindow.popup_msg_menu))
-					gtk_widget_destroy(msgwindow.popup_msg_menu);
-	if (msgwindow.popup_compiler_menu && GTK_IS_WIDGET(msgwindow.popup_compiler_menu))
-					gtk_widget_destroy(msgwindow.popup_compiler_menu);
+    // destroy popup menus
+    if (app->popup_menu && GTK_IS_WIDGET(app->popup_menu))
+                    gtk_widget_destroy(app->popup_menu);
+    if (ui_widgets.toolbar_menu && GTK_IS_WIDGET(ui_widgets.toolbar_menu))
+                    gtk_widget_destroy(ui_widgets.toolbar_menu);
+    if (tv.popup_taglist && GTK_IS_WIDGET(tv.popup_taglist))
+                    gtk_widget_destroy(tv.popup_taglist);
+    if (tv.popup_openfiles && GTK_IS_WIDGET(tv.popup_openfiles))
+                    gtk_widget_destroy(tv.popup_openfiles);
+    if (msgwindow.popup_status_menu && GTK_IS_WIDGET(msgwindow.popup_status_menu))
+                    gtk_widget_destroy(msgwindow.popup_status_menu);
+    if (msgwindow.popup_msg_menu && GTK_IS_WIDGET(msgwindow.popup_msg_menu))
+                    gtk_widget_destroy(msgwindow.popup_msg_menu);
+    if (msgwindow.popup_compiler_menu && GTK_IS_WIDGET(msgwindow.popup_compiler_menu))
+                    gtk_widget_destroy(msgwindow.popup_compiler_menu);
 
-	g_free(app);
+    g_free(app);
 
-	gtk_main_quit();
+    gtk_main_quit();
 }
 
 
@@ -872,7 +874,7 @@
 // Allocate an N-byte block of memory from the heap. If N is zero, allocate a 1-byte block.
 void *rpl_malloc(size_t n)
 {
-	if (n == 0)
-		n = 1;
-	return malloc(n);
+    if (n == 0)
+        n = 1;
+    return malloc(n);
 }
