SF.net SVN: geany:[5784] branches/0.20.1

colombanw at users.sourceforge.net colombanw at xxxxx
Mon May 9 17:38:02 UTC 2011


Revision: 5784
          http://geany.svn.sourceforge.net/geany/?rev=5784&view=rev
Author:   colombanw
Date:     2011-05-09 17:38:02 +0000 (Mon, 09 May 2011)

Log Message:
-----------
Update forced indent settings when setting the filetype

This makes documents created or set to a filetype with forced indent
setting (Makefile, F77) to have the correct setting right away.

Modified Paths:
--------------
    branches/0.20.1/ChangeLog
    branches/0.20.1/src/document.c

Modified: branches/0.20.1/ChangeLog
===================================================================
--- branches/0.20.1/ChangeLog	2011-05-09 17:37:39 UTC (rev 5783)
+++ branches/0.20.1/ChangeLog	2011-05-09 17:38:02 UTC (rev 5784)
@@ -14,6 +14,10 @@
  * src/callbacks.c:
    Create a new undo action when inserting templates, making sure the user
    can undo the template insertion without also undoing a previous action.
+ * src/document.c:
+   Update forced indent settings when setting the filetype. This makes
+   documents created or set to a filetype with forced indent setting
+   (Makefile, F77) to have the correct setting right away.
 
 
 2011-05-08  Enrico Tröger  <enrico(dot)troeger(at)uvena(dot)de>

Modified: branches/0.20.1/src/document.c
===================================================================
--- branches/0.20.1/src/document.c	2011-05-09 17:37:39 UTC (rev 5783)
+++ branches/0.20.1/src/document.c	2011-05-09 17:38:02 UTC (rev 5784)
@@ -1152,24 +1152,33 @@
 }
 
 
-void document_apply_indent_settings(GeanyDocument *doc)
+static gboolean apply_forced_indent_settings(GeanyDocument *doc)
 {
 	const GeanyIndentPrefs *iprefs = editor_get_indent_prefs(NULL);
-	GeanyIndentType type = iprefs->type;
 
 	switch (doc->file_type->id)
 	{
 		case GEANY_FILETYPES_MAKE:
 			/* force using tabs for indentation for Makefiles */
 			editor_set_indent(doc->editor, GEANY_INDENT_TYPE_TABS, iprefs->width);
-			return;
+			return TRUE;
 		case GEANY_FILETYPES_F77:
 			/* force using spaces for indentation for Fortran 77 */
 			editor_set_indent(doc->editor, GEANY_INDENT_TYPE_SPACES, iprefs->width);
-			return;
-		default:
-			break;
+			return TRUE;
 	}
+
+	return FALSE;
+}
+
+
+void document_apply_indent_settings(GeanyDocument *doc)
+{
+	const GeanyIndentPrefs *iprefs = editor_get_indent_prefs(NULL);
+	GeanyIndentType type = iprefs->type;
+
+	if (apply_forced_indent_settings(doc))
+		return;
 	if (iprefs->detect_type)
 	{
 		type = detect_indent_type(doc->editor);
@@ -2585,6 +2594,8 @@
 
 	if (ft_changed)
 	{
+		if (apply_forced_indent_settings(doc)) /* update forced indents, like Makefiles and F77 */
+			ui_document_show_hide(doc);
 		sidebar_openfiles_update(doc); /* to update the icon */
 		g_signal_emit_by_name(geany_object, "document-filetype-set", doc, old_ft);
 	}


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.



More information about the Commits mailing list