SF.net SVN: geany: [2596] trunk

eht16 at users.sourceforge.net eht16 at xxxxx
Sun May 18 16:03:32 UTC 2008


Revision: 2596
          http://geany.svn.sourceforge.net/geany/?rev=2596&view=rev
Author:   eht16
Date:     2008-05-18 09:03:20 -0700 (Sun, 18 May 2008)

Log Message:
-----------
Force using tabs for indentation when opening Makefiles.

Modified Paths:
--------------
    trunk/ChangeLog
    trunk/src/document.c

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2008-05-16 14:35:41 UTC (rev 2595)
+++ trunk/ChangeLog	2008-05-18 16:03:20 UTC (rev 2596)
@@ -1,3 +1,9 @@
+2008-05-18  Enrico Tröger  <enrico(dot)troeger(at)uvena(dot)de>
+
+ * src/document.c:
+   Force using tabs for indentation when opening Makefiles.
+
+
 2008-05-16  Enrico Tröger  <enrico(dot)troeger(at)uvena(dot)de>
 
  * plugins/pluginmacros.h, plugins/vcdiff.c, src/build.c,

Modified: trunk/src/document.c
===================================================================
--- trunk/src/document.c	2008-05-16 14:35:41 UTC (rev 2595)
+++ trunk/src/document.c	2008-05-18 16:03:20 UTC (rev 2596)
@@ -946,6 +946,25 @@
 }
 
 
+static void set_indentation(gint idx)
+{
+	/* force using tabs for indentation for Makefiles */
+	if (FILETYPE_ID(doc_list[idx].file_type) == GEANY_FILETYPES_MAKE)
+		editor_set_use_tabs(idx, TRUE);
+	else if (! editor_prefs.detect_tab_mode)
+		editor_set_use_tabs(idx, editor_prefs.use_tabs);
+	else
+	{	/* detect & set tabs/spaces */
+		gboolean use_tabs = detect_use_tabs(doc_list[idx].sci);
+
+		if (use_tabs != editor_prefs.use_tabs)
+			ui_set_statusbar(TRUE, _("Setting %s indentation mode."),
+				(use_tabs) ? _("Tabs") : _("Spaces"));
+		editor_set_use_tabs(idx, use_tabs);
+	}
+}
+
+
 /* To open a new file, set idx to -1; filename should be locale encoded.
  * To reload a file, set the idx for the document to be reloaded; filename should be NULL.
  * pos is the cursor position, which can be overridden by --line and --column.
@@ -1038,21 +1057,6 @@
 	sci_set_eol_mode(doc_list[idx].sci, editor_mode);
 	g_free(filedata.data);
 
-	if (reload)
-		editor_set_use_tabs(idx, doc_list[idx].use_tabs); /* resetup sci */
-	else
-	if (! editor_prefs.detect_tab_mode)
-		editor_set_use_tabs(idx, editor_prefs.use_tabs);
-	else
-	{	/* detect & set tabs/spaces */
-		gboolean use_tabs = detect_use_tabs(doc_list[idx].sci);
-
-		if (use_tabs != editor_prefs.use_tabs)
-			ui_set_statusbar(TRUE, _("Setting %s indentation mode."),
-				(use_tabs) ? _("Tabs") : _("Spaces"));
-		editor_set_use_tabs(idx, use_tabs);
-	}
-
 	sci_set_undo_collection(doc_list[idx].sci, TRUE);
 
 	doc_list[idx].mtime = filedata.mtime; /* get the modification time from file and keep it */
@@ -1092,6 +1096,12 @@
 	/* update taglist, typedef keywords and build menu if necessary */
 	document_set_filetype(idx, use_ft);
 
+	/* set indentation settings after setting the filetype */
+	if (reload)
+		editor_set_use_tabs(idx, doc_list[idx].use_tabs); /* resetup sci */
+	else
+		set_indentation(idx);
+
 	document_set_text_changed(idx);	/* also updates tab state */
 	ui_document_show_hide(idx);	/* update the document menu */
 
@@ -1414,8 +1424,9 @@
 		return FALSE;
 	}
 
-	/* replaces tabs by spaces */
-	if (file_prefs.replace_tabs) editor_replace_tabs(idx);
+	/* replaces tabs by spaces but only if the current file is not a Makefile */
+	if (file_prefs.replace_tabs && FILETYPE_ID(doc_list[idx].file_type) != GEANY_FILETYPES_MAKE)
+		editor_replace_tabs(idx);
 	/* strip trailing spaces */
 	if (file_prefs.strip_trailing_spaces) editor_strip_trailing_spaces(idx);
 	/* ensure the file has a newline at the end */


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