aboutsummaryrefslogtreecommitdiffstats
path: root/lib-src
diff options
context:
space:
mode:
authorMiles Bader2007-10-11 16:24:58 +0000
committerMiles Bader2007-10-11 16:24:58 +0000
commitc73bd236f75b742ad4642ec94798987ae6e3e1e8 (patch)
treeef5edc8db557fc1d25a17c379e4ae63a38b3ba5c /lib-src
parentecb21060d5c1752d41d7a742be565c59b5fcb855 (diff)
parent58ade22bf16a9ec2ff0aee6c59d8db4d1703e94f (diff)
downloademacs-c73bd236f75b742ad4642ec94798987ae6e3e1e8.tar.gz
emacs-c73bd236f75b742ad4642ec94798987ae6e3e1e8.zip
Merge from emacs--devo--0
Patches applied: * emacs--devo--0 (patch 866-879) - Merge multi-tty branch - Update from CVS - Merge from emacs--rel--22 Revision: emacs@sv.gnu.org/emacs--unicode--0--patch-257
Diffstat (limited to 'lib-src')
-rw-r--r--lib-src/ChangeLog111
-rw-r--r--lib-src/Makefile.in30
-rw-r--r--lib-src/emacsclient.c793
-rw-r--r--lib-src/emacstool.c504
-rw-r--r--lib-src/makefile.w32-in6
5 files changed, 731 insertions, 713 deletions
diff --git a/lib-src/ChangeLog b/lib-src/ChangeLog
index 9d7d076ca46..6ea05fb9e9a 100644
--- a/lib-src/ChangeLog
+++ b/lib-src/ChangeLog
@@ -1,3 +1,103 @@
12007-10-09 Juanma Barranquero <lekktu@gmail.com>
2
3 * emacsclient.c (print_help_and_exit): Fix space to improve
4 alignment in output messages.
5
62007-09-27 Jason Rumney <jasonr@gnu.org>
7
8 * makefile.w32-in (emacsclient, emacsclientw): Link to COMCTL32.
9
10 * emacsclient.c (w32_window_app): Init common controls when windowed.
11
122007-09-21 Glenn Morris <rgm@gnu.org>
13
14 * emacstool.c: Remove file.
15 * Makefile.in (emacstool, nemacstool, xvetool, xveterm):
16 Delete targets built from emacstool.
17
182007-09-21 Stefan Monnier <monnier@iro.umontreal.ca>
19
20 * emacsclient.c (decode_options): -t implies -c.
21
222007-09-20 Stefan Monnier <monnier@iro.umontreal.ca>
23
24 * emacsclient.c (DIRECTORY_SEP, IS_DIRECTORY_SEP, IS_DEVICE_SEP)
25 (IS_ANY_SEP): Only define if !defined(HAVE_GET_CURRENT_DIR_NAME).
26 (main_argc): Remove.
27 (strprefix): Use strncmp.
28
292007-09-20 Jason Rumney <jasonr@gnu.org>
30
31 * emacsclient.c (main) [SIGSTOP]: Change conditional from WINDOWSNT.
32
332007-09-20 Stefan Monnier <monnier@iro.umontreal.ca>
34
35 * emacsclient.c (current_frame): Change the default.
36 (longopts): Replace --current-frame by --create-frame.
37 (decode_options): Reverse the meaning of -c.
38 (print_help_and_exit): Update help text accordingly.
39 (main): Remove the -version and -good-version messages.
40
412007-09-12 Glenn Morris <rgm@gnu.org>
42
43 * Makefile.in (SOURCES, unlock, relock): Delete.
44
452007-08-29 Glenn Morris <rgm@gnu.org>
46
47 * makefile.w32-in (VERSION): Increase to 23.0.50.
48
492007-08-29 Dan Nicolaescu <dann@ics.uci.edu>
50
51 * emacsclient.c (w32_execvp): Move definition before use.
52 (decode_options): Don't use a tty on mac carbon or windows.
53
542007-08-29 Jason Rumney <jasonr@gnu.org>
55
56 * emacsclient.c (SEND_STRING, SEND_QUOTED): Remove obfuscation macros.
57 (quote_argument, set_tcp_socket, handle_sigcont, handle_sigtstp):
58 (main): Expand removed macros inline.
59 (main) [WINDOWSNT]: Don't call ttyname. Don't recognize -suspend
60 option.
61 (main) [NO_SOCKETS_IN_FILE_SYSTEM]: Don't call init_signals.
62
632007-08-29 Karoly Lorentey <lorentey@elte.hu>
64
65 * emacsclient.c (signal.h): New include.
66 (sys/stat.h, errno.h): Always include, even on WINDOWSNT.
67 (DIRECTORY_SEP, IS_DIRECTORY_SEP, IS_DEVICE_SEP, IS_ANY_SEP):
68 Copy definitions here from src/lisp.h.
69 (main_argc, main_argv, current_frame, window_system, tty): New vars.
70 (longopts): Add tty, current-frame.
71 (xmalloc, xstrdup): New functions.
72 (get_current_dir_name): New function, copied from src/sysdep.c.
73 (decode_options): Set display from environment. Add tty and
74 current_frame options. Make --no-wait imply --current-frame,
75 except when it is the only option given. Make sure no frame is
76 opened when --current-frame is set.
77 (print_help_and_exit): Document tty and current-frame options.
78 (fail): Change arguments to void.
79 (main): When sockets are not defined, set main_argc, main_argv,
80 and call fail() with no arguments.
81 (emacs_socket): New variable (moved out from main `s').
82 (quote_file_name): Rename to quote_argument.
83 (quote_argument): New name for old quote_file_name.
84 (unquote_argument, strprefix, pass_signal_to_emacs)
85 (handle_sigcont, handle_sigtstp, init_signals): New functions.
86 (set_local_socket): Initialize saved_errno to 0. If socket-name
87 is too long, call `fail' rather than `exit'.
88 (main): Doc update. Set main_argc, main_argv. New var `str'.
89 Don't need a filename or argument if tty or window_system set.
90 Call fail with no arguments. Use get_current_dir_name to send
91 over the current directory. Send version number to Emacs for
92 verification. If tty is set, check TERM, and pass name and type
93 to Emacs. Pass window_system to Emacs. Move sending of eval to
94 optind loop. Send -position, -file to Emacs. Call fsync after
95 fflush. Check for a client/server version match.
96 Handle -emacs-pid, -window-system-unsupported, -print, -error, and
97 -suspend commands. Don't exit prematurely on --no-wait, let Emacs
98 close the connection for us. When creating a new frame, send
99 environment and pwd to Emacs. Send current-frame to Emacs.
100
12007-08-25 Eli Zaretskii <eliz@gnu.org> 1012007-08-25 Eli Zaretskii <eliz@gnu.org>
2 102
3 * Makefile.in (rcs2log, rcs-checkin, grep-changelog, vcdiff): 103 * Makefile.in (rcs2log, rcs-checkin, grep-changelog, vcdiff):
@@ -316,8 +416,7 @@
316 suggest using options to make them explicit. 416 suggest using options to make them explicit.
317 (AUTH_KEY_LENGTH, SEND_BUFFER_SIZE): New constants. 417 (AUTH_KEY_LENGTH, SEND_BUFFER_SIZE): New constants.
318 (send_buffer, sblen): New variables. 418 (send_buffer, sblen): New variables.
319 (send_to_emacs): New function to buffer output and send it with 419 (send_to_emacs): New function to buffer output and send it with `send'.
320 send().
321 (quote_file_name): Use SEND_STRING. 420 (quote_file_name): Use SEND_STRING.
322 (close_winsock, initialize_sockets): New functions to load and 421 (close_winsock, initialize_sockets): New functions to load and
323 unload Winsock. 422 unload Winsock.
@@ -423,8 +522,8 @@
423 522
4242006-05-23 Francesco Potort,Al(B <pot@gnu.org> 5232006-05-23 Francesco Potort,Al(B <pot@gnu.org>
425 524
426 * pop.c (pop_open, socket_connection, KPOP_SERVICE): Added 525 * pop.c (pop_open, socket_connection, KPOP_SERVICE):
427 comments explaining why the "kpop" service is never used. 526 Add comments explaining why the "kpop" service is never used.
428 527
4292006-05-13 Eli Zaretskii <eliz@gnu.org> 5282006-05-13 Eli Zaretskii <eliz@gnu.org>
430 529
@@ -532,7 +631,7 @@
532 631
533 * makefile.w32-in (../src/config.h): Don't overwrite. Print a 632 * makefile.w32-in (../src/config.h): Don't overwrite. Print a
534 message instead. 633 message instead.
535 (../src/paths.h): Removed. 634 (../src/paths.h): Remove.
536 635
5372005-07-27 Juanma Barranquero <lekktu@gmail.com> 6362005-07-27 Juanma Barranquero <lekktu@gmail.com>
538 637
@@ -910,7 +1009,7 @@
910 1009
9112003-01-06 Kim F. Storm <storm@cua.dk> 10102003-01-06 Kim F. Storm <storm@cua.dk>
912 1011
913 * pop.c (__P): Renamed from _P to avoid problems on Cygwin. 1012 * pop.c (__P): Rename from _P to avoid problems on Cygwin.
914 All uses changed. 1013 All uses changed.
915 1014
9162002-12-18 Andrew Innes <andrewi@gnu.org> 10152002-12-18 Andrew Innes <andrewi@gnu.org>
diff --git a/lib-src/Makefile.in b/lib-src/Makefile.in
index 5d8da71dbdd..91074d3ccb1 100644
--- a/lib-src/Makefile.in
+++ b/lib-src/Makefile.in
@@ -122,9 +122,6 @@ SCRIPTS= rcs2log vcdiff
122 122
123EXECUTABLES= ${UTILITIES} ${INSTALLABLES} ${SCRIPTS} ${INSTALLABLE_SCRIPTS} 123EXECUTABLES= ${UTILITIES} ${INSTALLABLES} ${SCRIPTS} ${INSTALLABLE_SCRIPTS}
124 124
125SOURCES = COPYING ChangeLog Makefile.in README emacs.csh \
126 makedoc.com *.[chy] rcs2log vcdiff
127
128# Additional -D flags for movemail (add to MOVE_FLAGS if desired): 125# Additional -D flags for movemail (add to MOVE_FLAGS if desired):
129# MAIL_USE_POP Support mail retrieval from a POP mailbox. 126# MAIL_USE_POP Support mail retrieval from a POP mailbox.
130# MAIL_USE_MMDF Support MMDF mailboxes. 127# MAIL_USE_MMDF Support MMDF mailboxes.
@@ -368,12 +365,6 @@ maintainer-clean: distclean
368extraclean: maintainer-clean 365extraclean: maintainer-clean
369 -rm -f *~ \#* 366 -rm -f *~ \#*
370 367
371unlock:
372 chmod u+w $(SOURCES)
373
374relock:
375 chmod u-w $(SOURCES)
376
377/* Test the contents of the directory. */ 368/* Test the contents of the directory. */
378check: 369check:
379 @echo "We don't have any tests for GNU Emacs yet." 370 @echo "We don't have any tests for GNU Emacs yet."
@@ -471,24 +462,3 @@ update-game-score${EXEEXT}: update-game-score.o $(GETOPTDEPS)
471update-game-score.o: ${srcdir}/update-game-score.c ../src/config.h $(GETOPT_H) 462update-game-score.o: ${srcdir}/update-game-score.c ../src/config.h $(GETOPT_H)
472 $(CC) -c ${CPP_CFLAGS} ${srcdir}/update-game-score.c \ 463 $(CC) -c ${CPP_CFLAGS} ${srcdir}/update-game-score.c \
473 -DHAVE_SHARED_GAME_DIR="\"$(gamedir)\"" 464 -DHAVE_SHARED_GAME_DIR="\"$(gamedir)\""
474
475/* These are NOT included in INSTALLABLES or UTILITIES.
476 See ../src/Makefile.in. */
477emacstool${EXEEXT}: ${srcdir}/emacstool.c
478 $(CC) ${srcdir}/emacstool.c -o emacstool ${ALL_CFLAGS} \
479 -lsuntool -lsunwindow -lpixrect $(LOADLIBES)
480
481/* For SUN Japanese Language Environment. */
482nemacstool${EXEEXT}: ${srcdir}/emacstool.c
483 $(CC) -o nemacstool -DJLE ${ALL_CFLAGS} ${srcdir}/emacstool.c \
484 -lsuntool -lmle -lsunwindow -lpixrect $(LOADLIBES)
485
486xvetool${EXEEXT}: ${srcdir}/emacstool.c
487 $(CC) -o xvetool -DXVIEW ${ALL_CFLAGS} ${srcdir}/emacstool.c \
488 -lxview -lX -I$(OPENWINHOME)/include -L$(OPENWINHOME)/lib \
489 $(LOADLIBES)
490
491xveterm${EXEEXT}: ${srcdir}/emacstool.c
492 $(CC) -o xveterm -DXVIEW -DTTERM ${ALL_CFLAGS} ${srcdir}/emacstool.c \
493 -lxview -lolgx -lX -I$(OPENWINHOME)/include -L$(OPENWINHOME)/lib \
494 $(LOADLIBES)
diff --git a/lib-src/emacsclient.c b/lib-src/emacsclient.c
index 9edba132134..bfa4f9c01d7 100644
--- a/lib-src/emacsclient.c
+++ b/lib-src/emacsclient.c
@@ -35,6 +35,7 @@ Boston, MA 02110-1301, USA. */
35# include <malloc.h> 35# include <malloc.h>
36# include <stdlib.h> 36# include <stdlib.h>
37# include <windows.h> 37# include <windows.h>
38# include <commctrl.h>
38 39
39# define NO_SOCKETS_IN_FILE_SYSTEM 40# define NO_SOCKETS_IN_FILE_SYSTEM
40 41
@@ -76,7 +77,12 @@ Boston, MA 02110-1301, USA. */
76# include <pwd.h> 77# include <pwd.h>
77#endif /* not WINDOWSNT */ 78#endif /* not WINDOWSNT */
78#endif /* not VMS */ 79#endif /* not VMS */
80#include <sys/stat.h>
79 81
82#include <signal.h>
83#include <errno.h>
84
85
80char *getenv (), *getwd (); 86char *getenv (), *getwd ();
81char *(getcwd) (); 87char *(getcwd) ();
82 88
@@ -84,8 +90,6 @@ char *(getcwd) ();
84#define VERSION "unspecified" 90#define VERSION "unspecified"
85#endif 91#endif
86 92
87#define SEND_STRING(data) (send_to_emacs (s, (data)))
88#define SEND_QUOTED(data) (quote_file_name (s, (data)))
89 93
90#ifndef EXIT_SUCCESS 94#ifndef EXIT_SUCCESS
91#define EXIT_SUCCESS 0 95#define EXIT_SUCCESS 0
@@ -110,15 +114,27 @@ char *(getcwd) ();
110/* Name used to invoke this program. */ 114/* Name used to invoke this program. */
111char *progname; 115char *progname;
112 116
117/* The second argument to main. */
118char **main_argv;
119
113/* Nonzero means don't wait for a response from Emacs. --no-wait. */ 120/* Nonzero means don't wait for a response from Emacs. --no-wait. */
114int nowait = 0; 121int nowait = 0;
115 122
116/* Nonzero means args are expressions to be evaluated. --eval. */ 123/* Nonzero means args are expressions to be evaluated. --eval. */
117int eval = 0; 124int eval = 0;
118 125
126/* Nonzero means don't open a new frame. Inverse of --create-frame. */
127int current_frame = 1;
128
129/* Nonzero means open a new graphical frame. */
130int window_system = 0;
131
119/* The display on which Emacs should work. --display. */ 132/* The display on which Emacs should work. --display. */
120char *display = NULL; 133char *display = NULL;
121 134
135/* Nonzero means open a new Emacs frame on the current terminal. */
136int tty = 0;
137
122/* If non-NULL, the name of an editor to fallback to if the server 138/* If non-NULL, the name of an editor to fallback to if the server
123 is not running. --alternate-editor. */ 139 is not running. --alternate-editor. */
124const char *alternate_editor = NULL; 140const char *alternate_editor = NULL;
@@ -140,6 +156,8 @@ struct option longopts[] =
140 { "eval", no_argument, NULL, 'e' }, 156 { "eval", no_argument, NULL, 'e' },
141 { "help", no_argument, NULL, 'H' }, 157 { "help", no_argument, NULL, 'H' },
142 { "version", no_argument, NULL, 'V' }, 158 { "version", no_argument, NULL, 'V' },
159 { "tty", no_argument, NULL, 't' },
160 { "create-frame", no_argument, NULL, 'c' },
143 { "alternate-editor", required_argument, NULL, 'a' }, 161 { "alternate-editor", required_argument, NULL, 'a' },
144#ifndef NO_SOCKETS_IN_FILE_SYSTEM 162#ifndef NO_SOCKETS_IN_FILE_SYSTEM
145 { "socket-name", required_argument, NULL, 's' }, 163 { "socket-name", required_argument, NULL, 's' },
@@ -149,6 +167,130 @@ struct option longopts[] =
149 { 0, 0, 0, 0 } 167 { 0, 0, 0, 0 }
150}; 168};
151 169
170
171/* Like malloc but get fatal error if memory is exhausted. */
172
173long *
174xmalloc (size)
175 unsigned int size;
176{
177 long *result = (long *) malloc (size);
178 if (result == NULL)
179 {
180 perror ("malloc");
181 exit (EXIT_FAILURE);
182 }
183 return result;
184}
185
186/* Like strdup but get a fatal error if memory is exhausted. */
187
188char *
189xstrdup (const char *s)
190{
191 char *result = strdup (s);
192 if (result == NULL)
193 {
194 perror ("strdup");
195 exit (EXIT_FAILURE);
196 }
197 return result;
198}
199
200/* From sysdep.c */
201#if !defined (HAVE_GET_CURRENT_DIR_NAME) || defined (BROKEN_GET_CURRENT_DIR_NAME)
202
203/* From lisp.h */
204#ifndef DIRECTORY_SEP
205#define DIRECTORY_SEP '/'
206#endif
207#ifndef IS_DIRECTORY_SEP
208#define IS_DIRECTORY_SEP(_c_) ((_c_) == DIRECTORY_SEP)
209#endif
210#ifndef IS_DEVICE_SEP
211#ifndef DEVICE_SEP
212#define IS_DEVICE_SEP(_c_) 0
213#else
214#define IS_DEVICE_SEP(_c_) ((_c_) == DEVICE_SEP)
215#endif
216#endif
217#ifndef IS_ANY_SEP
218#define IS_ANY_SEP(_c_) (IS_DIRECTORY_SEP (_c_))
219#endif
220
221
222/* Return the current working directory. Returns NULL on errors.
223 Any other returned value must be freed with free. This is used
224 only when get_current_dir_name is not defined on the system. */
225char*
226get_current_dir_name ()
227{
228 char *buf;
229 char *pwd;
230 struct stat dotstat, pwdstat;
231 /* If PWD is accurate, use it instead of calling getwd. PWD is
232 sometimes a nicer name, and using it may avoid a fatal error if a
233 parent directory is searchable but not readable. */
234 if ((pwd = getenv ("PWD")) != 0
235 && (IS_DIRECTORY_SEP (*pwd) || (*pwd && IS_DEVICE_SEP (pwd[1])))
236 && stat (pwd, &pwdstat) == 0
237 && stat (".", &dotstat) == 0
238 && dotstat.st_ino == pwdstat.st_ino
239 && dotstat.st_dev == pwdstat.st_dev
240#ifdef MAXPATHLEN
241 && strlen (pwd) < MAXPATHLEN
242#endif
243 )
244 {
245 buf = (char *) xmalloc (strlen (pwd) + 1);
246 if (!buf)
247 return NULL;
248 strcpy (buf, pwd);
249 }
250#ifdef HAVE_GETCWD
251 else
252 {
253 size_t buf_size = 1024;
254 buf = (char *) xmalloc (buf_size);
255 if (!buf)
256 return NULL;
257 for (;;)
258 {
259 if (getcwd (buf, buf_size) == buf)
260 break;
261 if (errno != ERANGE)
262 {
263 int tmp_errno = errno;
264 free (buf);
265 errno = tmp_errno;
266 return NULL;
267 }
268 buf_size *= 2;
269 buf = (char *) realloc (buf, buf_size);
270 if (!buf)
271 return NULL;
272 }
273 }
274#else
275 else
276 {
277 /* We need MAXPATHLEN here. */
278 buf = (char *) xmalloc (MAXPATHLEN + 1);
279 if (!buf)
280 return NULL;
281 if (getwd (buf) == NULL)
282 {
283 int tmp_errno = errno;
284 free (buf);
285 errno = tmp_errno;
286 return NULL;
287 }
288 }
289#endif
290 return buf;
291}
292#endif
293
152/* Message functions. */ 294/* Message functions. */
153 295
154#ifdef WINDOWSNT 296#ifdef WINDOWSNT
@@ -159,13 +301,51 @@ w32_window_app ()
159 char szTitle[MAX_PATH]; 301 char szTitle[MAX_PATH];
160 302
161 if (window_app < 0) 303 if (window_app < 0)
162 /* Checking for STDOUT does not work; it's a valid handle also in 304 {
163 nonconsole apps. Testing for the console title seems to work. */ 305 /* Checking for STDOUT does not work; it's a valid handle also in
164 window_app = (GetConsoleTitleA (szTitle, MAX_PATH) == 0); 306 nonconsole apps. Testing for the console title seems to work. */
307 window_app = (GetConsoleTitleA (szTitle, MAX_PATH) == 0);
308 if (window_app)
309 InitCommonControls();
310 }
165 311
166 return window_app; 312 return window_app;
167} 313}
168#endif 314
315/*
316 execvp wrapper for Windows. Quotes arguments with embedded spaces.
317
318 This is necessary due to the broken implementation of exec* routines in
319 the Microsoft libraries: they concatenate the arguments together without
320 quoting special characters, and pass the result to CreateProcess, with
321 predictably bad results. By contrast, Posix execvp passes the arguments
322 directly into the argv array of the child process.
323*/
324int
325w32_execvp (path, argv)
326 char *path;
327 char **argv;
328{
329 int i;
330
331 /* Required to allow a .BAT script as alternate editor. */
332 argv[0] = (char *) alternate_editor;
333
334 for (i = 0; argv[i]; i++)
335 if (strchr (argv[i], ' '))
336 {
337 char *quoted = alloca (strlen (argv[i]) + 3);
338 sprintf (quoted, "\"%s\"", argv[i]);
339 argv[i] = quoted;
340 }
341
342 return execvp (path, argv);
343}
344
345#undef execvp
346#define execvp w32_execvp
347
348#endif /* WINDOWSNT */
169 349
170void 350void
171message (int is_error, char *message, ...) 351message (int is_error, char *message, ...)
@@ -204,16 +384,19 @@ decode_options (argc, argv)
204 char **argv; 384 char **argv;
205{ 385{
206 alternate_editor = getenv ("ALTERNATE_EDITOR"); 386 alternate_editor = getenv ("ALTERNATE_EDITOR");
387 display = getenv ("DISPLAY");
388 if (display && strlen (display) == 0)
389 display = NULL;
207 390
208 while (1) 391 while (1)
209 { 392 {
210 int opt = getopt_long (argc, argv, 393 int opt = getopt_long (argc, argv,
211#ifndef NO_SOCKETS_IN_FILE_SYSTEM 394#ifndef NO_SOCKETS_IN_FILE_SYSTEM
212 "VHnea:s:f:d:", 395 "VHnea:s:f:d:tc",
213#else 396#else
214 "VHnea:f:d:", 397 "VHnea:f:d:tc",
215#endif 398#endif
216 longopts, 0); 399 longopts, 0);
217 400
218 if (opt == EOF) 401 if (opt == EOF)
219 break; 402 break;
@@ -256,6 +439,15 @@ decode_options (argc, argv)
256 exit (EXIT_SUCCESS); 439 exit (EXIT_SUCCESS);
257 break; 440 break;
258 441
442 case 't':
443 tty = 1;
444 current_frame = 0;
445 break;
446
447 case 'c':
448 current_frame = 0;
449 break;
450
259 case 'H': 451 case 'H':
260 print_help_and_exit (); 452 print_help_and_exit ();
261 break; 453 break;
@@ -266,21 +458,49 @@ decode_options (argc, argv)
266 break; 458 break;
267 } 459 }
268 } 460 }
461
462 if (!tty && display)
463 window_system = 1;
464#if !defined (WINDOWSNT) && !defined (HAVE_CARBON)
465 else
466 tty = 1;
467#endif
468
469 /* --no-wait implies --current-frame on ttys when there are file
470 arguments or expressions given. */
471 if (nowait && tty && argc - optind > 0)
472 current_frame = 1;
473
474 if (current_frame)
475 {
476 tty = 0;
477 window_system = 0;
478 }
479
480 if (tty)
481 window_system = 0;
269} 482}
270 483
484
271void 485void
272print_help_and_exit () 486print_help_and_exit ()
273{ 487{
488 /* Spaces and tabs are significant in this message; they're chosen so the
489 message aligns properly both in a tty and in a Windows message box.
490 Please try to preserve them; otherwise the output is very hard to read
491 when using emacsclientw. */
274 message (FALSE, 492 message (FALSE,
275 "Usage: %s [OPTIONS] FILE...\n\ 493 "Usage: %s [OPTIONS] FILE...\n\
276Tell the Emacs server to visit the specified files.\n\ 494Tell the Emacs server to visit the specified files.\n\
277Every FILE can be either just a FILENAME or [+LINE[:COLUMN]] FILENAME.\n\ 495Every FILE can be either just a FILENAME or [+LINE[:COLUMN]] FILENAME.\n\
278\n\ 496\n\
279The following OPTIONS are accepted:\n\ 497The following OPTIONS are accepted:\n\
280\n\
281-V, --version Just print version info and return\n\ 498-V, --version Just print version info and return\n\
282-H, --help Print this usage information message\n\ 499-H, --help Print this usage information message\n\
283-e, --eval Evaluate FILE arguments as Lisp expressions\n\ 500-t, --tty Open a new Emacs frame on the current terminal\n\
501-c, --create-frame Create a new frame instead of trying to\n\
502 use the current Emacs frame\n\
503-e, --eval Evaluate the FILE arguments as ELisp expressions\n\
284-n, --no-wait Don't wait for the server to return\n\ 504-n, --no-wait Don't wait for the server to return\n\
285-d, --display=DISPLAY Visit the file in the given display\n" 505-d, --display=DISPLAY Visit the file in the given display\n"
286#ifndef NO_SOCKETS_IN_FILE_SYSTEM 506#ifndef NO_SOCKETS_IN_FILE_SYSTEM
@@ -290,66 +510,27 @@ The following OPTIONS are accepted:\n\
290"-f, --server-file=FILENAME\n\ 510"-f, --server-file=FILENAME\n\
291 Set filename of the TCP authentication file\n\ 511 Set filename of the TCP authentication file\n\
292-a, --alternate-editor=EDITOR\n\ 512-a, --alternate-editor=EDITOR\n\
293 Editor to fallback to if server is not running\n\ 513 Editor to fallback to if the server is not running\n\
294\n\ 514\n\
295Report bugs to bug-gnu-emacs@gnu.org.\n", progname); 515Report bugs to bug-gnu-emacs@gnu.org.\n", progname);
296 exit (EXIT_SUCCESS); 516 exit (EXIT_SUCCESS);
297} 517}
298 518
299
300#ifdef WINDOWSNT
301
302/*
303 execvp wrapper for Windows. Quotes arguments with embedded spaces.
304
305 This is necessary due to the broken implementation of exec* routines in
306 the Microsoft libraries: they concatenate the arguments together without
307 quoting special characters, and pass the result to CreateProcess, with
308 predictably bad results. By contrast, Posix execvp passes the arguments
309 directly into the argv array of the child process.
310*/
311int
312w32_execvp (path, argv)
313 char *path;
314 char **argv;
315{
316 int i;
317
318 /* Required to allow a .BAT script as alternate editor. */
319 argv[0] = (char *) alternate_editor;
320
321 for (i = 0; argv[i]; i++)
322 if (strchr (argv[i], ' '))
323 {
324 char *quoted = alloca (strlen (argv[i]) + 3);
325 sprintf (quoted, "\"%s\"", argv[i]);
326 argv[i] = quoted;
327 }
328
329 return execvp (path, argv);
330}
331
332#undef execvp
333#define execvp w32_execvp
334
335#endif /* WINDOWSNT */
336
337/* 519/*
338 Try to run a different command, or --if no alternate editor is 520 Try to run a different command, or --if no alternate editor is
339 defined-- exit with an errorcode. 521 defined-- exit with an errorcode.
522 Uses argv, but gets it from the global variable main_argv.
340*/ 523*/
341void 524void
342fail (argc, argv) 525fail (void)
343 int argc;
344 char **argv;
345{ 526{
346 if (alternate_editor) 527 if (alternate_editor)
347 { 528 {
348 int i = optind - 1; 529 int i = optind - 1;
349 530
350 execvp (alternate_editor, argv + i); 531 execvp (alternate_editor, main_argv + i);
351 message (TRUE, "%s: error executing alternate editor \"%s\"\n", 532 message (TRUE, "%s: error executing alternate editor \"%s\"\n",
352 progname, alternate_editor); 533 progname, alternate_editor);
353 } 534 }
354 exit (EXIT_FAILURE); 535 exit (EXIT_FAILURE);
355} 536}
@@ -362,10 +543,12 @@ main (argc, argv)
362 int argc; 543 int argc;
363 char **argv; 544 char **argv;
364{ 545{
365 message (TRUE, "%s: Sorry, the Emacs server is supported only\non systems with Berkely sockets.\n", 546 main_argv = argv;
547 progname = argv[0];
548 message (TRUE, "%s: Sorry, the Emacs server is supported only\n"
549 "on systems with Berkeley sockets.\n",
366 argv[0]); 550 argv[0]);
367 551 fail ();
368 fail (argc, argv);
369} 552}
370 553
371#else /* HAVE_SOCKETS && HAVE_INET_SOCKETS */ 554#else /* HAVE_SOCKETS && HAVE_INET_SOCKETS */
@@ -376,8 +559,6 @@ main (argc, argv)
376# include <sys/types.h> 559# include <sys/types.h>
377# include <sys/socket.h> 560# include <sys/socket.h>
378# include <sys/un.h> 561# include <sys/un.h>
379# include <sys/stat.h>
380# include <errno.h>
381#endif 562#endif
382 563
383#define AUTH_KEY_LENGTH 64 564#define AUTH_KEY_LENGTH 64
@@ -389,6 +570,8 @@ extern int errno;
389/* Buffer to accumulate data to send in TCP connections. */ 570/* Buffer to accumulate data to send in TCP connections. */
390char send_buffer[SEND_BUFFER_SIZE + 1]; 571char send_buffer[SEND_BUFFER_SIZE + 1];
391int sblen = 0; /* Fill pointer for the send buffer. */ 572int sblen = 0; /* Fill pointer for the send buffer. */
573/* Socket used to communicate with the Emacs server process. */
574HSOCKET emacs_socket = 0;
392 575
393/* Let's send the data to Emacs when either 576/* Let's send the data to Emacs when either
394 - the data ends in "\n", or 577 - the data ends in "\n", or
@@ -429,18 +612,21 @@ send_to_emacs (s, data)
429 } 612 }
430} 613}
431 614
432/* In NAME, insert a & before each &, each space, each newline, and 615
616/* In STR, insert a & before each &, each space, each newline, and
433 any initial -. Change spaces to underscores, too, so that the 617 any initial -. Change spaces to underscores, too, so that the
434 return value never contains a space. */ 618 return value never contains a space.
619
620 Does not change the string. Outputs the result to STREAM. */
435void 621void
436quote_file_name (s, name) 622quote_argument (s, str)
437 HSOCKET s; 623 HSOCKET s;
438 char *name; 624 char *str;
439{ 625{
440 char *copy = (char *) malloc (strlen (name) * 2 + 1); 626 char *copy = (char *) xmalloc (strlen (str) * 2 + 1);
441 char *p, *q; 627 char *p, *q;
442 628
443 p = name; 629 p = str;
444 q = copy; 630 q = copy;
445 while (*p) 631 while (*p)
446 { 632 {
@@ -458,18 +644,54 @@ quote_file_name (s, name)
458 } 644 }
459 else 645 else
460 { 646 {
461 if (*p == '&' || (*p == '-' && p == name)) 647 if (*p == '&' || (*p == '-' && p == str))
462 *q++ = '&'; 648 *q++ = '&';
463 *q++ = *p++; 649 *q++ = *p++;
464 } 650 }
465 } 651 }
466 *q++ = 0; 652 *q++ = 0;
467 653
468 SEND_STRING (copy); 654 send_to_emacs (s, copy);
469 655
470 free (copy); 656 free (copy);
471} 657}
472 658
659
660/* The inverse of quote_argument. Removes quoting in string STR by
661 modifying the string in place. Returns STR. */
662
663char *
664unquote_argument (str)
665 char *str;
666{
667 char *p, *q;
668
669 if (! str)
670 return str;
671
672 p = str;
673 q = str;
674 while (*p)
675 {
676 if (*p == '&')
677 {
678 p++;
679 if (*p == '&')
680 *p = '&';
681 else if (*p == '_')
682 *p = ' ';
683 else if (*p == 'n')
684 *p = '\n';
685 else if (*p == '-')
686 *p = '-';
687 }
688 *q++ = *p++;
689 }
690 *q = 0;
691 return str;
692}
693
694
473int 695int
474file_name_absolute_p (filename) 696file_name_absolute_p (filename)
475 const unsigned char *filename; 697 const unsigned char *filename;
@@ -551,6 +773,7 @@ initialize_sockets ()
551 atexit (close_winsock); 773 atexit (close_winsock);
552} 774}
553#endif /* WINDOWSNT */ 775#endif /* WINDOWSNT */
776
554 777
555/* 778/*
556 * Read the information needed to set up a TCP comm channel with 779 * Read the information needed to set up a TCP comm channel with
@@ -661,13 +884,22 @@ set_tcp_socket ()
661 */ 884 */
662 auth_string[AUTH_KEY_LENGTH] = '\0'; 885 auth_string[AUTH_KEY_LENGTH] = '\0';
663 886
664 SEND_STRING ("-auth "); 887 send_to_emacs (s, "-auth ");
665 SEND_STRING (auth_string); 888 send_to_emacs (s, auth_string);
666 SEND_STRING ("\n"); 889 send_to_emacs (s, "\n");
667 890
668 return s; 891 return s;
669} 892}
670 893
894
895/* Returns 1 if PREFIX is a prefix of STRING. */
896static int
897strprefix (char *prefix, char *string)
898{
899 return !strncmp (prefix, string, strlen (prefix));
900}
901
902
671#if !defined (NO_SOCKETS_IN_FILE_SYSTEM) 903#if !defined (NO_SOCKETS_IN_FILE_SYSTEM)
672 904
673/* Three possibilities: 905/* Three possibilities:
@@ -690,6 +922,93 @@ socket_status (socket_name)
690 return 0; 922 return 0;
691} 923}
692 924
925
926/* A signal handler that passes the signal to the Emacs process.
927 Useful for SIGWINCH. */
928
929SIGTYPE
930pass_signal_to_emacs (int signalnum)
931{
932 int old_errno = errno;
933
934 if (emacs_pid)
935 kill (emacs_pid, signalnum);
936
937 signal (signalnum, pass_signal_to_emacs);
938 errno = old_errno;
939}
940
941/* Signal handler for SIGCONT; notify the Emacs process that it can
942 now resume our tty frame. */
943
944SIGTYPE
945handle_sigcont (int signalnum)
946{
947 int old_errno = errno;
948
949 if (tcgetpgrp (1) == getpgrp ())
950 {
951 /* We are in the foreground. */
952 send_to_emacs (emacs_socket, "-resume \n");
953 }
954 else
955 {
956 /* We are in the background; cancel the continue. */
957 kill (getpid (), SIGSTOP);
958 }
959
960 signal (signalnum, handle_sigcont);
961 errno = old_errno;
962}
963
964/* Signal handler for SIGTSTP; notify the Emacs process that we are
965 going to sleep. Normally the suspend is initiated by Emacs via
966 server-handle-suspend-tty, but if the server gets out of sync with
967 reality, we may get a SIGTSTP on C-z. Handling this signal and
968 notifying Emacs about it should get things under control again. */
969
970SIGTYPE
971handle_sigtstp (int signalnum)
972{
973 int old_errno = errno;
974 sigset_t set;
975
976 if (emacs_socket)
977 send_to_emacs (emacs_socket, "-suspend \n");
978
979 /* Unblock this signal and call the default handler by temprarily
980 changing the handler and resignalling. */
981 sigprocmask (SIG_BLOCK, NULL, &set);
982 sigdelset (&set, signalnum);
983 signal (signalnum, SIG_DFL);
984 kill (getpid (), signalnum);
985 sigprocmask (SIG_SETMASK, &set, NULL); /* Let's the above signal through. */
986 signal (signalnum, handle_sigtstp);
987
988 errno = old_errno;
989}
990/* Set up signal handlers before opening a frame on the current tty. */
991
992void
993init_signals (void)
994{
995 /* Set up signal handlers. */
996 signal (SIGWINCH, pass_signal_to_emacs);
997
998 /* Don't pass SIGINT and SIGQUIT to Emacs, because it has no way of
999 deciding which terminal the signal came from. C-g is now a
1000 normal input event on secondary terminals. */
1001#if 0
1002 signal (SIGINT, pass_signal_to_emacs);
1003 signal (SIGQUIT, pass_signal_to_emacs);
1004#endif
1005
1006 signal (SIGCONT, handle_sigcont);
1007 signal (SIGTSTP, handle_sigtstp);
1008 signal (SIGTTOU, handle_sigtstp);
1009}
1010
1011
693HSOCKET 1012HSOCKET
694set_local_socket () 1013set_local_socket ()
695{ 1014{
@@ -711,30 +1030,30 @@ set_local_socket ()
711 { 1030 {
712 int sock_status = 0; 1031 int sock_status = 0;
713 int default_sock = !socket_name; 1032 int default_sock = !socket_name;
714 int saved_errno; 1033 int saved_errno = 0;
715 char *server_name = "server"; 1034 char *server_name = "server";
716 1035
717 if (socket_name && !index (socket_name, '/') && !index (socket_name, '\\')) 1036 if (socket_name && !index (socket_name, '/') && !index (socket_name, '\\'))
718 { /* socket_name is a file name component. */ 1037 { /* socket_name is a file name component. */
719 server_name = socket_name; 1038 server_name = socket_name;
720 socket_name = NULL; 1039 socket_name = NULL;
721 default_sock = 1; /* Try both UIDs. */ 1040 default_sock = 1; /* Try both UIDs. */
722 } 1041 }
723 1042
724 if (default_sock) 1043 if (default_sock)
725 { 1044 {
726 socket_name = alloca (100 + strlen (server_name)); 1045 socket_name = alloca (100 + strlen (server_name));
727 sprintf (socket_name, "/tmp/emacs%d/%s", 1046 sprintf (socket_name, "/tmp/emacs%d/%s",
728 (int) geteuid (), server_name); 1047 (int) geteuid (), server_name);
729 } 1048 }
730 1049
731 if (strlen (socket_name) < sizeof (server.sun_path)) 1050 if (strlen (socket_name) < sizeof (server.sun_path))
732 strcpy (server.sun_path, socket_name); 1051 strcpy (server.sun_path, socket_name);
733 else 1052 else
734 { 1053 {
735 message (TRUE, "%s: socket-name %s too long", 1054 message (TRUE, "%s: socket-name %s too long",
736 progname, socket_name); 1055 progname, socket_name);
737 exit (EXIT_FAILURE); 1056 fail ();
738 } 1057 }
739 1058
740 /* See if the socket exists, and if it's owned by us. */ 1059 /* See if the socket exists, and if it's owned by us. */
@@ -773,7 +1092,7 @@ set_local_socket ()
773 } 1092 }
774 1093
775 sock_status = socket_status (server.sun_path); 1094 sock_status = socket_status (server.sun_path);
776 saved_errno = errno; 1095 saved_errno = errno;
777 } 1096 }
778 else 1097 else
779 errno = saved_errno; 1098 errno = saved_errno;
@@ -783,26 +1102,26 @@ set_local_socket ()
783 switch (sock_status) 1102 switch (sock_status)
784 { 1103 {
785 case 1: 1104 case 1:
786 /* There's a socket, but it isn't owned by us. This is OK if 1105 /* There's a socket, but it isn't owned by us. This is OK if
787 we are root. */ 1106 we are root. */
788 if (0 != geteuid ()) 1107 if (0 != geteuid ())
789 { 1108 {
790 message (TRUE, "%s: Invalid socket owner\n", progname); 1109 message (TRUE, "%s: Invalid socket owner\n", progname);
791 return INVALID_SOCKET; 1110 return INVALID_SOCKET;
792 } 1111 }
793 break; 1112 break;
794 1113
795 case 2: 1114 case 2:
796 /* `stat' failed */ 1115 /* `stat' failed */
797 if (saved_errno == ENOENT) 1116 if (saved_errno == ENOENT)
798 message (TRUE, 1117 message (TRUE,
799 "%s: can't find socket; have you started the server?\n\ 1118 "%s: can't find socket; have you started the server?\n\
800To start the server in Emacs, type \"M-x server-start\".\n", 1119To start the server in Emacs, type \"M-x server-start\".\n",
801 progname); 1120 progname);
802 else 1121 else
803 message (TRUE, "%s: can't stat %s: %s\n", 1122 message (TRUE, "%s: can't stat %s: %s\n",
804 progname, server.sun_path, strerror (saved_errno)); 1123 progname, server.sun_path, strerror (saved_errno));
805 return INVALID_SOCKET; 1124 return INVALID_SOCKET;
806 } 1125 }
807 } 1126 }
808 1127
@@ -830,10 +1149,9 @@ set_socket ()
830 { 1149 {
831 s = set_local_socket (); 1150 s = set_local_socket ();
832 if ((s != INVALID_SOCKET) || alternate_editor) 1151 if ((s != INVALID_SOCKET) || alternate_editor)
833 return s; 1152 return s;
834
835 message (TRUE, "%s: error accessing socket \"%s\"", 1153 message (TRUE, "%s: error accessing socket \"%s\"",
836 progname, socket_name); 1154 progname, socket_name);
837 exit (EXIT_FAILURE); 1155 exit (EXIT_FAILURE);
838 } 1156 }
839#endif 1157#endif
@@ -846,10 +1164,10 @@ set_socket ()
846 { 1164 {
847 s = set_tcp_socket (); 1165 s = set_tcp_socket ();
848 if ((s != INVALID_SOCKET) || alternate_editor) 1166 if ((s != INVALID_SOCKET) || alternate_editor)
849 return s; 1167 return s;
850 1168
851 message (TRUE, "%s: error accessing server file \"%s\"", 1169 message (TRUE, "%s: error accessing server file \"%s\"",
852 progname, server_file); 1170 progname, server_file);
853 exit (EXIT_FAILURE); 1171 exit (EXIT_FAILURE);
854 } 1172 }
855 1173
@@ -938,129 +1256,264 @@ main (argc, argv)
938 int argc; 1256 int argc;
939 char **argv; 1257 char **argv;
940{ 1258{
941 HSOCKET s;
942 int i, rl, needlf = 0; 1259 int i, rl, needlf = 0;
943 char *cwd; 1260 char *cwd, *str;
944 char string[BUFSIZ+1]; 1261 char string[BUFSIZ+1];
945 1262
1263 main_argv = argv;
946 progname = argv[0]; 1264 progname = argv[0];
947 1265
948 /* Process options. */ 1266 /* Process options. */
949 decode_options (argc, argv); 1267 decode_options (argc, argv);
950 1268
951 if ((argc - optind < 1) && !eval) 1269 if ((argc - optind < 1) && !eval && !tty && !window_system)
952 { 1270 {
953 message (TRUE, "%s: file name or argument required\nTry `%s --help' for more information\n", 1271 message (TRUE, "%s: file name or argument required\n"
954 progname, progname); 1272 "Try `%s --help' for more information\n",
1273 progname, progname);
955 exit (EXIT_FAILURE); 1274 exit (EXIT_FAILURE);
956 } 1275 }
957 1276
958 if ((s = set_socket ()) == INVALID_SOCKET) 1277 if ((emacs_socket = set_socket ()) == INVALID_SOCKET)
959 fail (argc, argv); 1278 fail ();
960 1279
961#ifdef HAVE_GETCWD 1280
962 cwd = getcwd (string, sizeof string); 1281 cwd = get_current_dir_name ();
963#else
964 cwd = getwd (string);
965#endif
966 if (cwd == 0) 1282 if (cwd == 0)
967 { 1283 {
968 /* getwd puts message in STRING if it fails. */ 1284 /* getwd puts message in STRING if it fails. */
969 message (TRUE, "%s: %s (%s)\n", progname, 1285 message (TRUE, "%s: %s\n", progname,
970#ifdef HAVE_GETCWD 1286 "Cannot get current working directory");
971 "Cannot get current working directory", 1287 fail ();
972#else
973 string,
974#endif
975 strerror (errno));
976 fail (argc, argv);
977 } 1288 }
978 1289
979#ifdef WINDOWSNT 1290#ifdef WINDOWSNT
980 w32_give_focus (); 1291 w32_give_focus ();
981#endif 1292#endif
982 1293
1294 /* Send over our environment. */
1295 if (!current_frame)
1296 {
1297 extern char **environ;
1298 int i;
1299 for (i = 0; environ[i]; i++)
1300 {
1301 char *name = xstrdup (environ[i]);
1302 char *value = strchr (name, '=');
1303 send_to_emacs (emacs_socket, "-env ");
1304 quote_argument (emacs_socket, environ[i]);
1305 send_to_emacs (emacs_socket, " ");
1306 }
1307 }
1308
1309 /* Send over our current directory. */
1310 if (!current_frame)
1311 {
1312 send_to_emacs (emacs_socket, "-dir ");
1313 quote_argument (emacs_socket, cwd);
1314 send_to_emacs (emacs_socket, "/");
1315 send_to_emacs (emacs_socket, " ");
1316 }
1317
1318 retry:
983 if (nowait) 1319 if (nowait)
984 SEND_STRING ("-nowait "); 1320 send_to_emacs (emacs_socket, "-nowait ");
985 1321
986 if (eval) 1322 if (current_frame)
987 SEND_STRING ("-eval "); 1323 send_to_emacs (emacs_socket, "-current-frame ");
988 1324
989 if (display) 1325 if (display)
990 { 1326 {
991 SEND_STRING ("-display "); 1327 send_to_emacs (emacs_socket, "-display ");
992 SEND_QUOTED (display); 1328 quote_argument (emacs_socket, display);
993 SEND_STRING (" "); 1329 send_to_emacs (emacs_socket, " ");
994 } 1330 }
995 1331
1332 if (tty)
1333 {
1334 char *type = getenv ("TERM");
1335 char *tty_name = NULL;
1336#ifndef WINDOWSNT
1337 tty_name = ttyname (fileno (stdin));
1338#endif
1339
1340 if (! tty_name)
1341 {
1342 message (TRUE, "%s: could not get terminal name\n", progname);
1343 fail ();
1344 }
1345
1346 if (! type)
1347 {
1348 message (TRUE, "%s: please set the TERM variable to your terminal type\n",
1349 progname);
1350 fail ();
1351 }
1352
1353 if (! strcmp (type, "eterm"))
1354 {
1355 /* This causes nasty, MULTI_KBOARD-related input lockouts. */
1356 message (TRUE, "%s: opening a frame in an Emacs term buffer"
1357 " is not supported\n", progname);
1358 fail ();
1359 }
1360#if !defined (NO_SOCKETS_IN_FILE_SYSTEM)
1361 init_signals ();
1362#endif
1363
1364 send_to_emacs (emacs_socket, "-tty ");
1365 quote_argument (emacs_socket, tty_name);
1366 send_to_emacs (emacs_socket, " ");
1367 quote_argument (emacs_socket, type);
1368 send_to_emacs (emacs_socket, " ");
1369 }
1370
1371 if (window_system)
1372 send_to_emacs (emacs_socket, "-window-system ");
1373
996 if ((argc - optind > 0)) 1374 if ((argc - optind > 0))
997 { 1375 {
998 for (i = optind; i < argc; i++) 1376 for (i = optind; i < argc; i++)
999 { 1377 {
1378 int relative = 0;
1379
1000 if (eval) 1380 if (eval)
1001 ; /* Don't prepend any cwd or anything like that. */ 1381 {
1002 else if (*argv[i] == '+') 1382 /* Don't prepend cwd or anything like that. */
1003 { 1383 send_to_emacs (emacs_socket, "-eval ");
1384 quote_argument (emacs_socket, argv[i]);
1385 send_to_emacs (emacs_socket, " ");
1386 continue;
1387 }
1388
1389 if (*argv[i] == '+')
1390 {
1004 char *p = argv[i] + 1; 1391 char *p = argv[i] + 1;
1005 while (isdigit ((unsigned char) *p) || *p == ':') p++; 1392 while (isdigit ((unsigned char) *p) || *p == ':') p++;
1006 if (*p != 0) 1393 if (*p == 0)
1007 { 1394 {
1008 SEND_QUOTED (cwd); 1395 send_to_emacs (emacs_socket, "-position ");
1009 SEND_STRING ("/"); 1396 quote_argument (emacs_socket, argv[i]);
1010 } 1397 send_to_emacs (emacs_socket, " ");
1011 } 1398 continue;
1399 }
1400 else
1401 relative = 1;
1402 }
1012 else if (! file_name_absolute_p (argv[i])) 1403 else if (! file_name_absolute_p (argv[i]))
1013 { 1404 relative = 1;
1014 SEND_QUOTED (cwd); 1405
1015 SEND_STRING ("/"); 1406 send_to_emacs (emacs_socket, "-file ");
1016 } 1407 if (relative)
1017 1408 {
1018 SEND_QUOTED (argv[i]); 1409 quote_argument (emacs_socket, cwd);
1019 SEND_STRING (" "); 1410 send_to_emacs (emacs_socket, "/");
1020 } 1411 }
1412 quote_argument (emacs_socket, argv[i]);
1413 send_to_emacs (emacs_socket, " ");
1414 }
1021 } 1415 }
1022 else 1416 else
1023 { 1417 {
1024 while (fgets (string, BUFSIZ, stdin)) 1418 if (!tty && !window_system)
1025 { 1419 {
1026 SEND_QUOTED (string); 1420 while ((str = fgets (string, BUFSIZ, stdin)))
1027 } 1421 {
1028 SEND_STRING (" "); 1422 if (eval)
1423 send_to_emacs (emacs_socket, "-eval ");
1424 else
1425 send_to_emacs (emacs_socket, "-file ");
1426 quote_argument (emacs_socket, str);
1427 }
1428 send_to_emacs (emacs_socket, " ");
1429 }
1029 } 1430 }
1030 1431
1031 SEND_STRING ("\n"); 1432 send_to_emacs (emacs_socket, "\n");
1433
1434 /* Wait for an answer. */
1435 if (!eval && !tty && !nowait)
1436 {
1437 printf ("Waiting for Emacs...");
1438 needlf = 2;
1439 }
1440 fflush (stdout);
1441 fsync (1);
1032 1442
1033 /* Maybe wait for an answer. */ 1443 /* Now, wait for an answer and print any messages. */
1034 if (!nowait) 1444 while ((rl = recv (emacs_socket, string, BUFSIZ, 0)) > 0)
1035 { 1445 {
1036 if (!eval) 1446 char *p;
1447 string[rl] = '\0';
1448
1449 p = string + strlen (string) - 1;
1450 while (p > string && *p == '\n')
1451 *p-- = 0;
1452
1453 if (strprefix ("-emacs-pid ", string))
1037 { 1454 {
1038 printf ("Waiting for Emacs..."); 1455 /* -emacs-pid PID: The process id of the Emacs process. */
1039 needlf = 2; 1456 emacs_pid = strtol (string + strlen ("-emacs-pid"), NULL, 10);
1040 } 1457 }
1041 fflush (stdout); 1458 else if (strprefix ("-window-system-unsupported ", string))
1042
1043 /* Now, wait for an answer and print any messages. */
1044 while ((rl = recv (s, string, BUFSIZ, 0)) > 0)
1045 { 1459 {
1046 string[rl] = '\0'; 1460 /* -window-system-unsupported: Emacs was compiled without X
1047 if (needlf == 2) 1461 support. Try again on the terminal. */
1462 window_system = 0;
1463 nowait = 0;
1464 tty = 1;
1465 goto retry;
1466 }
1467 else if (strprefix ("-print ", string))
1468 {
1469 /* -print STRING: Print STRING on the terminal. */
1470 str = unquote_argument (string + strlen ("-print "));
1471 if (needlf)
1048 printf ("\n"); 1472 printf ("\n");
1049 printf ("%s", string); 1473 printf ("%s", str);
1050 needlf = string[0] == '\0' ? needlf : string[strlen (string) - 1] != '\n'; 1474 needlf = str[0] == '\0' ? needlf : str[strlen (str) - 1] != '\n';
1475 }
1476 else if (strprefix ("-error ", string))
1477 {
1478 /* -error DESCRIPTION: Signal an error on the terminal. */
1479 str = unquote_argument (string + strlen ("-error "));
1480 if (needlf)
1481 printf ("\n");
1482 fprintf (stderr, "*ERROR*: %s", str);
1483 needlf = str[0] == '\0' ? needlf : str[strlen (str) - 1] != '\n';
1484 }
1485#ifdef SIGSTOP
1486 else if (strprefix ("-suspend ", string))
1487 {
1488 /* -suspend: Suspend this terminal, i.e., stop the process. */
1489 if (needlf)
1490 printf ("\n");
1491 needlf = 0;
1492 kill (0, SIGSTOP);
1493 }
1494#endif
1495 else
1496 {
1497 /* Unknown command. */
1498 if (needlf)
1499 printf ("\n");
1500 printf ("*ERROR*: Unknown message: %s", string);
1501 needlf = string[0] == '\0' ? needlf : string[strlen (string) - 1] != '\n';
1051 } 1502 }
1052
1053 if (needlf)
1054 printf ("\n");
1055 fflush (stdout);
1056 } 1503 }
1057 1504
1058 CLOSE_SOCKET (s); 1505 if (needlf)
1506 printf ("\n");
1507 fflush (stdout);
1508 fsync (1);
1509
1510 CLOSE_SOCKET (emacs_socket);
1059 return EXIT_SUCCESS; 1511 return EXIT_SUCCESS;
1060} 1512}
1061 1513
1062#endif /* HAVE_SOCKETS && HAVE_INET_SOCKETS */ 1514#endif /* HAVE_SOCKETS && HAVE_INET_SOCKETS */
1063 1515
1516
1064#ifndef HAVE_STRERROR 1517#ifndef HAVE_STRERROR
1065char * 1518char *
1066strerror (errnum) 1519strerror (errnum)
diff --git a/lib-src/emacstool.c b/lib-src/emacstool.c
deleted file mode 100644
index 7b39d2ed8fd..00000000000
--- a/lib-src/emacstool.c
+++ /dev/null
@@ -1,504 +0,0 @@
1/*
2 Copyright (C) 1986, 1988, 1990, 1991, 2001, 2002, 2003, 2004,
3 2005, 2006, 2007 Free Software Foundation, Inc.
4
5This file is part of GNU Emacs.
6
7GNU Emacs is free software; you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published by
9the Free Software Foundation; either version 3, or (at your option)
10any later version.
11
12GNU Emacs is distributed in the hope that it will be useful,
13but WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15GNU General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along with GNU Emacs; see the file COPYING. If not, write to
19the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20Boston, MA 02110-1301, USA. */
21
22/*
23 * For Emacs in SunView/Sun-Windows: (supported by Sun Unix v3.2 or greater)
24 * Insert a notifier filter-function to convert all useful input
25 * to "key" sequences that emacs can understand. See: Emacstool(1).
26 *
27 * Author: Jeff Peck, Sun Microsystems, Inc. <peck@eng.sun.com>
28 *
29 * Original Idea: Ian Batten
30 * Updated 15-Mar-88, Jeff Peck: set IN_EMACSTOOL, TERM, TERMCAP
31 * Updated 10-Sep-88, Jeff Peck: add XVIEW and JLE support
32 * Updated 8-Oct-90, Jeff Peck: add Meta-bit for Xview
33 * Updated 6-Mar-91, Jeff Peck: Hack to detect -Wt invocation
34 * [note, TTYSW limitation means you must Click-To-Type in Openwin]
35 * [fixed in OW3 or use local/tty.o]
36 * for better results, this should move to using TERMSW.
37 * Updated 10-Mar-91, Jeff Peck, et al: support for TERMSW (TTERM)
38 * allows point-to-type even in OW2
39 *
40 * [note: xvetool should be started with the "-nw" flag for emacs!]
41 */
42
43#ifdef XVIEW
44#include <xview/xview.h>
45#include <xview/panel.h>
46#include <xview/attr.h>
47#include <xview/tty.h>
48#include <xview/ttysw.h> /* private defines */
49#include <xview/termsw.h> /* -DTTERM */
50#include <xview/font.h> /* for testing */
51#else
52#include <suntool/sunview.h>
53#include <suntool/tty.h>
54#include <suntool/ttysw.h>
55#endif XVIEW
56
57#ifdef JLE
58# include <locale.h>
59#endif JLE
60
61#include <stdio.h>
62#include <sys/file.h>
63
64#define BUFFER_SIZE 128 /* Size of all the buffers */
65
66/* define WANT_CAPS_LOCK to make f-key T1 (aka F1) behave as CapsLock */
67#define WANT_CAPS_LOCK
68#ifdef WANT_CAPS_LOCK
69int caps_lock; /* toggle indicator for f-key T1 caps lock */
70static char *Caps = "[CAPS] "; /* Caps Lock prefix string */
71#define CAPS_LEN 7 /* strlen (Caps) */
72#endif
73
74static char *mouse_prefix = "\030\000"; /* C-x C-@ */
75static int m_prefix_length = 2; /* mouse_prefix length */
76
77static char *key_prefix = "\030*"; /* C-x * */
78static int k_prefix_length = 2; /* key_prefix length */
79
80#ifdef JLE
81static char *emacs_name = "nemacs"; /* default run command */
82static char *title = "NEmacstool - "; /* initial title */
83#else
84static char *emacs_name = "emacs"; /* default run command */
85static char *title = "Emacstool - "; /* initial title */
86#endif JLE
87
88static char buffer[BUFFER_SIZE]; /* send to ttysw_input */
89static char *bold_name = 0; /* for -bold option */
90
91Frame frame; /* Base frame for system */
92
93#ifndef TTERM
94#define SWTYPE TTY
95Tty tty_win; /* Where emacs is reading */
96#else
97#define SWTYPE TERMSW
98Termsw tty_win; /* Termsw does follow-mouse */
99#endif TTERM
100
101#ifdef XVIEW
102Xv_Window tty_view; /* Where the events are in Xview*/
103#else
104Tty tty_view; /* SunView place filler */
105#endif XVIEW
106
107int font_width, font_height; /* For translating pixels to chars */
108int left_margin = 0; /* default window -- frame offset */
109
110int console_fd = 0; /* for debugging: setenv DEBUGEMACSTOOL */
111FILE *console; /* for debugging: setenv DEBUGEMACSTOOL */
112
113Icon frame_icon;
114/* make an icon_image for the default frame_icon */
115static short default_image[258] =
116{
117#include <images/terminal.icon>
118};
119mpr_static(icon_image, 64, 64, 1, default_image);
120
121/*
122 * Assign a value to a set of keys
123 */
124int
125button_value (event)
126 Event *event;
127{
128 int retval = 0;
129 /*
130 * Code up the current situation:
131 *
132 * 1 = MS_LEFT;
133 * 2 = MS_MIDDLE;
134 * 4 = MS_RIGHT;
135 * 8 = SHIFT;
136 * 16 = CONTROL;
137 * 32 = META;
138 * 64 = DOUBLE;
139 * 128 = UP;
140 */
141
142 if (MS_LEFT == (event_id (event))) retval = 1;
143 if (MS_MIDDLE == (event_id (event))) retval = 2;
144 if (MS_RIGHT == (event_id (event))) retval = 4;
145
146 if (event_shift_is_down (event)) retval += 8;
147 if (event_ctrl_is_down (event)) retval += 16;
148 if (event_meta_is_down (event)) retval += 32;
149 if (event_is_up (event)) retval += 128;
150 return retval;
151}
152
153/*
154 * Variables to store the time of the previous mouse event that was
155 * sent to emacs.
156 *
157 * The theory is that to time double clicks while ignoring UP buttons,
158 * we must keep track of the accumulated time.
159 *
160 * If someone writes a SUN-SET-INPUT-MASK for emacstool,
161 * That could be used to selectively disable UP events,
162 * and then this cruft wouldn't be necessary.
163 */
164static long prev_event_sec = 0;
165static long prev_event_usec = 0;
166
167/*
168 * Give the time difference in milliseconds, where one second
169 * is considered infinite.
170 */
171int
172time_delta (now_sec, now_usec, prev_sec, prev_usec)
173 long now_sec, now_usec, prev_sec, prev_usec;
174{
175 long sec_delta = now_sec - prev_sec;
176 long usec_delta = now_usec - prev_usec;
177
178 if (usec_delta < 0) { /* "borrow" a second */
179 usec_delta += 1000000;
180 --sec_delta;
181 }
182
183 if (sec_delta >= 10)
184 return (9999); /* Infinity */
185 else
186 return ((sec_delta * 1000) + (usec_delta / 1000));
187}
188
189
190/*
191 * Filter function to translate selected input events for emacs
192 * Mouse button events become ^X^@(button x-col y-line time-delta) .
193 * Function keys: ESC-*{c}{lrt} l,r,t for Left, Right, Top;
194 * {c} encodes the keynumber as a character [a-o]
195 */
196static Notify_value
197input_event_filter_function (window, event, arg, type)
198#ifdef XVIEW
199 Xv_Window window;
200#else
201 Window window;
202#endif XVIEW
203 Event *event;
204 Notify_arg arg;
205 Notify_event_type type;
206{
207 struct timeval time_stamp;
208
209 if (console_fd) fprintf(console, "Event: %d\n", event_id(event));
210
211 /* UP L1 is the STOP key */
212 if (event_id(event) == WIN_STOP) {
213 ttysw_input(tty_win, "\007\007\007\007\007\007\007", 7);
214 return NOTIFY_IGNORED;
215 }
216
217 /* UP L5 & L7 is Expose & Open, let them pass to sunview */
218 if (event_id(event) == KEY_LEFT(5) || event_id(event) == KEY_LEFT(7))
219 if(event_is_up (event))
220 return notify_next_event_func (window, event, arg, type);
221 else return NOTIFY_IGNORED;
222
223 if (event_is_button (event)) { /* do Mouse Button events */
224/* Commented out so that we send mouse up events too.
225 if (event_is_up (event))
226 return notify_next_event_func (window, event, arg, type);
227*/
228 time_stamp = event_time (event);
229 ttysw_input (tty_win, mouse_prefix, m_prefix_length);
230 sprintf (buffer, "(%d %d %d %d)\015",
231 button_value (event),
232 (event_x (event) - left_margin) / font_width,
233 event_y (event) / font_height,
234 time_delta (time_stamp.tv_sec, time_stamp.tv_usec,
235 prev_event_sec, prev_event_usec)
236 );
237 ttysw_input (tty_win, buffer, strlen(buffer));
238 prev_event_sec = time_stamp.tv_sec;
239 prev_event_usec = time_stamp.tv_usec;
240 return NOTIFY_IGNORED;
241 }
242
243 { /* Do the function key events */
244 int d;
245 char c = (char) 0;
246 if ((event_is_key_left (event)) ?
247 ((d = event_id(event) - KEY_LEFT(1) + 'a'), c='l') :
248 ((event_is_key_right (event)) ?
249 ((d = event_id(event) - KEY_RIGHT(1) + 'a'), c='r') :
250 ((event_is_key_top (event)) ?
251 ((d = event_id(event) - KEY_TOP(1) + 'a'), c='t') : 0)))
252 {
253 if (event_is_up(event)) return NOTIFY_IGNORED;
254 if (event_shift_is_down (event)) c = c - 32;
255 /* this will give a non-{lrt} for unshifted keys */
256 if (event_ctrl_is_down (event)) c = c - 64;
257 if (event_meta_is_down (event)) c = c + 128;
258#ifdef WANT_CAPS_LOCK
259/* set a toggle and relabel window so T1 can act like caps-lock */
260 if (event_id(event) == KEY_TOP(1))
261 {
262 /* make a frame label with and without CAPS */
263 strcpy (buffer, Caps);
264 title = &buffer[CAPS_LEN];
265 strncpy (title, (char *)window_get (frame, FRAME_LABEL),
266 BUFFER_SIZE - CAPS_LEN);
267 buffer[BUFFER_SIZE] = (char) 0;
268 if (strncmp (title, Caps, CAPS_LEN) == 0)
269 title += CAPS_LEN; /* already Caps */
270 caps_lock = (caps_lock ? 0 : CAPS_LEN);
271 window_set(frame, FRAME_LABEL, (title -= caps_lock), 0);
272 return NOTIFY_IGNORED;
273 }
274#endif
275 ttysw_input (tty_win, key_prefix, k_prefix_length);
276 sprintf (buffer, "%c%c", d, c);
277 ttysw_input(tty_win, buffer, strlen(buffer));
278
279 return NOTIFY_IGNORED;
280 }
281 }
282 if ((event_is_ascii(event) || event_is_meta(event))
283 && event_is_up(event)) return NOTIFY_IGNORED;
284#ifdef WANT_CAPS_LOCK
285/* shift alpha chars to upper case if toggle is set */
286 if ((caps_lock) && event_is_ascii(event)
287 && (event_id(event) >= 'a') && (event_id(event) <= 'z'))
288 event_set_id(event, (event_id(event) - 32));
289/* crufty, but it works for now. is there an UPCASE(event)? */
290#endif
291#ifndef NO_META_BIT
292/* under Openwindows/X, the meta bit is not set in the key event,
293 * emacs expects this so we add it in here:
294 */
295 if (event_is_ascii(event) && event_meta_is_down(event))
296 event_set_id(event, 128 | event_id(event));
297#endif
298 return notify_next_event_func (window, event, arg, type);
299}
300
301main (argc, argv)
302 int argc;
303 char **argv;
304{
305 int error_code; /* Error codes */
306
307#ifdef JLE
308 setlocale(LC_ALL, "");
309#endif JLE
310
311 if(getenv("DEBUGEMACSTOOL"))
312 console = fdopen (console_fd = open("/dev/console",O_WRONLY), "w");
313
314 putenv("IN_EMACSTOOL=t"); /* notify subprocess that it is in emacstool */
315
316 if (putenv("TERM=sun") != 0) /* TTY_WIN will be a TERM=sun window */
317 {fprintf (stderr, "%s: Could not set TERM=sun, using `%s'\n",
318 argv[0], (char *)getenv("TERM")) ;};
319 /*
320 * If TERMCAP starts with a slash, it is the pathname of the
321 * termcap file, not an entry extracted from it, so KEEP it!
322 * Otherwise, it may not relate to the new TERM, so Nuke-It.
323 * If there is no TERMCAP environment variable, don't make one.
324 */
325 {
326 char *termcap ; /* Current TERMCAP value */
327 termcap = (char *)getenv("TERMCAP") ;
328 if (termcap && (*termcap != '/'))
329 {
330 if (putenv("TERMCAP=") != 0)
331 {fprintf (stderr, "%s: Could not clear TERMCAP\n", argv[0]) ;} ;
332 } ;
333 } ;
334
335 /* find command to run as subprocess in window */
336 if (!(argv[0] = (char *)getenv("EMACSTOOL"))) /* Set emacs command name */
337 argv[0] = emacs_name;
338 /* Emacstool recognizes two special args: -rc <file> and -bold <bold-name> */
339 for (argc = 1; argv[argc]; argc++) /* Use last one on line */
340 {
341 if(!(strcmp ("-rc", argv[argc]))) /* Override if -rc given */
342 {int i = argc;
343 argv[argc--]=0; /* kill the -rc argument */
344 if (argv[i+1]) { /* move to argv[0] and squeeze the rest */
345 argv[0]=argv[i+1];
346 for (; argv[i+2]; (argv[i]=argv[i+2],argv[++i]=0));
347 }
348 }
349
350 if (!(strcmp ("-bold", argv[argc])))
351 {int i = argc;
352 argv[argc--]=0; /* kill the -bold argument */
353 if (argv[i+1]) { /* move to bold_name and squeeze the rest */
354 bold_name = argv[i+1];
355 for (; argv[i+2]; (argv[i]=argv[i+2],argv[++i]=0));
356 }
357 }
358 };
359
360 strcpy (buffer, title);
361 strncat (buffer, argv[0], /* append run command name */
362 (BUFFER_SIZE - (strlen (buffer)) - (strlen (argv[0]))) - 1);
363
364 error_code = interpose_on_window(argc,argv);
365 if (error_code != 0) { /* Barf */
366 fprintf (stderr, "notify_interpose_event_func returns %d.\n", error_code);
367 exit (1);
368 }
369
370#ifdef XVIEW
371 xv_main_loop (frame); /* And away we go */
372#else
373 window_main_loop (frame);
374#endif XVIEW
375}
376
377#ifdef XVIEW
378int interpose_on_window(argc,argv)
379 int argc;
380 char **argv;
381{
382#ifndef TTERM
383 int i, font_width_adjust = 1; /* hackery, and heuristics */
384 /* if -Wt is not supplied, then font comes out as lucida-14 (width=8)
385 * rather than the screen.r.12 (width=7) typically used
386 * this hack attempts to workaround it.
387 * could use a env var EMACSTOOL_DEFAULT_FONT_WIDTH instead */
388 for (i = 1; argv[i]; i++) {
389 if (!(strcmp ("-Wt", argv[i])))
390 {font_width_adjust = 0;
391 if (console_fd) fprintf(console, "-Wt = %d\n", font_width_adjust);
392 break;}
393 }
394#endif TTERM
395 /* initialize Xview, and strip window args */
396 xv_init(XV_INIT_ARGC_PTR_ARGV, &argc, argv, 0);
397
398 /* do this first, so arglist can override it */
399 frame_icon = icon_create (ICON_LABEL, "Emacstool",
400 ICON_IMAGE, &icon_image,
401 0);
402
403 /* Build a frame to run in */
404 frame = xv_create ((Xv_Window)NULL, FRAME,
405 FRAME_LABEL, buffer,
406 FRAME_ICON, frame_icon,
407 0);
408
409 /* Create a tty with emacs in it */
410 tty_win = xv_create (frame, SWTYPE, WIN_IS_CLIENT_PANE,
411 TTY_QUIT_ON_CHILD_DEATH, TRUE,
412 TTY_BOLDSTYLE, TTYSW_BOLD_INVERT,
413 TTY_ARGV, argv,
414 0);
415
416 if (bold_name) {
417 (void)xv_set(tty_win, TTY_BOLDSTYLE_NAME, bold_name, 0);
418 }
419
420 {
421 Xv_font font; /* declare temp font variable */
422 font = (Xv_font)xv_get (tty_win, XV_FONT);
423 font_height = (int)xv_get (font, FONT_DEFAULT_CHAR_HEIGHT);
424 font_width = (int)xv_get (font, FONT_DEFAULT_CHAR_WIDTH);
425 }
426 if (console_fd) fprintf(console, "Width = %d\n", font_width);
427
428#ifndef TTERM
429 font_width -= font_width_adjust; /* A guess! font bug in ttysw*/
430#else
431 /* make the termsw act as a tty */
432 xv_set(tty_win, TERMSW_MODE, TTYSW_MODE_TYPE, 0);
433 /* termsw has variable offset depending on scrollbar size/location */
434 left_margin = (int)xv_get (tty_win, TEXTSW_LEFT_MARGIN);
435#endif TTERM
436
437 tty_view = (Xv_Window) xv_get (tty_win, OPENWIN_NTH_VIEW, 0);
438 xv_set(tty_view,
439 WIN_CONSUME_EVENTS,
440 WIN_MOUSE_BUTTONS, WIN_UP_EVENTS,
441 ACTION_ADJUST, ACTION_MENU,
442 WIN_ASCII_EVENTS,
443 WIN_LEFT_KEYS, WIN_TOP_KEYS, WIN_RIGHT_KEYS,
444 0,
445 0);
446 /* Interpose my event function */
447 return (int) notify_interpose_event_func
448 (tty_view, input_event_filter_function, NOTIFY_SAFE);
449}
450#else
451int interpose_on_window (argc, argv)
452 int argc;
453 char **argv;
454{
455 /* do this first, so arglist can override it */
456 frame_icon = icon_create (ICON_LABEL, "Emacstool",
457 ICON_IMAGE, &icon_image,
458 0);
459
460 /* Build a frame to run in */
461 frame = window_create ((Window)NULL, FRAME,
462 FRAME_LABEL, buffer,
463 FRAME_ICON, frame_icon,
464 FRAME_ARGC_PTR_ARGV, &argc, argv,
465 0);
466
467 /* Create a tty with emacs in it */
468 tty_win = window_create (frame, TTY,
469 TTY_QUIT_ON_CHILD_DEATH, TRUE,
470 TTY_BOLDSTYLE, TTYSW_BOLD_INVERT,
471 TTY_ARGV, argv,
472 0);
473
474 if (bold_name) {
475 (void)window_set(tty_win, TTY_BOLDSTYLE_NAME, bold_name, 0);
476 }
477
478 /* ttysw uses pf_default, one must set WIN_FONT explicitly */
479 window_set (tty_win, WIN_FONT, pf_default(), 0);
480 font_height = (int)window_get (tty_win, WIN_ROW_HEIGHT);
481 font_width = (int)window_get (tty_win, WIN_COLUMN_WIDTH);
482
483 tty_view = tty_win;
484 window_set(tty_view,
485 WIN_CONSUME_PICK_EVENTS,
486 WIN_STOP,
487 WIN_MOUSE_BUTTONS, WIN_UP_EVENTS,
488 /* LOC_WINENTER, LOC_WINEXIT, LOC_MOVE, */
489 0,
490 WIN_CONSUME_KBD_EVENTS,
491 WIN_STOP,
492 WIN_ASCII_EVENTS,
493 WIN_LEFT_KEYS, WIN_TOP_KEYS, WIN_RIGHT_KEYS,
494 /* WIN_UP_ASCII_EVENTS, */
495 0,
496 0);
497 /* Interpose my event function */
498 return (int) notify_interpose_event_func
499 (tty_view, input_event_filter_function, NOTIFY_SAFE);
500}
501#endif XVIEW
502
503/* arch-tag: 7a2e7105-c059-418a-b3d9-5b5de96abb4e
504 (do not change this comment) */
diff --git a/lib-src/makefile.w32-in b/lib-src/makefile.w32-in
index 03ef92f023d..65ad9b08011 100644
--- a/lib-src/makefile.w32-in
+++ b/lib-src/makefile.w32-in
@@ -24,7 +24,7 @@ ALL = make-docfile hexl ctags etags movemail ebrowse sorted-doc digest-doc emacs
24 24
25.PHONY: $(ALL) 25.PHONY: $(ALL)
26 26
27VERSION = 22.1.50 27VERSION = 23.0.50
28 28
29LOCAL_FLAGS = -DWINDOWSNT -DDOS_NT -DSTDC_HEADERS=1 -DNO_LDAV=1 \ 29LOCAL_FLAGS = -DWINDOWSNT -DDOS_NT -DSTDC_HEADERS=1 -DNO_LDAV=1 \
30 -DNO_ARCHIVES=1 -DHAVE_CONFIG_H=1 -I../nt/inc \ 30 -DNO_ARCHIVES=1 -DHAVE_CONFIG_H=1 -I../nt/inc \
@@ -82,11 +82,11 @@ $(TRES): ../nt/emacs.rc
82 82
83$(BLD)/emacsclient.exe: $(ECLIENTOBJS) 83$(BLD)/emacsclient.exe: $(ECLIENTOBJS)
84# put wsock32.lib before $(LIBS) to ensure we don't link to ws2_32.lib 84# put wsock32.lib before $(LIBS) to ensure we don't link to ws2_32.lib
85 $(LINK) $(LINK_OUT)$@ $(LINK_FLAGS) $(ECLIENTOBJS) $(WSOCK32) $(USER32) $(LIBS) 85 $(LINK) $(LINK_OUT)$@ $(LINK_FLAGS) $(ECLIENTOBJS) $(WSOCK32) $(USER32) $(COMCTL32) $(LIBS)
86 86
87$(BLD)/emacsclientw.exe: $(ECLIENTOBJS) $(TRES) 87$(BLD)/emacsclientw.exe: $(ECLIENTOBJS) $(TRES)
88# put wsock32.lib before $(LIBS) to ensure we don't link to ws2_32.lib 88# put wsock32.lib before $(LIBS) to ensure we don't link to ws2_32.lib
89 $(LINK) $(LINK_OUT)$@ $(TRES) -mwindows $(LINK_FLAGS) $(ECLIENTOBJS) $(WSOCK32) $(USER32) $(LIBS) 89 $(LINK) $(LINK_OUT)$@ $(TRES) -mwindows $(LINK_FLAGS) $(ECLIENTOBJS) $(WSOCK32) $(USER32) $(COMCTL32) $(LIBS)
90 90
91# emacsclient.$(O) depends on makefile.w32-in because makefile.w32-in 91# emacsclient.$(O) depends on makefile.w32-in because makefile.w32-in
92# can be edited to define VERSION string, which is part of ECLIENT_CFLAGS. 92# can be edited to define VERSION string, which is part of ECLIENT_CFLAGS.