From jonathan at swintons.net  Tue Oct 16 11:00:43 2007
From: jonathan at swintons.net (Jonathan Swinton)
Date: Tue, 16 Oct 2007 10:00:43 +0100
Subject: [Rd] Additional file filter for Windows text editor Open/Save
	dialogues.
Message-ID: <47147DBB.4060101@swintons.net>


I propose the following very simple patch to src\gnuwin32\editor.c. Its purpose is to allow vignette files, specifically .Snw and .Rnw suffixes, to be an available filter in the Open and Save dialogues of the R GUI text editor.

I have successfully built and tested this against R 2.5.0, and found it useful.

Although the patch is against the current r-devel, I cannot currently build that (because of a failure to build Rblas.dll, FWIW, and no doubt all my fault for not reading the right bit of the manual).
However it seems to me unlikely that this patch would be the victim of such version differences, and I think it better to offer it now; I am unlikely to be able to troubleshoot my r-devel build for a long time if at all.




Index: editor.c
===================================================================
--- editor.c	(revision 43174)
+++ editor.c	(working copy)
@@ -52,6 +52,9 @@
  static int neditors  = 0;
  static Rboolean fix_editor_up = FALSE;

+/* Definition of available filters for Open and Save dialogues */
+#define EDITORFILEFILTER "R files (*.R)\0*.R\0S files (*.q, *.ssc, *.S)\0*.q;*.ssc;*.S\0Vignette files (*.Rnw,*.Snw)\0*.Rnw;*.Snw\0All files (*.*)\0*.*\0\0"
+
  static EditorData neweditordata (int file, char *filename)
  {
      EditorData p;
@@ -149,7 +152,7 @@
      EditorData p = getdata(t);
      char *current_name = (p->file ? p->filename : "");
      char *name;
-    setuserfilter("R files (*.R)\0*.R\0S files (*.q, *.ssc, *.S)\0*.q;*.ssc;*.S\0All files (*.*)\0*.*\0\0");
+    setuserfilter( EDITORFILEFILTER);
      name = askfilesave(G_("Save script as"), current_name);
      if (name == NULL)
  	return;
@@ -337,7 +340,7 @@
  {
      char *name;
      int i; textbox t; EditorData p;
-    setuserfilter("R files (*.R)\0*.R\0S files (*.q, *.ssc, *.S)\0*.q;*.ssc;*.S\0All files (*.*)\0*.*\0\0");
+    setuserfilter(EDITORFILEFILTER);
      name = askfilename("Open script", default_name); /* returns NULL if open dialog cancelled */
      if (name) {
  	/* check if file is already open in an editor. If so, close and open again */



[Rd] Additional file filter for Windows text editor Open/Save dialogues.
Jonathan Swinton