unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Patch to allow -nw to runemacs on w32
@ 2006-11-15 13:44 Lennart Borgman
  2006-11-15 15:22 ` Jason Rumney
  2006-11-15 17:41 ` Eli Zaretskii
  0 siblings, 2 replies; 16+ messages in thread
From: Lennart Borgman @ 2006-11-15 13:44 UTC (permalink / raw)


[-- Attachment #1: Type: text/plain, Size: 209 bytes --]

In some situations you may want to be able to use the -nw option with 
runemacs.exe. All other options to emacs can be given to runemacs, but 
-nw currently gives a fatal error. The attached patch fixes this.

[-- Attachment #2: runemacs-allow-nw.patch --]
[-- Type: text/plain, Size: 2876 bytes --]

Index: runemacs.c
===================================================================
RCS file: /cvsroot/emacs/emacs/nt/runemacs.c,v
retrieving revision 1.13
diff -u -r1.13 runemacs.c
--- runemacs.c	29 Oct 2006 22:43:37 -0000	1.13
+++ runemacs.c	15 Nov 2006 13:30:18 -0000
@@ -51,11 +51,12 @@
   SECURITY_ATTRIBUTES sec_attrs;
   PROCESS_INFORMATION child;
   int wait_for_child = FALSE;
-  DWORD priority_class = NORMAL_PRIORITY_CLASS;
+  DWORD creation_flags = NORMAL_PRIORITY_CLASS;
   DWORD ret_code = 0;
   char *new_cmdline;
   char *p;
   char modname[MAX_PATH];
+  BOOL create_console = FALSE;
 
   if (!GetModuleFileName (NULL, modname, MAX_PATH))
     goto error;
@@ -113,12 +114,12 @@
 	}
       else if (strncmp (cmdline+1, "high", 4) == 0)
 	{
-	  priority_class = HIGH_PRIORITY_CLASS;
+	  creation_flags = HIGH_PRIORITY_CLASS;
 	  cmdline += 5;
 	}
       else if (strncmp (cmdline+1, "low", 3) == 0)
 	{
-	  priority_class = IDLE_PRIORITY_CLASS;
+	  creation_flags = IDLE_PRIORITY_CLASS;
 	  cmdline += 4;
 	}
       else
@@ -129,6 +130,27 @@
 
   strcat (new_cmdline, cmdline);
 
+  /* Look for -nw since it requires the console flag */
+  while (cmdline[0] == '-' || cmdline[0] == '/')
+    {
+      if (strncmp (cmdline+1, "nw", 2) == 0)
+	{
+          creation_flags = creation_flags | CREATE_NEW_CONSOLE;
+          create_console = TRUE;
+	  cmdline += 5;
+	}
+      else if (strncmp (cmdline+1, "-no-window-system", 17) == 0)
+	{
+          creation_flags = creation_flags | CREATE_NEW_CONSOLE;
+          create_console = TRUE;
+	  cmdline += 18;
+	}
+      else
+	break;
+      /* Look for next argument.  */
+      while (*++cmdline == ' ');
+    }
+
   /* Set emacs_dir variable if runemacs was in "%emacs_dir%\bin".  */
   if ((p = strrchr (modname, '\\')) && stricmp (p, "\\bin") == 0)
     {
@@ -140,18 +162,20 @@
 
   memset (&start, 0, sizeof (start));
   start.cb = sizeof (start);
-  start.dwFlags = STARTF_USESHOWWINDOW | STARTF_USECOUNTCHARS;
-  start.wShowWindow = SW_HIDE;
-  /* Ensure that we don't waste memory if the user has specified a huge
-     default screen buffer for command windows.  */
-  start.dwXCountChars = 80;
-  start.dwYCountChars = 25;
+  if (!create_console) {
+    start.dwFlags = STARTF_USESHOWWINDOW | STARTF_USECOUNTCHARS;
+    start.wShowWindow = SW_HIDE;
+    /* Ensure that we don't waste memory if the user has specified a huge
+       default screen buffer for command windows.  */
+    start.dwXCountChars = 80;
+    start.dwYCountChars = 25;
+  }
 
   sec_attrs.nLength = sizeof (sec_attrs);
   sec_attrs.lpSecurityDescriptor = NULL;
   sec_attrs.bInheritHandle = FALSE;
 
-  if (CreateProcess (NULL, new_cmdline, &sec_attrs, NULL, TRUE, priority_class,
+  if (CreateProcess (NULL, new_cmdline, &sec_attrs, NULL, TRUE, creation_flags,
 		     NULL, NULL, &start, &child))
     {
       if (wait_for_child)

[-- Attachment #3: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2006-11-16  4:40 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-11-15 13:44 Patch to allow -nw to runemacs on w32 Lennart Borgman
2006-11-15 15:22 ` Jason Rumney
2006-11-15 15:34   ` Lennart Borgman
2006-11-15 15:47     ` Juanma Barranquero
2006-11-15 15:55       ` Juanma Barranquero
2006-11-15 16:12       ` Lennart Borgman
2006-11-15 16:37         ` Juanma Barranquero
2006-11-15 18:57           ` Juanma Barranquero
2006-11-15 21:35             ` Jason Rumney
2006-11-15 21:20           ` Lennart Borgman
2006-11-15 21:29             ` Juanma Barranquero
2006-11-15 17:41 ` Eli Zaretskii
2006-11-15 20:05   ` Lennart Borgman
2006-11-15 21:38     ` Jason Rumney
2006-11-15 22:02       ` Lennart Borgman
2006-11-16  4:40         ` Eli Zaretskii

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).