1 /* Fully extensible Emacs, running on Unix, intended for GNU.
2 Copyright (C) 1985,86,87,93,94,95,97,1998 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)
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. */
28 #include <sys/types.h>
40 #include <sys/ioctl.h>
49 #include "intervals.h"
53 #include "blockinput.h"
54 #include "syssignal.h"
56 #include "termhooks.h"
61 #include <sys/resource.h>
68 extern void malloc_warning ();
69 extern void set_time_zone_rule ();
70 extern char *index ();
71 extern char *strerror ();
73 /* Command line args from shell, as list of strings */
74 Lisp_Object Vcommand_line_args
;
76 /* The name under which Emacs was invoked, with any leading directory
78 Lisp_Object Vinvocation_name
;
80 /* The directory name from which Emacs was invoked. */
81 Lisp_Object Vinvocation_directory
;
83 /* The directory name in which to find subdirs such as lisp and etc.
84 nil means get them only from PATH_LOADSEARCH. */
85 Lisp_Object Vinstallation_directory
;
87 /* Hook run by `kill-emacs' before it does really anything. */
88 Lisp_Object Vkill_emacs_hook
;
91 /* Hooks for signal USR1 and USR2 handing */
92 Lisp_Object Vsignal_USR1_hook
;
94 Lisp_Object Vsignal_USR2_hook
;
98 /* Search path separator. */
99 Lisp_Object Vpath_separator
;
101 /* Set nonzero after Emacs has started up the first time.
102 Prevents reinitialization of the Lisp world and keymaps
103 on subsequent starts. */
106 #ifdef DOUG_LEA_MALLOC
107 /* Preserves a pointer to the memory allocated that copies that
108 static data inside glibc's malloc. */
109 void *malloc_state_ptr
;
110 /* From glibc, a routine that returns a copy of the malloc internal state. */
111 extern void *malloc_get_state ();
112 /* From glibc, a routine that overwrites the malloc internal state. */
113 extern void malloc_set_state ();
114 /* Non-zero if the MALLOC_CHECK_ enviroment variable was set while
115 dumping. Used to work around a bug in glibc's malloc. */
116 int malloc_using_checking
;
119 /* Variable whose value is symbol giving operating system type. */
120 Lisp_Object Vsystem_type
;
122 /* Variable whose value is string giving configuration built for. */
123 Lisp_Object Vsystem_configuration
;
125 /* Variable whose value is string giving configuration options,
126 for use when reporting bugs. */
127 Lisp_Object Vsystem_configuration_options
;
129 Lisp_Object Qfile_name_handler_alist
;
131 /* If non-zero, emacs should not attempt to use an window-specific code,
132 but instead should use the virtual terminal under which it was started */
133 int inhibit_window_system
;
135 /* If nonzero, set Emacs to run at this priority. This is also used
136 in child_setup and sys_suspend to make sure subshells run at normal
137 priority; Those functions have their own extern declaration. */
140 /* If non-zero a filter or a sentinel is running. Tested to save the match
141 data on the first attempt to change it inside asynchronous code. */
142 int running_asynch_code
;
146 extern int inherited_pgroup
;
149 #ifdef HAVE_X_WINDOWS
150 /* If non-zero, -d was specified, meaning we're using some window system. */
154 /* An address near the bottom of the stack.
155 Tells GC how to save a copy of the stack. */
158 #ifdef HAVE_WINDOW_SYSTEM
159 extern Lisp_Object Vwindow_system
;
160 #endif /* HAVE_WINDOW_SYSTEM */
162 extern Lisp_Object Vauto_save_list_file_name
;
164 #ifdef USG_SHARED_LIBRARIES
165 /* If nonzero, this is the place to put the end of the writable segment
168 unsigned int bss_end
= 0;
171 /* Nonzero means running Emacs without interactive terminal. */
175 /* Value of Lisp variable `noninteractive'.
176 Normally same as C variable `noninteractive'
177 but nothing terrible happens if user sets this one. */
181 /* Save argv and argc. */
185 static void sort_args ();
186 void syms_of_emacs ();
188 /* Signal code for the fatal signal that was received */
189 int fatal_error_code
;
191 /* Nonzero if handling a fatal error already */
192 int fatal_error_in_progress
;
196 handle_USR1_signal (sig
)
199 struct input_event buf
;
201 buf
.kind
= user_signal
;
203 buf
.frame_or_window
= selected_frame
;
207 kbd_buffer_store_event (&buf
);
213 handle_USR2_signal (sig
)
216 struct input_event buf
;
218 buf
.kind
= user_signal
;
220 buf
.frame_or_window
= selected_frame
;
224 kbd_buffer_store_event (&buf
);
228 /* Handle bus errors, illegal instruction, etc. */
230 fatal_error_signal (sig
)
233 fatal_error_code
= sig
;
234 signal (sig
, SIG_DFL
);
236 TOTALLY_UNBLOCK_INPUT
;
238 /* If fatal error occurs in code below, avoid infinite recursion. */
239 if (! fatal_error_in_progress
)
241 fatal_error_in_progress
= 1;
243 shut_down_emacs (sig
, 0, Qnil
);
247 LIB$
STOP (SS$_ABORT
);
249 /* Signal the same code; this time it will really be fatal.
250 Remember that since we're in a signal handler, the signal we're
251 going to send is probably blocked, so we have to unblock it if we
252 want to really receive it. */
254 sigunblock (sigmask (fatal_error_code
));
256 kill (getpid (), fatal_error_code
);
262 /* Handler for SIGDANGER. */
264 memory_warning_signal (sig
)
267 signal (sig
, memory_warning_signal
);
269 malloc_warning ("Operating system warns that virtual memory is running low.\n");
271 /* It might be unsafe to call do_auto_save now. */
272 force_auto_save_soon ();
276 /* We define abort, rather than using it from the library,
277 so that GDB can return from a breakpoint here.
278 MSDOS has its own definition on msdos.c */
280 #if ! defined (DOS_NT) && ! defined (NO_ABORT)
284 kill (getpid (), SIGABRT
);
285 /* This shouldn't be executed, but it prevents a warning. */
291 /* Code for dealing with Lisp access to the Unix command line */
294 init_cmdargs (argc
, argv
, skip_args
)
300 Lisp_Object name
, dir
, tem
;
301 int count
= specpdl_ptr
- specpdl
;
302 Lisp_Object raw_name
;
307 raw_name
= build_string (argv
[0]);
309 /* Add /: to the front of the name
310 if it would otherwise be treated as magic. */
311 tem
= Ffind_file_name_handler (raw_name
, Qt
);
313 raw_name
= concat2 (build_string ("/:"), raw_name
);
315 Vinvocation_name
= Ffile_name_nondirectory (raw_name
);
316 Vinvocation_directory
= Ffile_name_directory (raw_name
);
318 /* If we got no directory in argv[0], search PATH to find where
319 Emacs actually came from. */
320 if (NILP (Vinvocation_directory
))
323 int yes
= openp (Vexec_path
, Vinvocation_name
,
324 EXEC_SUFFIXES
, &found
, 1);
327 /* Add /: to the front of the name
328 if it would otherwise be treated as magic. */
329 tem
= Ffind_file_name_handler (found
, Qt
);
331 found
= concat2 (build_string ("/:"), found
);
332 Vinvocation_directory
= Ffile_name_directory (found
);
336 if (!NILP (Vinvocation_directory
)
337 && NILP (Ffile_name_absolute_p (Vinvocation_directory
)))
338 /* Emacs was started with relative path, like ./emacs.
340 Vinvocation_directory
= Fexpand_file_name (Vinvocation_directory
, Qnil
);
342 Vinstallation_directory
= Qnil
;
344 if (!NILP (Vinvocation_directory
))
346 dir
= Vinvocation_directory
;
347 name
= Fexpand_file_name (Vinvocation_name
, dir
);
350 Lisp_Object tem
, lib_src_exists
;
351 Lisp_Object etc_exists
, info_exists
;
353 /* See if dir contains subdirs for use by Emacs.
354 Check for the ones that would exist in a build directory,
355 not including lisp and info. */
356 tem
= Fexpand_file_name (build_string ("lib-src"), dir
);
357 lib_src_exists
= Ffile_exists_p (tem
);
360 /* MSDOS installations frequently remove lib-src, but we still
361 must set installation-directory, or else info won't find
362 its files (it uses the value of installation-directory). */
363 tem
= Fexpand_file_name (build_string ("info"), dir
);
364 info_exists
= Ffile_exists_p (tem
);
369 if (!NILP (lib_src_exists
) || !NILP (info_exists
))
371 tem
= Fexpand_file_name (build_string ("etc"), dir
);
372 etc_exists
= Ffile_exists_p (tem
);
373 if (!NILP (etc_exists
))
375 Vinstallation_directory
376 = Ffile_name_as_directory (dir
);
381 /* See if dir's parent contains those subdirs. */
382 tem
= Fexpand_file_name (build_string ("../lib-src"), dir
);
383 lib_src_exists
= Ffile_exists_p (tem
);
387 /* See the MSDOS commentary above. */
388 tem
= Fexpand_file_name (build_string ("../info"), dir
);
389 info_exists
= Ffile_exists_p (tem
);
394 if (!NILP (lib_src_exists
) || !NILP (info_exists
))
396 tem
= Fexpand_file_name (build_string ("../etc"), dir
);
397 etc_exists
= Ffile_exists_p (tem
);
398 if (!NILP (etc_exists
))
400 tem
= Fexpand_file_name (build_string (".."), dir
);
401 Vinstallation_directory
402 = Ffile_name_as_directory (tem
);
407 /* If the Emacs executable is actually a link,
408 next try the dir that the link points into. */
409 tem
= Ffile_symlink_p (name
);
412 name
= Fexpand_file_name (tem
, dir
);
413 dir
= Ffile_name_directory (name
);
420 Vcommand_line_args
= Qnil
;
422 for (i
= argc
- 1; i
>= 0; i
--)
424 if (i
== 0 || i
> skip_args
)
426 = Fcons (build_string (argv
[i
]), Vcommand_line_args
);
429 unbind_to (count
, Qnil
);
432 DEFUN ("invocation-name", Finvocation_name
, Sinvocation_name
, 0, 0, 0,
433 "Return the program name that was used to run Emacs.\n\
434 Any directory names are omitted.")
437 return Fcopy_sequence (Vinvocation_name
);
440 DEFUN ("invocation-directory", Finvocation_directory
, Sinvocation_directory
,
442 "Return the directory name in which the Emacs executable was located")
445 return Fcopy_sequence (Vinvocation_directory
);
450 #ifdef LINK_CRTL_SHARE
451 #ifdef SHARABLE_LIB_BUG
452 extern noshare
char **environ
;
453 #endif /* SHARABLE_LIB_BUG */
454 #endif /* LINK_CRTL_SHARE */
458 /* A valid but unlikely value for the TZ environment value.
459 It is OK (though a bit slower) if the user actually chooses this value. */
460 static char dump_tz
[] = "UtC0";
463 #ifndef ORDINARY_LINK
464 /* We don't include crtbegin.o and crtend.o in the link,
465 so these functions and variables might be missed.
466 Provide dummy definitions to avoid error.
467 (We don't have any real constructors or destructors.) */
469 #ifndef GCC_CTORS_IN_LIBC
470 void __do_global_ctors ()
472 void __do_global_ctors_aux ()
474 void __do_global_dtors ()
476 /* Linux has a bug in its library; avoid an error. */
478 char * __CTOR_LIST__
[2] = { (char *) (-1), 0 };
480 char * __DTOR_LIST__
[2] = { (char *) (-1), 0 };
481 #endif /* GCC_CTORS_IN_LIBC */
484 #endif /* __GNUC__ */
485 #endif /* ORDINARY_LINK */
487 /* Test whether the next argument in ARGV matches SSTR or a prefix of
488 LSTR (at least MINLEN characters). If so, then if VALPTR is non-null
489 (the argument is supposed to have a value) store in *VALPTR either
490 the next argument or the portion of this one after the equal sign.
491 ARGV is read starting at position *SKIPPTR; this index is advanced
492 by the number of arguments used.
494 Too bad we can't just use getopt for all of this, but we don't have
495 enough information to do it right. */
498 argmatch (argv
, argc
, sstr
, lstr
, minlen
, valptr
, skipptr
)
511 /* Don't access argv[argc]; give up in advance. */
512 if (argc
<= *skipptr
+ 1)
515 arg
= argv
[*skipptr
+1];
518 if (strcmp (arg
, sstr
) == 0)
522 *valptr
= argv
[*skipptr
+2];
529 arglen
= (valptr
!= NULL
&& (p
= index (arg
, '=')) != NULL
530 ? p
- arg
: strlen (arg
));
531 if (lstr
== 0 || arglen
< minlen
|| strncmp (arg
, lstr
, arglen
) != 0)
533 else if (valptr
== NULL
)
544 else if (argv
[*skipptr
+2] != NULL
)
546 *valptr
= argv
[*skipptr
+2];
556 #ifdef DOUG_LEA_MALLOC
558 /* malloc can be invoked even before main (e.g. by the dynamic
559 linker), so the dumped malloc state must be restored as early as
560 possible using this special hook. */
563 malloc_initialize_hook ()
565 extern char **environ
;
569 if (!malloc_using_checking
)
570 /* Work around a bug in glibc's malloc. MALLOC_CHECK_ must be
571 ignored if the heap to be restored was constructed without
572 malloc checking. Can't use unsetenv, since that calls malloc. */
576 for (p
= environ
; *p
; p
++)
577 if (strncmp (*p
, "MALLOC_CHECK_=", 14) == 0)
586 malloc_set_state (malloc_state_ptr
);
587 free (malloc_state_ptr
);
590 malloc_using_checking
= getenv ("MALLOC_CHECK_") != NULL
;
593 void (*__malloc_initialize_hook
) () = malloc_initialize_hook
;
595 #endif /* DOUG_LEA_MALLOC */
599 main (argc
, argv
, envp
)
604 char stack_bottom_variable
;
608 #ifdef HAVE_SETRLIMIT
613 #ifdef LINUX_SBRK_BUG
617 #ifdef RUN_TIME_REMAP
619 run_time_remap (argv
[0]);
622 sort_args (argc
, argv
);
624 while (argv
[argc
]) argc
++;
626 if (argmatch (argv
, argc
, "-version", "--version", 3, NULL
, &skip_args
)
627 /* We don't know the version number unless this is a dumped Emacs.
628 So ignore --version otherwise. */
632 tem
= Fsymbol_value (intern ("emacs-version"));
635 fprintf (stderr
, "Invalid value of `emacs-version'\n");
640 printf ("GNU Emacs %s\n", XSTRING (tem
)->data
);
641 printf ("Copyright (C) 1999 Free Software Foundation, Inc.\n");
642 printf ("GNU Emacs comes with ABSOLUTELY NO WARRANTY.\n");
643 printf ("You may redistribute copies of Emacs\n");
644 printf ("under the terms of the GNU General Public License.\n");
645 printf ("For more information about these matters, ");
646 printf ("see the file named COPYING.\n");
651 /* Map in shared memory, if we are using that. */
653 if (argmatch (argv
, argc
, "-nl", "--no-shared-memory", 6, NULL
, &skip_args
))
656 /* The shared memory was just restored, which clobbered this. */
662 /* The shared memory was just restored, which clobbered this. */
669 extern int malloc_cookie
;
670 /* This helps out unexnext.c. */
672 if (malloc_jumpstart (malloc_cookie
) != 0)
673 printf ("malloc jumpstart failed!\n");
678 /* If -map specified, map the data file in */
681 if (argmatch (argv
, argc
, "-map", "--map-data", 3, &mapin_file
, &skip_args
))
685 #ifdef LINK_CRTL_SHARE
686 #ifdef SHARABLE_LIB_BUG
687 /* Bletcherous shared libraries! */
689 stdin
= fdopen (0, "r");
691 stdout
= fdopen (1, "w");
693 stderr
= fdopen (2, "w");
696 #endif /* SHARABLE_LIB_BUG */
697 #endif /* LINK_CRTL_SHARE */
700 #if defined (HAVE_SETRLIMIT) && defined (RLIMIT_STACK)
701 /* Extend the stack space available.
702 Don't do that if dumping, since some systems (e.g. DJGPP)
703 might define a smaller stack limit at that time. */
706 && (!noninteractive
|| initialized
)
708 && !getrlimit (RLIMIT_STACK
, &rlim
))
711 extern int re_max_failures
;
712 /* Approximate the amount regex.c needs per unit of re_max_failures. */
713 int ratio
= 20 * sizeof (char *);
714 /* Then add 33% to cover the size of the smaller stacks that regex.c
715 successively allocates and discards, on its way to the maximum. */
717 /* Add in some extra to cover
718 what we're likely to use for other reasons. */
719 newlim
= re_max_failures
* ratio
+ 200000;
721 /* NetBSD (at least NetBSD 1.2G and former) has a bug in its
722 stack allocation routine for new process that the allocation
723 fails if stack limit is not on page boundary. So, round up the
724 new limit to page boundary. */
725 newlim
= (newlim
+ getpagesize () - 1) / getpagesize () * getpagesize();
727 if (newlim
> rlim
.rlim_max
)
729 newlim
= rlim
.rlim_max
;
730 /* Don't let regex.c overflow the stack we have. */
731 re_max_failures
= (newlim
- 200000) / ratio
;
733 if (rlim
.rlim_cur
< newlim
)
734 rlim
.rlim_cur
= newlim
;
736 setrlimit (RLIMIT_STACK
, &rlim
);
738 #endif /* HAVE_SETRLIMIT and RLIMIT_STACK */
740 /* Record (approximately) where the stack begins. */
741 stack_bottom
= &stack_bottom_variable
;
743 #ifdef USG_SHARED_LIBRARIES
745 brk ((void *)bss_end
);
750 #ifndef SYSTEM_MALLOC
751 /* Arrange to get warning messages as memory fills up. */
752 memory_warnings (0, malloc_warning
);
754 /* Call malloc at least once, to run the initial __malloc_hook.
755 Also call realloc and free for consistency. */
756 free (realloc (malloc (4), 4));
758 /* Arrange to disable interrupt input inside malloc etc. */
759 uninterrupt_malloc ();
760 #endif /* not SYSTEM_MALLOC */
763 /* We do all file input/output as binary files. When we need to translate
764 newlines, we do that manually. */
768 if (!isatty (fileno (stdin
)))
769 setmode (fileno (stdin
), O_BINARY
);
770 if (!isatty (fileno (stdout
)))
773 setmode (fileno (stdout
), O_BINARY
);
775 #else /* not __DJGPP__ >= 2 */
776 (stdin
)->_flag
&= ~_IOTEXT
;
777 (stdout
)->_flag
&= ~_IOTEXT
;
778 (stderr
)->_flag
&= ~_IOTEXT
;
779 #endif /* not __DJGPP__ >= 2 */
782 #ifdef SET_EMACS_PRIORITY
784 nice (emacs_priority
);
786 #endif /* SET_EMACS_PRIORITY */
788 #ifdef EXTRA_INITIALIZE
792 inhibit_window_system
= 0;
794 /* Handle the -t switch, which specifies filename to use as terminal */
798 if (argmatch (argv
, argc
, "-t", "--terminal", 4, &term
, &skip_args
))
803 result
= open (term
, O_RDWR
, 2 );
806 char *errstring
= strerror (errno
);
807 fprintf (stderr
, "emacs: %s: %s\n", term
, errstring
);
813 fprintf (stderr
, "emacs: %s: not a tty\n", term
);
816 fprintf (stderr
, "Using %s\n", term
);
817 #ifdef HAVE_WINDOW_SYSTEM
818 inhibit_window_system
= 1; /* -t => -nw */
825 if (argmatch (argv
, argc
, "-nw", "--no-windows", 6, NULL
, &skip_args
))
826 inhibit_window_system
= 1;
828 /* Handle the -batch switch, which means don't do interactive display. */
830 if (argmatch (argv
, argc
, "-batch", "--batch", 5, NULL
, &skip_args
))
833 /* Handle the --help option, which gives a usage message.. */
834 if (argmatch (argv
, argc
, "-help", "--help", 3, NULL
, &skip_args
))
837 Usage: %s [--batch] [-t term] [--terminal term]\n\
838 [-d display] [--display display] [-nw] [--no-windows]\n\
839 [-q] [--no-init-file] [-u user] [--user user] [--debug-init]\n\
840 [--unibyte] [--multibyte] [--version] [--no-site-file]\n\
841 [-f func] [--funcall func] [-l file] [--load file] [--eval expr]\n\
842 [--insert file] [+linenum] file-to-visit [--kill]\n\
843 Report bugs to bug-gnu-emacs@gnu.org. First, please see\n\
844 the Bugs section of the Emacs manual or the file BUGS.\n", argv
[0]);
848 if (! noninteractive
)
853 inherited_pgroup
= EMACS_GETPGRP (0);
854 setpgrp (0, getpid ());
857 #if defined (USG5) && defined (INTERRUPT_INPUT)
867 /* Don't catch SIGHUP if dumping. */
874 sigblock (sigmask (SIGHUP
));
875 /* In --batch mode, don't catch SIGHUP if already ignored.
876 That makes nohup work. */
878 || signal (SIGHUP
, SIG_IGN
) != SIG_IGN
)
879 signal (SIGHUP
, fatal_error_signal
);
880 sigunblock (sigmask (SIGHUP
));
885 ! noninteractive
|| initialized
891 /* Don't catch these signals in batch mode if dumping.
892 On some machines, this sets static data that would make
893 signal fail to work right when the dumped Emacs is run. */
894 signal (SIGQUIT
, fatal_error_signal
);
895 signal (SIGILL
, fatal_error_signal
);
896 signal (SIGTRAP
, fatal_error_signal
);
898 signal (SIGUSR1
, handle_USR1_signal
);
900 signal (SIGUSR2
, handle_USR2_signal
);
904 signal (SIGABRT
, fatal_error_signal
);
907 signal (SIGHWE
, fatal_error_signal
);
910 signal (SIGPRE
, fatal_error_signal
);
913 signal (SIGORE
, fatal_error_signal
);
916 signal (SIGUME
, fatal_error_signal
);
919 signal (SIGDLK
, fatal_error_signal
);
922 signal (SIGCPULIM
, fatal_error_signal
);
925 /* This is missing on some systems - OS/2, for example. */
926 signal (SIGIOT
, fatal_error_signal
);
929 signal (SIGEMT
, fatal_error_signal
);
931 signal (SIGFPE
, fatal_error_signal
);
933 signal (SIGBUS
, fatal_error_signal
);
935 signal (SIGSEGV
, fatal_error_signal
);
937 signal (SIGSYS
, fatal_error_signal
);
939 signal (SIGTERM
, fatal_error_signal
);
941 signal (SIGXCPU
, fatal_error_signal
);
944 signal (SIGXFSZ
, fatal_error_signal
);
948 /* This just means available memory is getting low. */
949 signal (SIGDANGER
, memory_warning_signal
);
953 /* 20 is SIGCHLD, 21 is SIGTTIN, 22 is SIGTTOU. */
954 signal (SIGXCPU
, fatal_error_signal
);
956 signal (SIGIOINT
, fatal_error_signal
);
958 signal (SIGGRANT
, fatal_error_signal
);
959 signal (SIGRETRACT
, fatal_error_signal
);
960 signal (SIGSOUND
, fatal_error_signal
);
961 signal (SIGMSG
, fatal_error_signal
);
965 noninteractive1
= noninteractive
;
967 /* Perform basic initializations (not merely interning symbols) */
974 init_charset_once ();
976 init_syntax_once (); /* Create standard syntax table. */
977 init_category_once (); /* Create standard category table. */
978 /* Must be done before init_buffer */
979 init_casetab_once ();
980 init_buffer_once (); /* Create buffer table and some buffers */
981 init_minibuf_once (); /* Create list of minibuffers */
982 /* Must precede init_window_once */
984 /* Call syms_of_xfaces before init_window_once because that
985 function creates Vterminal_frame. Termcap frames now use
986 faces, and the face implementation uses some symbols as
992 init_window_once (); /* Init the window system */
993 init_fileio_once (); /* Must precede any path manipulation. */
1000 #ifdef CLASH_DETECTION
1003 running_asynch_code
= 0;
1005 /* Handle --unibyte and the EMACS_UNIBYTE envvar,
1006 but not while dumping. */
1009 ! noninteractive
|| initialized
1015 int inhibit_unibyte
= 0;
1017 /* --multibyte overrides EMACS_UNIBYTE. */
1018 if (argmatch (argv
, argc
, "-no-unibyte", "--no-unibyte", 4, NULL
, &skip_args
)
1019 || argmatch (argv
, argc
, "-multibyte", "--multibyte", 4, NULL
, &skip_args
))
1020 inhibit_unibyte
= 1;
1022 /* --unibyte requests that we set up to do everything with single-byte
1023 buffers and strings. We need to handle this before calling
1024 init_lread, init_editfns and other places that generate Lisp strings
1025 from text in the environment. */
1026 /* Actually this shouldn't be needed as of 20.4 in a generally
1027 unibyte environment. As handa says, environment values
1028 aren't now decoded; also existing buffers are now made
1029 unibyte during startup if .emacs sets unibyte. Tested with
1030 8-bit data in environment variables and /etc/passwd, setting
1031 unibyte and Latin-1 in .emacs. -- Dave Love */
1032 if (argmatch (argv
, argc
, "-unibyte", "--unibyte", 4, NULL
, &skip_args
)
1033 || argmatch (argv
, argc
, "-no-multibyte", "--no-multibyte", 4, NULL
, &skip_args
)
1034 || (getenv ("EMACS_UNIBYTE") && !inhibit_unibyte
))
1036 Lisp_Object old_log_max
;
1037 Lisp_Object symbol
, tail
;
1039 symbol
= intern ("default-enable-multibyte-characters");
1040 Fset (symbol
, Qnil
);
1044 /* Erase pre-dump messages in *Messages* now so no abort. */
1045 old_log_max
= Vmessage_log_max
;
1046 XSETFASTINT (Vmessage_log_max
, 0);
1047 message_dolog ("", 0, 1, 0);
1048 Vmessage_log_max
= old_log_max
;
1051 for (tail
= Vbuffer_alist
; CONSP (tail
);
1052 tail
= XCONS (tail
)->cdr
)
1056 buffer
= Fcdr (XCONS (tail
)->car
);
1057 /* Verify that all buffers are empty now, as they
1059 if (BUF_Z (XBUFFER (buffer
)) > BUF_BEG (XBUFFER (buffer
)))
1061 /* It is safe to do this crudely in an empty buffer. */
1062 XBUFFER (buffer
)->enable_multibyte_characters
= Qnil
;
1068 = !argmatch (argv
, argc
, "-nl", "--no-loadup", 6, NULL
, &skip_args
);
1071 #ifdef HAVE_X_WINDOWS
1072 /* Stupid kludge to catch command-line display spec. We can't
1073 handle this argument entirely in window system dependent code
1074 because we don't even know which window system dependent code
1075 to run until we've recognized this argument. */
1077 char *displayname
= 0;
1078 int count_before
= skip_args
;
1080 /* Skip any number of -d options, but only use the last one. */
1083 int count_before_this
= skip_args
;
1085 if (argmatch (argv
, argc
, "-d", "--display", 3, &displayname
, &skip_args
))
1087 else if (argmatch (argv
, argc
, "-display", 0, 3, &displayname
, &skip_args
))
1092 count_before
= count_before_this
;
1095 /* If we have the form --display=NAME,
1096 convert it into -d name.
1097 This requires inserting a new element into argv. */
1098 if (displayname
!= 0 && skip_args
- count_before
== 1)
1100 char **new = (char **) xmalloc (sizeof (char *) * (argc
+ 2));
1103 for (j
= 0; j
< count_before
+ 1; j
++)
1105 new[count_before
+ 1] = "-d";
1106 new[count_before
+ 2] = displayname
;
1107 for (j
= count_before
+ 2; j
<argc
; j
++)
1108 new[j
+ 1] = argv
[j
];
1112 /* Change --display to -d, when its arg is separate. */
1113 else if (displayname
!= 0 && skip_args
> count_before
1114 && argv
[count_before
+ 1][1] == '-')
1115 argv
[count_before
+ 1] = "-d";
1117 /* Don't actually discard this arg. */
1118 skip_args
= count_before
;
1122 /* argmatch must not be used after here,
1123 except when bulding temacs
1124 because the -d argument has not been skipped in skip_args. */
1127 /* Call early 'cause init_environment needs it. */
1129 /* Set defaults for several environment variables. */
1131 init_environment (argc
, argv
, skip_args
);
1137 /* Initialize environment from registry settings. */
1138 init_environment (argv
);
1139 init_ntproc (); /* must precede init_editfns */
1142 /* egetenv is a pretty low-level facility, which may get called in
1143 many circumstances; it seems flimsy to put off initializing it
1144 until calling init_callproc. */
1145 set_process_environment ();
1146 /* AIX crashes are reported in system versions 3.2.3 and 3.2.4
1147 if this is not done. Do it after set_process_environment so that we
1148 don't pollute Vprocess_environment. */
1153 init_buffer (); /* Init default directory of main buffer */
1155 init_callproc_1 (); /* Must precede init_cmdargs and init_sys_modes. */
1156 init_cmdargs (argc
, argv
, skip_args
); /* Must precede init_lread. */
1160 /* Erase any pre-dump messages in the message log, to avoid confusion */
1161 Lisp_Object old_log_max
;
1162 old_log_max
= Vmessage_log_max
;
1163 XSETFASTINT (Vmessage_log_max
, 0);
1164 message_dolog ("", 0, 1, 0);
1165 Vmessage_log_max
= old_log_max
;
1168 init_callproc (); /* Must follow init_cmdargs but not init_sys_modes. */
1171 /* Intern the names of all standard functions and variables;
1172 define standard keys. */
1176 /* The basic levels of Lisp must come first */
1177 /* And data must come first of all
1178 for the sake of symbols like error-message */
1185 syms_of_floatfns ();
1189 syms_of_bytecode ();
1191 syms_of_casefiddle ();
1193 syms_of_callproc ();
1194 syms_of_category ();
1198 #ifndef NO_DIR_LIBRARY
1200 #endif /* not NO_DIR_LIBRARY */
1206 syms_of_coding (); /* This should be after syms_of_fileio. */
1207 #ifdef CLASH_DETECTION
1208 syms_of_filelock ();
1209 #endif /* CLASH_DETECTION */
1212 syms_of_keyboard ();
1217 syms_of_mocklisp ();
1228 /* Only defined if Emacs is compiled with USE_TEXT_PROPERTIES */
1229 syms_of_textprop ();
1235 #endif /* WINDOWSNT */
1238 #ifdef HAVE_X_WINDOWS
1245 #endif /* HAVE_X_WINDOWS */
1254 syms_of_w32faces ();
1255 syms_of_w32select ();
1258 #endif /* HAVE_NTGUI */
1268 keys_of_casefiddle ();
1271 keys_of_keyboard ();
1279 if (!noninteractive
)
1282 init_vms_input ();/* init_display calls get_frame_size, that needs this */
1284 init_display (); /* Determine terminal type. init_sys_modes uses results */
1286 init_keyboard (); /* This too must precede init_sys_modes */
1288 init_vmsproc (); /* And this too. */
1290 init_sys_modes (); /* Init system terminal modes (RAW or CBREAK, etc.) */
1291 #ifdef HAVE_X_WINDOWS
1293 #endif /* HAVE_X_WINDOWS */
1298 #ifdef LISP_FLOAT_TYPE
1312 /* Handle -l loadup, args passed by Makefile. */
1313 if (argmatch (argv
, argc
, "-l", "--load", 3, &file
, &skip_args
))
1314 Vtop_level
= Fcons (intern ("load"),
1315 Fcons (build_string (file
), Qnil
));
1317 /* Unless next switch is -nl, load "loadup.el" first thing. */
1319 Vtop_level
= Fcons (intern ("load"),
1320 Fcons (build_string ("loadup.el"), Qnil
));
1321 #endif /* CANNOT_DUMP */
1328 /* If the execution TZ happens to be the same as the dump TZ,
1329 change it to some other value and then change it back,
1330 to force the underlying implementation to reload the TZ info.
1331 This is needed on implementations that load TZ info from files,
1332 since the TZ file contents may differ between dump and execution. */
1333 char *tz
= getenv ("TZ");
1334 if (tz
&& !strcmp (tz
, dump_tz
))
1344 /* Gerd Moellmann <gerd@acm.org> says this makes profiling work on
1345 FreeBSD. It might work on some other systems too.
1346 Give it a try and tell me if it works on your system. */
1351 extern void _mcleanup ();
1353 extern void safe_bcopy ();
1355 /* This uses safe_bcopy because that function comes first in the
1356 Emacs executable. It might be better to use something that
1357 gives the start of the text segment, but start_of_text is not
1358 defined on all systems now. */
1359 monstartup (safe_bcopy
, &etext
);
1368 #ifdef LOCALTIME_CACHE
1369 /* Some versions of localtime have a bug. They cache the value of the time
1370 zone rather than looking it up every time. Since localtime() is
1371 called to bolt the undumping time into the undumped emacs, this
1372 results in localtime ignoring the TZ environment variable.
1373 This flushes the new TZ value into localtime. */
1375 #endif /* defined (LOCALTIME_CACHE) */
1377 /* Enter editor command loop. This never returns. */
1382 /* Sort the args so we can find the most important ones
1383 at the beginning of argv. */
1385 /* First, here's a table of all the standard options. */
1387 struct standard_args
1395 struct standard_args standard_args
[] =
1397 { "-version", "--version", 150, 0 },
1399 { "-nl", "--no-shared-memory", 140, 0 },
1402 { "-map", "--map-data", 130, 0 },
1404 { "-t", "--terminal", 120, 1 },
1405 { "-nw", "--no-windows", 110, 0 },
1406 { "-batch", "--batch", 100, 0 },
1407 { "-help", "--help", 90, 0 },
1408 { "-no-unibyte", "--no-unibyte", 83, 0 },
1409 { "-multibyte", "--multibyte", 82, 0 },
1410 { "-unibyte", "--unibyte", 81, 0 },
1411 { "-no-multibyte", "--no-multibyte", 80, 0 },
1413 { "-nl", "--no-loadup", 70, 0 },
1415 /* -d must come last before the options handled in startup.el. */
1416 { "-d", "--display", 60, 1 },
1417 { "-display", 0, 60, 1 },
1418 /* Now for the options handled in startup.el. */
1419 { "-q", "--no-init-file", 50, 0 },
1420 { "-no-init-file", 0, 50, 0 },
1421 { "-no-site-file", "--no-site-file", 40, 0 },
1422 { "-u", "--user", 30, 1 },
1423 { "-user", 0, 30, 1 },
1424 { "-debug-init", "--debug-init", 20, 0 },
1425 { "-i", "--icon-type", 15, 0 },
1426 { "-itype", 0, 15, 0 },
1427 { "-iconic", "--iconic", 15, 0 },
1428 { "-bg", "--background-color", 10, 1 },
1429 { "-background", 0, 10, 1 },
1430 { "-fg", "--foreground-color", 10, 1 },
1431 { "-foreground", 0, 10, 1 },
1432 { "-bd", "--border-color", 10, 1 },
1433 { "-bw", "--border-width", 10, 1 },
1434 { "-ib", "--internal-border", 10, 1 },
1435 { "-ms", "--mouse-color", 10, 1 },
1436 { "-cr", "--cursor-color", 10, 1 },
1437 { "-fn", "--font", 10, 1 },
1438 { "-font", 0, 10, 1 },
1439 { "-g", "--geometry", 10, 1 },
1440 { "-geometry", 0, 10, 1 },
1441 { "-T", "--title", 10, 1 },
1442 { "-title", 0, 10, 1 },
1443 { "-name", "--name", 10, 1 },
1444 { "-xrm", "--xrm", 10, 1 },
1445 { "-r", "--reverse-video", 5, 0 },
1447 { "-reverse", 0, 5, 0 },
1448 { "-hb", "--horizontal-scroll-bars", 5, 0 },
1449 { "-vb", "--vertical-scroll-bars", 5, 0 },
1450 /* These have the same priority as ordinary file name args,
1451 so they are not reordered with respect to those. */
1452 { "-L", "--directory", 0, 1 },
1453 { "-directory", 0, 0, 1 },
1454 { "-l", "--load", 0, 1 },
1455 { "-load", 0, 0, 1 },
1456 { "-f", "--funcall", 0, 1 },
1457 { "-funcall", 0, 0, 1 },
1458 { "-eval", "--eval", 0, 1 },
1459 { "-find-file", "--find-file", 0, 1 },
1460 { "-visit", "--visit", 0, 1 },
1461 { "-insert", "--insert", 0, 1 },
1462 /* This should be processed after ordinary file name args and the like. */
1463 { "-kill", "--kill", -10, 0 },
1466 /* Reorder the elements of ARGV (assumed to have ARGC elements)
1467 so that the highest priority ones come first.
1468 Do not change the order of elements of equal priority.
1469 If an option takes an argument, keep it and its argument together.
1471 If an option that takes no argument appears more
1472 than once, eliminate all but one copy of it. */
1475 sort_args (argc
, argv
)
1479 char **new = (char **) xmalloc (sizeof (char *) * argc
);
1480 /* For each element of argv,
1481 the corresponding element of options is:
1482 0 for an option that takes no arguments,
1483 1 for an option that takes one argument, etc.
1484 -1 for an ordinary non-option argument. */
1485 int *options
= (int *) xmalloc (sizeof (int) * argc
);
1486 int *priority
= (int *) xmalloc (sizeof (int) * argc
);
1488 int incoming_used
= 1;
1492 /* Categorize all the options,
1493 and figure out which argv elts are option arguments. */
1494 for (from
= 1; from
< argc
; from
++)
1498 if (argv
[from
][0] == '-')
1503 /* If we have found "--", don't consider
1504 any more arguments as options. */
1505 if (argv
[from
][1] == '-' && argv
[from
][2] == 0)
1507 /* Leave the "--", and everything following it, at the end. */
1508 for (; from
< argc
; from
++)
1510 priority
[from
] = -100;
1516 /* Look for a match with a known old-fashioned option. */
1517 for (i
= 0; i
< sizeof (standard_args
) / sizeof (standard_args
[0]); i
++)
1518 if (!strcmp (argv
[from
], standard_args
[i
].name
))
1520 options
[from
] = standard_args
[i
].nargs
;
1521 priority
[from
] = standard_args
[i
].priority
;
1522 if (from
+ standard_args
[i
].nargs
>= argc
)
1523 fatal ("Option `%s' requires an argument\n", argv
[from
]);
1524 from
+= standard_args
[i
].nargs
;
1528 /* Look for a match with a known long option.
1529 MATCH is -1 if no match so far, -2 if two or more matches so far,
1530 >= 0 (the table index of the match) if just one match so far. */
1531 if (argv
[from
][1] == '-')
1534 thislen
= strlen (argv
[from
]);
1535 equals
= index (argv
[from
], '=');
1537 thislen
= equals
- argv
[from
];
1540 i
< sizeof (standard_args
) / sizeof (standard_args
[0]); i
++)
1541 if (standard_args
[i
].longname
1542 && !strncmp (argv
[from
], standard_args
[i
].longname
,
1551 /* If we found exactly one match, use that. */
1554 options
[from
] = standard_args
[match
].nargs
;
1555 priority
[from
] = standard_args
[match
].priority
;
1556 /* If --OPTION=VALUE syntax is used,
1557 this option uses just one argv element. */
1560 if (from
+ options
[from
] >= argc
)
1561 fatal ("Option `%s' requires an argument\n", argv
[from
]);
1562 from
+= options
[from
];
1569 /* Copy the arguments, in order of decreasing priority, to NEW. */
1571 while (incoming_used
< argc
)
1574 int best_priority
= -9999;
1576 /* Find the highest priority remaining option.
1577 If several have equal priority, take the first of them. */
1578 for (from
= 1; from
< argc
; from
++)
1580 if (argv
[from
] != 0 && priority
[from
] > best_priority
)
1582 best_priority
= priority
[from
];
1585 /* Skip option arguments--they are tied to the options. */
1586 if (options
[from
] > 0)
1587 from
+= options
[from
];
1593 /* Copy the highest priority remaining option, with its args, to NEW.
1594 Unless it is a duplicate of the previous one. */
1595 if (! (options
[best
] == 0
1596 && ! strcmp (new[to
- 1], argv
[best
])))
1598 new[to
++] = argv
[best
];
1599 for (i
= 0; i
< options
[best
]; i
++)
1600 new[to
++] = argv
[best
+ i
+ 1];
1603 incoming_used
+= 1 + (options
[best
] > 0 ? options
[best
] : 0);
1605 /* Clear out this option in ARGV. */
1607 for (i
= 0; i
< options
[best
]; i
++)
1608 argv
[best
+ i
+ 1] = 0;
1611 /* If duplicate options were deleted, fill up extra space with null ptrs. */
1615 bcopy (new, argv
, sizeof (char *) * argc
);
1622 DEFUN ("kill-emacs", Fkill_emacs
, Skill_emacs
, 0, 1, "P",
1623 "Exit the Emacs job and kill it.\n\
1624 If ARG is an integer, return ARG as the exit program code.\n\
1625 If ARG is a string, stuff it as keyboard input.\n\n\
1626 The value of `kill-emacs-hook', if not void,\n\
1627 is a list of functions (of no args),\n\
1628 all of which are called before Emacs is actually killed.")
1632 struct gcpro gcpro1
;
1639 if (!NILP (Vrun_hooks
) && !noninteractive
)
1640 call1 (Vrun_hooks
, intern ("kill-emacs-hook"));
1644 /* Is it really necessary to do this deassign
1645 when we are going to exit anyway? */
1650 shut_down_emacs (0, 0, STRINGP (arg
) ? arg
: Qnil
);
1652 /* If we have an auto-save list file,
1653 kill it because we are exiting Emacs deliberately (not crashing).
1654 Do it after shut_down_emacs, which does an auto-save. */
1655 if (STRINGP (Vauto_save_list_file_name
))
1656 unlink (XSTRING (Vauto_save_list_file_name
)->data
);
1658 exit (INTEGERP (arg
) ? XINT (arg
)
1669 /* Perform an orderly shutdown of Emacs. Autosave any modified
1670 buffers, kill any child processes, clean up the terminal modes (if
1671 we're in the foreground), and other stuff like that. Don't perform
1672 any redisplay; this may be called when Emacs is shutting down in
1673 the background, or after its X connection has died.
1675 If SIG is a signal number, print a message for it.
1677 This is called by fatal signal handlers, X protocol error handlers,
1681 shut_down_emacs (sig
, no_x
, stuff
)
1685 /* Prevent running of hooks from now on. */
1688 /* If we are controlling the terminal, reset terminal modes */
1689 #ifdef EMACS_HAVE_TTY_PGRP
1691 int pgrp
= EMACS_GETPGRP (0);
1694 if (EMACS_GET_TTY_PGRP (0, &tpgrp
) != -1
1699 if (sig
&& sig
!= SIGTERM
)
1700 fprintf (stderr
, "Fatal error (%d).", sig
);
1708 stuff_buffered_input (stuff
);
1710 kill_buffer_processes (Qnil
);
1711 Fdo_auto_save (Qt
, Qnil
);
1713 #ifdef CLASH_DETECTION
1714 unlock_all_files ();
1718 kill_vms_processes ();
1721 #if 0 /* This triggers a bug in XCloseDisplay and is not needed. */
1722 #ifdef HAVE_X_WINDOWS
1723 /* It's not safe to call intern here. Maybe we are crashing. */
1724 if (!noninteractive
&& SYMBOLP (Vwindow_system
)
1725 && XSYMBOL (Vwindow_system
)->name
->size
== 1
1726 && XSYMBOL (Vwindow_system
)->name
->data
[0] == 'x'
1728 Fx_close_current_connection ();
1729 #endif /* HAVE_X_WINDOWS */
1733 /* There is a tendency for a SIGIO signal to arrive within exit,
1734 and cause a SIGHUP because the input descriptor is already closed. */
1736 signal (SIGIO
, SIG_IGN
);
1743 check_glyph_memory ();
1744 check_message_stack ();
1757 DEFUN ("dump-emacs-data", Fdump_emacs_data
, Sdump_emacs_data
, 1, 1, 0,
1758 "Dump current state of Emacs into data file FILENAME.\n\
1759 This function exists on systems that use HAVE_SHM.")
1761 Lisp_Object filename
;
1763 extern char my_edata
[];
1766 CHECK_STRING (filename
, 0);
1767 filename
= Fexpand_file_name (filename
, Qnil
);
1770 Vpurify_flag
= Qnil
;
1773 /* Tell malloc where start of impure now is */
1774 /* Also arrange for warnings when nearly out of space. */
1775 #ifndef SYSTEM_MALLOC
1776 memory_warnings (my_edata
, malloc_warning
);
1778 map_out_data (XSTRING (filename
)->data
);
1785 #else /* not HAVE_SHM */
1787 DEFUN ("dump-emacs", Fdump_emacs
, Sdump_emacs
, 2, 2, 0,
1788 "Dump current state of Emacs into executable file FILENAME.\n\
1789 Take symbols from SYMFILE (presumably the file you executed to run Emacs).\n\
1790 This is used in the file `loadup.el' when building Emacs.\n\
1792 You must run Emacs in batch mode in order to dump it.")
1794 Lisp_Object filename
, symfile
;
1796 extern char my_edata
[];
1799 int count
= specpdl_ptr
- specpdl
;
1801 if (! noninteractive
)
1802 error ("Dumping Emacs works only in batch mode");
1804 /* Bind `command-line-processed' to nil before dumping,
1805 so that the dumped Emacs will process its command line
1806 and set up to work with X windows if appropriate. */
1807 symbol
= intern ("command-line-process");
1808 specbind (symbol
, Qnil
);
1810 CHECK_STRING (filename
, 0);
1811 filename
= Fexpand_file_name (filename
, Qnil
);
1812 if (!NILP (symfile
))
1814 CHECK_STRING (symfile
, 0);
1815 if (XSTRING (symfile
)->size
)
1816 symfile
= Fexpand_file_name (symfile
, Qnil
);
1820 Vpurify_flag
= Qnil
;
1823 set_time_zone_rule (dump_tz
);
1824 #ifndef LOCALTIME_CACHE
1825 /* Force a tz reload, since set_time_zone_rule doesn't. */
1832 mapout_data (XSTRING (filename
)->data
);
1834 /* Tell malloc where start of impure now is */
1835 /* Also arrange for warnings when nearly out of space. */
1836 #ifndef SYSTEM_MALLOC
1838 /* On Windows, this was done before dumping, and that once suffices.
1839 Meanwhile, my_edata is not valid on Windows. */
1840 memory_warnings (my_edata
, malloc_warning
);
1841 #endif /* not WINDOWSNT */
1843 #ifdef DOUG_LEA_MALLOC
1844 malloc_state_ptr
= malloc_get_state ();
1846 unexec (XSTRING (filename
)->data
,
1847 !NILP (symfile
) ? XSTRING (symfile
)->data
: 0, my_edata
, 0, 0);
1848 #ifdef DOUG_LEA_MALLOC
1849 free (malloc_state_ptr
);
1851 #endif /* not VMS */
1855 return unbind_to (count
, Qnil
);
1858 #endif /* not HAVE_SHM */
1860 #endif /* not CANNOT_DUMP */
1867 decode_env_path (evarname
, defalt
)
1868 char *evarname
, *defalt
;
1870 register char *path
, *p
;
1871 Lisp_Object lpath
, element
, tem
;
1873 /* It's okay to use getenv here, because this function is only used
1874 to initialize variables when Emacs starts up, and isn't called
1877 path
= (char *) getenv (evarname
);
1883 /* Ensure values from the environment use the proper directory separator. */
1886 p
= alloca (strlen (path
) + 1);
1890 if ('/' == DIRECTORY_SEP
)
1891 dostounix_filename (path
);
1893 unixtodos_filename (path
);
1899 p
= index (path
, SEPCHAR
);
1900 if (!p
) p
= path
+ strlen (path
);
1901 element
= (p
- path
? make_string (path
, p
- path
)
1902 : build_string ("."));
1904 /* Add /: to the front of the name
1905 if it would otherwise be treated as magic. */
1906 tem
= Ffind_file_name_handler (element
, Qt
);
1908 element
= concat2 (build_string ("/:"), element
);
1910 lpath
= Fcons (element
, lpath
);
1916 return Fnreverse (lpath
);
1922 Qfile_name_handler_alist
= intern ("file-name-handler-alist");
1923 staticpro (&Qfile_name_handler_alist
);
1927 defsubr (&Sdump_emacs_data
);
1929 defsubr (&Sdump_emacs
);
1933 defsubr (&Skill_emacs
);
1935 defsubr (&Sinvocation_name
);
1936 defsubr (&Sinvocation_directory
);
1938 DEFVAR_LISP ("command-line-args", &Vcommand_line_args
,
1939 "Args passed by shell to Emacs, as a list of strings.");
1941 DEFVAR_LISP ("system-type", &Vsystem_type
,
1942 "Value is symbol indicating type of operating system you are using.");
1943 Vsystem_type
= intern (SYSTEM_TYPE
);
1945 DEFVAR_LISP ("system-configuration", &Vsystem_configuration
,
1946 "Value is string indicating configuration Emacs was built for.");
1947 Vsystem_configuration
= build_string (EMACS_CONFIGURATION
);
1949 DEFVAR_LISP ("system-configuration-options", &Vsystem_configuration_options
,
1950 "String containing the configuration options Emacs was built with.");
1951 Vsystem_configuration_options
= build_string (EMACS_CONFIG_OPTIONS
);
1953 DEFVAR_BOOL ("noninteractive", &noninteractive1
,
1954 "Non-nil means Emacs is running without interactive terminal.");
1956 DEFVAR_LISP ("kill-emacs-hook", &Vkill_emacs_hook
,
1957 "Hook to be run whenever kill-emacs is called.\n\
1958 Since kill-emacs may be invoked when the terminal is disconnected (or\n\
1959 in other similar situations), functions placed on this hook should not\n\
1960 expect to be able to interact with the user. To ask for confirmation,\n\
1961 see `kill-emacs-query-functions' instead.");
1962 Vkill_emacs_hook
= Qnil
;
1965 DEFVAR_LISP ("signal-USR1-hook", &Vsignal_USR1_hook
,
1966 "Hook to be run whenever emacs receives a USR1 signal");
1967 Vsignal_USR1_hook
= Qnil
;
1969 DEFVAR_LISP ("signal-USR2-hook", &Vsignal_USR2_hook
,
1970 "Hook to be run whenever emacs receives a USR2 signal");
1971 Vsignal_USR2_hook
= Qnil
;
1976 DEFVAR_INT ("emacs-priority", &emacs_priority
,
1977 "Priority for Emacs to run at.\n\
1978 This value is effective only if set before Emacs is dumped,\n\
1979 and only if the Emacs executable is installed with setuid to permit\n\
1980 it to change priority. (Emacs sets its uid back to the real uid.)\n\
1981 Currently, you need to define SET_EMACS_PRIORITY in `config.h'\n\
1982 before you compile Emacs, to enable the code for this feature.");
1985 DEFVAR_LISP ("path-separator", &Vpath_separator
,
1986 "The directory separator in search paths, as a string.");
1989 Vpath_separator
= make_string (&c
, 1);
1992 DEFVAR_LISP ("invocation-name", &Vinvocation_name
,
1993 "The program name that was used to run Emacs.\n\
1994 Any directory names are omitted.");
1996 DEFVAR_LISP ("invocation-directory", &Vinvocation_directory
,
1997 "The directory in which the Emacs executable was found, to run it.\n\
1998 The value is nil if that directory's name is not known.");
2000 DEFVAR_LISP ("installation-directory", &Vinstallation_directory
,
2001 "A directory within which to look for the `lib-src' and `etc' directories.\n\
2002 This is non-nil when we can't find those directories in their standard\n\
2003 installed locations, but we can find them\n\
2004 near where the Emacs executable was found.");
2005 Vinstallation_directory
= Qnil
;