all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Lennart Borgman <lennart.borgman.073@student.lu.se>
Cc: Juanma Barranquero <lekktu@gmail.com>
Subject: Re: emacsclientw
Date: Mon, 13 Nov 2006 17:19:07 +0100	[thread overview]
Message-ID: <45589AFB.2040103@student.lu.se> (raw)
In-Reply-To: <f7ccd24b0611130423o37d02d30oc3fc43ae13fd0e51@mail.gmail.com>

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

Juanma Barranquero wrote:
> On 11/13/06, Jason Rumney <jasonr@gnu.org> wrote:
>
>> Have you tested the emacsclientw.exe build with MSVC?
>
> No, I have not set up a build enviroment for MSVC. Did you try it?
>
> BTW, Lennart's got a bunch of changes to emacsclient that would allow
> emacsclient's error messages to go to GUI message boxes when run as
> emacsclientw.exe. I'm testing it right now.

I have attached this patch. Neither Juanma nor I can test it on for 
example GNU/Linux. Can someone please do that? (It should in effect 
change nothing at all except on w32.)


[-- Attachment #2: emacsclient-messagebox.diff --]
[-- Type: text/plain, Size: 9731 bytes --]

Index: emacsclient.c
===================================================================
RCS file: /cvsroot/emacs/emacs/lib-src/emacsclient.c,v
retrieving revision 1.89
diff -u -r1.89 emacsclient.c
--- emacsclient.c	10 Nov 2006 15:41:44 -0000	1.89
+++ emacsclient.c	13 Nov 2006 00:31:08 -0000
@@ -30,6 +30,7 @@
 
 # include <malloc.h>
 # include <stdlib.h>
+# include <windows.h>
 
 # define HAVE_SOCKETS
 # define HAVE_INET_SOCKETS
@@ -142,6 +143,109 @@
   { 0, 0, 0, 0 }
 };
 
+/* Message functions. */
+
+#ifdef WINDOWSNT
+int w32_console_app = 0;
+
+void
+w32_check_console_app()
+{
+  /* Did not work, found also in nonconsole app: stdinhandle =
+     GetStdHandle(STD_OUTPUT_HANDLE);
+   */
+  /* Test for console title */
+  TCHAR szOldTitle[MAX_PATH];
+  DWORD titlen;
+
+  titlen = GetConsoleTitle(szOldTitle, MAX_PATH);
+  if (titlen) {
+    //MessageBox ( NULL, szOldTitle, "testing", MB_ICONINFORMATION);
+    w32_console_app = 1;
+  } else {
+    //MessageBox ( NULL, "no title", "testing", MB_ICONINFORMATION);
+  }
+  //exit (EXIT_FAILURE);
+}
+#endif
+
+void
+message_internal(msg, is_error)
+     char *msg;
+     int is_error;
+{
+#ifdef WINDOWSNT
+  if (!w32_console_app) {
+    if (is_error) {
+      MessageBox (NULL, msg, "Emacsclient", MB_ICONINFORMATION);
+    } else {
+      MessageBox (NULL, msg, "Emacsclient ERROR", MB_ICONINFORMATION);
+    }
+  } else {
+#endif
+    //MessageBox (NULL, "here 0", "Emacsclient ERROR", MB_ICONINFORMATION);
+    if (is_error) {
+      //MessageBox (NULL, "here 1", "Emacsclient ERROR", MB_ICONINFORMATION);
+      fprintf(stderr, msg);
+    } else {
+      //MessageBox (NULL, "here 2", "Emacsclient ERROR", MB_ICONINFORMATION);
+      printf(msg);
+    }
+#ifdef WINDOWSNT
+  }
+#endif
+}
+
+void
+errormsg(msg)
+     char *msg;
+{
+  message_internal(msg, 1);
+}
+
+void
+errormsg1(msg, par1)
+     char *msg;
+     char *par1;
+{
+  char buf[2048];
+  sprintf(buf, msg, par1);
+  message_internal(buf, 1);
+}
+
+void
+errormsg2(msg, par1, par2)
+     char *msg;
+     char *par1;
+     char *par2;
+{
+  char buf[2048];
+  sprintf(buf, msg, par1, par2);
+  message_internal(buf, 1);
+}
+
+void
+errormsg3(msg, par1, par2, par3)
+     char *msg;
+     char *par1;
+     char *par2;
+     char *par3;
+{
+  char buf[2048];
+  sprintf(buf, msg, par1, par2, par3);
+  message_internal(buf, 1);
+}
+
+void
+message1(msg, par1)
+     char *msg;
+     char *par1;
+{
+  char buf[2048];
+  sprintf(buf, msg, par1);
+  message_internal(buf, 1);
+}
+
 /* Decode the options from argv and argc.
    The global variable `optind' will say how many arguments we used up.  */
 
@@ -199,7 +303,7 @@
 	  break;
 
 	case 'V':
-	  printf ("emacsclient %s\n", VERSION);
+	  message1 ("emacsclient %s\n", VERSION);
 	  exit (EXIT_SUCCESS);
 	  break;
 
@@ -208,7 +312,7 @@
 	  break;
 
 	default:
-	  fprintf (stderr, "Try `%s --help' for more information\n", progname);
+	  errormsg1 ("Try `%s --help' for more information\n", progname);
 	  exit (EXIT_FAILURE);
 	  break;
 	}
@@ -218,7 +322,7 @@
 void
 print_help_and_exit ()
 {
-  printf (
+  message1 (
 	  "Usage: %s [OPTIONS] FILE...\n\
 Tell the Emacs server to visit the specified files.\n\
 Every FILE can be either just a FILENAME or [+LINE[:COLUMN]] FILENAME.\n\
@@ -259,7 +363,7 @@
       argv[i] = (char *)alternate_editor;
 #endif
       execvp (alternate_editor, argv + i);
-      fprintf (stderr, "%s: error executing alternate editor \"%s\"\n",
+      errormsg2 ("%s: error executing alternate editor \"%s\"\n",
                progname, alternate_editor);
     }
   exit (EXIT_FAILURE);
@@ -273,9 +377,8 @@
      int argc;
      char **argv;
 {
-  fprintf (stderr, "%s: Sorry, the Emacs server is supported only\n",
+  errormsg1 ("%s: Sorry, the Emacs server is supported only\non systems with Berkely sockets.\n",
 	   argv[0]);
-  fprintf (stderr, "on systems with Berkeley sockets.\n");
 
   fail (argc, argv);
 }
@@ -424,7 +527,7 @@
 
   if (WSAStartup (MAKEWORD (2, 0), &wsaData))
     {
-      fprintf (stderr, "%s: error initializing WinSock2", progname);
+      errormsg1 ("%s: error initializing WinSock2", progname);
       exit (EXIT_FAILURE);
     }
 
@@ -480,7 +583,7 @@
     }
   else
     {
-      fprintf (stderr, "%s: invalid configuration info", progname);
+      errormsg1 ("%s: invalid configuration info", progname);
       exit (EXIT_FAILURE);
     }
 
@@ -490,7 +593,7 @@
 
   if (! fread (authentication, AUTH_KEY_LENGTH, 1, config))
     {
-      fprintf (stderr, "%s: cannot read authentication info", progname);
+      errormsg1 ("%s: cannot read authentication info", progname);
       exit (EXIT_FAILURE);
     }
 
@@ -535,7 +638,7 @@
     return INVALID_SOCKET;
 
   if (server.sin_addr.s_addr != inet_addr ("127.0.0.1"))
-    fprintf (stderr, "%s: connected to remote socket at %s\n",
+    errormsg2 ("%s: connected to remote socket at %s\n",
              progname, inet_ntoa (server.sin_addr));
 
   /*
@@ -543,8 +646,8 @@
    */
   if ((s = socket (AF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0)
     {
-      fprintf (stderr, "%s: ", progname);
-      perror ("socket");
+      errormsg2 ("%s: socket: %s\n", progname, strerror(errno));
+      //perror ("socket");
       return INVALID_SOCKET;
     }
 
@@ -553,8 +656,8 @@
    */
   if (connect (s, (struct sockaddr *) &server, sizeof server) < 0)
     {
-      fprintf (stderr, "%s: ", progname);
-      perror ("connect");
+      errormsg2 ("%s: connect: %s\n", progname, strerror(errno));
+      //perror ("connect");
       return INVALID_SOCKET;
     }
 
@@ -606,8 +709,8 @@
 
   if ((s = socket (AF_UNIX, SOCK_STREAM, 0)) < 0)
     {
-      fprintf (stderr, "%s: ", progname);
-      perror ("socket");
+      errormsg2 ("%s: socket: %s\n", progname, strerror(errno));
+      //perror ("socket");
       return INVALID_SOCKET;
     }
 
@@ -637,7 +740,7 @@
       strcpy (server.sun_path, socket_name);
     else
       {
-	fprintf (stderr, "%s: socket-name %s too long",
+	errormsg2 ("%s: socket-name %s too long",
 		 progname, socket_name);
 	exit (EXIT_FAILURE);
       }
@@ -672,7 +775,7 @@
 		  strcpy (server.sun_path, socket_name);
 		else
 		  {
-		    fprintf (stderr, "%s: socket-name %s too long",
+		    errormsg2 ("%s: socket-name %s too long",
 			     progname, socket_name);
 		    exit (EXIT_FAILURE);
 		  }
@@ -692,7 +795,7 @@
            we are root. */
         if (0 != geteuid ())
           {
-            fprintf (stderr, "%s: Invalid socket owner\n", progname);
+            errormsg1 ("%s: Invalid socket owner\n", progname);
 	    return INVALID_SOCKET;
           }
         break;
@@ -700,12 +803,12 @@
       case 2:
         /* `stat' failed */
         if (saved_errno == ENOENT)
-          fprintf (stderr,
+          errormsg1 (
                    "%s: can't find socket; have you started the server?\n\
 To start the server in Emacs, type \"M-x server-start\".\n",
 		   progname);
         else
-          fprintf (stderr, "%s: can't stat %s: %s\n",
+          errormsg3 ("%s: can't stat %s: %s\n",
 		   progname, server.sun_path, strerror (saved_errno));
         return INVALID_SOCKET;
       }
@@ -714,8 +817,8 @@
   if (connect (s, (struct sockaddr *) &server, strlen (server.sun_path) + 2)
       < 0)
     {
-      fprintf (stderr, "%s: ", progname);
-      perror ("connect");
+      errormsg2 ("%s: connect: %s\n", progname, strerror(errno));
+      //perror ("connect");
       return INVALID_SOCKET;
     }
 
@@ -738,7 +841,7 @@
       if ((s != INVALID_SOCKET) || alternate_editor)
         return s;
 
-      fprintf (stderr, "%s: error accessing socket \"%s\"",
+      errormsg2 ("%s: error accessing socket \"%s\"",
                progname, socket_name);
       exit (EXIT_FAILURE);
     }
@@ -754,7 +857,7 @@
       if ((s != INVALID_SOCKET) || alternate_editor)
         return s;
 
-      fprintf (stderr, "%s: error accessing server file \"%s\"",
+      errormsg2 ("%s: error accessing server file \"%s\"",
                progname, server_file);
       exit (EXIT_FAILURE);
     }
@@ -773,7 +876,7 @@
     return s;
 
   /* No implicit or explicit socket, and no alternate editor.  */
-  fprintf (stderr, "%s: No socket or alternate editor.  Please use:\n\n"
+  errormsg1 ("%s: No socket or alternate editor.  Please use:\n\n"
 #ifndef NO_SOCKETS_IN_FILE_SYSTEM
 "\t--socket-name\n"
 #endif
@@ -793,6 +896,10 @@
   char *cwd;
   char string[BUFSIZ+1];
 
+#ifdef WINDOWSNT
+  w32_check_console_app();
+#endif
+
   progname = argv[0];
 
   /* Process options.  */
@@ -800,8 +907,8 @@
 
   if ((argc - optind < 1) && !eval)
     {
-      fprintf (stderr, "%s: file name or argument required\n", progname);
-      fprintf (stderr, "Try `%s --help' for more information\n", progname);
+      errormsg2 ("%s: file name or argument required\nTry `%s --help' for more information\n",
+              progname, progname);
       exit (EXIT_FAILURE);
     }
 
@@ -817,10 +924,10 @@
     {
       /* getwd puts message in STRING if it fails.  */
 #ifdef HAVE_GETCWD
-      fprintf (stderr, "%s: %s (%s)\n", progname,
+      errormsg3 ("%s: %s (%s)\n", progname,
 	       "Cannot get current working directory", strerror (errno));
 #else
-      fprintf (stderr, "%s: %s (%s)\n", progname, string, strerror (errno));
+      errormsg3 ("%s: %s (%s)\n", progname, string, strerror (errno));
 #endif
       fail (argc, argv);
     }

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

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

  reply	other threads:[~2006-11-13 16:19 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-11-12 22:17 I can't build from cvs sources on cygwin for some time now Eric Lilja
2006-11-12 22:23 ` Juanma Barranquero
2006-11-12 22:29   ` Eric Lilja
2006-11-12 22:34     ` Juanma Barranquero
2006-11-12 22:46       ` Eric Lilja
2006-11-12 22:56         ` Eric Lilja
2006-11-12 23:05           ` Juanma Barranquero
2006-11-12 23:22             ` Eric Lilja
2006-11-12 23:44               ` Juanma Barranquero
2006-11-12 23:52                 ` Eric Lilja
2006-11-13  0:07           ` Jason Rumney
2006-11-13  0:49             ` Juanma Barranquero
2006-11-13  2:13               ` Juanma Barranquero
2006-11-13  8:21                 ` Eric Lilja
2006-11-13 11:37                 ` Jason Rumney
2006-11-13 12:25                   ` Juanma Barranquero
2006-11-13 11:41                 ` emacsclientw Jason Rumney
2006-11-13 12:23                   ` emacsclientw Juanma Barranquero
2006-11-13 16:19                     ` Lennart Borgman [this message]
2006-11-13 12:36                   ` emacsclientw dhruva
2006-11-13 12:39                     ` emacsclientw Juanma Barranquero
2006-11-13 13:14                       ` emacsclientw dhruva
2006-11-13 13:31                         ` emacsclientw Juanma Barranquero
2006-11-13 22:43                         ` emacsclientw Jason Rumney
2006-11-13 22:56                           ` emacsclientw Lennart Borgman
2006-11-14  3:32                           ` emacsclientw dhruva
2006-11-14  7:18                             ` emacsclientw Mathias Dahl
2006-11-14  7:34                               ` emacsclientw Jason Rumney
2006-11-14  8:44                                 ` emacsclientw Mathias Dahl
2006-12-05 23:15                                   ` emacsclientw Stuart D. Herring
2006-11-14  8:39                               ` emacsclientw dhruva
2006-11-14  7:30                             ` emacsclientw Jason Rumney
2006-11-13 14:11                   ` emacsclientw Lennart Borgman
2006-11-13 14:40                     ` emacsclientw Juanma Barranquero
2006-11-13 19:36                       ` emacsclientw Stefan Monnier
2006-11-13 20:08                         ` emacsclientw Juanma Barranquero
2006-11-13 21:33                           ` emacsclientw Stefan Monnier
2006-11-13 22:23                             ` emacsclientw Lennart Borgman
2006-11-13 22:40                             ` emacsclientw Juanma Barranquero
2006-11-13 22:54                               ` emacsclientw Lennart Borgman
2006-11-13 23:10                                 ` emacsclientw Juanma Barranquero
2006-11-14  0:45                                   ` emacsclientw Lennart Borgman
2006-11-13 23:20                               ` emacsclientw Jason Rumney
2006-11-13 20:12                     ` emacsclientw Eli Zaretskii
2006-11-12 23:01         ` I can't build from cvs sources on cygwin for some time now Juanma Barranquero
2006-11-12 23:24           ` Eric Lilja
2006-11-12 23:45             ` Juanma Barranquero
2006-11-13 12:21 ` Eric Lilja

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=45589AFB.2040103@student.lu.se \
    --to=lennart.borgman.073@student.lu.se \
    --cc=lekktu@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.