SF.net SVN: geany:[5611] trunk

colombanw at users.sourceforge.net colombanw at xxxxx
Sun Mar 20 17:51:00 UTC 2011


Revision: 5611
          http://geany.svn.sourceforge.net/geany/?rev=5611&view=rev
Author:   colombanw
Date:     2011-03-20 17:50:59 +0000 (Sun, 20 Mar 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:
--------------
    trunk/ChangeLog
    trunk/src/document.c

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2011-03-20 16:02:52 UTC (rev 5610)
+++ trunk/ChangeLog	2011-03-20 17:50:59 UTC (rev 5611)
@@ -8,6 +8,10 @@
  * src/editor.c, src/search.c, tagmanager/diff.c:
    Don't use strlen(..) > 0 or == 0, simply check the first character
    against 0.
+ * 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-03-19  Colomban Wendling  <colomban(at)geany(dot)org>

Modified: trunk/src/document.c
===================================================================
--- trunk/src/document.c	2011-03-20 16:02:52 UTC (rev 5610)
+++ trunk/src/document.c	2011-03-20 17:50:59 UTC (rev 5611)
@@ -1001,24 +1001,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);
@@ -2434,6 +2443,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