[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] Changes to emacs/lib-src/emacsclient.c,v
From: |
Chong Yidong |
Subject: |
[Emacs-diffs] Changes to emacs/lib-src/emacsclient.c,v |
Date: |
Sun, 02 Nov 2008 21:41:58 +0000 |
CVSROOT: /sources/emacs
Module name: emacs
Changes by: Chong Yidong <cyd> 08/11/02 21:41:58
Index: emacsclient.c
===================================================================
RCS file: /sources/emacs/emacs/lib-src/emacsclient.c,v
retrieving revision 1.138
retrieving revision 1.139
diff -u -b -r1.138 -r1.139
--- emacsclient.c 1 Nov 2008 13:48:55 -0000 1.138
+++ emacsclient.c 2 Nov 2008 21:41:57 -0000 1.139
@@ -129,9 +129,6 @@
/* Nonzero means don't open a new frame. Inverse of --create-frame. */
int current_frame = 1;
-/* Nonzero means open a new graphical frame. */
-int window_system = 0;
-
/* The display on which Emacs should work. --display. */
char *display = NULL;
@@ -527,11 +524,9 @@
to allow it, for the occasional case where the user is
connecting with a w32 client to a server compiled with X11
support. */
-#if 1 /* !defined WINDOWS */
case 'd':
display = optarg;
break;
-#endif
case 'n':
nowait = 1;
@@ -566,38 +561,27 @@
}
}
- /* We used to set `display' to $DISPLAY by default, but this changed the
- default behavior and is sometimes inconvenient. So instead of forcing
- users to say "--display ''" when they want to use Emacs's existing tty
- or display connection, we force them to use "--display $DISPLAY" if
- they want Emacs to connect to their current display.
- -c still implicitly passes --display $DISPLAY unless -t was specified
- so as to try and mimick the behavior of `emacs' which either uses
- the current tty or the current $DISPLAY. */
+ /* If the -c option is used (without -t) and no --display argument
+ is provided, try $DISPLAY.
+ Without the -c option, we used to set `display' to $DISPLAY by
+ default, but this changed the default behavior and is sometimes
+ inconvenient. So we force users to use "--display $DISPLAY" if
+ they want Emacs to connect to their current display. */
if (!current_frame && !tty && !display)
display = egetenv ("DISPLAY");
+ /* A null-string display is invalid. */
if (display && strlen (display) == 0)
display = NULL;
- if (!tty && display)
- window_system = 1;
- else if (!current_frame)
+ /* If no display is available, new frames are tty frames. */
+ if (!current_frame && !display)
tty = 1;
/* --no-wait implies --current-frame on ttys when there are file
arguments or expressions given. */
if (nowait && tty && argc - optind > 0)
current_frame = 1;
-
- if (current_frame)
- {
- tty = 0;
- window_system = 0;
- }
-
- if (tty)
- window_system = 0;
}
@@ -1099,6 +1083,60 @@
errno = old_errno;
}
+
+
+/* Get tty name and type. If successful, return the type in TTY_TYPE
+ and the name in TTY_NAME, and return 1. Otherwise, fail if NOABORT
+ is zero, or return 0 if NOABORT is non-zero. */
+
+int
+find_tty (char **tty_type, char **tty_name, int noabort)
+{
+ char *type = egetenv ("TERM");
+ char *name = ttyname (fileno (stdout));
+
+ if (!name)
+ {
+ if (noabort)
+ return 0;
+ else
+ {
+ message (TRUE, "%s: could not get terminal name\n", progname);
+ fail ();
+ }
+ }
+
+ if (!type)
+ {
+ if (noabort)
+ return 0;
+ else
+ {
+ message (TRUE, "%s: please set the TERM variable to your terminal
type\n",
+ progname);
+ fail ();
+ }
+ }
+
+ if (strcmp (type, "eterm") == 0)
+ {
+ if (noabort)
+ return 0;
+ else
+ {
+ /* This causes nasty, MULTI_KBOARD-related input lockouts. */
+ message (TRUE, "%s: opening a frame in an Emacs term buffer"
+ " is not supported\n", progname);
+ fail ();
+ }
+ }
+
+ *tty_name = name;
+ *tty_type = type;
+ return 1;
+}
+
+
/* Set up signal handlers before opening a frame on the current tty. */
void
@@ -1384,7 +1422,7 @@
/* Process options. */
decode_options (argc, argv);
- if ((argc - optind < 1) && !eval && !tty && !window_system)
+ if ((argc - optind < 1) && !eval && current_frame)
{
message (TRUE, "%s: file name or argument required\n"
"Try `%s --help' for more information\n",
@@ -1409,7 +1447,7 @@
w32_give_focus ();
#endif
- /* Send over our environment. */
+ /* Send over our environment and current directory. */
if (!current_frame)
{
extern char **environ;
@@ -1422,11 +1460,6 @@
quote_argument (emacs_socket, environ[i]);
send_to_emacs (emacs_socket, " ");
}
- }
-
- /* Send over our current directory. */
- if (!current_frame)
- {
send_to_emacs (emacs_socket, "-dir ");
quote_argument (emacs_socket, cwd);
send_to_emacs (emacs_socket, "/");
@@ -1452,43 +1485,22 @@
frame is available. */
if (tty || (current_frame && !eval))
{
- char *type = egetenv ("TERM");
- char *tty_name = NULL;
-
- tty_name = ttyname (fileno (stdout));
-
- if (! tty_name)
- {
- message (TRUE, "%s: could not get terminal name\n", progname);
- fail ();
- }
+ char *tty_type, *tty_name;
- if (! type)
+ if (find_tty (&tty_type, &tty_name, !tty))
{
- message (TRUE, "%s: please set the TERM variable to your terminal
type\n",
- progname);
- fail ();
- }
-
- if (! strcmp (type, "eterm"))
- {
- /* This causes nasty, MULTI_KBOARD-related input lockouts. */
- message (TRUE, "%s: opening a frame in an Emacs term buffer"
- " is not supported\n", progname);
- fail ();
- }
#if !defined (NO_SOCKETS_IN_FILE_SYSTEM)
init_signals ();
#endif
-
send_to_emacs (emacs_socket, "-tty ");
quote_argument (emacs_socket, tty_name);
send_to_emacs (emacs_socket, " ");
- quote_argument (emacs_socket, type);
+ quote_argument (emacs_socket, tty_type);
send_to_emacs (emacs_socket, " ");
}
+ }
- if (window_system)
+ if (!current_frame && !tty)
send_to_emacs (emacs_socket, "-window-system ");
if ((argc - optind > 0))
@@ -1555,21 +1567,16 @@
send_to_emacs (emacs_socket, " ");
}
}
- else
- {
- if (!tty && !window_system)
+ else if (eval)
{
+ /* Read expressions interactively. */
while ((str = fgets (string, BUFSIZ, stdin)))
{
- if (eval)
send_to_emacs (emacs_socket, "-eval ");
- else
- send_to_emacs (emacs_socket, "-file ");
quote_argument (emacs_socket, str);
}
send_to_emacs (emacs_socket, " ");
}
- }
send_to_emacs (emacs_socket, "\n");
@@ -1601,7 +1608,6 @@
{
/* -window-system-unsupported: Emacs was compiled without X
support. Try again on the terminal. */
- window_system = 0;
nowait = 0;
tty = 1;
goto retry;