1 /* XEmacs -- Fully extensible Emacs, running on Unix and other platforms.
2 Copyright (C) 1985, 1986, 1987, 1992, 1993, 1994
3 Free Software Foundation, Inc.
4 Copyright (C) 1995 Sun Microsystems, Inc.
5 Copyright (C) 2000 Ben Wing.
7 This file is part of XEmacs.
9 XEmacs is free software; you can redistribute it and/or modify it
10 under the terms of the GNU General Public License as published by the
11 Free Software Foundation; either version 2, or (at your option) any
14 XEmacs is distributed in the hope that it will be useful, but WITHOUT
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19 You should have received a copy of the GNU General Public License
20 along with XEmacs; see the file COPYING. If not, write to
21 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22 Boston, MA 02111-1307, USA. */
24 /* Synched up with: Mule 2.0, FSF 19.28. */
26 /* Capsule summary of the various releases of Lucid Emacs/XEmacs and
27 FSF/GNU Emacs. Provided here for use in cross-referencing version
28 releases and dates in comments, esp. in the authorship comments at
29 the beginning of each file. More information about history can be
30 found in the beginning of the Internals Manual and in the About page.
33 -- A time line for Lucid Emacs/XEmacs is
35 version 19.0 shipped with Energize 1.0, April 1992.
36 version 19.1 released June 4, 1992.
37 version 19.2 released June 19, 1992.
38 version 19.3 released September 9, 1992.
39 version 19.4 released January 21, 1993.
40 version 19.5 was a repackaging of 19.4 with a few bug fixes and
41 shipped with Energize 2.0. Never released to the net.
42 version 19.6 released April 9, 1993.
43 version 19.7 was a repackaging of 19.6 with a few bug fixes and
44 shipped with Energize 2.1. Never released to the net.
45 version 19.8 released September 6, 1993.
46 version 19.9 released January 12, 1994.
47 version 19.10 released May 27, 1994.
48 version 19.11 (first XEmacs) released September 13, 1994.
49 version 19.12 released June 23, 1995.
50 version 19.13 released September 1, 1995.
51 version 19.14 released June 23, 1996.
52 version 20.0 released February 9, 1997.
53 version 19.15 released March 28, 1997.
54 version 20.1 (not released to the net) April 15, 1997.
55 version 20.2 released May 16, 1997.
56 version 19.16 released October 31, 1997.
57 version 20.3 (the first stable version of XEmacs 20.x) released
59 version 20.4 released February 28, 1998.
62 -- A time line for GNU Emacs version 19 is
64 version 19.7 (beta) (first beta release) released ??????; prob. late May 1993.
65 version 19.8 (beta) released May 27, 1993.
66 version 19.9 (beta) released May 27, 1993.
67 version 19.10 (beta) released May 30, 1993.
68 version 19.11 (beta) released June 1, 1993.
69 version 19.12 (beta) released June 2, 1993.
70 version 19.13 (beta) released June 8, 1993.
71 version 19.14 (beta) released June 17, 1993.
72 version 19.15 (beta) released June 19, 1993.
73 version 19.16 (beta) released July 6, 1993.
74 version 19.17 (beta) released late July, 1993.
75 version 19.18 (beta) released August 9, 1993.
76 version 19.19 (beta) released August 15, 1993.
77 version 19.20 (beta) released November 17, 1993.
78 version 19.21 (beta) released November 17, 1993.
79 version 19.22 (beta) released November 28, 1993.
80 version 19.23 (beta) released May 17, 1994.
81 version 19.24 (beta) released May 16, 1994.
82 version 19.25 (beta) released June 3, 1994.
83 version 19.26 (beta) released September 11, 1994.
84 version 19.27 (beta) released September 14, 1994.
85 version 19.28 (first ``official'' release) released November 1, 1994.
86 version 19.29 released June 21, 1995.
87 version 19.30 released November 24, 1995.
88 version 19.31 released May 25, 1996.
89 version 19.32 released July 31, 1996.
90 version 19.33 released August 11, 1996.
91 version 19.34 released August 21, 1996.
92 version 19.34b released September 6, 1996.
95 -- A time line for GNU Emacs version 20 is
97 version 20.1 released September 17, 1997.
98 version 20.2 released September 20, 1997.
99 version 20.3 released August 19, 1998.
102 -- A time line for GNU Emacs version 18 and older is
104 GNU Emacs version 15 (15.34) was released sometime in 1984 or 1985 and
105 shared some code with a version of Emacs written by James Gosling (the
106 same James Gosling who later created the Java language).
107 GNU Emacs version 16 (first released version was 16.56) was released on
108 July 15, 1985. All Gosling code was removed due to potential copyright
109 problems with the code.
110 version 16.57: released on September 16, 1985.
111 versions 16.58, 16.59: released on September 17, 1985.
112 version 16.60: released on September 19, 1985. These later version 16's
113 incorporated patches from the net, esp. for getting Emacs to work under
115 version 17.36 (first official v17 release) released on December 20, 1985.
116 Included a TeX-able user manual. First official unpatched version that
117 worked on vanilla System V machines.
118 version 17.43 (second official v17 release) released on January 25, 1986.
119 version 17.45 released on January 30, 1986.
120 version 17.46 released on February 4, 1986.
121 version 17.48 released on February 10, 1986.
122 version 17.49 released on February 12, 1986.
123 version 17.55 released on March 18, 1986.
124 version 17.57 released on March 27, 1986.
125 version 17.58 released on April 4, 1986.
126 version 17.61 released on April 12, 1986.
127 version 17.63 released on May 7, 1986.
128 version 17.64 released on May 12, 1986.
129 version 18.24 (a beta version) released on October 2, 1986.
130 version 18.30 (a beta version) released on November 15, 1986.
131 version 18.31 (a beta version) released on November 23, 1986.
132 version 18.32 (a beta version) released on December 7, 1986.
133 version 18.33 (a beta version) released on December 12, 1986.
134 version 18.35 (a beta version) released on January 5, 1987.
135 version 18.36 (a beta version) released on January 21, 1987.
136 January 27, 1987: The Great Usenet Renaming. net.emacs is now comp.emacs.
137 version 18.37 (a beta version) released on February 12, 1987.
138 version 18.38 (a beta version) released on March 3, 1987.
139 version 18.39 (a beta version) released on March 14, 1987.
140 version 18.40 (a beta version) released on March 18, 1987.
141 version 18.41 (the first ``official'' release) released on March 22, 1987.
142 version 18.45 released on June 2, 1987.
143 version 18.46 released on June 9, 1987.
144 version 18.47 released on June 18, 1987.
145 version 18.48 released on September 3, 1987.
146 version 18.49 released on September 18, 1987.
147 version 18.50 released on February 13, 1988.
148 version 18.51 released on May 7, 1988.
149 version 18.52 released on September 1, 1988.
150 version 18.53 released on February 24, 1989.
151 version 18.54 released on April 26, 1989.
152 version 18.55 released on August 23, 1989. This is the earliest version
153 that is still available by FTP.
154 version 18.56 released on January 17, 1991.
155 version 18.57 released late January, 1991.
156 version 18.58 released ?????.
157 version 18.59 released October 31, 1992.
161 /* Note: It is necessary to specify <config.h> and not "config.h" in
162 order for the --srcdir type of compilation to work properly.
163 Otherwise the config.h from the srcdir, rather than the one from
164 the build dir, will be used. */
169 #include "backtrace.h" /* run-emacs-from-temacs needs this */
171 #include "commands.h"
174 #include "redisplay.h"
178 #include "syssignal.h" /* Always include before systty.h */
192 #include <quantify.h>
199 #if defined (HAVE_LOCALE_H) && \
200 (defined (I18N2) || defined (I18N3) || defined (I18N4))
208 #if defined (WIN32_NATIVE)
215 #if defined (HEAP_IN_DATA) && !defined(PDUMP)
216 void report_sheap_usage (int die_if_pure_storage_exceeded);
219 #if !defined (SYSTEM_MALLOC) && !defined (DOUG_LEA_MALLOC)
220 extern void *(*__malloc_hook)(size_t);
221 extern void *(*__realloc_hook)(void *, size_t);
222 extern void (*__free_hook)(void *);
223 #endif /* not SYSTEM_MALLOC && not DOUG_LEA_MALLOC */
225 /* Command line args from shell, as list of strings */
226 Lisp_Object Vcommand_line_args;
228 /* Set nonzero after XEmacs has started up the first time.
229 Prevents reinitialization of the Lisp world and keymaps
230 on subsequent starts. */
233 #ifdef DOUG_LEA_MALLOC
235 /* Preserves a pointer to the memory allocated that copies that
236 static data inside glibc's malloc. */
237 static void *malloc_state_ptr;
238 #endif /* DOUG_LEA_MALLOC */
241 void r_alloc_reinit (void);
245 void console_type_create_select_gtk(void);
248 /* Variable whose value is symbol giving operating system type. */
249 Lisp_Object Vsystem_type;
251 /* Variable whose value is string giving configuration built for. */
252 Lisp_Object Vsystem_configuration;
254 /* Variable whose value is string containing the configuration options
255 XEmacs was built with. */
256 Lisp_Object Vsystem_configuration_options;
258 /* Version numbers and strings */
259 Lisp_Object Vemacs_major_version;
260 Lisp_Object Vemacs_minor_version;
261 Lisp_Object Vemacs_patch_level;
262 Lisp_Object Vemacs_beta_version;
263 Lisp_Object Vxemacs_codename;
265 Lisp_Object Vinfodock_major_version;
266 Lisp_Object Vinfodock_minor_version;
267 Lisp_Object Vinfodock_build_version;
270 /* The path under which XEmacs was invoked. */
271 Lisp_Object Vinvocation_path;
273 /* The name under which XEmacs was invoked, with any leading directory
275 Lisp_Object Vinvocation_name;
277 /* The directory name from which XEmacs was invoked. */
278 Lisp_Object Vinvocation_directory;
281 /* The directory name in which to find subdirs such as lisp and etc.
282 nil means get them only from PATH_LOADSEARCH. */
283 Lisp_Object Vinstallation_directory;
286 Lisp_Object Vemacs_program_name, Vemacs_program_version;
287 Lisp_Object Vexec_path;
288 Lisp_Object Vexec_directory, Vconfigure_exec_directory;
289 Lisp_Object Vlisp_directory, Vconfigure_lisp_directory;
290 Lisp_Object Vmule_lisp_directory, Vconfigure_mule_lisp_directory;
291 Lisp_Object Vmodule_directory, Vconfigure_module_directory;
292 Lisp_Object Vsite_module_directory, Vconfigure_site_module_directory;
293 Lisp_Object Vconfigure_package_path;
294 Lisp_Object Vdata_directory, Vconfigure_data_directory;
295 Lisp_Object Vdoc_directory, Vconfigure_doc_directory;
296 Lisp_Object Vconfigure_lock_directory;
297 Lisp_Object Vdata_directory_list;
298 Lisp_Object Vconfigure_info_directory;
299 Lisp_Object Vsite_directory, Vconfigure_site_directory;
300 Lisp_Object Vconfigure_info_path;
301 Lisp_Object Vinternal_error_checking;
302 Lisp_Object Vmail_lock_methods, Vconfigure_mail_lock_method;
303 Lisp_Object Vpath_separator;
305 /* The default base directory XEmacs is installed under. */
306 Lisp_Object Vconfigure_exec_prefix_directory, Vconfigure_prefix_directory;
308 /* If nonzero, set XEmacs to run at this priority. This is also used
309 in child_setup and sys_suspend to make sure subshells run at normal
311 Fixnum emacs_priority;
313 /* Some FSF junk with running_asynch_code, to preserve the match
314 data. Not necessary because we don't call process filters
315 asynchronously (i.e. from within QUIT). */
316 /* #### Delete this when merging the rest of my code */
317 int running_asynch_code;
319 /* If non-zero, a window-system was specified on the command line. */
322 /* Type of display specified. We cannot use a Lisp symbol here because
323 Lisp symbols may not initialized at the time that we set this
325 const char *display_use;
327 /* If non-zero, then the early error handler will only print the error
329 int suppress_early_error_handler_backtrace;
331 /* An address near the bottom of the stack.
332 Tells GC how to save a copy of the stack. */
335 #ifdef USG_SHARED_LIBRARIES
336 /* If nonzero, this is the place to put the end of the writable segment
339 uintptr_t bss_end = 0;
342 /* Number of bytes of writable memory we can expect to be able to get */
343 unsigned int lim_data;
347 Some LISP-visible command-line options are set by XEmacs _before_ the
348 data is dumped in building a --pdump XEmacs, but used _after_ it is
349 restored in normal operation. Thus the dump-time values overwrite the
350 values XEmacs is getting at runtime. Such variables must be saved
351 before loading the dumpfile, and restored afterward.
353 Therefore these variables may not be initialized in vars_of_emacs().
355 The save/restore is done immediately before and after pdump_load() in
356 main_1(). See that function for the current list of protected variables.
358 Note that saving/restoring is only necessary for a few variables that are
359 o command line arguments effective at runtime (as opposed to dump-time),
360 o parsed before pdump_load, and
361 o exported to Lisp via a DEFVAR.
364 /* Nonzero means running XEmacs without interactive terminal. */
368 /* Value of Lisp variable `noninteractive'.
369 Normally same as C variable `noninteractive'
370 but nothing terrible happens if user sets this one.
372 Shadowed from the pdumper by `noninteractive'. */
376 /* Nonzero means don't perform site-lisp searches at startup */
377 int inhibit_site_lisp;
379 /* Nonzero means don't perform site-modules searches at startup */
380 int inhibit_site_modules;
382 /* Nonzero means don't respect early packages at startup */
383 int inhibit_early_packages;
385 /* Nonzero means don't load package autoloads at startup */
386 int inhibit_autoloads;
388 /* Nonzero means don't load the dump file (ignored if not PDUMP) */
392 /* Nonzero means print debug information about path searching */
395 /* Save argv and argc. */
396 static Extbyte **initial_argv; /* #### currently unused */
397 static int initial_argc; /* #### currently unused */
399 static void sort_args (int argc, char **argv);
401 Lisp_Object Qkill_emacs_hook;
402 Lisp_Object Qsave_buffers_kill_emacs;
404 extern Lisp_Object Vlisp_EXEC_SUFFIXES;
408 /* Ben's capsule summary about expected and unexpected exits from XEmacs.
410 Expected exits occur when the user directs XEmacs to exit, for example
411 by pressing the close button on the only frame in XEmacs, or by typing
412 C-x C-c. This runs `save-buffers-kill-emacs', which saves any necessary
413 buffers, and then exits using the primitive `kill-emacs'.
415 However, unexpected exits occur in a few different ways:
417 -- a memory access violation or other hardware-generated exception
418 occurs. This is the worst possible problem to deal with, because
419 the fault can occur while XEmacs is in any state whatsoever, even
420 quite unstable ones. As a result, we need to be *extremely* careful
422 -- we are using one X display (or if we've used more, we've closed the
423 others already), and some hardware or other problem happens and
424 suddenly we've lost our connection to the display. In this situation,
425 things are not so dire as in the last one; our code itself isn't
426 trashed, so we can continue execution as normal, after having set
427 things up so that we can exit at the appropriate time. Our exit
428 still needs to be of the emergency nature; we have no displays, so
429 any attempts to use them will fail. We simply want to auto-save
430 (the single most important thing to do during shut-down), do minimal
431 cleanup of stuff that has an independent existence outside of XEmacs,
434 Currently, both unexpected exit scenarios described above set
435 preparing_for_armageddon to indicate that nonessential and possibly
436 dangerous things should not be done, specifically:
438 -- no garbage collection.
440 -- no messages of any sort from autosaving.
441 -- autosaving tries harder, ignoring certain failures.
442 -- existing frames are not deleted.
444 (Also, all places that set preparing_for_armageddon also
445 set dont_check_for_quit. This happens separately because it's
446 also necessary to set other variables to make absolutely sure
447 no quitting happens.)
449 In the first scenario above (the access violation), we also set
450 fatal_error_in_progress. This causes more things to not happen:
452 -- assertion failures do not abort.
453 -- printing code does not do code conversion or gettext when
454 printing to stdout/stderr.
457 /* Nonzero if handling a fatal error already. */
458 int fatal_error_in_progress;
460 /* Non-nil means we're going down, so we better not run any hooks
461 or do other non-essential stuff. */
462 int preparing_for_armageddon;
465 static JMP_BUF run_temacs_catch;
467 static int run_temacs_argc;
468 static char **run_temacs_argv;
469 static char *run_temacs_args;
470 static size_t run_temacs_argv_size;
471 static size_t run_temacs_args_size;
473 static void shut_down_emacs (int sig, Lisp_Object stuff, int no_auto_save);
476 ensure_no_quitting_from_now_on (void)
478 /* make sure no quitting from now on!! */
479 dont_check_for_quit = 1;
484 /* Handle bus errors, illegal instruction, etc. */
486 fatal_error_signal (int sig)
488 fatal_error_in_progress++;
489 preparing_for_armageddon = 1;
491 ensure_no_quitting_from_now_on ();
493 /* Unblock the signal so that if the same signal gets sent in the
494 code below, we avoid a deadlock. */
495 EMACS_UNBLOCK_SIGNAL (sig);
497 /* Only try auto-saving first time through. If we crash in auto-saving,
498 don't do it again. */
499 if (fatal_error_in_progress == 1)
501 Fdo_auto_save (Qt, Qnil); /* do this before anything hazardous */
502 /* Do this so that the variable has the same value of 2 regardless of
503 whether we made it through auto-saving correctly. */
504 fatal_error_in_progress++;
506 else if (fatal_error_in_progress == 2)
507 stderr_out ("WARNING: Unable to auto-save your files properly.\n"
508 "Some or all may in fact have been auto-saved.\n"
511 /* Now, reset our signal handler, so the next time, we just die.
512 Don't do this before auto-saving. */
513 signal (sig, SIG_DFL);
515 /* Keep in mind that there's more than one signal that we can crash
517 /* If fatal error occurs in code below, avoid infinite recursion. */
518 if (fatal_error_in_progress <= 2)
520 shut_down_emacs (sig, Qnil, 1);
521 stderr_out ("\nLisp backtrace follows:\n\n");
522 Fbacktrace (Qexternal_debugging_output, Qt);
523 # if 0 /* This is evil, rarely useful, and causes grief in some cases. */
524 /* Check for Sun-style stack printing via /proc */
526 const char *pstack = "/usr/proc/bin/pstack";
527 if (access (pstack, X_OK) == 0)
530 stderr_out ("\nC backtrace follows:\n"
531 "(A real debugger may provide better information)\n\n");
532 sprintf (buf, "%s %d >&2", pstack, (int)getpid());
538 /* Signal the same code; this time it will really be fatal. */
539 kill (getpid (), sig);
546 mswindows_handle_hardware_exceptions (DWORD code)
548 if (code != STATUS_ACCESS_VIOLATION && code != STATUS_ILLEGAL_INSTRUCTION
549 && code != STATUS_PRIVILEGED_INSTRUCTION
550 && code != STATUS_DATATYPE_MISALIGNMENT)
551 return EXCEPTION_CONTINUE_SEARCH;
553 /* I don't know if this filter is still wrapped in the outer __try, but
554 it doesn't hurt to have another one. --ben
555 And it lets us control more exactly what we really want to do in such
559 fatal_error_in_progress++;
560 preparing_for_armageddon = 1;
562 ensure_no_quitting_from_now_on ();
564 /* Only try auto-saving first time through. If we crash in auto-saving,
565 don't do it again. */
566 if (fatal_error_in_progress == 1)
568 Fdo_auto_save (Qt, Qnil); /* do this before anything hazardous */
569 /* Do this so that the variable has the same value of 2 regardless of
570 whether we made it through auto-saving correctly. */
571 fatal_error_in_progress++;
573 else if (fatal_error_in_progress == 2)
574 stderr_out ("WARNING: Unable to auto-save your files properly.\n"
575 "Some or all may in fact have been auto-saved.\n"
578 /* If fatal error occurs in code below, avoid infinite recursion. */
579 if (fatal_error_in_progress <= 2)
581 shut_down_emacs (-1, Qnil, 1);
582 stderr_out ("\nLisp backtrace follows:\n\n");
583 Fbacktrace (Qexternal_debugging_output, Qt);
586 /* VC++ documentation says that
587 GetExceptionCode() cannot be called inside the filter itself. */
589 /* __except (mswindows_handle_hardware_exceptions (GetExceptionCode ())) {}
591 The line above is original. Unfortunately, when an error is tripped
592 inside of the handler (e.g. during Fbacktrace()), and the handler for
593 the handler is invoked, it correctly notices that something is amiss
594 and it should just return -- but it returns EXCEPTION_CONTINUE_SEARCH,
595 which causes the debugger to be invoked debugging the handler code in
596 this function -- and WITH THE STACK UNWOUND so that you see main()
597 calling mswindows_handle_hardware_exceptions(), calling Fbacktrace(),
598 and a crash a couple of frames in -- AND NO SIGN OF THE ORIGINAL CRASH!
600 There's some real weirdness going on in the stack handling -- unlike
601 in Unix, where further crashes just keep adding to the stack, it seems
602 that under the structured-exception-handling, the stack can actually
603 bounce back and forth between the full stack at the location of the
604 exception and the unwound stack at the place where the __try clause was
605 established. I don't completely understand it. What I do know is that
606 returning EXCEPTION_EXECUTE_HANDLER on nested crash has the effect of
607 aborting execution of the handler and going back to the outer filter
608 function, which returns EXCEPTION_CONTINUE_SEARCH and everything is
609 hunky-dorey -- your debugger sees a crash at the right location with
612 I'm leaving in the trickier Unix-like code in the handler; someone who
613 understands better than me how the stack works in these handlers could
614 fix it up more. As it is, it works pretty well, so I'm not likely to
618 __except (EXCEPTION_EXECUTE_HANDLER) {}
621 /* pretend we didn't handle this, so that the debugger is invoked and/or
622 the normal GPF box appears. */
623 return EXCEPTION_CONTINUE_SEARCH;
626 #endif /* _MSC_VER */
632 /* Handler for SIGDANGER. */
634 memory_warning_signal (int sig)
636 /* #### bad bad bad; this function shouldn't do anything except
637 set a flag, or weird corruption could happen. */
638 signal (sig, memory_warning_signal);
641 (GETTEXT ("Operating system warns that virtual memory is running low.\n"));
643 /* It might be unsafe to call do_auto_save now. */
644 force_auto_save_soon ();
646 #endif /* SIGDANGER */
648 /* Code for dealing with Lisp access to the Unix command line */
651 make_arg_list_1 (int argc, Extbyte **argv, int skip_args)
653 Lisp_Object result = Qnil;
656 for (i = argc - 1; i >= 0; i--)
658 if (i == 0 || i > skip_args)
663 /* Do not trust to what crt0 has stuffed into argv[0] */
664 char full_exe_path[MAX_PATH];
665 Lisp_Object fullpath;
667 GetModuleFileName (NULL, full_exe_path, MAX_PATH);
668 fullpath = build_ext_string (full_exe_path, Qmswindows_tstr);
669 result = Fcons (fullpath, result);
670 #if defined(HAVE_SHLIB)
672 Extbyte *fullpathext;
674 LISP_STRING_TO_EXTERNAL (fullpath, fullpathext,
675 Qdll_filename_encoding);
676 (void) dll_init (fullpathext);
682 result = Fcons (build_ext_string (argv[i],
683 Qcommand_argument_encoding),
691 make_arg_list (int argc, Extbyte **argv)
693 return make_arg_list_1 (argc, argv, 0);
696 /* Calling functions are also responsible for calling free_argc_argv
697 when they are done with the generated list. */
699 make_argc_argv (Lisp_Object argv_list, int *argc, Extbyte ***argv)
702 int n = XINT (Flength (argv_list));
704 *argv = (Extbyte**) xmalloc ((n+1) * sizeof (Extbyte*));
706 for (i = 0, next = argv_list; i < n; i++, next = XCDR (next))
709 CHECK_STRING (XCAR (next));
711 LISP_STRING_TO_EXTERNAL (XCAR (next), temp, Qcommand_argument_encoding);
712 (*argv) [i] = xstrdup (temp);
719 free_argc_argv (Extbyte **argv)
732 init_cmdargs (int argc, Extbyte **argv, int skip_args)
737 Vcommand_line_args = make_arg_list_1 (argc, argv, skip_args);
740 DEFUN ("invocation-name", Finvocation_name, 0, 0, 0, /*
741 Return the program name that was used to run XEmacs.
742 Any directory names are omitted.
746 return Fcopy_sequence (Vinvocation_name);
749 DEFUN ("invocation-directory", Finvocation_directory, 0, 0, 0, /*
750 Return the directory name in which the Emacs executable was located.
754 return Fcopy_sequence (Vinvocation_directory);
759 /* #### - don't know why I18N4 on SunOS/JLE
760 can't deal with this. It's a potential
761 bug that needs to be looked at. */
762 # undef RUN_TIME_REMAP
765 /* Test whether the next argument in ARGV matches SSTR or a prefix of
766 LSTR (at least MINLEN characters). If so, then if VALPTR is non-null
767 (the argument is supposed to have a value) store in *VALPTR either
768 the next argument or the portion of this one after the equal sign.
769 ARGV is read starting at position *SKIPPTR; this index is advanced
770 by the number of arguments used.
772 Too bad we can't just use getopt for all of this, but we don't have
773 enough information to do it right. */
776 argmatch (char **argv, int argc, char *sstr, char *lstr,
777 int minlen, char **valptr, int *skipptr)
783 /* Don't access argv[argc]; give up in advance. */
784 if (argc <= *skipptr + 1)
787 arg = argv[*skipptr+1];
790 if (strcmp (arg, sstr) == 0)
794 *valptr = argv[*skipptr+2];
801 arglen = (valptr != NULL && (p = strchr (arg, '=')) != NULL
802 ? p - arg : (int) strlen (arg));
803 if (lstr == 0 || arglen < minlen || strncmp (arg, lstr, arglen) != 0)
805 else if (valptr == NULL)
816 else if (argv[*skipptr+2] != NULL)
818 *valptr = argv[*skipptr+2];
828 /* Make stack traces always identify version + configuration */
829 #define main_1 STACK_TRACE_EYE_CATCHER
831 /* This function is not static, so that the compiler is less likely to
832 inline it, which would make it not show up in stack traces.
834 The restart argument is a flag that indicates that main_1 is now
835 being called for the second time in this invocation of xemacs; this can
836 only happen in an xemacs that is not loaded with dumped data (temacs
837 with the conventional dumper or xemacs -nd with the pdumper). See
838 Frun_emacs_from_temacs().
840 restart interacts with initialized as follows (per Olivier Galibert):
844 initialized==0 => temacs
845 initialized!=0 && restart!=0 => run-temacs
846 initialized!=0 && restart==0 => xemacs/post pdump_load()
848 DECLARE_DOESNT_RETURN (main_1 (int, char **, char **, int));
850 main_1 (int argc, char **argv, char **envp, int restart)
852 char stack_bottom_variable;
855 int inhibit_window_system;
857 extern int malloc_cookie;
860 #if (!defined (SYSTEM_MALLOC) && !defined (HAVE_LIBMCHECK) \
861 && !defined (DOUG_LEA_MALLOC))
862 /* Make sure that any libraries we link against haven't installed a
863 hook for a gmalloc of a potentially incompatible version. */
864 /* If we're using libmcheck, the hooks have already been initialized, */
865 /* don't touch them. -slb */
866 __malloc_hook = NULL;
867 __realloc_hook = NULL;
869 #endif /* not SYSTEM_MALLOC or HAVE_LIBMCHECK or DOUG_LEA_MALLOC */
875 * NeXT secret magic, ripped from Emacs-for-NS by Carl Edman
876 * <cedman@princeton.edu>. Note that even Carl doesn't know what this
877 * does; it was provided by NeXT, and it presumable makes NS's mallocator
878 * work with dumping. But malloc_jumpstart() and malloc_freezedry() in
879 * unexnext.c are both completely undocumented, even in NS header files!
880 * But hey, it solves all NS related memory problems, so who's
882 if (initialized && malloc_jumpstart (malloc_cookie) != 0)
883 stderr_out ("malloc jumpstart failed!\n");
887 #if defined (GNU_MALLOC) && \
888 defined (ERROR_CHECK_MALLOC) && \
889 !defined (HAVE_LIBMCHECK)
891 #if defined(LOSING_GCC_DESTRUCTOR_FREE_BUG)
892 /* Prior to XEmacs 21, this was `#if 0'ed out. */
893 /* I'm enabling this because it is the only reliable way I've found to */
894 /* prevent a very annoying problem where GCC will attempt to free(3) */
895 /* memory at exit() and cause a coredump. */
899 sort_args (argc, argv);
901 #if defined (WIN32_NATIVE) || defined (_SCO_DS)
905 /* Record (approximately) where the stack begins. */
906 stack_bottom = &stack_bottom_variable;
908 #ifdef USG_SHARED_LIBRARIES
910 brk ((void *) bss_end);
915 #if defined (HAVE_MMAP) && defined (REL_ALLOC)
916 /* ralloc can only be used if using the GNU memory allocator. */
918 #elif defined (REL_ALLOC) && !defined(DOUG_LEA_MALLOC)
926 #endif /* HAVE_SOCKS */
928 #ifndef SYSTEM_MALLOC
930 /* Arrange to get warning messages as memory fills up. */
931 memory_warnings (0, malloc_warning);
932 #endif /* not SYSTEM_MALLOC */
934 #ifdef SET_EMACS_PRIORITY
935 if (emacs_priority != 0)
936 nice (-emacs_priority);
938 #endif /* SET_EMACS_PRIORITY */
940 #ifdef EXTRA_INITIALIZE
944 #ifdef HAVE_WINDOW_SYSTEM
945 inhibit_window_system = 0;
947 inhibit_window_system = 1;
950 /* Handle the -sd/--show-dump-id switch, which means show the hex dump_id and quit */
951 if (argmatch (argv, argc, "-sd", "--show-dump-id", 9, NULL, &skip_args))
954 printf ("%08x\n", dump_id);
956 printf ("Portable dumper not configured; -sd just forces exit.\n");
961 /* Handle the -t switch, which specifies filename to use as terminal */
964 if (argmatch (argv, argc, "-t", "--terminal", 4, &term, &skip_args))
968 if (open (term, O_RDWR | OPEN_BINARY, 2) < 0)
969 fatal ("%s: %s", term, strerror (errno));
972 fatal ("%s: not a tty", term);
975 stderr_out ("Using %s", ttyname (0));
977 stderr_out ("Using %s", term);
978 inhibit_window_system = 1; /* -t => -nw */
982 /* Handle the --no-dump-file/-nd switch, which means don't load the dump file (ignored when not using pdump) */
983 if (argmatch (argv, argc, "-nd", "--no-dump-file", 7, NULL, &skip_args))
988 /* Handle -nw switch */
989 if (argmatch (argv, argc, "-nw", "--no-windows", 6, NULL, &skip_args))
990 inhibit_window_system = 1;
992 /* Handle the -batch switch, which means don't do interactive display. */
993 if (argmatch (argv, argc, "-batch", "--batch", 5, NULL, &skip_args))
995 #if 0 /* I don't think this is correct. */
996 inhibit_autoloads = 1;
1001 if (argmatch (argv, argc, "-debug-paths", "--debug-paths",
1002 11, NULL, &skip_args))
1005 /* Partially handle -no-autoloads, -no-early-packages and -vanilla. Packages */
1006 /* are searched prior to the rest of the command line being parsed in */
1008 if (argmatch (argv, argc, "-no-early-packages", "--no-early-packages",
1009 6, NULL, &skip_args))
1011 inhibit_early_packages = 1;
1015 if (argmatch (argv, argc, "-no-site-modules", "--no-site-modules",
1016 9, NULL, &skip_args))
1018 inhibit_site_modules = 1;
1022 inhibit_site_modules = 1;
1024 if (argmatch (argv, argc, "-vanilla", "--vanilla",
1025 7, NULL, &skip_args))
1027 inhibit_early_packages = 1;
1031 if (argmatch (argv, argc, "-no-autoloads", "--no-autoloads",
1032 7, NULL, &skip_args))
1034 /* Inhibit everything */
1035 inhibit_autoloads = 1;
1039 if (argmatch (argv, argc, "-debug-paths", "--debug-paths",
1040 6, NULL, &skip_args))
1047 /* Partially handle the -version and -help switches: they imply -batch,
1048 but are not removed from the list. */
1049 if (argmatch (argv, argc, "-help", "--help", 3, NULL, &skip_args))
1050 noninteractive = 1, skip_args--;
1052 if (argmatch (argv, argc, "-version", "--version", 3, NULL, &skip_args) ||
1053 argmatch (argv, argc, "-V", 0, 2, NULL, &skip_args))
1054 noninteractive = 1, skip_args--;
1056 /* Now, figure out which type of console is our first console. */
1061 display_use = "stream";
1063 display_use = "tty";
1066 if (inhibit_window_system)
1067 fatal ("Sorry, this XEmacs was not compiled with TTY support");
1070 #ifdef HAVE_WINDOW_SYSTEM
1071 /* Stupid kludge to catch command-line display spec. We can't
1072 handle this argument entirely in window-system-dependent code
1073 because we don't even know which window-system-dependent code
1074 to run until we've recognized this argument. */
1075 if (!inhibit_window_system && !noninteractive)
1077 #ifdef HAVE_X_WINDOWS
1079 int count_before = skip_args;
1081 if (argmatch (argv, argc, "-d", "--display", 3, &dpy, &skip_args) ||
1082 argmatch (argv, argc, "-display", 0, 3, &dpy, &skip_args))
1087 /* If we have the form --display=NAME,
1088 convert it into -d name.
1089 This requires inserting a new element into argv. */
1090 if (dpy != 0 && skip_args - count_before == 1)
1092 char **new = (char **) xmalloc (sizeof (char *) * (argc + 2));
1095 for (j = 0; j < count_before + 1; j++)
1097 new[count_before + 1] = "-d";
1098 new[count_before + 2] = dpy;
1099 for (j = count_before + 2; j <argc; j++)
1100 new[j + 1] = argv[j];
1104 /* Change --display to -d, when its arg is separate. */
1105 else if (dpy != 0 && skip_args > count_before
1106 && argv[count_before + 1][1] == '-')
1107 argv[count_before + 1] = "-d";
1109 /* Don't actually discard this arg. */
1110 skip_args = count_before;
1112 /* If there is a non-empty environment var DISPLAY, set
1113 `display_use', but not `display_arg', which is only to be set
1114 if the display was specified on the command line. */
1115 if ((dpy = getenv ("DISPLAY")) && dpy[0])
1118 #endif /* HAVE_X_WINDOWS */
1121 char *dpy = getenv ("DISPLAY");
1123 display_use = "gtk";
1126 #ifdef HAVE_MS_WINDOWS
1127 if (strcmp(display_use, "x") != 0)
1128 display_use = "mswindows";
1129 #endif /* HAVE_MS_WINDOWS */
1131 #endif /* HAVE_WINDOW_SYSTEM */
1133 noninteractive1 = noninteractive;
1135 /****** Now initialize everything *******/
1137 /* First, do really basic environment initialization -- catching signals
1138 and the like. These functions have no dependence on any part of
1139 the Lisp engine and need to be done both at dump time and at run time. */
1141 init_signals_very_early ();
1142 init_data_very_early (); /* Catch math errors. */
1143 #ifdef LISP_FLOAT_TYPE
1144 init_floatfns_very_early (); /* Catch floating-point math errors. */
1146 init_process_times_very_early (); /* Initialize our process timers.
1147 As early as possible, of course,
1148 so we can be fairly accurate. */
1149 init_intl_very_early (); /* set up the locale and domain for gettext and
1151 #ifdef HAVE_MS_WINDOWS
1152 init_mswindows_very_early (); /* Some things - like dde need to be
1153 initialized early so that the
1154 client doesn't give up waiting. */
1157 /* Now initialize the Lisp engine and the like. Done only during
1158 dumping. No dependence on anything that may be in the user's
1159 environment when the dumped XEmacs is run.
1161 We try to do things in an order that minimizes the non-obvious
1162 dependencies between functions. */
1164 /* purify_flag 1 is correct even if CANNOT_DUMP.
1165 * loadup.el will set to nil at end. */
1171 else if (nodumpfile) {
1176 /* Keep command options from getting stomped.
1178 Some LISP-visible options are changed by XEmacs _after_ the data is
1179 dumped in building a --pdump XEmacs, but _before_ it is restored in
1180 normal operation. Thus the restored values overwrite the values
1181 XEmacs is getting at run-time. Such variables must be saved here,
1182 and restored after loading the dumped data.
1184 Boy, this is ugly, but how else to do it?
1187 /* noninteractive1 is saved in noninteractive, which isn't LISP-visible */
1188 int inhibit_early_packages_save = inhibit_early_packages;
1189 int inhibit_autoloads_save = inhibit_autoloads;
1190 int debug_paths_save = debug_paths;
1191 /* #### Give inhibit-site-lisp a command switch? If so, uncomment: */
1192 /* int inhibit_site_lisp_save = inhibit_site_lisp; */
1193 int inhibit_site_modules_save = inhibit_site_modules;
1195 initialized = pdump_load (argv[0]);
1197 /* Now unstomp everything */
1198 noninteractive1 = noninteractive;
1199 inhibit_early_packages = inhibit_early_packages_save;
1200 inhibit_autoloads = inhibit_autoloads_save;
1201 debug_paths = debug_paths_save;
1202 /* #### Give inhibit-site-lisp a command switch? If so, uncomment: */
1203 /* inhibit_site_lisp = inhibit_site_lisp_save; */
1204 inhibit_site_modules = inhibit_site_modules_save;
1207 run_temacs_argc = -1;
1218 /* Initialize things so that new Lisp objects
1219 can be created and objects can be staticpro'd.
1220 Must be basically the very first thing done
1221 because pretty much all of the initialization
1222 routines below create new objects. */
1223 init_alloc_once_early ();
1225 /* Initialize Qnil, Qt, Qunbound, and the
1226 obarray. After this, symbols can be
1227 interned. This depends on init_alloc_once_early(). */
1228 init_symbols_once_early ();
1230 /* Declare the basic symbols pertaining to errors,
1231 So that DEFERROR*() can be called. */
1232 init_errors_once_early ();
1234 /* Make sure that opaque pointers can be created. */
1235 init_opaque_once_early ();
1237 /* Now declare all the symbols and define all the Lisp primitives.
1239 The *only* thing that the syms_of_*() functions are allowed to do
1240 is call one of the following:
1242 INIT_LRECORD_IMPLEMENTATION()
1243 defsymbol(), DEFSYMBOL(), or DEFSYMBOL_MULTIWORD_PREDICATE()
1244 defsubr() (i.e. DEFSUBR)
1245 deferror(), DEFERROR(), or DEFERROR_STANDARD()
1246 defkeyword() or DEFKEYWORD()
1248 Order does not matter in these functions.
1254 syms_of_bytecode ();
1256 syms_of_callproc ();
1257 syms_of_casefiddle ();
1267 #endif /* DEBUG_XEMACS */
1278 #ifdef HAVE_X_WINDOWS
1279 syms_of_event_Xt ();
1282 syms_of_event_gtk ();
1284 #ifdef HAVE_DRAGNDROP
1285 syms_of_dragdrop ();
1287 syms_of_event_stream ();
1292 #ifdef CLASH_DETECTION
1293 syms_of_filelock ();
1294 #endif /* CLASH_DETECTION */
1295 syms_of_floatfns ();
1297 syms_of_font_lock ();
1301 syms_of_glyphs_eimage ();
1302 syms_of_glyphs_widget ();
1312 #ifdef HAVE_DATABASE
1313 syms_of_database ();
1315 #ifdef HAVE_MENUBARS
1324 #if !defined (NO_SUBPROCESSES)
1326 #ifdef HAVE_WIN32_PROCESSES
1327 syms_of_process_nt ();
1331 #if defined (HAVE_MMAP) && defined (REL_ALLOC) && !defined(DOUG_LEA_MALLOC)
1333 #endif /* HAVE_MMAP && REL_ALLOC */
1334 syms_of_rangetab ();
1335 syms_of_redisplay ();
1340 syms_of_specifier ();
1343 #ifdef HAVE_SCROLLBARS
1344 syms_of_scrollbar ();
1346 #ifdef HAVE_TOOLBARS
1354 syms_of_console_tty ();
1355 syms_of_device_tty ();
1356 syms_of_objects_tty ();
1360 syms_of_device_gtk ();
1361 syms_of_frame_gtk ();
1362 syms_of_glyphs_gtk ();
1363 syms_of_objects_gtk ();
1365 syms_of_select_gtk ();
1367 syms_of_dialog_gtk ();
1369 #ifdef HAVE_MENUBARS
1370 syms_of_menubar_gtk ();
1372 syms_of_select_gtk ();
1374 #if defined (HAVE_MENUBARS) || defined(HAVE_SCROLLBARS) || defined(HAVE_DIALOGS) || defined(HAVE_TOOLBARS)
1377 #endif /* HAVE_GTK */
1379 #ifdef HAVE_X_WINDOWS
1380 #ifdef HAVE_BALLOON_HELP
1381 syms_of_balloon_x ();
1383 syms_of_device_x ();
1385 syms_of_dialog_x ();
1388 syms_of_glyphs_x ();
1389 syms_of_objects_x ();
1390 #ifdef HAVE_MENUBARS
1391 syms_of_menubar_x ();
1393 syms_of_select_x ();
1394 #if defined (HAVE_MENUBARS) || defined (HAVE_SCROLLBARS) || defined (HAVE_DIALOGS) || defined (HAVE_TOOLBARS)
1399 syms_of_input_method_xlib ();
1401 #endif /* HAVE_XIM */
1402 #endif /* HAVE_X_WINDOWS */
1404 #ifdef HAVE_MS_WINDOWS
1405 syms_of_console_mswindows ();
1406 syms_of_device_mswindows ();
1407 syms_of_dialog_mswindows ();
1408 syms_of_frame_mswindows ();
1409 syms_of_objects_mswindows ();
1410 syms_of_select_mswindows ();
1411 syms_of_glyphs_mswindows ();
1412 syms_of_gui_mswindows ();
1413 #ifdef HAVE_MENUBARS
1414 syms_of_menubar_mswindows ();
1416 #ifdef HAVE_SCROLLBARS
1417 syms_of_scrollbar_mswindows ();
1419 #endif /* HAVE_MS_WINDOWS */
1420 #ifdef HAVE_MSW_C_DIRED
1421 syms_of_dired_mswindows ();
1426 #if defined (WIN32_NATIVE) || defined (CYGWIN)
1432 syms_of_mule_ccl ();
1433 syms_of_mule_charset ();
1436 syms_of_file_coding ();
1440 syms_of_mule_wnn ();
1443 syms_of_mule_canna ();
1444 #endif /* HAVE_CANNA */
1456 #if defined (GNU_MALLOC) && \
1457 defined (ERROR_CHECK_MALLOC) && \
1458 !defined (HAVE_LIBMCHECK)
1460 /* Prior to XEmacs 21, this was `#if 0'ed out. -slb */
1461 #if defined (LOSING_GCC_DESTRUCTOR_FREE_BUG)
1462 syms_of_free_hook ();
1466 syms_of_tooltalk ();
1478 syms_of_gpmevent ();
1481 #ifdef HAVE_POSTGRESQL
1482 syms_of_postgresql ();
1485 /* Now create the subtypes for the types that have them.
1486 We do this before the vars_*() because more symbols
1487 may get initialized here. */
1489 /* Now initialize the console types and associated symbols.
1490 Other than the first function below, the functions may
1491 make exactly the following function/macro calls:
1493 INITIALIZE_CONSOLE_TYPE()
1494 CONSOLE_HAS_METHOD()
1496 For any given console type, the former macro must be called
1497 before the any calls to the latter macro. */
1499 console_type_create ();
1501 console_type_create_stream ();
1504 console_type_create_tty ();
1505 console_type_create_device_tty ();
1506 console_type_create_frame_tty ();
1507 console_type_create_objects_tty ();
1508 console_type_create_redisplay_tty ();
1512 console_type_create_gtk ();
1513 console_type_create_select_gtk ();
1514 console_type_create_device_gtk ();
1515 console_type_create_frame_gtk ();
1516 console_type_create_objects_gtk ();
1517 console_type_create_glyphs_gtk ();
1518 console_type_create_redisplay_gtk ();
1519 #ifdef HAVE_MENUBARS
1520 console_type_create_menubar_gtk ();
1522 #ifdef HAVE_SCROLLBARS
1523 console_type_create_scrollbar_gtk ();
1525 #ifdef HAVE_TOOLBARS
1526 console_type_create_toolbar_gtk ();
1529 console_type_create_dialog_gtk ();
1531 #endif /* HAVE_GTK */
1533 #ifdef HAVE_X_WINDOWS
1534 console_type_create_x ();
1535 console_type_create_device_x ();
1536 console_type_create_frame_x ();
1537 console_type_create_glyphs_x ();
1538 console_type_create_select_x ();
1539 #ifdef HAVE_MENUBARS
1540 console_type_create_menubar_x ();
1542 console_type_create_objects_x ();
1543 console_type_create_redisplay_x ();
1544 #ifdef HAVE_SCROLLBARS
1545 console_type_create_scrollbar_x ();
1547 #ifdef HAVE_TOOLBARS
1548 console_type_create_toolbar_x ();
1551 console_type_create_dialog_x ();
1553 #endif /* HAVE_X_WINDOWS */
1555 #ifdef HAVE_MS_WINDOWS
1556 console_type_create_mswindows ();
1557 console_type_create_device_mswindows ();
1558 console_type_create_frame_mswindows ();
1559 console_type_create_objects_mswindows ();
1560 console_type_create_redisplay_mswindows ();
1561 console_type_create_glyphs_mswindows ();
1562 console_type_create_select_mswindows ();
1563 # ifdef HAVE_SCROLLBARS
1564 console_type_create_scrollbar_mswindows ();
1566 #ifdef HAVE_MENUBARS
1567 console_type_create_menubar_mswindows ();
1569 #ifdef HAVE_TOOLBARS
1570 console_type_create_toolbar_mswindows ();
1573 console_type_create_dialog_mswindows ();
1577 /* Now initialize the specifier types and associated symbols.
1578 Other than the first function below, the functions may
1579 make exactly the following function/macro calls:
1581 INITIALIZE_SPECIFIER_TYPE()
1582 SPECIFIER_HAS_METHOD()
1584 For any given specifier type, the former macro must be called
1585 before the any calls to the latter macro. */
1587 specifier_type_create ();
1589 specifier_type_create_image ();
1590 specifier_type_create_gutter ();
1591 specifier_type_create_objects ();
1592 #ifdef HAVE_TOOLBARS
1593 specifier_type_create_toolbar ();
1596 /* Now initialize the structure types and associated symbols.
1597 Other than the first function below, the functions may
1598 make exactly the following function/macro calls:
1600 define_structure_type()
1601 define_structure_type_keyword()
1605 structure_type_create ();
1607 structure_type_create_chartab ();
1608 structure_type_create_faces ();
1609 structure_type_create_rangetab ();
1610 structure_type_create_hash_table ();
1612 /* Now initialize the image instantiator formats and associated symbols.
1613 Other than the first function below, the functions may
1614 make exactly the following function/macro calls:
1616 INITIALIZE_IMAGE_INSTANTIATOR_FORMAT()
1617 IIFORMAT_HAS_METHOD()
1618 IIFORMAT_VALID_KEYWORD()
1620 For any given image instantiator format, the first macro must be
1621 called before the any calls to the other macros. */
1623 image_instantiator_format_create ();
1624 image_instantiator_format_create_glyphs_eimage ();
1625 image_instantiator_format_create_glyphs_widget ();
1627 image_instantiator_format_create_glyphs_tty ();
1629 #ifdef HAVE_X_WINDOWS
1630 image_instantiator_format_create_glyphs_x ();
1631 #endif /* HAVE_X_WINDOWS */
1632 #ifdef HAVE_MS_WINDOWS
1633 image_instantiator_format_create_glyphs_mswindows ();
1634 #endif /* HAVE_MSWINDOWS_WINDOWS */
1636 image_instantiator_format_create_glyphs_gtk ();
1639 /* Now initialize the lstream types and associated symbols.
1640 Other than the first function below, the functions may
1641 make exactly the following function/macro calls:
1643 LSTREAM_HAS_METHOD()
1647 lstream_type_create ();
1649 lstream_type_create_file_coding ();
1651 #if defined (HAVE_MS_WINDOWS) && !defined(HAVE_MSG_SELECT)
1652 lstream_type_create_mswindows_selectable ();
1655 /* Initialize processes implementation.
1656 The functions may make exactly the following function/macro calls:
1658 PROCESS_HAS_METHOD()
1660 #ifdef HAVE_UNIX_PROCESSES
1661 process_type_create_unix ();
1663 #ifdef HAVE_WIN32_PROCESSES
1664 process_type_create_nt ();
1667 /* Now initialize most variables.
1669 These functions may do exactly the following:
1682 defsymbol(), if it's absolutely necessary and you're sure that
1683 the symbol isn't referenced anywhere else in the initialization
1685 Fset() on a symbol that is unbound
1686 assigning a symbol or constant value to a variable
1687 using a global variable that has been initialized
1688 earlier on in the same function
1690 Any of the object-creating functions in alloc.c: e.g.
1703 perhaps a few others.
1705 NB: Initialization or assignment should not be done here to certain
1706 variables settable from the command line. See the comment above
1707 the call to pdump_load() in main_1(). This caveat should only
1708 apply to vars_of_emacs().
1711 /* Now allow Fprovide() statements to be made. */
1712 init_provide_once ();
1714 /* Do that before any specifier creation (esp. vars_of_glyphs()) */
1715 vars_of_specifier ();
1720 vars_of_bytecode ();
1722 vars_of_callproc ();
1732 vars_of_console_stream ();
1739 #ifdef HAVE_DRAGNDROP
1740 vars_of_dragdrop ();
1747 #ifdef HAVE_X_WINDOWS
1748 vars_of_event_Xt ();
1750 #if defined(HAVE_TTY) && (defined (DEBUG_TTY_EVENT_STREAM) || !defined (HAVE_X_WINDOWS))
1751 vars_of_event_tty ();
1753 #ifdef HAVE_MS_WINDOWS
1754 vars_of_event_mswindows ();
1756 vars_of_event_stream ();
1762 #ifdef CLASH_DETECTION
1763 vars_of_filelock ();
1765 vars_of_floatfns ();
1766 vars_of_font_lock ();
1769 vars_of_glyphs_eimage ();
1770 vars_of_glyphs_widget ();
1778 vars_of_input_method_motif ();
1779 #else /* XIM_XLIB */
1780 vars_of_input_method_xlib ();
1782 #endif /* HAVE_XIM */
1788 #ifdef HAVE_DATABASE
1789 vars_of_database ();
1791 #ifdef HAVE_MENUBARS
1805 #ifndef NO_SUBPROCESSES
1807 #ifdef HAVE_UNIX_PROCESSES
1808 vars_of_process_unix ();
1810 #ifdef HAVE_WIN32_PROCESSES
1811 vars_of_process_nt ();
1816 #if defined (HAVE_MMAP) && defined (REL_ALLOC) && !defined(DOUG_LEA_MALLOC)
1818 #endif /* HAVE_MMAP && REL_ALLOC */
1819 vars_of_redisplay ();
1820 #ifdef HAVE_SCROLLBARS
1821 vars_of_scrollbar ();
1828 #ifdef HAVE_TOOLBARS
1835 vars_of_console_tty ();
1836 vars_of_frame_tty ();
1837 vars_of_objects_tty ();
1841 vars_of_device_gtk ();
1843 vars_of_dialog_gtk ();
1845 vars_of_event_gtk ();
1846 vars_of_frame_gtk ();
1847 vars_of_glyphs_gtk ();
1849 #ifdef HAVE_MENUBARS
1850 vars_of_menubar_gtk ();
1852 vars_of_objects_gtk ();
1853 vars_of_select_gtk ();
1854 #ifdef HAVE_SCROLLBARS
1855 vars_of_scrollbar_gtk ();
1857 #if defined (HAVE_MENUBARS) || defined (HAVE_SCROLLBARS) || defined (HAVE_DIALOGS) || defined (HAVE_TOOLBARS)
1860 #endif /* HAVE_GTK */
1862 #ifdef HAVE_X_WINDOWS
1863 #ifdef HAVE_BALLOON_HELP
1864 vars_of_balloon_x ();
1866 vars_of_device_x ();
1868 vars_of_dialog_x ();
1871 vars_of_glyphs_x ();
1872 #ifdef HAVE_MENUBARS
1873 vars_of_menubar_x ();
1875 vars_of_objects_x ();
1876 vars_of_select_x ();
1877 #ifdef HAVE_SCROLLBARS
1878 vars_of_scrollbar_x ();
1880 #if defined (HAVE_MENUBARS) || defined (HAVE_SCROLLBARS) || defined (HAVE_DIALOGS) || defined (HAVE_TOOLBARS)
1883 #endif /* HAVE_X_WINDOWS */
1886 #ifdef HAVE_MS_WINDOWS
1887 vars_of_device_mswindows ();
1888 vars_of_console_mswindows ();
1889 vars_of_frame_mswindows ();
1890 vars_of_objects_mswindows ();
1891 vars_of_select_mswindows ();
1892 vars_of_glyphs_mswindows ();
1893 #ifdef HAVE_SCROLLBARS
1894 vars_of_scrollbar_mswindows ();
1896 #ifdef HAVE_MENUBARS
1897 vars_of_menubar_mswindows ();
1899 #ifdef HAVE_MSW_C_DIRED
1900 vars_of_dired_mswindows ();
1903 vars_of_dialog_mswindows ();
1905 #endif /* HAVE_MS_WINDOWS */
1909 vars_of_mule_ccl ();
1910 vars_of_mule_charset ();
1913 vars_of_file_coding ();
1917 vars_of_mule_wnn ();
1920 vars_of_mule_canna ();
1921 #endif /* HAVE_CANNA */
1925 vars_of_tooltalk ();
1936 #ifdef HAVE_POSTGRESQL
1937 vars_of_postgresql();
1941 vars_of_gpmevent ();
1944 /* Now initialize any specifier variables. We do this later
1945 because it has some dependence on the vars initialized
1948 These functions should *only* initialize specifier variables,
1949 and may make use of the following functions/macros in addition
1950 to the ones listed above:
1954 set_specifier_fallback()
1955 set_specifier_caching()
1958 specifier_vars_of_glyphs ();
1959 specifier_vars_of_gutter ();
1960 #ifdef HAVE_MENUBARS
1961 specifier_vars_of_menubar ();
1963 specifier_vars_of_redisplay ();
1964 #ifdef HAVE_SCROLLBARS
1965 specifier_vars_of_scrollbar ();
1967 #ifdef HAVE_TOOLBARS
1968 specifier_vars_of_toolbar ();
1970 specifier_vars_of_window ();
1972 /* Now comes all the rest of the variables that couldn't
1973 be handled above. There may be dependencies on variables
1974 initialized above, and dependencies between one complex_vars_()
1975 function and another. */
1977 /* Calls Fmake_range_table(). */
1978 complex_vars_of_regex ();
1979 /* Calls Fmake_range_table(). */
1980 complex_vars_of_search ();
1982 /* Calls make_lisp_hash_table(). */
1983 complex_vars_of_extents ();
1985 /* Depends on hash tables and specifiers. */
1986 complex_vars_of_faces ();
1989 /* These two depend on hash tables and various variables declared
1990 earlier. The second may also depend on the first. */
1991 complex_vars_of_mule_charset ();
1994 complex_vars_of_file_coding ();
1997 /* This calls allocate_glyph(), which creates specifiers
1998 and also relies on a variable (Vthe_nothing_vector) initialized
1999 above. It also calls make_ext_string(), which under Mule
2000 could require that the charsets be initialized. */
2001 complex_vars_of_glyphs ();
2003 /* These rely on the glyphs just created in the previous function,
2004 and call Fadd_spec_to_specifier(), which relies on various
2005 variables initialized above. */
2007 complex_vars_of_glyphs_gtk ();
2009 #ifdef HAVE_X_WINDOWS
2010 complex_vars_of_glyphs_x ();
2012 #ifdef HAVE_MS_WINDOWS
2013 complex_vars_of_glyphs_mswindows ();
2016 /* This calls Fmake_glyph_internal(). */
2017 complex_vars_of_alloc ();
2019 /* This calls Fmake_glyph_internal(). */
2020 #ifdef HAVE_MENUBARS
2021 complex_vars_of_menubar ();
2024 /* This calls Fmake_glyph_internal(). */
2025 #ifdef HAVE_SCROLLBARS
2026 complex_vars_of_scrollbar ();
2029 /* This calls allocate_glyph(). */
2030 complex_vars_of_frame ();
2032 /* This calls Fcopy_category_table() under Mule, which calls who
2034 complex_vars_of_chartab ();
2036 /* This calls set_string_char(), which (under Mule) depends on the
2037 charsets being initialized. */
2038 complex_vars_of_casetab ();
2040 /* This calls Fcopy_syntax_table(), which relies on char tables. */
2041 complex_vars_of_syntax ();
2043 /* This initializes buffer-local variables, sets things up so
2044 that buffers can be created, and creates a couple of basic
2045 buffers. This depends on Vstandard_syntax_table and
2046 Vstandard_category_table (initialized in the previous
2047 functions), as well as a whole horde of variables that may
2048 have been initialized above. */
2049 complex_vars_of_buffer ();
2051 /* This initializes console-local variables. */
2052 complex_vars_of_console ();
2054 /* This creates a couple more buffers, and depends on the
2055 previous function. */
2056 complex_vars_of_minibuf ();
2058 /* These two might call Ffile_name_as_directory(), which
2059 might depend on all sorts of things; I'm not sure. */
2060 complex_vars_of_emacs ();
2062 /* This creates a couple of basic keymaps and depends on Lisp
2063 hash tables and Ffset() (both of which depend on some variables
2064 initialized in the vars_of_*() section) and possibly other
2066 complex_vars_of_keymap ();
2068 /* Calls make_lisp_hash_table() and creates a keymap */
2069 complex_vars_of_event_stream ();
2071 #ifdef ERROR_CHECK_GC
2073 extern int always_gc;
2074 if (always_gc) /* purification debugging hack */
2075 garbage_collect_1 ();
2079 } else if (!restart) { /* after successful pdump_load() */
2080 reinit_alloc_once_early ();
2081 reinit_symbols_once_early ();
2082 reinit_opaque_once_early ();
2084 reinit_console_type_create_stream ();
2086 reinit_console_type_create_tty ();
2088 #ifdef HAVE_X_WINDOWS
2089 reinit_console_type_create_x ();
2090 reinit_console_type_create_device_x ();
2092 #ifdef HAVE_MS_WINDOWS
2093 reinit_console_type_create_mswindows ();
2096 reinit_console_type_create_gtk ();
2099 reinit_specifier_type_create ();
2100 reinit_specifier_type_create_image ();
2101 reinit_specifier_type_create_gutter ();
2102 reinit_specifier_type_create_objects ();
2103 #ifdef HAVE_TOOLBARS
2104 reinit_specifier_type_create_toolbar ();
2107 structure_type_create ();
2109 structure_type_create_chartab ();
2110 structure_type_create_faces ();
2111 structure_type_create_rangetab ();
2112 structure_type_create_hash_table ();
2114 lstream_type_create ();
2116 lstream_type_create_file_coding ();
2118 #if defined (HAVE_MS_WINDOWS) && !defined(HAVE_MSG_SELECT)
2119 lstream_type_create_mswindows_selectable ();
2121 #ifdef HAVE_UNIX_PROCESSES
2122 process_type_create_unix ();
2124 #ifdef HAVE_WIN32_PROCESSES
2125 process_type_create_nt ();
2128 reinit_vars_of_buffer ();
2129 reinit_vars_of_console ();
2131 reinit_vars_of_debug ();
2133 reinit_vars_of_device ();
2134 reinit_vars_of_eval ();
2135 #ifdef HAVE_X_WINDOWS
2136 reinit_vars_of_event_Xt ();
2139 reinit_vars_of_event_gtk ();
2141 #if defined(HAVE_TTY) && (defined (DEBUG_TTY_EVENT_STREAM) || !defined (HAVE_X_WINDOWS))
2142 reinit_vars_of_event_tty ();
2144 #ifdef HAVE_MS_WINDOWS
2145 reinit_vars_of_event_mswindows ();
2147 reinit_vars_of_event_stream ();
2148 reinit_vars_of_events ();
2149 reinit_vars_of_extents ();
2150 reinit_vars_of_fileio ();
2151 reinit_vars_of_font_lock ();
2152 reinit_vars_of_glyphs ();
2153 reinit_vars_of_glyphs_widget ();
2154 reinit_vars_of_insdel ();
2155 reinit_vars_of_lread ();
2156 reinit_vars_of_lstream ();
2157 reinit_vars_of_minibuf ();
2159 reinit_vars_of_module ();
2161 reinit_vars_of_objects ();
2162 reinit_vars_of_print ();
2163 reinit_vars_of_search ();
2164 reinit_vars_of_undo ();
2165 reinit_vars_of_window ();
2167 #ifdef HAVE_MS_WINDOWS
2168 reinit_vars_of_frame_mswindows ();
2172 reinit_vars_of_menubar_gtk ();
2175 #ifdef HAVE_X_WINDOWS
2176 reinit_vars_of_device_x ();
2177 #ifdef HAVE_SCROLLBARS
2178 reinit_vars_of_scrollbar_x ();
2180 #ifdef HAVE_MENUBARS
2181 reinit_vars_of_menubar_x ();
2183 reinit_vars_of_select_x ();
2184 #if defined (HAVE_MENUBARS) || defined (HAVE_SCROLLBARS) || defined (HAVE_DIALOGS) || defined (HAVE_TOOLBARS)
2185 reinit_vars_of_gui_x ();
2187 #endif /* HAVE_X_WINDOWS */
2189 #if defined(MULE) && defined(HAVE_WNN)
2190 reinit_vars_of_mule_wnn ();
2193 reinit_complex_vars_of_buffer ();
2194 reinit_complex_vars_of_console ();
2195 reinit_complex_vars_of_minibuf ();
2200 /* CONGRATULATIONS!!! We have successfully initialized the Lisp
2205 /* Stuff that should not be done at dump time, including stuff that
2206 needs to be reset at run time. Order below should not matter.
2208 Many initializations taken from the environment should go here. */
2212 reinit_mule_category ();
2214 #ifdef HAVE_POSTGRESQL
2215 init_postgresql_from_environment();
2219 /* Now do further initialization/setup of stuff that is not needed by the
2220 syms_of_() routines. This involves stuff that only is enabled in
2221 an interactive run (redisplay, user input, etc.) and stuff that is
2222 not needed until we start loading Lisp code (the reader). A lot
2223 of this stuff involves querying the current environment and needs
2224 to be done both at dump time and at run time. */
2226 init_initial_directory(); /* get the directory to use for the
2227 "*scratch*" buffer, etc. */
2231 * For Win32, call init_environment() now, so that environment/registry
2232 * variables will be properly entered into Vprocess_environment.
2237 init_callproc (); /* Set up the process environment (so that egetenv
2238 works), the basic directory variables
2239 (exec-directory and so on), and stuff
2240 related to subprocesses. This should be
2241 first because many of the functions below
2242 call egetenv() to get environment variables. */
2243 init_lread (); /* Set up the Lisp reader. */
2244 init_cmdargs (argc, (Extbyte **) argv,
2245 skip_args); /* Create list Vcommand_line_args */
2246 init_buffer (); /* Set default directory of *scratch* buffer */
2252 init_redisplay (); /* Determine terminal type.
2253 init_sys_modes uses results */
2255 init_event_stream (); /* Set up so we can get user input. */
2256 init_macros (); /* set up so we can run macros. */
2257 init_editfns (); /* Determine the name of the user we're running as */
2258 init_xemacs_process (); /* set up for calling subprocesses */
2260 init_sunpro (); /* Set up Sunpro usage tracking */
2262 #if defined (WIN32_NATIVE) || defined (CYGWIN)
2265 #if defined (HAVE_NATIVE_SOUND) && defined (hp9000s800)
2271 init_console_stream (restart); /* Create the first console */
2273 /* try to get the actual pathname of the exec file we are running */
2276 Vinvocation_name = Fcar (Vcommand_line_args);
2277 if (XSTRING_DATA(Vinvocation_name)[0] == '-')
2279 /* XEmacs as a login shell, oh goody! */
2280 Vinvocation_name = build_string(getenv("SHELL"));
2282 Vinvocation_directory = Vinvocation_name;
2284 if (!NILP (Ffile_name_directory (Vinvocation_name)))
2286 /* invocation-name includes a directory component -- presumably it
2287 is relative to cwd, not $PATH */
2288 Vinvocation_directory = Fexpand_file_name (Vinvocation_name,
2290 Vinvocation_path = Qnil;
2294 Vinvocation_path = decode_env_path ("PATH", NULL);
2295 locate_file (Vinvocation_path, Vinvocation_name,
2296 Vlisp_EXEC_SUFFIXES,
2297 &Vinvocation_directory, X_OK);
2300 if (NILP (Vinvocation_directory))
2301 Vinvocation_directory = Vinvocation_name;
2303 Vinvocation_name = Ffile_name_nondirectory (Vinvocation_directory);
2304 Vinvocation_directory = Ffile_name_directory (Vinvocation_directory);
2307 #if defined(HAVE_SHLIB) && !defined(WIN32_NATIVE)
2308 /* This is Unix only. MS Windows NT has a library call that does
2309 The Right Thing on that system. Rumor has it, this must be
2310 called for GNU dld in temacs and xemacs. */
2312 char *buf = (char *)alloca (XSTRING_LENGTH (Vinvocation_directory)
2313 + XSTRING_LENGTH (Vinvocation_name)
2315 sprintf (buf, "%s/%s", XSTRING_DATA (Vinvocation_directory),
2316 XSTRING_DATA (Vinvocation_name));
2318 /* All we can do is cry if an error happens, so ignore it. */
2319 (void) dll_init (buf);
2323 #if defined (LOCALTIME_CACHE) && defined (HAVE_TZSET)
2324 /* sun's localtime() has a bug. it caches the value of the time
2325 zone rather than looking it up every time. Since localtime() is
2326 called to bolt the undumping time into the undumped emacs, this
2327 results in localtime() ignoring the TZ environment variable.
2328 This flushes the new TZ value into localtime(). */
2330 #endif /* LOCALTIME_CACHE and TZSET */
2335 /* Handle -l loadup-and-dump, args passed by Makefile. */
2336 if (argc > 2 + skip_args && !strcmp (argv[1 + skip_args], "-l"))
2337 load_me = build_string (argv[2 + skip_args]);
2338 #if 0 /* CANNOT_DUMP - this can never be right in XEmacs --andyp */
2339 /* Unless next switch is -nl, load "loadup.el" first thing. */
2340 if (!(argc > 1 + skip_args && !strcmp (argv[1 + skip_args], "-nl")))
2341 load_me = build_string ("loadup.el");
2342 #endif /* CANNOT_DUMP */
2347 quantify_start_recording_data ();
2348 #endif /* QUANTIFY */
2352 /* This never returns. */
2353 initial_command_loop (load_me);
2358 /* Sort the args so we can find the most important ones
2359 at the beginning of argv. */
2361 /* First, here's a table of all the standard options. */
2363 struct standard_args
2366 const char *longname;
2371 static const struct standard_args standard_args[] =
2373 /* Handled by main_1 above: */
2374 { "-sd", "--show-dump-id", 105, 0 },
2375 { "-t", "--terminal", 100, 1 },
2376 { "-nd", "--no-dump-file", 95, 0 },
2377 { "-nw", "--no-windows", 90, 0 },
2378 { "-batch", "--batch", 85, 0 },
2379 { "-debug-paths", "--debug-paths", 82, 0 },
2380 { "-help", "--help", 80, 0 },
2381 { "-version", "--version", 75, 0 },
2383 { "-d", "--display", 80, 1 },
2384 { "-display", 0, 80, 1 },
2385 { "-NXHost", 0, 79, 0 },
2386 { "-MachLaunch", 0, 79, 0},
2388 /* Handled by command-line-early in startup.el: */
2389 { "-q", "--no-init-file", 50, 0 },
2390 { "-unmapped", 0, 50, 0 },
2391 { "-no-init-file", 0, 50, 0 },
2392 { "-vanilla", "--vanilla", 50, 0 },
2393 { "-no-autoloads", "--no-autoloads", 50, 0 },
2394 { "-no-site-file", "--no-site-file", 40, 0 },
2395 { "-no-early-packages", "--no-early-packages", 35, 0 },
2396 { "-u", "--user", 30, 1 },
2397 { "-user", 0, 30, 1 },
2398 { "-debug-init", "--debug-init", 20, 0 },
2399 { "-debug-paths", "--debug-paths", 20, 0 },
2402 { "-i", "--icon-type", 15, 0 },
2403 { "-itype", 0, 15, 0 },
2404 { "-iconic", "--iconic", 15, 0 },
2405 { "-bg", "--background-color", 10, 1 },
2406 { "-background", 0, 10, 1 },
2407 { "-fg", "--foreground-color", 10, 1 },
2408 { "-foreground", 0, 10, 1 },
2409 { "-bd", "--border-color", 10, 1 },
2410 { "-bw", "--border-width", 10, 1 },
2411 { "-ib", "--internal-border", 10, 1 },
2412 { "-ms", "--mouse-color", 10, 1 },
2413 { "-cr", "--cursor-color", 10, 1 },
2414 { "-fn", "--font", 10, 1 },
2415 { "-font", 0, 10, 1 },
2416 { "-g", "--geometry", 10, 1 },
2417 { "-geometry", 0, 10, 1 },
2418 { "-T", "--title", 10, 1 },
2419 { "-title", 0, 10, 1 },
2420 { "-name", "--name", 10, 1 },
2421 { "-xrm", "--xrm", 10, 1 },
2422 { "-r", "--reverse-video", 5, 0 },
2424 { "-reverse", 0, 5, 0 },
2425 { "-hb", "--horizontal-scroll-bars", 5, 0 },
2426 { "-vb", "--vertical-scroll-bars", 5, 0 },
2428 /* These have the same priority as ordinary file name args,
2429 so they are not reordered with respect to those. */
2430 { "-L", "--directory", 0, 1 },
2431 { "-directory", 0, 0, 1 },
2432 { "-l", "--load", 0, 1 },
2433 { "-load", 0, 0, 1 },
2434 { "-f", "--funcall", 0, 1 },
2435 { "-funcall", 0, 0, 1 },
2436 { "-eval", "--eval", 0, 1 },
2437 { "-insert", "--insert", 0, 1 },
2438 /* This should be processed after ordinary file name args and the like. */
2439 { "-kill", "--kill", -10, 0 },
2442 /* Reorder the elements of ARGV (assumed to have ARGC elements)
2443 so that the highest priority ones come first.
2444 Do not change the order of elements of equal priority.
2445 If an option takes an argument, keep it and its argument together. */
2448 sort_args (int argc, char **argv)
2450 char **new_argv = xnew_array (char *, argc);
2451 /* For each element of argv,
2452 the corresponding element of options is:
2453 0 for an option that takes no arguments,
2454 1 for an option that takes one argument, etc.
2455 -1 for an ordinary non-option argument. */
2456 int *options = xnew_array (int, argc);
2457 int *priority = xnew_array (int, argc);
2461 int end_of_options_p = 0;
2463 /* Categorize all the options,
2464 and figure out which argv elts are option arguments. */
2465 for (from = 1; from < argc; from++)
2469 /* Pseudo options "--" and "run-temacs" indicate end of options */
2470 if (!strcmp (argv[from], "--") ||
2471 !strcmp (argv[from], "run-temacs"))
2472 end_of_options_p = 1;
2473 if (!end_of_options_p && argv[from][0] == '-')
2478 /* Look for a match with a known old-fashioned option. */
2479 for (i = 0; i < countof (standard_args); i++)
2480 if (!strcmp (argv[from], standard_args[i].name))
2482 options[from] = standard_args[i].nargs;
2483 priority[from] = standard_args[i].priority;
2484 if (from + standard_args[i].nargs >= argc)
2485 fatal ("Option `%s' requires an argument\n", argv[from]);
2486 from += standard_args[i].nargs;
2490 /* Look for a match with a known long option.
2491 MATCH is -1 if no match so far, -2 if two or more matches so far,
2492 >= 0 (the table index of the match) if just one match so far. */
2493 if (argv[from][1] == '-')
2496 thislen = strlen (argv[from]);
2497 equals = strchr (argv[from], '=');
2499 thislen = equals - argv[from];
2501 for (i = 0; i < countof (standard_args); i++)
2502 if (standard_args[i].longname
2503 && !strncmp (argv[from], standard_args[i].longname,
2512 /* If we found exactly one match, use that. */
2515 options[from] = standard_args[match].nargs;
2516 priority[from] = standard_args[match].priority;
2517 /* If --OPTION=VALUE syntax is used,
2518 this option uses just one argv element. */
2521 if (from + options[from] >= argc)
2522 fatal ("Option `%s' requires an argument\n", argv[from]);
2523 from += options[from];
2530 /* Copy the arguments, in order of decreasing priority, to NEW_ARGV. */
2531 new_argv[0] = argv[0];
2535 int best_priority = -9999;
2537 /* Find the highest priority remaining option.
2538 If several have equal priority, take the first of them. */
2539 for (from = 1; from < argc; from++)
2541 if (argv[from] != 0 && priority[from] > best_priority)
2543 best_priority = priority[from];
2546 /* Skip option arguments--they are tied to the options. */
2547 if (options[from] > 0)
2548 from += options[from];
2554 /* Copy the highest priority remaining option, with its args, to NEW_ARGV. */
2555 new_argv[to++] = argv[best];
2556 for (i = 0; i < options[best]; i++)
2557 new_argv[to++] = argv[best + i + 1];
2559 /* Clear out this option in ARGV. */
2561 for (i = 0; i < options[best]; i++)
2562 argv[best + i + 1] = 0;
2565 memcpy (argv, new_argv, sizeof (char *) * argc);
2571 DEFUN ("running-temacs-p", Frunning_temacs_p, 0, 0, 0, /*
2572 True if running temacs. This means we are in the dumping stage.
2573 This is false during normal execution of the `xemacs' program, and
2574 becomes false once `run-emacs-from-temacs' is run.
2578 return run_temacs_argc >= 0 ? Qt : Qnil;
2581 DEFUN ("run-emacs-from-temacs", Frun_emacs_from_temacs, 0, MANY, 0, /*
2582 Do not call this. It will reinitialize your XEmacs. You'll be sorry.
2584 /* If this function is called from startup.el, it will be possible to run
2585 temacs as an editor using 'temacs -batch -l loadup.el run-temacs', instead
2586 of having to dump an emacs and then run that (when debugging emacs itself,
2587 this can be much faster)). [Actually, the speed difference isn't that
2588 much as long as your filesystem is local, and you don't end up with
2589 a dumped version in case you want to rerun it. This function is most
2590 useful when used as part of the `make all-elc' command. --ben]
2591 This will "restart" emacs with the specified command-line arguments.
2593 Martin thinks this function is most useful when using debugging
2594 tools like Purify or tcov that get confused by XEmacs' dumping. */
2595 (int nargs, Lisp_Object *args))
2598 const Extbyte *wampum;
2601 Lisp_Object orig_invoc_name = Fcar (Vcommand_line_args);
2602 const Extbyte **wampum_all = alloca_array (const Extbyte *, nargs);
2603 int *wampum_all_len = alloca_array (int, nargs);
2605 assert (!gc_in_progress);
2607 if (run_temacs_argc < 0)
2608 error ("I've lost my temacs-hood.");
2610 /* Need to convert the orig_invoc_name and all of the arguments
2611 to external format. */
2613 TO_EXTERNAL_FORMAT (LISP_STRING, orig_invoc_name,
2614 ALLOCA, (wampum, namesize),
2618 for (ac = 0, total_len = namesize; ac < nargs; ac++)
2620 CHECK_STRING (args[ac]);
2621 TO_EXTERNAL_FORMAT (LISP_STRING, args[ac],
2622 ALLOCA, (wampum_all[ac], wampum_all_len[ac]),
2624 wampum_all_len[ac]++;
2625 total_len += wampum_all_len[ac];
2627 DO_REALLOC (run_temacs_args, run_temacs_args_size, total_len, char);
2628 DO_REALLOC (run_temacs_argv, run_temacs_argv_size, nargs+2, char *);
2630 memcpy (run_temacs_args, wampum, namesize);
2631 run_temacs_argv [0] = run_temacs_args;
2632 for (ac = 0; ac < nargs; ac++)
2634 memcpy (run_temacs_args + namesize,
2635 wampum_all[ac], wampum_all_len[ac]);
2636 run_temacs_argv [ac + 1] = run_temacs_args + namesize;
2637 namesize += wampum_all_len[ac];
2639 run_temacs_argv [nargs + 1] = 0;
2640 catchlist = NULL; /* Important! Otherwise free_cons() calls in
2641 condition_case_unwind() may lead to GC death. */
2642 unbind_to (0, Qnil); /* this closes loadup.el */
2644 run_temacs_argc = nargs + 1;
2645 #if defined (HEAP_IN_DATA) && !defined(PDUMP)
2646 report_sheap_usage (0);
2648 LONGJMP (run_temacs_catch, 1);
2649 return Qnil; /* not reached; warning suppression */
2654 main (int argc, char **argv, char **envp)
2658 /* Under VC++, access violations and the like are not sent through
2659 the standard signal() mechanism. Rather, they need to be handled
2660 using the Microsoft "structured exception handling" mechanism,
2661 which vaguely resembles the C++ mechanisms. */
2666 int volatile vol_argc = argc;
2667 char ** volatile vol_argv = argv;
2668 char ** volatile vol_envp = envp;
2669 /* This is hairy. We need to compute where the XEmacs binary was invoked
2670 from because temacs initialization requires it to find the lisp
2671 directories. The code that recomputes the path is guarded by the
2672 restarted flag. There are three possible paths I've found so far
2675 temacs -- When running temacs for basic build stuff, the first main_1
2676 will be the only one invoked. It must compute the path else there
2677 will be a very ugly bomb in startup.el (can't find obvious location
2678 for doc-directory data-directory, etc.).
2680 temacs w/ run-temacs on the command line -- This is run to bytecompile
2681 all the out of date dumped lisp. It will execute both of the main_1
2682 calls and the second one must not touch the first computation because
2683 argc/argv are hosed the second time through.
2685 xemacs -- Only the second main_1 is executed. The invocation path must
2686 computed but this only matters when running in place or when running
2689 As a bonus for straightening this out, XEmacs can now be run in place
2690 as a login shell. This never used to work.
2692 As another bonus, we can now guarantee that
2693 (concat invocation-directory invocation-name) contains the filename
2694 of the XEmacs binary we are running. This can now be used in a
2695 definite test for out of date dumped files. -slb */
2698 quantify_stop_recording_data ();
2699 quantify_clear_data ();
2700 #endif /* QUANTIFY */
2702 suppress_early_error_handler_backtrace = 0;
2703 lim_data = 0; /* force reinitialization of this variable */
2705 /* Lisp_Object must fit in a word; check VALBITS and GCTYPEBITS */
2706 assert (sizeof (Lisp_Object) == sizeof (void *));
2708 #ifdef LINUX_SBRK_BUG
2714 #ifdef DOUG_LEA_MALLOC
2715 mallopt (M_MMAP_MAX, 0);
2717 run_temacs_argc = 0;
2718 if (! SETJMP (run_temacs_catch))
2720 main_1 (vol_argc, vol_argv, vol_envp, 0);
2722 /* run-emacs-from-temacs called */
2724 vol_argc = run_temacs_argc;
2725 vol_argv = run_temacs_argv;
2727 /* This makes absolutely no sense to anyone involved. There are
2728 several people using this stuff. We've compared versions on
2729 everything we can think of. We can find no difference.
2730 However, on both my systems environ is a plain old global
2731 variable initialized to zero. _environ is the one that
2732 contains pointers to the actual environment.
2734 Since we can't figure out the difference (and we're hours
2735 away from a release), this takes a very cowardly approach and
2736 is bracketed with both a system specific preprocessor test
2737 and a runtime "do you have this problem" test
2739 06/20/96 robertl@dgii.com */
2741 extern char **_environ;
2742 if ((unsigned) environ == 0)
2745 #endif /* _SCO_DS */
2748 #if defined (RUN_TIME_REMAP) && ! defined (PDUMP)
2750 /* obviously no-one uses this because where it was before initialized was
2752 run_time_remap (argv[0]);
2755 #ifdef DOUG_LEA_MALLOC
2756 if (initialized && (malloc_state_ptr != NULL))
2758 int rc = malloc_set_state (malloc_state_ptr);
2761 stderr_out ("malloc_set_state failed, rc = %d\n", rc);
2765 free (malloc_state_ptr);
2767 /* mmap works in glibc-2.1, glibc-2.0 (Non-Mule only) and Linux libc5 */
2768 #if (defined(__GLIBC__) && __GLIBC_MINOR__ >= 1) || \
2769 defined(_NO_MALLOC_WARNING_) || \
2770 (defined(__GLIBC__) && __GLIBC_MINOR__ < 1 && !defined(MULE)) || \
2771 defined(DEBUG_DOUG_LEA_MALLOC)
2772 mallopt (M_MMAP_MAX, 64);
2778 #endif /* DOUG_LEA_MALLOC */
2780 run_temacs_argc = -1;
2782 main_1 (vol_argc, vol_argv, vol_envp, restarted);
2786 /* VC++ documentation says that
2787 GetExceptionCode() cannot be called inside the filter itself. */
2788 __except (mswindows_handle_hardware_exceptions (GetExceptionCode ())) {}
2791 return 0; /* unreached */
2795 /* Dumping apparently isn't supported by versions of GCC >= 2.8. */
2796 /* The following needs conditionalization on whether either XEmacs or */
2797 /* various system shared libraries have been built and linked with */
2798 /* GCC >= 2.8. -slb */
2799 #if defined(GNU_MALLOC)
2801 voodoo_free_hook (void *mem)
2803 /* Disable all calls to free() when XEmacs is exiting and it doesn't */
2806 #ifdef __GNUC__ /* prototype of __free_hook varies with glibc version */
2807 (__typeof__ (__free_hook))
2811 #endif /* GNU_MALLOC */
2813 DEFUN ("kill-emacs", Fkill_emacs, 0, 1, "P", /*
2814 Exit the XEmacs job and kill it. Ask for confirmation, without argument.
2815 If ARG is an integer, return ARG as the exit program code.
2816 If ARG is a string, stuff it as keyboard input.
2818 The value of `kill-emacs-hook', if not void,
2819 is a list of functions (of no args),
2820 all of which are called before XEmacs is actually killed.
2824 /* This function can GC */
2825 struct gcpro gcpro1;
2832 if (!preparing_for_armageddon && !noninteractive)
2833 run_hook (Qkill_emacs_hook);
2835 ensure_no_quitting_from_now_on ();
2837 if (!preparing_for_armageddon)
2839 Lisp_Object concons, nextcons;
2841 /* Normally, go ahead and delete all the consoles now.
2842 Some unmentionably lame window systems (MS Wwwww...... eek,
2843 I can't even say it) don't properly clean up after themselves,
2844 and even for those that do, it might be cleaner this way.
2845 If we're going down, however, we don't do this (might
2846 be too dangerous), and if we get a crash somewhere within
2847 this loop, we'll still autosave and won't try this again. */
2849 LIST_LOOP_DELETING (concons, nextcons, Vconsole_list)
2851 /* There is very little point in deleting the stream console.
2852 It uses stdio, which should flush any buffered output and
2853 something can only go wrong. -slb */
2854 /* I changed my mind. There's a stupid hack in close to add
2855 a trailing newline. */
2856 /*if (!CONSOLE_STREAM_P (XCONSOLE (XCAR (concons))))*/
2857 delete_console_internal (XCONSOLE (XCAR (concons)), 1, 1, 0);
2863 #ifdef HAVE_MS_WINDOWS
2864 /* If we displayed a message on the console, then we must allow the
2865 user to see this message. This may be unnecessary, but can't hurt,
2866 and we can't necessarily check arg; e.g. xemacs --help kills with
2868 if (mswindows_message_outputted)
2869 Fmswindows_message_box (build_string ("Messages outputted. XEmacs is exiting."),
2873 shut_down_emacs (0, STRINGP (arg) ? arg : Qnil, 0);
2875 #if defined(GNU_MALLOC)
2877 #ifdef __GNUC__ /* prototype of __free_hook varies with glibc version */
2878 (__typeof__ (__free_hook))
2883 exit (INTP (arg) ? XINT (arg) : 0);
2885 return Qnil; /* I'm sick of the compiler warning */
2888 /* Perform an orderly shutdown of XEmacs. Autosave any modified
2889 buffers, kill any child processes, clean up the terminal modes (if
2890 we're in the foreground), and other stuff like that. Don't perform
2891 any redisplay; this may be called when XEmacs is shutting down in
2892 the background, or after its X connection has died.
2894 If SIG is a signal number, print a message for it.
2896 This is called by fatal signal handlers and Fkill_emacs. It used to
2897 be called by X protocol error handlers, but instead they now call
2900 shut_down_emacs (int sig, Lisp_Object stuff, int no_auto_save)
2902 /* This function can GC */
2903 /* Prevent running of hooks and other non-essential stuff
2905 preparing_for_armageddon = 1;
2907 ensure_no_quitting_from_now_on ();
2910 quantify_stop_recording_data ();
2911 #endif /* QUANTIFY */
2913 /* This is absolutely the most important thing to do, so make sure
2914 we do it now, before anything else. We might have crashed and
2915 be in a weird inconsistent state, and potentially anything could
2916 set off another protection fault and cause us to bail out
2918 /* Steve writes the following:
2920 [[I'm not removing the code entirely, yet. We have run up against
2921 a spate of problems in diagnosing crashes due to crashes within
2922 crashes. It has very definitely been determined that code called
2923 during auto-saving cannot work if XEmacs crashed inside of GC.
2924 We already auto-save on an itimer so there cannot be too much
2925 unsaved stuff around, and if we get better crash reports we might
2926 be able to get more problems fixed so I'm disabling this. -slb]]
2928 and DISABLES AUTO-SAVING ENTIRELY during crashes! Way way bad idea.
2930 Instead let's just be more intelligent about avoiding crashing
2931 when possible, esp. nested crashes.
2934 Fdo_auto_save (Qt, Qnil); /* do this before anything hazardous */
2937 reset_all_consoles ();
2938 if (sig && sig != SIGTERM)
2941 stderr_out ("\nFatal error.\n\n");
2943 stderr_out ("\nFatal error (%d).\n\n", sig);
2945 ("Your files have been auto-saved.\n"
2946 "Use `M-x recover-session' to recover them.\n"
2948 "If you have access to the PROBLEMS file that came with your\n"
2949 "version of XEmacs, please check to see if your crash is described\n"
2950 "there, as there may be a workaround available.\n"
2952 "Otherwise, please report this bug by selecting `Report-Bug'\n"
2953 "in the InfoDock menu.\n"
2955 "Otherwise, please report this bug by running the send-pr\n"
2956 "script included with XEmacs, or selecting `Send Bug Report'\n"
2957 "from the help menu.\n"
2958 "As a last resort send ordinary email to `crashes@xemacs.org'.\n"
2960 "*MAKE SURE* to include the information in the command\n"
2961 "M-x describe-installation.\n"
2964 "If at all possible, *please* try to obtain a C stack backtrace;\n"
2965 "it will help us immensely in determining what went wrong.\n"
2966 "To do this, locate the core file that was produced as a result\n"
2967 "of this crash (it's usually called `core' and is located in the\n"
2968 "directory in which you started the editor, or maybe in your home\n"
2969 "directory), and type\n"
2979 /* Now try to determine the actual path to the executable,
2980 to try to make the backtrace-determination process as foolproof
2982 if (STRINGP (Vinvocation_name))
2983 name = (char *) XSTRING_DATA (Vinvocation_name);
2986 if (STRINGP (Vinvocation_directory))
2987 dir = (char *) XSTRING_DATA (Vinvocation_directory);
2988 if (!dir || dir[0] != '/')
2989 stderr_out ("`which %s`", name);
2990 else if (dir[strlen (dir) - 1] != '/')
2991 stderr_out ("%s/%s", dir, name);
2993 stderr_out ("%s%s", dir, name);
2997 "then type `where' when the debugger prompt comes up.\n"
2998 "(If you don't have GDB on your system, you might have DBX,\n"
2999 "or XDB, or SDB. A similar procedure should work for all of\n"
3000 "these. Ask your system administrator if you need more help.)\n");
3001 #endif /* _MSC_VER */
3004 stuff_buffered_input (stuff);
3006 kill_buffer_processes (Qnil);
3008 #ifdef CLASH_DETECTION
3009 unlock_all_files ();
3013 tt_session_quit (tt_default_session ());
3015 /* The following crashes when built on X11R5 and run on X11R6 */
3018 #endif /* TOOLTALK */
3025 #if !defined(PDUMP) || !defined(SYSTEM_MALLOC)
3026 extern char my_edata[];
3029 extern void disable_free_hook (void);
3031 DEFUN ("dump-emacs", Fdump_emacs, 2, 2, 0, /*
3032 Dump current state of XEmacs into executable file FILENAME.
3033 Take symbols from SYMFILE (presumably the file you executed to run XEmacs).
3034 This is used in the file `loadup.el' when building XEmacs.
3036 Remember to set `command-line-processed' to nil before dumping
3037 if you want the dumped XEmacs to process its command line
3038 and announce itself normally when it is run.
3040 (filename, symfile))
3042 /* This function can GC */
3043 struct gcpro gcpro1, gcpro2;
3046 GCPRO2 (filename, symfile);
3048 #ifdef FREE_CHECKING
3049 Freally_free (Qnil);
3051 /* When we're dumping, we can't use the debugging free() */
3052 disable_free_hook ();
3055 CHECK_STRING (filename);
3056 filename = Fexpand_file_name (filename, Qnil);
3057 if (!NILP (symfile))
3059 CHECK_STRING (symfile);
3060 if (XSTRING_LENGTH (symfile) > 0)
3061 symfile = Fexpand_file_name (symfile, Qnil);
3066 opurify = purify_flag;
3069 #if defined (HEAP_IN_DATA) && !defined(PDUMP)
3070 report_sheap_usage (1);
3078 disksave_object_finalization ();
3079 release_breathing_space ();
3081 /* Tell malloc where start of impure now is */
3082 /* Also arrange for warnings when nearly out of space. */
3083 #ifndef SYSTEM_MALLOC
3084 memory_warnings (my_edata, malloc_warning);
3093 LISP_STRING_TO_EXTERNAL (filename, filename_ext, Qfile_name);
3095 if (STRINGP (symfile))
3096 LISP_STRING_TO_EXTERNAL (symfile, symfile_ext, Qfile_name);
3100 garbage_collect_1 ();
3106 #ifdef DOUG_LEA_MALLOC
3107 malloc_state_ptr = malloc_get_state ();
3109 /* here we break our rule that the filename conversion should
3110 be performed at the actual time that the system call is made.
3111 It's a whole lot easier to do the conversion here than to
3112 modify all the unexec routines to ensure that filename
3113 conversion is applied everywhere. Don't worry about memory
3114 leakage because this call only happens once. */
3115 unexec (filename_ext, symfile_ext, (uintptr_t) my_edata, 0, 0);
3116 #ifdef DOUG_LEA_MALLOC
3117 free (malloc_state_ptr);
3119 #endif /* not PDUMP */
3122 purify_flag = opurify;
3127 #endif /* not CANNOT_DUMP */
3130 /* Split STRING into a list of substrings. The substrings are the
3131 parts of original STRING separated by SEPCHAR. */
3133 split_string_by_emchar_1 (const Bufbyte *string, Bytecount size,
3136 Lisp_Object result = Qnil;
3137 const Bufbyte *end = string + size;
3141 const Bufbyte *p = string;
3144 if (charptr_emchar (p) == sepchar)
3148 result = Fcons (make_string (string, p - string), result);
3152 INC_CHARPTR (string); /* skip sepchar */
3157 return Fnreverse (result);
3160 /* The same as the above, except PATH is an external C string (it is
3161 converted using Qfile_name), and sepchar is hardcoded to SEPCHAR
3162 (':' or whatever). */
3164 decode_path (const char *path)
3171 TO_INTERNAL_FORMAT (C_STRING, path, ALLOCA, (newpath, newlen), Qfile_name);
3173 /* #### Does this make sense? It certainly does for
3174 decode_env_path(), but it looks dubious here. Does any code
3175 depend on decode_path("") returning nil instead of an empty
3180 return split_string_by_emchar_1 (newpath, newlen, SEPCHAR);
3184 decode_env_path (const char *evarname, const char *default_)
3186 const char *path = 0;
3188 path = egetenv (evarname);
3191 return decode_path (path);
3194 /* Ben thinks this function should not exist or be exported to Lisp.
3195 We use it to define split-path-string in subr.el (not!). */
3197 DEFUN ("split-string-by-char", Fsplit_string_by_char, 1, 2, 0, /*
3198 Split STRING into a list of substrings originally separated by SEPCHAR.
3202 CHECK_STRING (string);
3203 CHECK_CHAR (sepchar);
3204 return split_string_by_emchar_1 (XSTRING_DATA (string),
3205 XSTRING_LENGTH (string),
3209 /* #### This was supposed to be in subr.el, but is used VERY early in
3210 the bootstrap process, so it goes here. Damn. */
3212 DEFUN ("split-path", Fsplit_path, 1, 1, 0, /*
3213 Explode a search path into a list of strings.
3214 The path components are separated with the characters specified
3215 with `path-separator'.
3219 CHECK_STRING (path);
3221 while (!STRINGP (Vpath_separator)
3222 || (XSTRING_CHAR_LENGTH (Vpath_separator) != 1))
3223 Vpath_separator = signal_simple_continuable_error
3224 ("`path-separator' should be set to a single-character string",
3227 return (split_string_by_emchar_1
3228 (XSTRING_DATA (path), XSTRING_LENGTH (path),
3229 charptr_emchar (XSTRING_DATA (Vpath_separator))));
3232 DEFUN ("noninteractive", Fnoninteractive, 0, 0, 0, /*
3233 Non-nil return value means XEmacs is running without interactive terminal.
3237 return noninteractive ? Qt : Qnil;
3240 /* This flag is useful to define if you're under a debugger; this way, you
3241 can put a breakpoint of assert_failed() and debug multiple problems
3242 in one session without having to recompile. */
3243 /* #define ASSERTIONS_DONT_ABORT */
3245 #ifdef USE_ASSERTIONS
3246 /* This highly dubious kludge ... shut up Jamie, I'm tired of your slagging. */
3248 static int in_assert_failed;
3249 static const char *assert_failed_file;
3250 static int assert_failed_line;
3251 static const char *assert_failed_expr;
3257 #undef abort /* avoid infinite #define loop... */
3259 #if defined (WIN32_NATIVE) && defined (DEBUG_XEMACS)
3260 #define enter_debugger() DebugBreak ()
3262 #define enter_debugger()
3266 assert_failed (const char *file, int line, const char *expr)
3268 /* If we're already crashing, let's not crash again. This might be
3269 critical to getting auto-saving working properly. */
3270 if (fatal_error_in_progress)
3273 /* We are extremely paranoid so we sensibly deal with recursive
3274 assertion failures. */
3277 if (in_assert_failed >= 4)
3279 else if (in_assert_failed == 3)
3284 else if (in_assert_failed == 2)
3286 /* Not stderr_out(), which does additional things and may trigger
3287 a recursive assertion failure. fprintf was undeffed above, in
3288 case it was encapsulated. */
3290 "Fatal error: recursive assertion failure, "
3291 "file %s, line %d, %s\n",
3294 "Original assertion failure: file %s, line %d, %s\n",
3295 assert_failed_file, assert_failed_line, assert_failed_expr);
3299 assert_failed_file = file;
3300 assert_failed_line = line;
3301 assert_failed_expr = expr;
3305 "Fatal error: assertion failed, file %s, line %d, %s\n",
3308 stderr_out ("Fatal error: assertion failed, file %s, line %d, %s\n",
3313 #if !defined (ASSERTIONS_DONT_ABORT)
3316 in_assert_failed = 0;
3318 #endif /* USE_ASSERTIONS */
3321 DEFUN ("quantify-start-recording-data", Fquantify_start_recording_data,
3323 Start recording Quantify data.
3327 quantify_start_recording_data ();
3331 DEFUN ("quantify-stop-recording-data", Fquantify_stop_recording_data,
3333 Stop recording Quantify data.
3337 quantify_stop_recording_data ();
3341 DEFUN ("quantify-clear-data", Fquantify_clear_data, 0, 0, "", /*
3342 Clear all Quantify data.
3346 quantify_clear_data ();
3349 #endif /* QUANTIFY */
3352 syms_of_emacs (void)
3355 DEFSUBR (Fdump_emacs);
3356 #endif /* !CANNOT_DUMP */
3358 DEFSUBR (Frun_emacs_from_temacs);
3359 DEFSUBR (Frunning_temacs_p);
3360 DEFSUBR (Finvocation_name);
3361 DEFSUBR (Finvocation_directory);
3362 DEFSUBR (Fkill_emacs);
3363 DEFSUBR (Fnoninteractive);
3366 DEFSUBR (Fquantify_start_recording_data);
3367 DEFSUBR (Fquantify_stop_recording_data);
3368 DEFSUBR (Fquantify_clear_data);
3369 #endif /* QUANTIFY */
3371 DEFSUBR (Fsplit_string_by_char);
3372 DEFSUBR (Fsplit_path); /* #### */
3374 defsymbol (&Qkill_emacs_hook, "kill-emacs-hook");
3375 defsymbol (&Qsave_buffers_kill_emacs, "save-buffers-kill-emacs");
3379 vars_of_emacs (void)
3381 DEFVAR_BOOL ("suppress-early-error-handler-backtrace",
3382 &suppress_early_error_handler_backtrace /*
3383 Non-nil means early error handler shouldn't print a backtrace.
3386 DEFVAR_LISP ("command-line-args", &Vcommand_line_args /*
3387 Args passed by shell to XEmacs, as a list of strings.
3390 DEFVAR_LISP ("invocation-name", &Vinvocation_name /*
3391 The program name that was used to run XEmacs.
3392 Any directory names are omitted.
3395 DEFVAR_LISP ("invocation-directory", &Vinvocation_directory /*
3396 The directory in which the XEmacs executable was found, to run it.
3397 The value is simply the program name if that directory's name is not known.
3400 DEFVAR_LISP ("invocation-path", &Vinvocation_path /*
3401 The path in which the XEmacs executable was found, to run it.
3402 The value is simply the value of environment variable PATH on startup
3403 if XEmacs was found there.
3407 xxDEFVAR_LISP ("installation-directory", &Vinstallation_directory,
3408 "A directory within which to look for the `lib-src' and `etc' directories.\n"
3409 "This is non-nil when we can't find those directories in their standard\n"
3410 "installed locations, but we can find them\n"
3411 "near where the XEmacs executable was found.");
3414 DEFVAR_LISP ("system-type", &Vsystem_type /*
3415 Symbol indicating type of operating system you are using.
3417 Vsystem_type = intern (SYSTEM_TYPE);
3418 Fprovide (intern(SYSTEM_TYPE));
3420 #ifndef EMACS_CONFIGURATION
3421 # define EMACS_CONFIGURATION "UNKNOWN"
3423 DEFVAR_LISP ("system-configuration", &Vsystem_configuration /*
3424 String naming the configuration XEmacs was built for.
3426 Vsystem_configuration = build_string (EMACS_CONFIGURATION);
3428 #ifndef EMACS_CONFIG_OPTIONS
3429 # define EMACS_CONFIG_OPTIONS "UNKNOWN"
3431 DEFVAR_LISP ("system-configuration-options", &Vsystem_configuration_options /*
3432 String containing the configuration options XEmacs was built with.
3434 Vsystem_configuration_options = build_string (EMACS_CONFIG_OPTIONS);
3436 DEFVAR_LISP ("emacs-major-version", &Vemacs_major_version /*
3437 Major version number of this version of Emacs, as an integer.
3438 Warning: this variable did not exist in Emacs versions earlier than:
3442 Vemacs_major_version = make_int (EMACS_MAJOR_VERSION);
3444 DEFVAR_LISP ("emacs-minor-version", &Vemacs_minor_version /*
3445 Minor version number of this version of Emacs, as an integer.
3446 Warning: this variable did not exist in Emacs versions earlier than:
3450 Vemacs_minor_version = make_int (EMACS_MINOR_VERSION);
3452 DEFVAR_LISP ("emacs-patch-level", &Vemacs_patch_level /*
3453 The patch level of this version of Emacs, as an integer.
3454 The value is non-nil if this version of XEmacs is part of a series of
3455 stable XEmacsen, but has bug fixes applied.
3456 Warning: this variable does not exist in FSF Emacs or in XEmacs versions
3459 #ifdef EMACS_PATCH_LEVEL
3460 Vemacs_patch_level = make_int (EMACS_PATCH_LEVEL);
3462 Vemacs_patch_level = Qnil;
3465 DEFVAR_LISP ("emacs-beta-version", &Vemacs_beta_version /*
3466 Beta number of this version of Emacs, as an integer.
3467 The value is nil if this is an officially released version of XEmacs.
3468 Warning: this variable does not exist in FSF Emacs or in XEmacs versions
3471 #ifdef EMACS_BETA_VERSION
3472 Vemacs_beta_version = make_int (EMACS_BETA_VERSION);
3474 Vemacs_beta_version = Qnil;
3478 DEFVAR_LISP ("infodock-major-version", &Vinfodock_major_version /*
3479 Major version number of this InfoDock release.
3481 Vinfodock_major_version = make_int (INFODOCK_MAJOR_VERSION);
3483 DEFVAR_LISP ("infodock-minor-version", &Vinfodock_minor_version /*
3484 Minor version number of this InfoDock release.
3486 Vinfodock_minor_version = make_int (INFODOCK_MINOR_VERSION);
3488 DEFVAR_LISP ("infodock-build-version", &Vinfodock_build_version /*
3489 Build version of this InfoDock release.
3491 Vinfodock_build_version = make_int (INFODOCK_BUILD_VERSION);
3494 DEFVAR_LISP ("xemacs-codename", &Vxemacs_codename /*
3495 Codename of this version of Emacs (a string).
3497 #ifndef XEMACS_CODENAME
3498 #define XEMACS_CODENAME "Noname"
3500 Vxemacs_codename = build_string (XEMACS_CODENAME);
3502 /* Lisp variables which contain command line flags.
3504 The portable dumper stomps on these; they must be saved and restored
3505 if they are processed before the call to pdump_load() in main_1().
3507 DEFVAR_BOOL ("noninteractive", &noninteractive1 /*
3508 Non-nil means XEmacs is running without interactive terminal.
3511 DEFVAR_BOOL ("inhibit-early-packages", &inhibit_early_packages /*
3512 Set to non-nil when the early packages should not be respected at startup.
3515 DEFVAR_BOOL ("inhibit-autoloads", &inhibit_autoloads /*
3516 Set to non-nil when autoloads should not be loaded at startup.
3519 DEFVAR_BOOL ("debug-paths", &debug_paths /*
3520 Set to non-nil when debug information about paths should be printed.
3523 DEFVAR_BOOL ("inhibit-site-lisp", &inhibit_site_lisp /*
3524 Set to non-nil when the site-lisp should not be searched at startup.
3526 #ifdef INHIBIT_SITE_LISP
3527 inhibit_site_lisp = 1;
3530 DEFVAR_BOOL ("inhibit-site-modules", &inhibit_site_modules /*
3531 Set to non-nil when site-modules should not be searched at startup.
3533 #ifdef INHIBIT_SITE_MODULES
3534 inhibit_site_modules = 1;
3537 DEFVAR_INT ("emacs-priority", &emacs_priority /*
3538 Priority for XEmacs to run at.
3539 This value is effective only if set before XEmacs is dumped,
3540 and only if the XEmacs executable is installed with setuid to permit
3541 it to change priority. (XEmacs sets its uid back to the real uid.)
3542 Currently, you need to define SET_EMACS_PRIORITY in `config.h'
3543 before you compile XEmacs, to enable the code for this feature.
3547 DEFVAR_CONST_LISP ("internal-error-checking", &Vinternal_error_checking /*
3548 Internal error checking built-in into this instance of XEmacs.
3549 This is a list of symbols, initialized at build-time. Legal symbols
3552 extents - check extents prior to each extent change;
3553 typecheck - check types strictly, aborting in case of error;
3554 malloc - check operation of malloc;
3555 gc - check garbage collection;
3556 bufpos - check buffer positions.
3558 quick-build - user has requested the "quick-build" configure option.
3560 Vinternal_error_checking = Qnil;
3561 #ifdef ERROR_CHECK_EXTENTS
3562 Vinternal_error_checking = Fcons (intern ("extents"),
3563 Vinternal_error_checking);
3565 #ifdef ERROR_CHECK_TYPECHECK
3566 Vinternal_error_checking = Fcons (intern ("typecheck"),
3567 Vinternal_error_checking);
3569 #ifdef ERROR_CHECK_MALLOC
3570 Vinternal_error_checking = Fcons (intern ("malloc"),
3571 Vinternal_error_checking);
3573 #ifdef ERROR_CHECK_GC
3574 Vinternal_error_checking = Fcons (intern ("gc"),
3575 Vinternal_error_checking);
3577 #ifdef ERROR_CHECK_BUFPOS
3578 Vinternal_error_checking = Fcons (intern ("bufpos"),
3579 Vinternal_error_checking);
3582 Vinternal_error_checking = Fcons (intern ("quick-build"),
3583 Vinternal_error_checking);
3586 DEFVAR_CONST_LISP ("mail-lock-methods", &Vmail_lock_methods /*
3587 Mail spool locking methods supported by this instance of XEmacs.
3588 This is a list of symbols. Each of the symbols is one of the
3589 following: dot, lockf, flock, locking, mmdf.
3592 Vmail_lock_methods = Qnil;
3593 Vmail_lock_methods = Fcons (intern ("dot"), Vmail_lock_methods);
3595 Vmail_lock_methods = Fcons (intern ("lockf"), Vmail_lock_methods);
3598 Vmail_lock_methods = Fcons (intern ("flock"), Vmail_lock_methods);
3601 Vmail_lock_methods = Fcons (intern ("mmdf"), Vmail_lock_methods);
3604 Vmail_lock_methods = Fcons (intern ("locking"), Vmail_lock_methods);
3608 DEFVAR_CONST_LISP ("configure-mail-lock-method", &Vconfigure_mail_lock_method /*
3609 Mail spool locking method suggested by configure. This is one
3610 of the symbols in MAIL-LOCK-METHODS.
3613 #if defined(MAIL_LOCK_FLOCK) && defined(HAVE_FLOCK)
3614 Vconfigure_mail_lock_method = intern("flock");
3615 #elif defined(MAIL_LOCK_LOCKF) && defined(HAVE_LOCKF)
3616 Vconfigure_mail_lock_method = intern("lockf");
3617 #elif defined(MAIL_LOCK_MMDF) && defined(HAVE_MMDF)
3618 Vconfigure_mail_lock_method = intern("mmdf");
3619 #elif defined(MAIL_LOCK_LOCKING) && defined(HAVE_LOCKING)
3620 Vconfigure_mail_lock_method = intern("locking");
3622 Vconfigure_mail_lock_method = intern("dot");
3626 DEFVAR_LISP ("path-separator", &Vpath_separator /*
3627 The directory separator in search paths, as a string.
3631 Vpath_separator = make_string ((Bufbyte *)&c, 1);
3636 complex_vars_of_emacs (void)
3638 /* This is all related to path searching. */
3640 DEFVAR_LISP ("emacs-program-name", &Vemacs_program_name /*
3641 *Name of the Emacs variant.
3642 For example, this may be \"xemacs\" or \"infodock\".
3643 This is mainly meant for use in path searching.
3645 Vemacs_program_name = build_string ((char *) PATH_PROGNAME);
3647 DEFVAR_LISP ("emacs-program-version", &Vemacs_program_version /*
3648 *Version of the Emacs variant.
3649 This typically has the form NN.NN-bNN.
3650 This is mainly meant for use in path searching.
3652 Vemacs_program_version = build_string ((char *) PATH_VERSION);
3654 DEFVAR_LISP ("exec-path", &Vexec_path /*
3655 *List of directories to search programs to run in subprocesses.
3656 Each element is a string (directory name) or nil (try default directory).
3660 DEFVAR_LISP ("exec-directory", &Vexec_directory /*
3661 *Directory of architecture-dependent files that come with XEmacs,
3662 especially executable programs intended for XEmacs to invoke.
3664 Vexec_directory = Qnil;
3666 DEFVAR_LISP ("configure-exec-directory", &Vconfigure_exec_directory /*
3667 For internal use by the build procedure only.
3668 configure's idea of what `exec-directory' will be.
3671 Vconfigure_exec_directory = Ffile_name_as_directory
3672 (build_string ((char *) PATH_EXEC));
3674 Vconfigure_exec_directory = Qnil;
3677 DEFVAR_LISP ("lisp-directory", &Vlisp_directory /*
3678 *Directory of core Lisp files that come with XEmacs.
3680 Vlisp_directory = Qnil;
3682 DEFVAR_LISP ("configure-lisp-directory", &Vconfigure_lisp_directory /*
3683 For internal use by the build procedure only.
3684 configure's idea of what `lisp-directory' will be.
3686 #ifdef PATH_LOADSEARCH
3687 Vconfigure_lisp_directory = Ffile_name_as_directory
3688 (build_string ((char *) PATH_LOADSEARCH));
3690 Vconfigure_lisp_directory = Qnil;
3693 DEFVAR_LISP ("mule-lisp-directory", &Vmule_lisp_directory /*
3694 *Directory of Mule Lisp files that come with XEmacs.
3696 Vmule_lisp_directory = Qnil;
3698 DEFVAR_LISP ("configure-mule-lisp-directory", &Vconfigure_mule_lisp_directory /*
3699 For internal use by the build procedure only.
3700 configure's idea of what `mule-lisp-directory' will be.
3702 #ifdef PATH_MULELOADSEARCH
3703 Vconfigure_mule_lisp_directory = Ffile_name_as_directory
3704 (build_string ((char *) PATH_MULELOADSEARCH));
3706 Vconfigure_mule_lisp_directory = Qnil;
3709 DEFVAR_LISP ("module-directory", &Vmodule_directory /*
3710 *Directory of core dynamic modules that come with XEmacs.
3712 Vmodule_directory = Qnil;
3714 DEFVAR_LISP ("configure-module-directory", &Vconfigure_module_directory /*
3715 For internal use by the build procedure only.
3716 configure's idea of what `module-directory' will be.
3718 #ifdef PATH_MODULESEARCH
3719 Vconfigure_module_directory = Ffile_name_as_directory
3720 (build_string ((char *) PATH_MODULESEARCH));
3722 Vconfigure_module_directory = Qnil;
3725 DEFVAR_LISP ("configure-package-path", &Vconfigure_package_path /*
3726 For internal use by the build procedure only.
3727 configure's idea of what the package path will be.
3729 #ifdef PATH_PACKAGEPATH
3730 Vconfigure_package_path = decode_path (PATH_PACKAGEPATH);
3732 Vconfigure_package_path = Qnil;
3735 DEFVAR_LISP ("data-directory", &Vdata_directory /*
3736 *Directory of architecture-independent files that come with XEmacs,
3737 intended for XEmacs to use.
3738 Use of this variable in new code is almost never correct. See the
3739 functions `locate-data-file' and `locate-data-directory' and the variable
3740 `data-directory-list'.
3742 Vdata_directory = Qnil;
3744 DEFVAR_LISP ("configure-data-directory", &Vconfigure_data_directory /*
3745 For internal use by the build procedure only.
3746 configure's idea of what `data-directory' will be.
3749 Vconfigure_data_directory = Ffile_name_as_directory
3750 (build_string ((char *) PATH_DATA));
3752 Vconfigure_data_directory = Qnil;
3755 DEFVAR_LISP ("data-directory-list", &Vdata_directory_list /*
3756 *List of directories of architecture-independent files that come with XEmacs
3757 or were installed as packages, and are intended for XEmacs to use.
3759 Vdata_directory_list = Qnil;
3761 DEFVAR_LISP ("site-directory", &Vsite_directory /*
3762 *Directory of site-specific Lisp files that come with XEmacs.
3764 Vsite_directory = Qnil;
3766 DEFVAR_LISP ("configure-site-directory", &Vconfigure_site_directory /*
3767 For internal use by the build procedure only.
3768 configure's idea of what `site-directory' will be.
3771 Vconfigure_site_directory = Ffile_name_as_directory
3772 (build_string ((char *) PATH_SITE));
3774 Vconfigure_site_directory = Qnil;
3777 DEFVAR_LISP ("site-module-directory", &Vsite_module_directory /*
3778 *Directory of site-specific loadable modules that come with XEmacs.
3780 Vsite_module_directory = Qnil;
3782 DEFVAR_LISP ("configure-site-module-directory", &Vconfigure_site_module_directory /*
3783 For internal use by the build procedure only.
3784 configure's idea of what `site-directory' will be.
3786 #ifdef PATH_SITE_MODULES
3787 Vconfigure_site_module_directory = Ffile_name_as_directory
3788 (build_string ((char *) PATH_SITE_MODULES));
3790 Vconfigure_site_module_directory = Qnil;
3793 DEFVAR_LISP ("doc-directory", &Vdoc_directory /*
3794 *Directory containing the DOC file that comes with XEmacs.
3795 This is usually the same as `exec-directory'.
3797 Vdoc_directory = Qnil;
3799 DEFVAR_LISP ("configure-doc-directory", &Vconfigure_doc_directory /*
3800 For internal use by the build procedure only.
3801 configure's idea of what `doc-directory' will be.
3804 Vconfigure_doc_directory = Ffile_name_as_directory
3805 (build_string ((char *) PATH_DOC));
3807 Vconfigure_doc_directory = Qnil;
3810 DEFVAR_LISP ("configure-exec-prefix-directory", &Vconfigure_exec_prefix_directory /*
3811 For internal use by the build procedure only.
3812 configure's idea of what `exec-prefix-directory' will be.
3814 #ifdef PATH_EXEC_PREFIX
3815 Vconfigure_exec_prefix_directory = Ffile_name_as_directory
3816 (build_string ((char *) PATH_EXEC_PREFIX));
3818 Vconfigure_exec_prefix_directory = Qnil;
3821 DEFVAR_LISP ("configure-prefix-directory", &Vconfigure_prefix_directory /*
3822 For internal use by the build procedure only.
3823 configure's idea of what `prefix-directory' will be.
3826 Vconfigure_prefix_directory = Ffile_name_as_directory
3827 (build_string ((char *) PATH_PREFIX));
3829 Vconfigure_prefix_directory = Qnil;
3832 DEFVAR_LISP ("configure-info-directory", &Vconfigure_info_directory /*
3833 For internal use by the build procedure only.
3834 This is the name of the directory in which the build procedure installed
3835 Emacs's info files; the default value for Info-default-directory-list
3839 Vconfigure_info_directory =
3840 Ffile_name_as_directory (build_string (PATH_INFO));
3842 Vconfigure_info_directory = Qnil;
3845 DEFVAR_LISP ("configure-info-path", &Vconfigure_info_path /*
3846 The configured initial path for info documentation.
3848 #ifdef PATH_INFOPATH
3849 Vconfigure_info_path = decode_path (PATH_INFOPATH);
3851 Vconfigure_info_path = Qnil;
3855 #if defined(__sgi) && !defined(PDUMP)
3856 /* This is so tremendously ugly I'd puke. But then, it works.
3857 * The target is to override the static constructor from the
3858 * libiflPNG.so library which is masquerading as libz, and
3859 * cores on us when re-started from the dumped executable.
3860 * This will have to go for 21.1 -- OG.
3862 void __sti__iflPNGFile_c___ (void);
3864 __sti__iflPNGFile_c___ (void)