emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Patch to allow -nw to runemacs on w32


From: Lennart Borgman
Subject: Patch to allow -nw to runemacs on w32
Date: Wed, 15 Nov 2006 14:44:25 +0100
User-agent: Thunderbird 1.5.0.8 (Windows/20061025)

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.
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)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]