/* Nonzero means args are expressions to be evaluated. --eval. */
int eval = 0;
+/* Nonzero means open a new graphical frame. */
+int window_system = 0;
+
/* The display on which Emacs should work. --display. */
char *display = NULL;
/* Nonzero means open a new Emacs frame on the current terminal. */
-int frame = 0;
+int tty = 0;
/* If non-NULL, the name of an editor to fallback to if the server
is not running. --alternate-editor. */
{ "help", no_argument, NULL, 'H' },
{ "version", no_argument, NULL, 'V' },
{ "tty", no_argument, NULL, 't' },
+ { "window-system", no_argument, NULL, 'w' },
{ "alternate-editor", required_argument, NULL, 'a' },
{ "socket-name", required_argument, NULL, 's' },
{ "display", required_argument, NULL, 'd' },
char **argv;
{
alternate_editor = getenv ("ALTERNATE_EDITOR");
+ display = getenv ("DISPLAY");
while (1)
{
int opt = getopt_long (argc, argv,
- "VHnea:s:d:t", longopts, 0);
+ "VHnea:s:d:tw", longopts, 0);
if (opt == EOF)
break;
break;
case 't':
- frame = 1;
+ tty = 1;
+ window_system = 0;
+ break;
+
+ case 'w':
+ window_system = 1;
+ tty = 0;
break;
case 'H':
}
}
- if (frame) {
+ if (tty) {
nowait = 0;
display = 0;
}
-
}
void
-V, --version Just print a version info and return\n\
-H, --help Print this usage information message\n\
-t, --tty Open a new Emacs frame on the current terminal\n\
+-w, --window-system Open a new graphical Emacs frame\n\
-n, --no-wait Don't wait for the server to return\n\
-e, --eval Evaluate the FILE arguments as ELisp expressions\n\
-d, --display=DISPLAY Visit the file in the given display\n\
int emacs_pid;
-#ifdef nec_ews_svr4
-extern char *_sobuf ;
-#else
-#if defined (USG) || defined (DGUX)
-unsigned char _sobuf[BUFSIZ+8];
-#else
-char _sobuf[BUFSIZ];
-#endif
-#endif
-
/* A signal handler that passes the signal to the Emacs process.
Useful for SIGWINCH. */
/* Process options. */
decode_options (argc, argv);
- if ((argc - optind < 1) && !eval && !frame)
+ if ((argc - optind < 1) && !eval && !tty && !window_system)
{
fprintf (stderr, "%s: file name or argument required\n", progname);
fprintf (stderr, "Try `%s --help' for more information\n", progname);
fprintf (out, " ");
}
- if (frame)
+ if (tty)
{
char *tty_name = ttyname (fileno (stdin));
if (! tty_name)
quote_file_name (getenv("TERM"), out);
fprintf (out, " ");
}
+
+ if (window_system)
+ fprintf (out, "-window-system ");
if ((argc - optind > 0))
{
}
else
{
- if (!frame)
+ if (!tty && !window_system)
{
while ((str = fgets (string, BUFSIZ, stdin)))
{
return 0;
}
- if (!eval && !frame)
+ if (!eval && !tty)
{
printf ("Waiting for Emacs...");
needlf = 2;
/* Now, wait for an answer and print any messages. */
while ((str = fgets (string, BUFSIZ, in)))
{
- if (frame)
+ if (strprefix ("-emacs-pid ", str))
{
- if (strprefix ("emacs-pid ", str))
- {
- emacs_pid = strtol (string + strlen ("emacs-pid"), NULL, 10);
- }
+ emacs_pid = strtol (string + strlen ("-emacs-pid"), NULL, 10);
+ }
+ else if (strprefix ("-print ", str))
+ {
+ if (needlf == 2)
+ printf ("\n");
+ printf ("%s", str + strlen ("-print "));
+ needlf = str[0] == '\0' ? needlf : str[strlen (str) - 1] != '\n';
+ }
+ else if (strprefix ("-error ", str))
+ {
+ if (needlf == 2)
+ printf ("\n");
+ printf ("*ERROR*: %s", str + strlen ("-print "));
+ needlf = str[0] == '\0' ? needlf : str[strlen (str) - 1] != '\n';
}
else
{
if (needlf == 2)
printf ("\n");
- printf ("%s", str);
+ printf ("*ERROR*: Unknown message: %s", str);
needlf = str[0] == '\0' ? needlf : str[strlen (str) - 1] != '\n';
}
}