]> code.delx.au - gnu-emacs/blobdiff - nt/runemacs.c
* lisp/apropos.el (apropos-variable): Doc fix. (Bug#22813).
[gnu-emacs] / nt / runemacs.c
index 47b8f54bb02c2e806b05462639f59a5a9f3e192d..2685b25c30da5aed496f2a7bd982cc97f6bfaf6e 100644 (file)
@@ -1,6 +1,6 @@
 /* runemacs --- Simple program to start Emacs with its console window hidden.
 
 /* runemacs --- Simple program to start Emacs with its console window hidden.
 
-Copyright (C) 2001-201 Free Software Foundation, Inc.
+Copyright (C) 2001-2016 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
 
 This file is part of GNU Emacs.
 
@@ -59,6 +59,7 @@ WinMain (HINSTANCE hSelf, HINSTANCE hPrev, LPSTR cmdline, int nShow)
   char *new_cmdline;
   char *p;
   char modname[MAX_PATH];
   char *new_cmdline;
   char *p;
   char modname[MAX_PATH];
+  static const char iconic_opt[] = "--iconic ", maximized_opt[] = "--maximized ";
 
   if (!ensure_unicows_dll ())
     goto error;
 
   if (!ensure_unicows_dll ())
     goto error;
@@ -71,10 +72,21 @@ WinMain (HINSTANCE hSelf, HINSTANCE hPrev, LPSTR cmdline, int nShow)
     goto error;
   *p = 0;
 
     goto error;
   *p = 0;
 
-  new_cmdline = alloca (MAX_PATH + strlen (cmdline) + 3);
+  new_cmdline = alloca (MAX_PATH
+                       + strlen (cmdline)
+                       + ((nShow == SW_SHOWMINNOACTIVE
+                           || nShow == SW_SHOWMAXIMIZED)
+                          ? max (sizeof (iconic_opt), sizeof (maximized_opt))
+                          : 0)
+                       + 3);
   /* Quote executable name in case of spaces in the path. */
   *new_cmdline = '"';
   strcpy (new_cmdline + 1, modname);
   /* Quote executable name in case of spaces in the path. */
   *new_cmdline = '"';
   strcpy (new_cmdline + 1, modname);
+  /* Detect and handle un-installed runemacs.exe in nt/ subdirectory,
+     while emacs.exe is in src/.  */
+  if ((p = strrchr (new_cmdline, '\\')) != NULL
+      && stricmp (p, "\\nt") == 0)
+    strcpy (p, "\\src");
 
 #ifdef CHOOSE_NEWEST_EXE
   {
 
 #ifdef CHOOSE_NEWEST_EXE
   {
@@ -111,7 +123,7 @@ WinMain (HINSTANCE hSelf, HINSTANCE hPrev, LPSTR cmdline, int nShow)
 #endif
 
   /* Append original arguments if any; first look for arguments we
 #endif
 
   /* Append original arguments if any; first look for arguments we
-     recognise (-wait, -high, and -low), and apply them ourselves.  */
+     recognize (-wait, -high, and -low), and apply them ourselves.  */
   while (cmdline[0] == '-' || cmdline[0] == '/')
     {
       if (strncmp (cmdline+1, "wait", 4) == 0)
   while (cmdline[0] == '-' || cmdline[0] == '/')
     {
       if (strncmp (cmdline+1, "wait", 4) == 0)
@@ -135,6 +147,14 @@ WinMain (HINSTANCE hSelf, HINSTANCE hPrev, LPSTR cmdline, int nShow)
       while (*++cmdline == ' ');
     }
 
       while (*++cmdline == ' ');
     }
 
+  /* If the desktop shortcut properties tell to invoke runemacs
+     minimized, or if they invoked runemacs via "start /min", pass
+     '--iconic' to Emacs, as that's what users will expect.  Likewise
+     with invoking runemacs maximized: pass '--maximized' to Emacs.  */
+  if (nShow == SW_SHOWMINNOACTIVE)
+    strcat (new_cmdline, iconic_opt);
+  else if (nShow == SW_SHOWMAXIMIZED)
+    strcat (new_cmdline, maximized_opt);
   strcat (new_cmdline, cmdline);
 
   /* Set emacs_dir variable if runemacs was in "%emacs_dir%\bin".  */
   strcat (new_cmdline, cmdline);
 
   /* Set emacs_dir variable if runemacs was in "%emacs_dir%\bin".  */
@@ -229,8 +249,6 @@ ensure_unicows_dll (void)
                               "Emacs cannot load the UNICOWS.DLL library.\n"
                               "This library is essential for using Emacs\n"
                               "on this system.  You need to install it.\n\n"
                               "Emacs cannot load the UNICOWS.DLL library.\n"
                               "This library is essential for using Emacs\n"
                               "on this system.  You need to install it.\n\n"
-                              "However, you can still use Emacs by invoking\n"
-                              "it with the '-nw' command-line option.\n\n"
                               "Emacs will exit when you click OK.",
                               "Emacs cannot load UNICOWS.DLL",
                               MB_ICONERROR | MB_TASKMODAL
                               "Emacs will exit when you click OK.",
                               "Emacs cannot load UNICOWS.DLL",
                               MB_ICONERROR | MB_TASKMODAL