Merge in octave.el; don't require octave.el.
[emacs.git] / src / emacs.c
blob7349a21698d9bb7aafb36a3fbe98d4b255933455
1 /* Fully extensible Emacs, running on Unix, intended for GNU.
2 Copyright (C) 1985, 86, 87, 93, 94, 95 Free Software Foundation, Inc.
4 This file is part of GNU Emacs.
6 GNU Emacs is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2, or (at your option)
9 any later version.
11 GNU Emacs is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with GNU Emacs; see the file COPYING. If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. */
22 #include <signal.h>
23 #include <errno.h>
25 #include <config.h>
26 #include <stdio.h>
28 #include <sys/types.h>
29 #include <sys/file.h>
31 #ifdef VMS
32 #include <ssdef.h>
33 #endif
35 #ifdef BSD_SYSTEM
36 #include <sys/ioctl.h>
37 #endif
39 #include "lisp.h"
40 #include "commands.h"
41 #include "intervals.h"
43 #include "systty.h"
44 #include "blockinput.h"
45 #include "syssignal.h"
46 #include "process.h"
48 #ifdef HAVE_SETRLIMIT
49 #include <sys/time.h>
50 #include <sys/resource.h>
51 #endif
53 #ifndef O_RDWR
54 #define O_RDWR 2
55 #endif
57 extern void malloc_warning ();
58 extern void set_time_zone_rule ();
59 extern char *index ();
60 extern char *strerror ();
62 /* Command line args from shell, as list of strings */
63 Lisp_Object Vcommand_line_args;
65 /* The name under which Emacs was invoked, with any leading directory
66 names discarded. */
67 Lisp_Object Vinvocation_name;
69 /* The directory name from which Emacs was invoked. */
70 Lisp_Object Vinvocation_directory;
72 /* The directory name in which to find subdirs such as lisp and etc.
73 nil means get them only from PATH_LOADSEARCH. */
74 Lisp_Object Vinstallation_directory;
76 /* Hook run by `kill-emacs' before it does really anything. */
77 Lisp_Object Vkill_emacs_hook;
79 /* Set nonzero after Emacs has started up the first time.
80 Prevents reinitialization of the Lisp world and keymaps
81 on subsequent starts. */
82 int initialized;
84 /* Variable whose value is symbol giving operating system type. */
85 Lisp_Object Vsystem_type;
87 /* Variable whose value is string giving configuration built for. */
88 Lisp_Object Vsystem_configuration;
90 /* Variable whose value is string giving configuration options,
91 for use when reporting bugs. */
92 Lisp_Object Vsystem_configuration_options;
94 Lisp_Object Qfile_name_handler_alist;
96 /* If non-zero, emacs should not attempt to use an window-specific code,
97 but instead should use the virtual terminal under which it was started */
98 int inhibit_window_system;
100 /* If nonzero, set Emacs to run at this priority. This is also used
101 in child_setup and sys_suspend to make sure subshells run at normal
102 priority; Those functions have their own extern declaration. */
103 int emacs_priority;
105 /* If non-zero a filter or a sentinel is running. Tested to save the match
106 data on the first attempt to change it inside asynchronous code. */
107 int running_asynch_code;
109 #ifdef BSD_PGRPS
110 /* See sysdep.c. */
111 extern int inherited_pgroup;
112 #endif
114 #ifdef HAVE_X_WINDOWS
115 /* If non-zero, -d was specified, meaning we're using some window system. */
116 int display_arg;
117 #endif
119 /* An address near the bottom of the stack.
120 Tells GC how to save a copy of the stack. */
121 char *stack_bottom;
123 #ifdef HAVE_WINDOW_SYSTEM
124 extern Lisp_Object Vwindow_system;
125 #endif /* HAVE_WINDOW_SYSTEM */
127 extern Lisp_Object Vauto_save_list_file_name;
129 #ifdef USG_SHARED_LIBRARIES
130 /* If nonzero, this is the place to put the end of the writable segment
131 at startup. */
133 unsigned int bss_end = 0;
134 #endif
136 /* Nonzero means running Emacs without interactive terminal. */
138 int noninteractive;
140 /* Value of Lisp variable `noninteractive'.
141 Normally same as C variable `noninteractive'
142 but nothing terrible happens if user sets this one. */
144 int noninteractive1;
146 /* Save argv and argc. */
147 char **initial_argv;
148 int initial_argc;
150 static void sort_args ();
152 /* Signal code for the fatal signal that was received */
153 int fatal_error_code;
155 /* Nonzero if handling a fatal error already */
156 int fatal_error_in_progress;
158 /* Handle bus errors, illegal instruction, etc. */
159 SIGTYPE
160 fatal_error_signal (sig)
161 int sig;
163 fatal_error_code = sig;
164 signal (sig, SIG_DFL);
166 TOTALLY_UNBLOCK_INPUT;
168 /* If fatal error occurs in code below, avoid infinite recursion. */
169 if (! fatal_error_in_progress)
171 fatal_error_in_progress = 1;
173 shut_down_emacs (sig, 0, Qnil);
176 #ifdef VMS
177 LIB$STOP (SS$_ABORT);
178 #else
179 /* Signal the same code; this time it will really be fatal.
180 Remember that since we're in a signal handler, the signal we're
181 going to send is probably blocked, so we have to unblock it if we
182 want to really receive it. */
183 #ifndef MSDOS
184 sigunblock (sigmask (fatal_error_code));
185 #endif
186 kill (getpid (), fatal_error_code);
187 #endif /* not VMS */
190 #ifdef SIGDANGER
192 /* Handler for SIGDANGER. */
193 SIGTYPE
194 memory_warning_signal (sig)
195 int sig;
197 signal (sig, memory_warning_signal);
199 malloc_warning ("Operating system warns that virtual memory is running low.\n");
201 /* It might be unsafe to call do_auto_save now. */
202 force_auto_save_soon ();
204 #endif
206 /* Code for dealing with Lisp access to the Unix command line */
208 static
209 init_cmdargs (argc, argv, skip_args)
210 int argc;
211 char **argv;
212 int skip_args;
214 register int i;
215 Lisp_Object name, dir, tem;
216 int count = specpdl_ptr - specpdl;
217 Lisp_Object raw_name;
219 initial_argv = argv;
220 initial_argc = argc;
222 raw_name = build_string (argv[0]);
224 /* Add /: to the front of the name
225 if it would otherwise be treated as magic. */
226 tem = Ffind_file_name_handler (raw_name, Qt);
227 if (! NILP (tem))
228 raw_name = concat2 (build_string ("/:"), raw_name);
230 Vinvocation_name = Ffile_name_nondirectory (raw_name);
231 Vinvocation_directory = Ffile_name_directory (raw_name);
233 /* If we got no directory in argv[0], search PATH to find where
234 Emacs actually came from. */
235 if (NILP (Vinvocation_directory))
237 Lisp_Object found;
238 int yes = openp (Vexec_path, Vinvocation_name,
239 EXEC_SUFFIXES, &found, 1);
240 if (yes == 1)
242 /* Add /: to the front of the name
243 if it would otherwise be treated as magic. */
244 tem = Ffind_file_name_handler (found, Qt);
245 if (! NILP (tem))
246 found = concat2 (build_string ("/:"), found);
247 Vinvocation_directory = Ffile_name_directory (found);
251 if (!NILP (Vinvocation_directory)
252 && NILP (Ffile_name_absolute_p (Vinvocation_directory)))
253 /* Emacs was started with relative path, like ./emacs.
254 Make it absolute. */
255 Vinvocation_directory = Fexpand_file_name (Vinvocation_directory, Qnil);
257 Vinstallation_directory = Qnil;
259 if (!NILP (Vinvocation_directory))
261 dir = Vinvocation_directory;
262 name = Fexpand_file_name (Vinvocation_name, dir);
263 while (1)
265 Lisp_Object tem, lib_src_exists;
266 Lisp_Object etc_exists, info_exists;
268 /* See if dir contains subdirs for use by Emacs.
269 Check for the ones that would exist in a build directory,
270 not including lisp and info. */
271 tem = Fexpand_file_name (build_string ("lib-src"), dir);
272 lib_src_exists = Ffile_exists_p (tem);
274 /* MSDOS installations frequently remove lib-src, but we still
275 must set installation-directory, or else info won't find
276 its files (it uses the value of installation-directory). */
277 tem = Fexpand_file_name (build_string ("info"), dir);
278 info_exists = Ffile_exists_p (tem);
280 if (!NILP (lib_src_exists) || !NILP (info_exists))
282 tem = Fexpand_file_name (build_string ("etc"), dir);
283 etc_exists = Ffile_exists_p (tem);
284 if (!NILP (etc_exists))
286 Vinstallation_directory
287 = Ffile_name_as_directory (dir);
288 break;
292 /* See if dir's parent contains those subdirs. */
293 tem = Fexpand_file_name (build_string ("../lib-src"), dir);
294 lib_src_exists = Ffile_exists_p (tem);
296 tem = Fexpand_file_name (build_string ("../info"), dir);
297 info_exists = Ffile_exists_p (tem);
299 if (!NILP (lib_src_exists) || !NILP (info_exists))
301 tem = Fexpand_file_name (build_string ("../etc"), dir);
302 etc_exists = Ffile_exists_p (tem);
303 if (!NILP (etc_exists))
305 tem = Fexpand_file_name (build_string (".."), dir);
306 Vinstallation_directory
307 = Ffile_name_as_directory (tem);
308 break;
312 /* If the Emacs executable is actually a link,
313 next try the dir that the link points into. */
314 tem = Ffile_symlink_p (name);
315 if (!NILP (tem))
317 name = Fexpand_file_name (tem, dir);
318 dir = Ffile_name_directory (name);
320 else
321 break;
325 Vcommand_line_args = Qnil;
327 for (i = argc - 1; i >= 0; i--)
329 if (i == 0 || i > skip_args)
330 Vcommand_line_args
331 = Fcons (build_string (argv[i]), Vcommand_line_args);
334 unbind_to (count, Qnil);
337 DEFUN ("invocation-name", Finvocation_name, Sinvocation_name, 0, 0, 0,
338 "Return the program name that was used to run Emacs.\n\
339 Any directory names are omitted.")
342 return Fcopy_sequence (Vinvocation_name);
345 DEFUN ("invocation-directory", Finvocation_directory, Sinvocation_directory,
346 0, 0, 0,
347 "Return the directory name in which the Emacs executable was located")
350 return Fcopy_sequence (Vinvocation_directory);
354 #ifdef VMS
355 #ifdef LINK_CRTL_SHARE
356 #ifdef SHARABLE_LIB_BUG
357 extern noshare char **environ;
358 #endif /* SHARABLE_LIB_BUG */
359 #endif /* LINK_CRTL_SHARE */
360 #endif /* VMS */
362 #ifdef HAVE_TZSET
363 /* A valid but unlikely value for the TZ environment value.
364 It is OK (though a bit slower) if the user actually chooses this value. */
365 static char dump_tz[] = "UtC0";
366 #endif
368 #ifndef ORDINARY_LINK
369 /* We don't include crtbegin.o and crtend.o in the link,
370 so these functions and variables might be missed.
371 Provide dummy definitions to avoid error.
372 (We don't have any real constructors or destructors.) */
373 #ifdef __GNUC__
374 #ifndef GCC_CTORS_IN_LIBC
375 __do_global_ctors ()
377 __do_global_ctors_aux ()
379 __do_global_dtors ()
381 /* Linux has a bug in its library; avoid an error. */
382 #ifndef LINUX
383 char * __CTOR_LIST__[2] = { (char *) (-1), 0 };
384 #endif
385 char * __DTOR_LIST__[2] = { (char *) (-1), 0 };
386 #endif /* GCC_CTORS_IN_LIBC */
387 __main ()
389 #endif /* __GNUC__ */
390 #endif /* ORDINARY_LINK */
392 /* Test whether the next argument in ARGV matches SSTR or a prefix of
393 LSTR (at least MINLEN characters). If so, then if VALPTR is non-null
394 (the argument is supposed to have a value) store in *VALPTR either
395 the next argument or the portion of this one after the equal sign.
396 ARGV is read starting at position *SKIPPTR; this index is advanced
397 by the number of arguments used.
399 Too bad we can't just use getopt for all of this, but we don't have
400 enough information to do it right. */
402 static int
403 argmatch (argv, argc, sstr, lstr, minlen, valptr, skipptr)
404 char **argv;
405 int argc;
406 char *sstr;
407 char *lstr;
408 int minlen;
409 char **valptr;
410 int *skipptr;
412 char *p;
413 int arglen;
414 char *arg;
416 /* Don't access argv[argc]; give up in advance. */
417 if (argc <= *skipptr + 1)
418 return 0;
420 arg = argv[*skipptr+1];
421 if (arg == NULL)
422 return 0;
423 if (strcmp (arg, sstr) == 0)
425 if (valptr != NULL)
427 *valptr = argv[*skipptr+2];
428 *skipptr += 2;
430 else
431 *skipptr += 1;
432 return 1;
434 arglen = (valptr != NULL && (p = index (arg, '=')) != NULL
435 ? p - arg : strlen (arg));
436 if (lstr == 0 || arglen < minlen || strncmp (arg, lstr, arglen) != 0)
437 return 0;
438 else if (valptr == NULL)
440 *skipptr += 1;
441 return 1;
443 else if (p != NULL)
445 *valptr = p+1;
446 *skipptr += 1;
447 return 1;
449 else if (argv[*skipptr+2] != NULL)
451 *valptr = argv[*skipptr+2];
452 *skipptr += 2;
453 return 1;
455 else
457 return 0;
461 /* ARGSUSED */
462 main (argc, argv, envp)
463 int argc;
464 char **argv;
465 char **envp;
467 char stack_bottom_variable;
468 int skip_args = 0;
469 extern int errno;
470 extern sys_nerr;
471 #ifdef HAVE_SETRLIMIT
472 struct rlimit rlim;
473 #endif
475 #ifdef LINUX_SBRK_BUG
476 __sbrk (1);
477 #endif
479 sort_args (argc, argv);
481 if (argmatch (argv, argc, "-version", "--version", 3, NULL, &skip_args))
483 Lisp_Object tem;
484 tem = Fsymbol_value (intern ("emacs-version"));
485 if (!STRINGP (tem))
487 fprintf (stderr, "Invalid value of `emacs-version'\n");
488 exit (1);
490 else
492 printf ("GNU Emacs %s\n", XSTRING (tem)->data);
493 printf ("Copyright (C) 1996 Free Software Foundation, Inc.\n");
494 printf ("GNU Emacs comes with ABSOLUTELY NO WARRANTY.\n");
495 printf ("You may redistribute copies of Emacs\n");
496 printf ("under the terms of the GNU General Public License.\n");
497 printf ("For more information about these matters, ");
498 printf ("see the files named COPYING.\n");
499 exit (0);
503 /* Map in shared memory, if we are using that. */
504 #ifdef HAVE_SHM
505 if (argmatch (argv, argc, "-nl", "--no-shared-memory", 6, NULL, &skip_args))
507 map_in_data (0);
508 /* The shared memory was just restored, which clobbered this. */
509 skip_args = 1;
511 else
513 map_in_data (1);
514 /* The shared memory was just restored, which clobbered this. */
515 skip_args = 0;
517 #endif
519 #ifdef NeXT
521 extern int malloc_cookie;
522 /* This helps out unexnext.c. */
523 if (initialized)
524 if (malloc_jumpstart (malloc_cookie) != 0)
525 printf ("malloc jumpstart failed!\n");
527 #endif /* NeXT */
529 #ifdef VMS
530 /* If -map specified, map the data file in */
532 char *file;
533 if (argmatch (argv, argc, "-map", "--map-data", 3, &mapin_file, &skip_args))
534 mapin_data (file);
537 #ifdef LINK_CRTL_SHARE
538 #ifdef SHARABLE_LIB_BUG
539 /* Bletcherous shared libraries! */
540 if (!stdin)
541 stdin = fdopen (0, "r");
542 if (!stdout)
543 stdout = fdopen (1, "w");
544 if (!stderr)
545 stderr = fdopen (2, "w");
546 if (!environ)
547 environ = envp;
548 #endif /* SHARABLE_LIB_BUG */
549 #endif /* LINK_CRTL_SHARE */
550 #endif /* VMS */
552 #ifdef HAVE_SETRLIMIT
553 /* Extend the stack space available. */
554 if (!getrlimit (RLIMIT_STACK, &rlim))
556 rlim.rlim_cur = rlim.rlim_max;
557 setrlimit (RLIMIT_STACK, &rlim);
559 #endif
561 /* Record (approximately) where the stack begins. */
562 stack_bottom = &stack_bottom_variable;
564 #ifdef RUN_TIME_REMAP
565 if (initialized)
566 run_time_remap (argv[0]);
567 #endif
569 #ifdef USG_SHARED_LIBRARIES
570 if (bss_end)
571 brk ((void *)bss_end);
572 #endif
574 clearerr (stdin);
576 #ifndef SYSTEM_MALLOC
577 if (! initialized)
579 /* Arrange to get warning messages as memory fills up. */
580 memory_warnings (0, malloc_warning);
582 /* Arrange to disable interrupt input while malloc and friends are
583 running. */
584 uninterrupt_malloc ();
586 #endif /* not SYSTEM_MALLOC */
588 #ifdef MSDOS
589 /* We do all file input/output as binary files. When we need to translate
590 newlines, we do that manually. */
591 _fmode = O_BINARY;
593 #if __DJGPP__ >= 2
594 if (!isatty (fileno (stdin)))
595 setmode (fileno (stdin), O_BINARY);
596 if (!isatty (fileno (stdout)))
598 fflush (stdout);
599 setmode (fileno (stdout), O_BINARY);
601 #else /* not __DJGPP__ >= 2 */
602 (stdin)->_flag &= ~_IOTEXT;
603 (stdout)->_flag &= ~_IOTEXT;
604 (stderr)->_flag &= ~_IOTEXT;
605 #endif /* not __DJGPP__ >= 2 */
606 #endif /* MSDOS */
608 #ifdef SET_EMACS_PRIORITY
609 if (emacs_priority)
610 nice (emacs_priority);
611 setuid (getuid ());
612 #endif /* SET_EMACS_PRIORITY */
614 #ifdef EXTRA_INITIALIZE
615 EXTRA_INITIALIZE;
616 #endif
618 inhibit_window_system = 0;
620 /* Handle the -t switch, which specifies filename to use as terminal */
622 char *term;
623 if (argmatch (argv, argc, "-t", "--terminal", 4, &term, &skip_args))
625 int result;
626 close (0);
627 close (1);
628 result = open (term, O_RDWR, 2 );
629 if (result < 0)
631 char *errstring = strerror (errno);
632 fprintf (stderr, "emacs: %s: %s\n", term, errstring);
633 exit (1);
635 dup (0);
636 if (! isatty (0))
638 fprintf (stderr, "emacs: %s: not a tty\n", term);
639 exit (1);
641 fprintf (stderr, "Using %s\n", term);
642 #ifdef HAVE_WINDOW_SYSTEM
643 inhibit_window_system = 1; /* -t => -nw */
644 #endif
647 if (argmatch (argv, argc, "-nw", "--no-windows", 6, NULL, &skip_args))
648 inhibit_window_system = 1;
650 /* Handle the -batch switch, which means don't do interactive display. */
651 noninteractive = 0;
652 if (argmatch (argv, argc, "-batch", "--batch", 5, NULL, &skip_args))
653 noninteractive = 1;
655 /* Handle the --help option, which gives a usage message.. */
656 if (argmatch (argv, argc, "-help", "--help", 3, NULL, &skip_args))
658 printf ("\
659 Usage: %s [-t term] [--terminal term] [-nw] [--no-windows] [--batch]\n\
660 [-q] [--no-init-file] [-u user] [--user user] [--debug-init]\n\
661 [--version] [--no-site-file]\n\
662 [-f func] [--funcall func] [-l file] [--load file] [--insert file]\n\
663 [+linenum] file-to-visit [--kill]\n\
664 Report bugs to bug-gnu-emacs@prep.ai.mit.edu. First, please see\n\
665 the Bugs section of the Emacs manual or the file BUGS.", argv[0]);
666 exit (0);
669 #ifdef HAVE_X_WINDOWS
670 /* Stupid kludge to catch command-line display spec. We can't
671 handle this argument entirely in window system dependent code
672 because we don't even know which window system dependent code
673 to run until we've recognized this argument. */
675 char *displayname = 0;
676 int i;
677 int count_before = skip_args;
679 if (argmatch (argv, argc, "-d", "--display", 3, &displayname, &skip_args))
680 display_arg = 1;
681 else if (argmatch (argv, argc, "-display", 0, 3, &displayname, &skip_args))
682 display_arg = 1;
684 /* If we have the form --display=NAME,
685 convert it into -d name.
686 This requires inserting a new element into argv. */
687 if (displayname != 0 && skip_args - count_before == 1)
689 char **new = (char **) xmalloc (sizeof (char *) * (argc + 2));
690 int j;
692 for (j = 0; j < count_before + 1; j++)
693 new[j] = argv[j];
694 new[count_before + 1] = "-d";
695 new[count_before + 2] = displayname;
696 for (j = count_before + 2; j <argc; j++)
697 new[j + 1] = argv[j];
698 argv = new;
699 argc++;
701 /* Change --display to -d, when its arg is separate. */
702 else if (displayname != 0 && skip_args > count_before
703 && argv[count_before + 1][1] == '-')
704 argv[count_before + 1] = "-d";
706 /* Don't actually discard this arg. */
707 skip_args = count_before;
709 #endif
711 if (! noninteractive)
713 #ifdef BSD_PGRPS
714 if (initialized)
716 inherited_pgroup = EMACS_GETPGRP (0);
717 setpgrp (0, getpid ());
719 #else
720 #if defined (USG5) && defined (INTERRUPT_INPUT)
721 setpgrp ();
722 #endif
723 #endif
726 #ifdef POSIX_SIGNALS
727 init_signals ();
728 #endif
730 /* Don't catch SIGHUP if dumping. */
731 if (1
732 #ifndef CANNOT_DUMP
733 && initialized
734 #endif
737 sigblock (sigmask (SIGHUP));
738 /* In --batch mode, don't catch SIGHUP if already ignored.
739 That makes nohup work. */
740 if (! noninteractive
741 || signal (SIGHUP, SIG_IGN) != SIG_IGN)
742 signal (SIGHUP, fatal_error_signal);
743 sigunblock (sigmask (SIGHUP));
746 if (
747 #ifndef CANNOT_DUMP
748 ! noninteractive || initialized
749 #else
751 #endif
754 /* Don't catch these signals in batch mode if dumping.
755 On some machines, this sets static data that would make
756 signal fail to work right when the dumped Emacs is run. */
757 signal (SIGQUIT, fatal_error_signal);
758 signal (SIGILL, fatal_error_signal);
759 signal (SIGTRAP, fatal_error_signal);
760 #ifdef SIGABRT
761 signal (SIGABRT, fatal_error_signal);
762 #endif
763 #ifdef SIGHWE
764 signal (SIGHWE, fatal_error_signal);
765 #endif
766 #ifdef SIGPRE
767 signal (SIGPRE, fatal_error_signal);
768 #endif
769 #ifdef SIGORE
770 signal (SIGORE, fatal_error_signal);
771 #endif
772 #ifdef SIGUME
773 signal (SIGUME, fatal_error_signal);
774 #endif
775 #ifdef SIGDLK
776 signal (SIGDLK, fatal_error_signal);
777 #endif
778 #ifdef SIGCPULIM
779 signal (SIGCPULIM, fatal_error_signal);
780 #endif
781 #ifdef SIGIOT
782 /* This is missing on some systems - OS/2, for example. */
783 signal (SIGIOT, fatal_error_signal);
784 #endif
785 #ifdef SIGEMT
786 signal (SIGEMT, fatal_error_signal);
787 #endif
788 signal (SIGFPE, fatal_error_signal);
789 #ifdef SIGBUS
790 signal (SIGBUS, fatal_error_signal);
791 #endif
792 signal (SIGSEGV, fatal_error_signal);
793 #ifdef SIGSYS
794 signal (SIGSYS, fatal_error_signal);
795 #endif
796 signal (SIGTERM, fatal_error_signal);
797 #ifdef SIGXCPU
798 signal (SIGXCPU, fatal_error_signal);
799 #endif
800 #ifdef SIGXFSZ
801 signal (SIGXFSZ, fatal_error_signal);
802 #endif /* SIGXFSZ */
804 #ifdef SIGDANGER
805 /* This just means available memory is getting low. */
806 signal (SIGDANGER, memory_warning_signal);
807 #endif
809 #ifdef AIX
810 /* 20 is SIGCHLD, 21 is SIGTTIN, 22 is SIGTTOU. */
811 signal (SIGXCPU, fatal_error_signal);
812 #ifndef _I386
813 signal (SIGIOINT, fatal_error_signal);
814 #endif
815 signal (SIGGRANT, fatal_error_signal);
816 signal (SIGRETRACT, fatal_error_signal);
817 signal (SIGSOUND, fatal_error_signal);
818 signal (SIGMSG, fatal_error_signal);
819 #endif /* AIX */
822 noninteractive1 = noninteractive;
824 /* Perform basic initializations (not merely interning symbols) */
826 if (!initialized)
828 init_alloc_once ();
829 init_obarray ();
830 init_eval_once ();
831 init_syntax_once (); /* Create standard syntax table. */
832 /* Must be done before init_buffer */
833 init_casetab_once ();
834 init_buffer_once (); /* Create buffer table and some buffers */
835 init_minibuf_once (); /* Create list of minibuffers */
836 /* Must precede init_window_once */
837 init_window_once (); /* Init the window system */
840 init_alloc ();
841 init_eval ();
842 init_data ();
843 running_asynch_code = 0;
845 #ifdef MSDOS
846 /* Call early 'cause init_environment needs it. */
847 init_dosfns ();
848 /* Set defaults for several environment variables. */
849 if (initialized)
850 init_environment (argc, argv, skip_args);
851 else
852 tzset ();
853 #endif /* MSDOS */
855 #ifdef WINDOWSNT
856 /* Initialize environment from registry settings. */
857 init_environment ();
858 init_ntproc (); /* must precede init_editfns */
859 #endif
861 /* egetenv is a pretty low-level facility, which may get called in
862 many circumstances; it seems flimsy to put off initializing it
863 until calling init_callproc. */
864 set_process_environment ();
865 /* AIX crashes are reported in system versions 3.2.3 and 3.2.4
866 if this is not done. Do it after set_process_environment so that we
867 don't pollute Vprocess_environment. */
868 #ifdef AIX
869 putenv ("LANG=C");
870 #endif
872 init_buffer (); /* Init default directory of main buffer */
874 init_callproc_1 (); /* Must precede init_cmdargs and init_sys_modes. */
875 init_cmdargs (argc, argv, skip_args); /* Must precede init_lread. */
877 if (initialized)
879 /* Erase any pre-dump messages in the message log, to avoid confusion */
880 Lisp_Object old_log_max;
881 old_log_max = Vmessage_log_max;
882 XSETFASTINT (Vmessage_log_max, 0);
883 message_dolog ("", 0, 1);
884 Vmessage_log_max = old_log_max;
887 init_callproc (); /* Must follow init_cmdargs but not init_sys_modes. */
888 init_lread ();
890 if (!noninteractive)
892 #ifdef VMS
893 init_vms_input ();/* init_display calls get_frame_size, that needs this */
894 #endif /* VMS */
895 init_display (); /* Determine terminal type. init_sys_modes uses results */
897 init_keyboard (); /* This too must precede init_sys_modes */
898 #ifdef VMS
899 init_vmsproc (); /* And this too. */
900 #endif /* VMS */
901 init_sys_modes (); /* Init system terminal modes (RAW or CBREAK, etc.) */
902 init_xdisp ();
903 init_macros ();
904 init_editfns ();
905 #ifdef LISP_FLOAT_TYPE
906 init_floatfns ();
907 #endif
908 #ifdef VMS
909 init_vmsfns ();
910 #endif /* VMS */
911 init_process ();
912 #ifdef CLASH_DETECTION
913 init_filelock ();
914 #endif /* CLASH_DETECTION */
916 /* Intern the names of all standard functions and variables; define standard keys */
918 if (!initialized)
920 /* The basic levels of Lisp must come first */
921 /* And data must come first of all
922 for the sake of symbols like error-message */
923 syms_of_data ();
924 syms_of_alloc ();
925 syms_of_lread ();
926 syms_of_print ();
927 syms_of_eval ();
928 syms_of_fns ();
929 syms_of_floatfns ();
931 syms_of_abbrev ();
932 syms_of_buffer ();
933 syms_of_bytecode ();
934 syms_of_callint ();
935 syms_of_casefiddle ();
936 syms_of_casetab ();
937 syms_of_callproc ();
938 syms_of_cmds ();
939 #ifndef NO_DIR_LIBRARY
940 syms_of_dired ();
941 #endif /* not NO_DIR_LIBRARY */
942 syms_of_display ();
943 syms_of_doc ();
944 syms_of_editfns ();
945 syms_of_emacs ();
946 syms_of_fileio ();
947 #ifdef CLASH_DETECTION
948 syms_of_filelock ();
949 #endif /* CLASH_DETECTION */
950 syms_of_indent ();
951 syms_of_insdel ();
952 syms_of_keyboard ();
953 syms_of_keymap ();
954 syms_of_macros ();
955 syms_of_marker ();
956 syms_of_minibuf ();
957 syms_of_mocklisp ();
958 syms_of_process ();
959 syms_of_search ();
960 syms_of_frame ();
961 syms_of_syntax ();
962 syms_of_term ();
963 syms_of_undo ();
965 /* Only defined if Emacs is compiled with USE_TEXT_PROPERTIES */
966 syms_of_textprop ();
967 #ifdef VMS
968 syms_of_vmsproc ();
969 #endif /* VMS */
970 #ifdef WINDOWSNT
971 syms_of_ntproc ();
972 #endif /* WINDOWSNT */
973 syms_of_window ();
974 syms_of_xdisp ();
975 #ifdef HAVE_X_WINDOWS
976 syms_of_xterm ();
977 syms_of_xfns ();
978 syms_of_xfaces ();
979 #ifdef HAVE_X11
980 syms_of_xselect ();
981 #endif
982 #endif /* HAVE_X_WINDOWS */
984 #if defined (MSDOS) && !defined (HAVE_X_WINDOWS)
985 syms_of_xfaces ();
986 #endif
988 #ifndef HAVE_NTGUI
989 syms_of_xmenu ();
990 #endif
992 #ifdef HAVE_NTGUI
993 syms_of_w32term ();
994 syms_of_w32fns ();
995 syms_of_w32faces ();
996 syms_of_w32select ();
997 syms_of_w32menu ();
998 #endif /* HAVE_NTGUI */
1000 #ifdef SYMS_SYSTEM
1001 SYMS_SYSTEM;
1002 #endif
1004 #ifdef SYMS_MACHINE
1005 SYMS_MACHINE;
1006 #endif
1008 keys_of_casefiddle ();
1009 keys_of_cmds ();
1010 keys_of_buffer ();
1011 keys_of_keyboard ();
1012 keys_of_keymap ();
1013 keys_of_macros ();
1014 keys_of_minibuf ();
1015 keys_of_window ();
1016 keys_of_frame ();
1019 if (!initialized)
1021 char *file;
1022 /* Handle -l loadup-and-dump, args passed by Makefile. */
1023 if (argmatch (argv, argc, "-l", "--load", 3, &file, &skip_args))
1024 Vtop_level = Fcons (intern ("load"),
1025 Fcons (build_string (file), Qnil));
1026 #ifdef CANNOT_DUMP
1027 /* Unless next switch is -nl, load "loadup.el" first thing. */
1028 if (!argmatch (argv, argc, "-nl", "--no-loadup", 6, NULL, &skip_args))
1029 Vtop_level = Fcons (intern ("load"),
1030 Fcons (build_string ("loadup.el"), Qnil));
1031 #endif /* CANNOT_DUMP */
1034 if (initialized)
1036 #ifdef HAVE_TZSET
1038 /* If the execution TZ happens to be the same as the dump TZ,
1039 change it to some other value and then change it back,
1040 to force the underlying implementation to reload the TZ info.
1041 This is needed on implementations that load TZ info from files,
1042 since the TZ file contents may differ between dump and execution. */
1043 char *tz = getenv ("TZ");
1044 if (tz && !strcmp (tz, dump_tz))
1046 ++*tz;
1047 tzset ();
1048 --*tz;
1051 #endif
1054 initialized = 1;
1056 #ifdef LOCALTIME_CACHE
1057 /* Some versions of localtime have a bug. They cache the value of the time
1058 zone rather than looking it up every time. Since localtime() is
1059 called to bolt the undumping time into the undumped emacs, this
1060 results in localtime ignoring the TZ environment variable.
1061 This flushes the new TZ value into localtime. */
1062 tzset ();
1063 #endif /* defined (LOCALTIME_CACHE) */
1065 /* Enter editor command loop. This never returns. */
1066 Frecursive_edit ();
1067 /* NOTREACHED */
1070 /* Sort the args so we can find the most important ones
1071 at the beginning of argv. */
1073 /* First, here's a table of all the standard options. */
1075 struct standard_args
1077 char *name;
1078 char *longname;
1079 int priority;
1080 int nargs;
1083 struct standard_args standard_args[] =
1085 { "-version", "--version", 110, 0 },
1086 { "-help", "--help", 110, 0 },
1087 { "-nl", "--no-shared-memory", 100, 0 },
1088 #ifdef VMS
1089 { "-map", "--map-data", 100, 0 },
1090 #endif
1091 { "-t", "--terminal", 90, 1 },
1092 { "-d", "--display", 80, 1 },
1093 { "-display", 0, 80, 1 },
1094 { "-nw", "--no-windows", 70, 0 },
1095 { "-batch", "--batch", 60, 0 },
1096 { "-q", "--no-init-file", 50, 0 },
1097 { "-no-init-file", 0, 50, 0 },
1098 { "-no-site-file", "--no-site-file", 40, 0 },
1099 { "-u", "--user", 30, 1 },
1100 { "-user", 0, 30, 1 },
1101 { "-debug-init", "--debug-init", 20, 0 },
1102 { "-i", "--icon-type", 15, 0 },
1103 { "-itype", 0, 15, 0 },
1104 { "-iconic", "--iconic", 15, 0 },
1105 { "-bg", "--background-color", 10, 1 },
1106 { "-background", 0, 10, 1 },
1107 { "-fg", "--foreground-color", 10, 1 },
1108 { "-foreground", 0, 10, 1 },
1109 { "-bd", "--border-color", 10, 1 },
1110 { "-bw", "--border-width", 10, 1 },
1111 { "-ib", "--internal-border", 10, 1 },
1112 { "-ms", "--mouse-color", 10, 1 },
1113 { "-cr", "--cursor-color", 10, 1 },
1114 { "-fn", "--font", 10, 1 },
1115 { "-font", 0, 10, 1 },
1116 { "-g", "--geometry", 10, 1 },
1117 { "-geometry", 0, 10, 1 },
1118 { "-T", "--title", 10, 1 },
1119 { "-title", 0, 10, 1 },
1120 { "-name", "--name", 10, 1 },
1121 { "-xrm", "--xrm", 10, 1 },
1122 { "-r", "--reverse-video", 5, 0 },
1123 { "-rv", 0, 5, 0 },
1124 { "-reverse", 0, 5, 0 },
1125 { "-hb", "--horizontal-scroll-bars", 5, 0 },
1126 { "-vb", "--vertical-scroll-bars", 5, 0 },
1127 /* These have the same priority as ordinary file name args,
1128 so they are not reordered with respect to those. */
1129 { "-L", "--directory", 0, 1 },
1130 { "-directory", 0, 0, 1 },
1131 { "-l", "--load", 0, 1 },
1132 { "-load", 0, 0, 1 },
1133 { "-f", "--funcall", 0, 1 },
1134 { "-funcall", 0, 0, 1 },
1135 { "-eval", "--eval", 0, 1 },
1136 { "-find-file", "--find-file", 0, 1 },
1137 { "-visit", "--visit", 0, 1 },
1138 { "-insert", "--insert", 0, 1 },
1139 /* This should be processed after ordinary file name args and the like. */
1140 { "-kill", "--kill", -10, 0 },
1143 /* Reorder the elements of ARGV (assumed to have ARGC elements)
1144 so that the highest priority ones come first.
1145 Do not change the order of elements of equal priority.
1146 If an option takes an argument, keep it and its argument together. */
1148 static void
1149 sort_args (argc, argv)
1150 int argc;
1151 char **argv;
1153 char **new = (char **) xmalloc (sizeof (char *) * argc);
1154 /* For each element of argv,
1155 the corresponding element of options is:
1156 0 for an option that takes no arguments,
1157 1 for an option that takes one argument, etc.
1158 -1 for an ordinary non-option argument. */
1159 int *options = (int *) xmalloc (sizeof (int) * argc);
1160 int *priority = (int *) xmalloc (sizeof (int) * argc);
1161 int to = 1;
1162 int from;
1163 int i;
1164 int end_of_options = argc;
1166 /* Categorize all the options,
1167 and figure out which argv elts are option arguments. */
1168 for (from = 1; from < argc; from++)
1170 options[from] = -1;
1171 priority[from] = 0;
1172 if (argv[from][0] == '-')
1174 int match, thislen;
1175 char *equals;
1177 /* If we have found "--", don't consider
1178 any more arguments as options. */
1179 if (argv[from][1] == '-')
1181 /* Leave the "--", and everything following it, at the end. */
1182 for (; from < argc; from++)
1184 priority[from] = -100;
1185 options[from] = -1;
1187 break;
1190 /* Look for a match with a known old-fashioned option. */
1191 for (i = 0; i < sizeof (standard_args) / sizeof (standard_args[0]); i++)
1192 if (!strcmp (argv[from], standard_args[i].name))
1194 options[from] = standard_args[i].nargs;
1195 priority[from] = standard_args[i].priority;
1196 if (from + standard_args[i].nargs >= argc)
1197 fatal ("Option `%s' requires an argument\n", argv[from]);
1198 from += standard_args[i].nargs;
1199 goto done;
1202 /* Look for a match with a known long option.
1203 MATCH is -1 if no match so far, -2 if two or more matches so far,
1204 >= 0 (the table index of the match) if just one match so far. */
1205 if (argv[from][1] == '-')
1207 match = -1;
1208 thislen = strlen (argv[from]);
1209 equals = index (argv[from], '=');
1210 if (equals != 0)
1211 thislen = equals - argv[from];
1213 for (i = 0;
1214 i < sizeof (standard_args) / sizeof (standard_args[0]); i++)
1215 if (standard_args[i].longname
1216 && !strncmp (argv[from], standard_args[i].longname,
1217 thislen))
1219 if (match == -1)
1220 match = i;
1221 else
1222 match = -2;
1225 /* If we found exactly one match, use that. */
1226 if (match >= 0)
1228 options[from] = standard_args[match].nargs;
1229 priority[from] = standard_args[match].priority;
1230 /* If --OPTION=VALUE syntax is used,
1231 this option uses just one argv element. */
1232 if (equals != 0)
1233 options[from] = 0;
1234 if (from + options[from] >= argc)
1235 fatal ("Option `%s' requires an argument\n", argv[from]);
1236 from += options[from];
1239 done: ;
1243 /* Copy the arguments, in order of decreasing priority, to NEW. */
1244 new[0] = argv[0];
1245 while (to < argc)
1247 int best = -1;
1248 int best_priority = -9999;
1250 /* Find the highest priority remaining option.
1251 If several have equal priority, take the first of them. */
1252 for (from = 1; from < argc; from++)
1254 if (argv[from] != 0 && priority[from] > best_priority)
1256 best_priority = priority[from];
1257 best = from;
1259 /* Skip option arguments--they are tied to the options. */
1260 if (options[from] > 0)
1261 from += options[from];
1264 if (best < 0)
1265 abort ();
1267 /* Copy the highest priority remaining option, with its args, to NEW. */
1268 new[to++] = argv[best];
1269 for (i = 0; i < options[best]; i++)
1270 new[to++] = argv[best + i + 1];
1272 /* Clear out this option in ARGV. */
1273 argv[best] = 0;
1274 for (i = 0; i < options[best]; i++)
1275 argv[best + i + 1] = 0;
1278 bcopy (new, argv, sizeof (char *) * argc);
1281 DEFUN ("kill-emacs", Fkill_emacs, Skill_emacs, 0, 1, "P",
1282 "Exit the Emacs job and kill it.\n\
1283 If ARG is an integer, return ARG as the exit program code.\n\
1284 If ARG is a string, stuff it as keyboard input.\n\n\
1285 The value of `kill-emacs-hook', if not void,\n\
1286 is a list of functions (of no args),\n\
1287 all of which are called before Emacs is actually killed.")
1288 (arg)
1289 Lisp_Object arg;
1291 Lisp_Object hook, hook1;
1292 int i;
1293 struct gcpro gcpro1;
1295 GCPRO1 (arg);
1297 if (feof (stdin))
1298 arg = Qt;
1300 if (!NILP (Vrun_hooks) && !noninteractive)
1301 call1 (Vrun_hooks, intern ("kill-emacs-hook"));
1303 UNGCPRO;
1305 /* Is it really necessary to do this deassign
1306 when we are going to exit anyway? */
1307 /* #ifdef VMS
1308 stop_vms_input ();
1309 #endif */
1311 shut_down_emacs (0, 0, STRINGP (arg) ? arg : Qnil);
1313 /* If we have an auto-save list file,
1314 kill it because we are exiting Emacs deliberately (not crashing).
1315 Do it after shut_down_emacs, which does an auto-save. */
1316 if (STRINGP (Vauto_save_list_file_name))
1317 unlink (XSTRING (Vauto_save_list_file_name)->data);
1319 exit (INTEGERP (arg) ? XINT (arg)
1320 #ifdef VMS
1322 #else
1324 #endif
1326 /* NOTREACHED */
1330 /* Perform an orderly shutdown of Emacs. Autosave any modified
1331 buffers, kill any child processes, clean up the terminal modes (if
1332 we're in the foreground), and other stuff like that. Don't perform
1333 any redisplay; this may be called when Emacs is shutting down in
1334 the background, or after its X connection has died.
1336 If SIG is a signal number, print a message for it.
1338 This is called by fatal signal handlers, X protocol error handlers,
1339 and Fkill_emacs. */
1341 void
1342 shut_down_emacs (sig, no_x, stuff)
1343 int sig, no_x;
1344 Lisp_Object stuff;
1346 /* Prevent running of hooks from now on. */
1347 Vrun_hooks = Qnil;
1349 /* If we are controlling the terminal, reset terminal modes */
1350 #ifdef EMACS_HAVE_TTY_PGRP
1352 int pgrp = EMACS_GETPGRP (0);
1354 int tpgrp;
1355 if (EMACS_GET_TTY_PGRP (0, &tpgrp) != -1
1356 && tpgrp == pgrp)
1358 fflush (stdout);
1359 reset_sys_modes ();
1360 if (sig && sig != SIGTERM)
1361 fprintf (stderr, "Fatal error (%d).", sig);
1364 #else
1365 fflush (stdout);
1366 reset_sys_modes ();
1367 #endif
1369 stuff_buffered_input (stuff);
1371 kill_buffer_processes (Qnil);
1372 Fdo_auto_save (Qt, Qnil);
1374 #ifdef CLASH_DETECTION
1375 unlock_all_files ();
1376 #endif
1378 #ifdef VMS
1379 kill_vms_processes ();
1380 #endif
1382 #if 0 /* This triggers a bug in XCloseDisplay and is not needed. */
1383 #ifdef HAVE_X_WINDOWS
1384 /* It's not safe to call intern here. Maybe we are crashing. */
1385 if (!noninteractive && SYMBOLP (Vwindow_system)
1386 && XSYMBOL (Vwindow_system)->name->size == 1
1387 && XSYMBOL (Vwindow_system)->name->data[0] == 'x'
1388 && ! no_x)
1389 Fx_close_current_connection ();
1390 #endif /* HAVE_X_WINDOWS */
1391 #endif
1393 #ifdef SIGIO
1394 /* There is a tendency for a SIGIO signal to arrive within exit,
1395 and cause a SIGHUP because the input descriptor is already closed. */
1396 unrequest_sigio ();
1397 signal (SIGIO, SIG_IGN);
1398 #endif
1400 #ifdef WINDOWSNT
1401 term_ntproc ();
1402 #endif
1407 #ifndef CANNOT_DUMP
1409 #ifdef HAVE_SHM
1411 DEFUN ("dump-emacs-data", Fdump_emacs_data, Sdump_emacs_data, 1, 1, 0,
1412 "Dump current state of Emacs into data file FILENAME.\n\
1413 This function exists on systems that use HAVE_SHM.")
1414 (filename)
1415 Lisp_Object filename;
1417 extern char my_edata[];
1418 Lisp_Object tem;
1420 CHECK_STRING (filename, 0);
1421 filename = Fexpand_file_name (filename, Qnil);
1423 tem = Vpurify_flag;
1424 Vpurify_flag = Qnil;
1426 fflush (stdout);
1427 /* Tell malloc where start of impure now is */
1428 /* Also arrange for warnings when nearly out of space. */
1429 #ifndef SYSTEM_MALLOC
1430 memory_warnings (my_edata, malloc_warning);
1431 #endif
1432 map_out_data (XSTRING (filename)->data);
1434 Vpurify_flag = tem;
1436 return Qnil;
1439 #else /* not HAVE_SHM */
1441 DEFUN ("dump-emacs", Fdump_emacs, Sdump_emacs, 2, 2, 0,
1442 "Dump current state of Emacs into executable file FILENAME.\n\
1443 Take symbols from SYMFILE (presumably the file you executed to run Emacs).\n\
1444 This is used in the file `loadup.el' when building Emacs.\n\
1446 Bind `command-line-processed' to nil before dumping,\n\
1447 if you want the dumped Emacs to process its command line\n\
1448 and announce itself normally when it is run.")
1449 (filename, symfile)
1450 Lisp_Object filename, symfile;
1452 extern char my_edata[];
1453 Lisp_Object tem;
1455 CHECK_STRING (filename, 0);
1456 filename = Fexpand_file_name (filename, Qnil);
1457 if (!NILP (symfile))
1459 CHECK_STRING (symfile, 0);
1460 if (XSTRING (symfile)->size)
1461 symfile = Fexpand_file_name (symfile, Qnil);
1464 tem = Vpurify_flag;
1465 Vpurify_flag = Qnil;
1467 #ifdef HAVE_TZSET
1468 set_time_zone_rule (dump_tz);
1469 #ifndef LOCALTIME_CACHE
1470 /* Force a tz reload, since set_time_zone_rule doesn't. */
1471 tzset ();
1472 #endif
1473 #endif
1475 fflush (stdout);
1476 #ifdef VMS
1477 mapout_data (XSTRING (filename)->data);
1478 #else
1479 /* Tell malloc where start of impure now is */
1480 /* Also arrange for warnings when nearly out of space. */
1481 #ifndef SYSTEM_MALLOC
1482 #ifndef WINDOWSNT
1483 /* On Windows, this was done before dumping, and that once suffices.
1484 Meanwhile, my_edata is not valid on Windows. */
1485 memory_warnings (my_edata, malloc_warning);
1486 #endif /* not WINDOWSNT */
1487 #endif
1488 unexec (XSTRING (filename)->data,
1489 !NILP (symfile) ? XSTRING (symfile)->data : 0, my_edata, 0, 0);
1490 #endif /* not VMS */
1492 Vpurify_flag = tem;
1494 return Qnil;
1497 #endif /* not HAVE_SHM */
1499 #endif /* not CANNOT_DUMP */
1501 #ifndef SEPCHAR
1502 #define SEPCHAR ':'
1503 #endif
1505 Lisp_Object
1506 decode_env_path (evarname, defalt)
1507 char *evarname, *defalt;
1509 register char *path, *p;
1510 Lisp_Object lpath, element, tem;
1512 /* It's okay to use getenv here, because this function is only used
1513 to initialize variables when Emacs starts up, and isn't called
1514 after that. */
1515 if (evarname != 0)
1516 path = (char *) getenv (evarname);
1517 else
1518 path = 0;
1519 if (!path)
1520 path = defalt;
1521 lpath = Qnil;
1522 while (1)
1524 p = index (path, SEPCHAR);
1525 if (!p) p = path + strlen (path);
1526 element = (p - path ? make_string (path, p - path)
1527 : build_string ("."));
1529 /* Add /: to the front of the name
1530 if it would otherwise be treated as magic. */
1531 tem = Ffind_file_name_handler (element, Qt);
1532 if (! NILP (tem))
1533 element = concat2 (build_string ("/:"), element);
1535 lpath = Fcons (element, lpath);
1536 if (*p)
1537 path = p + 1;
1538 else
1539 break;
1541 return Fnreverse (lpath);
1544 syms_of_emacs ()
1546 Qfile_name_handler_alist = intern ("file-name-handler-alist");
1547 staticpro (&Qfile_name_handler_alist);
1549 #ifndef CANNOT_DUMP
1550 #ifdef HAVE_SHM
1551 defsubr (&Sdump_emacs_data);
1552 #else
1553 defsubr (&Sdump_emacs);
1554 #endif
1555 #endif
1557 defsubr (&Skill_emacs);
1559 defsubr (&Sinvocation_name);
1560 defsubr (&Sinvocation_directory);
1562 DEFVAR_LISP ("command-line-args", &Vcommand_line_args,
1563 "Args passed by shell to Emacs, as a list of strings.");
1565 DEFVAR_LISP ("system-type", &Vsystem_type,
1566 "Value is symbol indicating type of operating system you are using.");
1567 Vsystem_type = intern (SYSTEM_TYPE);
1569 DEFVAR_LISP ("system-configuration", &Vsystem_configuration,
1570 "Value is string indicating configuration Emacs was built for.");
1571 Vsystem_configuration = build_string (EMACS_CONFIGURATION);
1573 DEFVAR_LISP ("system-configuration-options", &Vsystem_configuration_options,
1574 "String containing the configuration options Emacs was built with.");
1575 Vsystem_configuration_options = build_string (EMACS_CONFIG_OPTIONS);
1577 DEFVAR_BOOL ("noninteractive", &noninteractive1,
1578 "Non-nil means Emacs is running without interactive terminal.");
1580 DEFVAR_LISP ("kill-emacs-hook", &Vkill_emacs_hook,
1581 "Hook to be run whenever kill-emacs is called.\n\
1582 Since kill-emacs may be invoked when the terminal is disconnected (or\n\
1583 in other similar situations), functions placed on this hook should not\n\
1584 expect to be able to interact with the user. To ask for confirmation,\n\
1585 see `kill-emacs-query-functions' instead.");
1586 Vkill_emacs_hook = Qnil;
1588 DEFVAR_INT ("emacs-priority", &emacs_priority,
1589 "Priority for Emacs to run at.\n\
1590 This value is effective only if set before Emacs is dumped,\n\
1591 and only if the Emacs executable is installed with setuid to permit\n\
1592 it to change priority. (Emacs sets its uid back to the real uid.)\n\
1593 Currently, you need to define SET_EMACS_PRIORITY in `config.h'\n\
1594 before you compile Emacs, to enable the code for this feature.");
1595 emacs_priority = 0;
1597 DEFVAR_LISP ("invocation-name", &Vinvocation_name,
1598 "The program name that was used to run Emacs.\n\
1599 Any directory names are omitted.");
1601 DEFVAR_LISP ("invocation-directory", &Vinvocation_directory,
1602 "The directory in which the Emacs executable was found, to run it.\n\
1603 The value is nil if that directory's name is not known.");
1605 DEFVAR_LISP ("installation-directory", &Vinstallation_directory,
1606 "A directory within which to look for the `lib-src' and `etc' directories.\n\
1607 This is non-nil when we can't find those directories in their standard\n\
1608 installed locations, but we can find them\n\
1609 near where the Emacs executable was found.");
1610 Vinstallation_directory = Qnil;