[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: emacsclientw
From: |
Lennart Borgman |
Subject: |
Re: emacsclientw |
Date: |
Mon, 13 Nov 2006 17:19:07 +0100 |
User-agent: |
Thunderbird 1.5.0.8 (Windows/20061025) |
Juanma Barranquero wrote:
On 11/13/06, Jason Rumney <address@hidden> 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.)
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);
}
- Re: I can't build from cvs sources on cygwin for some time now, (continued)
- Re: I can't build from cvs sources on cygwin for some time now, Jason Rumney, 2006/11/12
- Re: I can't build from cvs sources on cygwin for some time now, Juanma Barranquero, 2006/11/12
- Re: I can't build from cvs sources on cygwin for some time now, Juanma Barranquero, 2006/11/12
- Re: I can't build from cvs sources on cygwin for some time now, Eric Lilja, 2006/11/13
- Re: I can't build from cvs sources on cygwin for some time now, Jason Rumney, 2006/11/13
- Re: I can't build from cvs sources on cygwin for some time now, Juanma Barranquero, 2006/11/13
- emacsclientw, Jason Rumney, 2006/11/13
- Re: emacsclientw, Juanma Barranquero, 2006/11/13
- Re: emacsclientw,
Lennart Borgman <=
- Re: emacsclientw, dhruva, 2006/11/13
- Re: emacsclientw, Juanma Barranquero, 2006/11/13
- Re: emacsclientw, dhruva, 2006/11/13
- Re: emacsclientw, Juanma Barranquero, 2006/11/13
- Re: emacsclientw, Jason Rumney, 2006/11/13
- Re: emacsclientw, Lennart Borgman, 2006/11/13
- Re: emacsclientw, dhruva, 2006/11/13
- Re: emacsclientw, Mathias Dahl, 2006/11/14
- Re: emacsclientw, Jason Rumney, 2006/11/14
- Re: emacsclientw, Mathias Dahl, 2006/11/14