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>
36 #include <sys/ioctl.h>
45 #include "intervals.h"
49 #include "blockinput.h"
50 #include "syssignal.h"
52 #include "termhooks.h"
57 #include <sys/resource.h>
64 extern void malloc_warning ();
65 extern void set_time_zone_rule ();
66 extern char *index ();
67 extern char *strerror ();
69 /* Command line args from shell, as list of strings */
70 Lisp_Object Vcommand_line_args
;
72 /* The name under which Emacs was invoked, with any leading directory
74 Lisp_Object Vinvocation_name
;
76 /* The directory name from which Emacs was invoked. */
77 Lisp_Object Vinvocation_directory
;
79 /* The directory name in which to find subdirs such as lisp and etc.
80 nil means get them only from PATH_LOADSEARCH. */
81 Lisp_Object Vinstallation_directory
;
83 /* Hook run by `kill-emacs' before it does really anything. */
84 Lisp_Object Vkill_emacs_hook
;
87 /* Hooks for signal USR1 and USR2 handing */
88 Lisp_Object Vsignal_USR1_hook
;
90 Lisp_Object Vsignal_USR2_hook
;
94 /* Search path separator. */
95 Lisp_Object Vpath_separator
;
97 /* Set nonzero after Emacs has started up the first time.
98 Prevents reinitialization of the Lisp world and keymaps
99 on subsequent starts. */
102 #ifdef DOUG_LEA_MALLOC
103 /* Preserves a pointer to the memory allocated that copies that
104 static data inside glibc's malloc. */
105 void *malloc_state_ptr
;
106 /* From glibc, a routine that returns a copy of the malloc internal state. */
107 extern void *malloc_get_state ();
108 /* From glibc, a routine that overwrites the malloc internal state. */
109 extern void malloc_set_state ();
110 /* Non-zero if the MALLOC_CHECK_ enviroment variable was set while
111 dumping. Used to work around a bug in glibc's malloc. */
112 int malloc_using_checking
;
115 /* Variable whose value is symbol giving operating system type. */
116 Lisp_Object Vsystem_type
;
118 /* Variable whose value is string giving configuration built for. */
119 Lisp_Object Vsystem_configuration
;
121 /* Variable whose value is string giving configuration options,
122 for use when reporting bugs. */
123 Lisp_Object Vsystem_configuration_options
;
125 Lisp_Object Qfile_name_handler_alist
;
127 /* If non-zero, emacs should not attempt to use an window-specific code,
128 but instead should use the virtual terminal under which it was started */
129 int inhibit_window_system
;
131 /* If nonzero, set Emacs to run at this priority. This is also used
132 in child_setup and sys_suspend to make sure subshells run at normal
133 priority; Those functions have their own extern declaration. */
136 /* If non-zero a filter or a sentinel is running. Tested to save the match
137 data on the first attempt to change it inside asynchronous code. */
138 int running_asynch_code
;
142 extern int inherited_pgroup
;
145 #ifdef HAVE_X_WINDOWS
146 /* If non-zero, -d was specified, meaning we're using some window system. */
150 /* An address near the bottom of the stack.
151 Tells GC how to save a copy of the stack. */
154 #ifdef HAVE_WINDOW_SYSTEM
155 extern Lisp_Object Vwindow_system
;
156 #endif /* HAVE_WINDOW_SYSTEM */
158 extern Lisp_Object Vauto_save_list_file_name
;
160 #ifdef USG_SHARED_LIBRARIES
161 /* If nonzero, this is the place to put the end of the writable segment
164 unsigned int bss_end
= 0;
167 /* Nonzero means running Emacs without interactive terminal. */
171 /* Value of Lisp variable `noninteractive'.
172 Normally same as C variable `noninteractive'
173 but nothing terrible happens if user sets this one. */
177 /* Save argv and argc. */
181 static void sort_args ();
182 void syms_of_emacs ();
184 /* Signal code for the fatal signal that was received */
185 int fatal_error_code
;
187 /* Nonzero if handling a fatal error already */
188 int fatal_error_in_progress
;
192 handle_USR1_signal (sig
)
195 struct input_event buf
;
197 buf
.kind
= user_signal
;
199 buf
.frame_or_window
= Fselected_frame ();
203 kbd_buffer_store_event (&buf
);
209 handle_USR2_signal (sig
)
212 struct input_event buf
;
214 buf
.kind
= user_signal
;
216 buf
.frame_or_window
= Fselected_frame ();
220 kbd_buffer_store_event (&buf
);
224 /* Handle bus errors, illegal instruction, etc. */
226 fatal_error_signal (sig
)
229 fatal_error_code
= sig
;
230 signal (sig
, SIG_DFL
);
232 TOTALLY_UNBLOCK_INPUT
;
234 /* If fatal error occurs in code below, avoid infinite recursion. */
235 if (! fatal_error_in_progress
)
237 fatal_error_in_progress
= 1;
239 shut_down_emacs (sig
, 0, Qnil
);
243 LIB$
STOP (SS$_ABORT
);
245 /* Signal the same code; this time it will really be fatal.
246 Remember that since we're in a signal handler, the signal we're
247 going to send is probably blocked, so we have to unblock it if we
248 want to really receive it. */
250 sigunblock (sigmask (fatal_error_code
));
252 kill (getpid (), fatal_error_code
);
258 /* Handler for SIGDANGER. */
260 memory_warning_signal (sig
)
263 signal (sig
, memory_warning_signal
);
265 malloc_warning ("Operating system warns that virtual memory is running low.\n");
267 /* It might be unsafe to call do_auto_save now. */
268 force_auto_save_soon ();
272 /* We define abort, rather than using it from the library,
273 so that GDB can return from a breakpoint here.
274 MSDOS has its own definition on msdos.c */
276 #if ! defined (DOS_NT) && ! defined (NO_ABORT)
280 kill (getpid (), SIGABRT
);
281 /* This shouldn't be executed, but it prevents a warning. */
287 /* Code for dealing with Lisp access to the Unix command line */
290 init_cmdargs (argc
, argv
, skip_args
)
296 Lisp_Object name
, dir
, tem
;
297 int count
= specpdl_ptr
- specpdl
;
298 Lisp_Object raw_name
;
303 raw_name
= build_string (argv
[0]);
305 /* Add /: to the front of the name
306 if it would otherwise be treated as magic. */
307 tem
= Ffind_file_name_handler (raw_name
, Qt
);
309 raw_name
= concat2 (build_string ("/:"), raw_name
);
311 Vinvocation_name
= Ffile_name_nondirectory (raw_name
);
312 Vinvocation_directory
= Ffile_name_directory (raw_name
);
314 /* If we got no directory in argv[0], search PATH to find where
315 Emacs actually came from. */
316 if (NILP (Vinvocation_directory
))
319 int yes
= openp (Vexec_path
, Vinvocation_name
,
320 EXEC_SUFFIXES
, &found
, 1);
323 /* Add /: to the front of the name
324 if it would otherwise be treated as magic. */
325 tem
= Ffind_file_name_handler (found
, Qt
);
327 found
= concat2 (build_string ("/:"), found
);
328 Vinvocation_directory
= Ffile_name_directory (found
);
332 if (!NILP (Vinvocation_directory
)
333 && NILP (Ffile_name_absolute_p (Vinvocation_directory
)))
334 /* Emacs was started with relative path, like ./emacs.
336 Vinvocation_directory
= Fexpand_file_name (Vinvocation_directory
, Qnil
);
338 Vinstallation_directory
= Qnil
;
340 if (!NILP (Vinvocation_directory
))
342 dir
= Vinvocation_directory
;
343 name
= Fexpand_file_name (Vinvocation_name
, dir
);
346 Lisp_Object tem
, lib_src_exists
;
347 Lisp_Object etc_exists
, info_exists
;
349 /* See if dir contains subdirs for use by Emacs.
350 Check for the ones that would exist in a build directory,
351 not including lisp and info. */
352 tem
= Fexpand_file_name (build_string ("lib-src"), dir
);
353 lib_src_exists
= Ffile_exists_p (tem
);
356 /* MSDOS installations frequently remove lib-src, but we still
357 must set installation-directory, or else info won't find
358 its files (it uses the value of installation-directory). */
359 tem
= Fexpand_file_name (build_string ("info"), dir
);
360 info_exists
= Ffile_exists_p (tem
);
365 if (!NILP (lib_src_exists
) || !NILP (info_exists
))
367 tem
= Fexpand_file_name (build_string ("etc"), dir
);
368 etc_exists
= Ffile_exists_p (tem
);
369 if (!NILP (etc_exists
))
371 Vinstallation_directory
372 = Ffile_name_as_directory (dir
);
377 /* See if dir's parent contains those subdirs. */
378 tem
= Fexpand_file_name (build_string ("../lib-src"), dir
);
379 lib_src_exists
= Ffile_exists_p (tem
);
383 /* See the MSDOS commentary above. */
384 tem
= Fexpand_file_name (build_string ("../info"), dir
);
385 info_exists
= Ffile_exists_p (tem
);
390 if (!NILP (lib_src_exists
) || !NILP (info_exists
))
392 tem
= Fexpand_file_name (build_string ("../etc"), dir
);
393 etc_exists
= Ffile_exists_p (tem
);
394 if (!NILP (etc_exists
))
396 tem
= Fexpand_file_name (build_string (".."), dir
);
397 Vinstallation_directory
398 = Ffile_name_as_directory (tem
);
403 /* If the Emacs executable is actually a link,
404 next try the dir that the link points into. */
405 tem
= Ffile_symlink_p (name
);
408 name
= Fexpand_file_name (tem
, dir
);
409 dir
= Ffile_name_directory (name
);
416 Vcommand_line_args
= Qnil
;
418 for (i
= argc
- 1; i
>= 0; i
--)
420 if (i
== 0 || i
> skip_args
)
422 = Fcons (build_string (argv
[i
]), Vcommand_line_args
);
425 unbind_to (count
, Qnil
);
428 DEFUN ("invocation-name", Finvocation_name
, Sinvocation_name
, 0, 0, 0,
429 "Return the program name that was used to run Emacs.\n\
430 Any directory names are omitted.")
433 return Fcopy_sequence (Vinvocation_name
);
436 DEFUN ("invocation-directory", Finvocation_directory
, Sinvocation_directory
,
438 "Return the directory name in which the Emacs executable was located")
441 return Fcopy_sequence (Vinvocation_directory
);
446 #ifdef LINK_CRTL_SHARE
447 #ifdef SHARABLE_LIB_BUG
448 extern noshare
char **environ
;
449 #endif /* SHARABLE_LIB_BUG */
450 #endif /* LINK_CRTL_SHARE */
454 /* A valid but unlikely value for the TZ environment value.
455 It is OK (though a bit slower) if the user actually chooses this value. */
456 static char dump_tz
[] = "UtC0";
459 #ifndef ORDINARY_LINK
460 /* We don't include crtbegin.o and crtend.o in the link,
461 so these functions and variables might be missed.
462 Provide dummy definitions to avoid error.
463 (We don't have any real constructors or destructors.) */
465 #ifndef GCC_CTORS_IN_LIBC
466 void __do_global_ctors ()
468 void __do_global_ctors_aux ()
470 void __do_global_dtors ()
472 /* Linux has a bug in its library; avoid an error. */
474 char * __CTOR_LIST__
[2] = { (char *) (-1), 0 };
476 char * __DTOR_LIST__
[2] = { (char *) (-1), 0 };
477 #endif /* GCC_CTORS_IN_LIBC */
480 #endif /* __GNUC__ */
481 #endif /* ORDINARY_LINK */
483 /* Test whether the next argument in ARGV matches SSTR or a prefix of
484 LSTR (at least MINLEN characters). If so, then if VALPTR is non-null
485 (the argument is supposed to have a value) store in *VALPTR either
486 the next argument or the portion of this one after the equal sign.
487 ARGV is read starting at position *SKIPPTR; this index is advanced
488 by the number of arguments used.
490 Too bad we can't just use getopt for all of this, but we don't have
491 enough information to do it right. */
494 argmatch (argv
, argc
, sstr
, lstr
, minlen
, valptr
, skipptr
)
507 /* Don't access argv[argc]; give up in advance. */
508 if (argc
<= *skipptr
+ 1)
511 arg
= argv
[*skipptr
+1];
514 if (strcmp (arg
, sstr
) == 0)
518 *valptr
= argv
[*skipptr
+2];
525 arglen
= (valptr
!= NULL
&& (p
= index (arg
, '=')) != NULL
526 ? p
- arg
: strlen (arg
));
527 if (lstr
== 0 || arglen
< minlen
|| strncmp (arg
, lstr
, arglen
) != 0)
529 else if (valptr
== NULL
)
540 else if (argv
[*skipptr
+2] != NULL
)
542 *valptr
= argv
[*skipptr
+2];
552 #ifdef DOUG_LEA_MALLOC
554 /* malloc can be invoked even before main (e.g. by the dynamic
555 linker), so the dumped malloc state must be restored as early as
556 possible using this special hook. */
559 malloc_initialize_hook ()
561 extern char **environ
;
565 if (!malloc_using_checking
)
566 /* Work around a bug in glibc's malloc. MALLOC_CHECK_ must be
567 ignored if the heap to be restored was constructed without
568 malloc checking. Can't use unsetenv, since that calls malloc. */
572 for (p
= environ
; *p
; p
++)
573 if (strncmp (*p
, "MALLOC_CHECK_=", 14) == 0)
582 malloc_set_state (malloc_state_ptr
);
583 free (malloc_state_ptr
);
586 malloc_using_checking
= getenv ("MALLOC_CHECK_") != NULL
;
589 void (*__malloc_initialize_hook
) () = malloc_initialize_hook
;
591 #endif /* DOUG_LEA_MALLOC */
595 main (argc
, argv
, envp
)
600 char stack_bottom_variable
;
604 #ifdef HAVE_SETRLIMIT
609 #ifdef LINUX_SBRK_BUG
613 #ifdef RUN_TIME_REMAP
615 run_time_remap (argv
[0]);
618 sort_args (argc
, argv
);
620 while (argv
[argc
]) argc
++;
622 if (argmatch (argv
, argc
, "-version", "--version", 3, NULL
, &skip_args
)
623 /* We don't know the version number unless this is a dumped Emacs.
624 So ignore --version otherwise. */
628 tem
= Fsymbol_value (intern ("emacs-version"));
631 fprintf (stderr
, "Invalid value of `emacs-version'\n");
636 printf ("GNU Emacs %s\n", XSTRING (tem
)->data
);
637 printf ("Copyright (C) 1999 Free Software Foundation, Inc.\n");
638 printf ("GNU Emacs comes with ABSOLUTELY NO WARRANTY.\n");
639 printf ("You may redistribute copies of Emacs\n");
640 printf ("under the terms of the GNU General Public License.\n");
641 printf ("For more information about these matters, ");
642 printf ("see the file named COPYING.\n");
647 /* Map in shared memory, if we are using that. */
649 if (argmatch (argv
, argc
, "-nl", "--no-shared-memory", 6, NULL
, &skip_args
))
652 /* The shared memory was just restored, which clobbered this. */
658 /* The shared memory was just restored, which clobbered this. */
665 extern int malloc_cookie
;
666 /* This helps out unexnext.c. */
668 if (malloc_jumpstart (malloc_cookie
) != 0)
669 printf ("malloc jumpstart failed!\n");
674 /* If -map specified, map the data file in */
677 if (argmatch (argv
, argc
, "-map", "--map-data", 3, &mapin_file
, &skip_args
))
681 #ifdef LINK_CRTL_SHARE
682 #ifdef SHARABLE_LIB_BUG
683 /* Bletcherous shared libraries! */
685 stdin
= fdopen (0, "r");
687 stdout
= fdopen (1, "w");
689 stderr
= fdopen (2, "w");
692 #endif /* SHARABLE_LIB_BUG */
693 #endif /* LINK_CRTL_SHARE */
696 #if defined (HAVE_SETRLIMIT) && defined (RLIMIT_STACK)
697 /* Extend the stack space available.
698 Don't do that if dumping, since some systems (e.g. DJGPP)
699 might define a smaller stack limit at that time. */
702 && (!noninteractive
|| initialized
)
704 && !getrlimit (RLIMIT_STACK
, &rlim
))
707 extern int re_max_failures
;
708 /* Approximate the amount regex.c needs per unit of re_max_failures. */
709 int ratio
= 20 * sizeof (char *);
710 /* Then add 33% to cover the size of the smaller stacks that regex.c
711 successively allocates and discards, on its way to the maximum. */
713 /* Add in some extra to cover
714 what we're likely to use for other reasons. */
715 newlim
= re_max_failures
* ratio
+ 200000;
717 /* NetBSD (at least NetBSD 1.2G and former) has a bug in its
718 stack allocation routine for new process that the allocation
719 fails if stack limit is not on page boundary. So, round up the
720 new limit to page boundary. */
721 newlim
= (newlim
+ getpagesize () - 1) / getpagesize () * getpagesize();
723 if (newlim
> rlim
.rlim_max
)
725 newlim
= rlim
.rlim_max
;
726 /* Don't let regex.c overflow the stack we have. */
727 re_max_failures
= (newlim
- 200000) / ratio
;
729 if (rlim
.rlim_cur
< newlim
)
730 rlim
.rlim_cur
= newlim
;
732 setrlimit (RLIMIT_STACK
, &rlim
);
734 #endif /* HAVE_SETRLIMIT and RLIMIT_STACK */
736 /* Record (approximately) where the stack begins. */
737 stack_bottom
= &stack_bottom_variable
;
739 #ifdef USG_SHARED_LIBRARIES
741 brk ((void *)bss_end
);
746 #ifndef SYSTEM_MALLOC
747 /* Arrange to get warning messages as memory fills up. */
748 memory_warnings (0, malloc_warning
);
750 /* Call malloc at least once, to run the initial __malloc_hook.
751 Also call realloc and free for consistency. */
752 free (realloc (malloc (4), 4));
754 /* Arrange to disable interrupt input inside malloc etc. */
755 uninterrupt_malloc ();
756 #endif /* not SYSTEM_MALLOC */
759 /* We do all file input/output as binary files. When we need to translate
760 newlines, we do that manually. */
764 if (!isatty (fileno (stdin
)))
765 setmode (fileno (stdin
), O_BINARY
);
766 if (!isatty (fileno (stdout
)))
769 setmode (fileno (stdout
), O_BINARY
);
771 #else /* not __DJGPP__ >= 2 */
772 (stdin
)->_flag
&= ~_IOTEXT
;
773 (stdout
)->_flag
&= ~_IOTEXT
;
774 (stderr
)->_flag
&= ~_IOTEXT
;
775 #endif /* not __DJGPP__ >= 2 */
778 #ifdef SET_EMACS_PRIORITY
780 nice (emacs_priority
);
782 #endif /* SET_EMACS_PRIORITY */
784 #ifdef EXTRA_INITIALIZE
788 inhibit_window_system
= 0;
790 /* Handle the -t switch, which specifies filename to use as terminal */
794 if (argmatch (argv
, argc
, "-t", "--terminal", 4, &term
, &skip_args
))
799 result
= open (term
, O_RDWR
, 2 );
802 char *errstring
= strerror (errno
);
803 fprintf (stderr
, "emacs: %s: %s\n", term
, errstring
);
809 fprintf (stderr
, "emacs: %s: not a tty\n", term
);
812 fprintf (stderr
, "Using %s\n", term
);
813 #ifdef HAVE_WINDOW_SYSTEM
814 inhibit_window_system
= 1; /* -t => -nw */
821 if (argmatch (argv
, argc
, "-nw", "--no-windows", 6, NULL
, &skip_args
))
822 inhibit_window_system
= 1;
824 /* Handle the -batch switch, which means don't do interactive display. */
826 if (argmatch (argv
, argc
, "-batch", "--batch", 5, NULL
, &skip_args
))
829 /* Handle the --help option, which gives a usage message.. */
830 if (argmatch (argv
, argc
, "-help", "--help", 3, NULL
, &skip_args
))
833 Usage: %s [--batch] [-t term] [--terminal term]\n\
834 [-d display] [--display display] [-nw] [--no-windows]\n\
835 [-q] [--no-init-file] [-u user] [--user user] [--debug-init]\n\
836 [--unibyte] [--multibyte] [--version] [--no-site-file]\n\
837 [-f func] [--funcall func] [-l file] [--load file] [--eval expr]\n\
838 [--insert file] [+linenum] file-to-visit [--kill]\n\
839 Report bugs to bug-gnu-emacs@gnu.org. First, please see\n\
840 the Bugs section of the Emacs manual or the file BUGS.\n", argv
[0]);
844 if (! noninteractive
)
849 inherited_pgroup
= EMACS_GETPGRP (0);
850 setpgrp (0, getpid ());
853 #if defined (USG5) && defined (INTERRUPT_INPUT)
863 /* Don't catch SIGHUP if dumping. */
870 sigblock (sigmask (SIGHUP
));
871 /* In --batch mode, don't catch SIGHUP if already ignored.
872 That makes nohup work. */
874 || signal (SIGHUP
, SIG_IGN
) != SIG_IGN
)
875 signal (SIGHUP
, fatal_error_signal
);
876 sigunblock (sigmask (SIGHUP
));
881 ! noninteractive
|| initialized
887 /* Don't catch these signals in batch mode if dumping.
888 On some machines, this sets static data that would make
889 signal fail to work right when the dumped Emacs is run. */
890 signal (SIGQUIT
, fatal_error_signal
);
891 signal (SIGILL
, fatal_error_signal
);
892 signal (SIGTRAP
, fatal_error_signal
);
894 signal (SIGUSR1
, handle_USR1_signal
);
896 signal (SIGUSR2
, handle_USR2_signal
);
900 signal (SIGABRT
, fatal_error_signal
);
903 signal (SIGHWE
, fatal_error_signal
);
906 signal (SIGPRE
, fatal_error_signal
);
909 signal (SIGORE
, fatal_error_signal
);
912 signal (SIGUME
, fatal_error_signal
);
915 signal (SIGDLK
, fatal_error_signal
);
918 signal (SIGCPULIM
, fatal_error_signal
);
921 /* This is missing on some systems - OS/2, for example. */
922 signal (SIGIOT
, fatal_error_signal
);
925 signal (SIGEMT
, fatal_error_signal
);
927 signal (SIGFPE
, fatal_error_signal
);
929 signal (SIGBUS
, fatal_error_signal
);
931 signal (SIGSEGV
, fatal_error_signal
);
933 signal (SIGSYS
, fatal_error_signal
);
935 signal (SIGTERM
, fatal_error_signal
);
937 signal (SIGXCPU
, fatal_error_signal
);
940 signal (SIGXFSZ
, fatal_error_signal
);
944 /* This just means available memory is getting low. */
945 signal (SIGDANGER
, memory_warning_signal
);
949 /* 20 is SIGCHLD, 21 is SIGTTIN, 22 is SIGTTOU. */
950 signal (SIGXCPU
, fatal_error_signal
);
952 signal (SIGIOINT
, fatal_error_signal
);
954 signal (SIGGRANT
, fatal_error_signal
);
955 signal (SIGRETRACT
, fatal_error_signal
);
956 signal (SIGSOUND
, fatal_error_signal
);
957 signal (SIGMSG
, fatal_error_signal
);
961 noninteractive1
= noninteractive
;
963 /* Perform basic initializations (not merely interning symbols) */
970 init_charset_once ();
972 init_syntax_once (); /* Create standard syntax table. */
973 init_category_once (); /* Create standard category table. */
974 /* Must be done before init_buffer */
975 init_casetab_once ();
976 init_buffer_once (); /* Create buffer table and some buffers */
977 init_minibuf_once (); /* Create list of minibuffers */
978 /* Must precede init_window_once */
980 /* Call syms_of_xfaces before init_window_once because that
981 function creates Vterminal_frame. Termcap frames now use
982 faces, and the face implementation uses some symbols as
988 init_window_once (); /* Init the window system */
989 init_fileio_once (); /* Must precede any path manipulation. */
996 #ifdef CLASH_DETECTION
999 running_asynch_code
= 0;
1001 /* Handle --unibyte and the EMACS_UNIBYTE envvar,
1002 but not while dumping. */
1005 ! noninteractive
|| initialized
1011 int inhibit_unibyte
= 0;
1013 /* --multibyte overrides EMACS_UNIBYTE. */
1014 if (argmatch (argv
, argc
, "-no-unibyte", "--no-unibyte", 4, NULL
, &skip_args
)
1015 || argmatch (argv
, argc
, "-multibyte", "--multibyte", 4, NULL
, &skip_args
))
1016 inhibit_unibyte
= 1;
1018 /* --unibyte requests that we set up to do everything with single-byte
1019 buffers and strings. We need to handle this before calling
1020 init_lread, init_editfns and other places that generate Lisp strings
1021 from text in the environment. */
1022 /* Actually this shouldn't be needed as of 20.4 in a generally
1023 unibyte environment. As handa says, environment values
1024 aren't now decoded; also existing buffers are now made
1025 unibyte during startup if .emacs sets unibyte. Tested with
1026 8-bit data in environment variables and /etc/passwd, setting
1027 unibyte and Latin-1 in .emacs. -- Dave Love */
1028 if (argmatch (argv
, argc
, "-unibyte", "--unibyte", 4, NULL
, &skip_args
)
1029 || argmatch (argv
, argc
, "-no-multibyte", "--no-multibyte", 4, NULL
, &skip_args
)
1030 || (getenv ("EMACS_UNIBYTE") && !inhibit_unibyte
))
1032 Lisp_Object old_log_max
;
1033 Lisp_Object symbol
, tail
;
1035 symbol
= intern ("default-enable-multibyte-characters");
1036 Fset (symbol
, Qnil
);
1040 /* Erase pre-dump messages in *Messages* now so no abort. */
1041 old_log_max
= Vmessage_log_max
;
1042 XSETFASTINT (Vmessage_log_max
, 0);
1043 message_dolog ("", 0, 1, 0);
1044 Vmessage_log_max
= old_log_max
;
1047 for (tail
= Vbuffer_alist
; CONSP (tail
);
1048 tail
= XCONS (tail
)->cdr
)
1052 buffer
= Fcdr (XCONS (tail
)->car
);
1053 /* Verify that all buffers are empty now, as they
1055 if (BUF_Z (XBUFFER (buffer
)) > BUF_BEG (XBUFFER (buffer
)))
1057 /* It is safe to do this crudely in an empty buffer. */
1058 XBUFFER (buffer
)->enable_multibyte_characters
= Qnil
;
1064 = !argmatch (argv
, argc
, "-nl", "--no-loadup", 6, NULL
, &skip_args
);
1067 #ifdef HAVE_X_WINDOWS
1068 /* Stupid kludge to catch command-line display spec. We can't
1069 handle this argument entirely in window system dependent code
1070 because we don't even know which window system dependent code
1071 to run until we've recognized this argument. */
1073 char *displayname
= 0;
1075 int count_before
= skip_args
;
1077 /* Skip any number of -d options, but only use the last one. */
1080 int count_before_this
= skip_args
;
1082 if (argmatch (argv
, argc
, "-d", "--display", 3, &displayname
, &skip_args
))
1084 else if (argmatch (argv
, argc
, "-display", 0, 3, &displayname
, &skip_args
))
1089 count_before
= count_before_this
;
1092 /* If we have the form --display=NAME,
1093 convert it into -d name.
1094 This requires inserting a new element into argv. */
1095 if (displayname
!= 0 && skip_args
- count_before
== 1)
1097 char **new = (char **) xmalloc (sizeof (char *) * (argc
+ 2));
1100 for (j
= 0; j
< count_before
+ 1; j
++)
1102 new[count_before
+ 1] = "-d";
1103 new[count_before
+ 2] = displayname
;
1104 for (j
= count_before
+ 2; j
<argc
; j
++)
1105 new[j
+ 1] = argv
[j
];
1109 /* Change --display to -d, when its arg is separate. */
1110 else if (displayname
!= 0 && skip_args
> count_before
1111 && argv
[count_before
+ 1][1] == '-')
1112 argv
[count_before
+ 1] = "-d";
1114 /* Don't actually discard this arg. */
1115 skip_args
= count_before
;
1119 /* argmatch must not be used after here,
1120 except when bulding temacs
1121 because the -d argument has not been skipped in skip_args. */
1124 /* Call early 'cause init_environment needs it. */
1126 /* Set defaults for several environment variables. */
1128 init_environment (argc
, argv
, skip_args
);
1134 /* Initialize environment from registry settings. */
1135 init_environment (argv
);
1136 init_ntproc (); /* must precede init_editfns */
1139 /* egetenv is a pretty low-level facility, which may get called in
1140 many circumstances; it seems flimsy to put off initializing it
1141 until calling init_callproc. */
1142 set_process_environment ();
1143 /* AIX crashes are reported in system versions 3.2.3 and 3.2.4
1144 if this is not done. Do it after set_process_environment so that we
1145 don't pollute Vprocess_environment. */
1150 init_buffer (); /* Init default directory of main buffer */
1152 init_callproc_1 (); /* Must precede init_cmdargs and init_sys_modes. */
1153 init_cmdargs (argc
, argv
, skip_args
); /* Must precede init_lread. */
1157 /* Erase any pre-dump messages in the message log, to avoid confusion */
1158 Lisp_Object old_log_max
;
1159 old_log_max
= Vmessage_log_max
;
1160 XSETFASTINT (Vmessage_log_max
, 0);
1161 message_dolog ("", 0, 1, 0);
1162 Vmessage_log_max
= old_log_max
;
1165 init_callproc (); /* Must follow init_cmdargs but not init_sys_modes. */
1168 /* Intern the names of all standard functions and variables;
1169 define standard keys. */
1173 /* The basic levels of Lisp must come first */
1174 /* And data must come first of all
1175 for the sake of symbols like error-message */
1182 syms_of_floatfns ();
1186 syms_of_bytecode ();
1188 syms_of_casefiddle ();
1190 syms_of_callproc ();
1191 syms_of_category ();
1195 #ifndef NO_DIR_LIBRARY
1197 #endif /* not NO_DIR_LIBRARY */
1203 syms_of_coding (); /* This should be after syms_of_fileio. */
1204 #ifdef CLASH_DETECTION
1205 syms_of_filelock ();
1206 #endif /* CLASH_DETECTION */
1209 syms_of_keyboard ();
1214 syms_of_mocklisp ();
1225 /* Only defined if Emacs is compiled with USE_TEXT_PROPERTIES */
1226 syms_of_textprop ();
1232 #endif /* WINDOWSNT */
1235 #ifdef HAVE_X_WINDOWS
1242 #endif /* HAVE_X_WINDOWS */
1251 syms_of_w32faces ();
1252 syms_of_w32select ();
1255 #endif /* HAVE_NTGUI */
1265 keys_of_casefiddle ();
1268 keys_of_keyboard ();
1276 if (!noninteractive
)
1279 init_vms_input ();/* init_display calls get_frame_size, that needs this */
1281 init_display (); /* Determine terminal type. init_sys_modes uses results */
1283 init_keyboard (); /* This too must precede init_sys_modes */
1285 init_vmsproc (); /* And this too. */
1287 init_sys_modes (); /* Init system terminal modes (RAW or CBREAK, etc.) */
1288 #ifdef HAVE_X_WINDOWS
1290 #endif /* HAVE_X_WINDOWS */
1295 #ifdef LISP_FLOAT_TYPE
1309 /* Handle -l loadup, args passed by Makefile. */
1310 if (argmatch (argv
, argc
, "-l", "--load", 3, &file
, &skip_args
))
1311 Vtop_level
= Fcons (intern ("load"),
1312 Fcons (build_string (file
), Qnil
));
1314 /* Unless next switch is -nl, load "loadup.el" first thing. */
1316 Vtop_level
= Fcons (intern ("load"),
1317 Fcons (build_string ("loadup.el"), Qnil
));
1318 #endif /* CANNOT_DUMP */
1325 /* If the execution TZ happens to be the same as the dump TZ,
1326 change it to some other value and then change it back,
1327 to force the underlying implementation to reload the TZ info.
1328 This is needed on implementations that load TZ info from files,
1329 since the TZ file contents may differ between dump and execution. */
1330 char *tz
= getenv ("TZ");
1331 if (tz
&& !strcmp (tz
, dump_tz
))
1341 /* Gerd Moellmann <gerd@acm.org> says this makes profiling work on
1342 FreeBSD. It might work on some other systems too.
1343 Give it a try and tell me if it works on your system. */
1348 extern void _mcleanup ();
1350 extern void safe_bcopy ();
1352 /* This uses safe_bcopy because that function comes first in the
1353 Emacs executable. It might be better to use something that
1354 gives the start of the text segment, but start_of_text is not
1355 defined on all systems now. */
1356 monstartup (safe_bcopy
, &etext
);
1365 #ifdef LOCALTIME_CACHE
1366 /* Some versions of localtime have a bug. They cache the value of the time
1367 zone rather than looking it up every time. Since localtime() is
1368 called to bolt the undumping time into the undumped emacs, this
1369 results in localtime ignoring the TZ environment variable.
1370 This flushes the new TZ value into localtime. */
1372 #endif /* defined (LOCALTIME_CACHE) */
1374 /* Enter editor command loop. This never returns. */
1379 /* Sort the args so we can find the most important ones
1380 at the beginning of argv. */
1382 /* First, here's a table of all the standard options. */
1384 struct standard_args
1392 struct standard_args standard_args
[] =
1394 { "-version", "--version", 150, 0 },
1396 { "-nl", "--no-shared-memory", 140, 0 },
1399 { "-map", "--map-data", 130, 0 },
1401 { "-t", "--terminal", 120, 1 },
1402 { "-nw", "--no-windows", 110, 0 },
1403 { "-batch", "--batch", 100, 0 },
1404 { "-help", "--help", 90, 0 },
1405 { "-no-unibyte", "--no-unibyte", 83, 0 },
1406 { "-multibyte", "--multibyte", 82, 0 },
1407 { "-unibyte", "--unibyte", 81, 0 },
1408 { "-no-multibyte", "--no-multibyte", 80, 0 },
1410 { "-nl", "--no-loadup", 70, 0 },
1412 /* -d must come last before the options handled in startup.el. */
1413 { "-d", "--display", 60, 1 },
1414 { "-display", 0, 60, 1 },
1415 /* Now for the options handled in startup.el. */
1416 { "-q", "--no-init-file", 50, 0 },
1417 { "-no-init-file", 0, 50, 0 },
1418 { "-no-site-file", "--no-site-file", 40, 0 },
1419 { "-u", "--user", 30, 1 },
1420 { "-user", 0, 30, 1 },
1421 { "-debug-init", "--debug-init", 20, 0 },
1422 { "-i", "--icon-type", 15, 0 },
1423 { "-itype", 0, 15, 0 },
1424 { "-iconic", "--iconic", 15, 0 },
1425 { "-bg", "--background-color", 10, 1 },
1426 { "-background", 0, 10, 1 },
1427 { "-fg", "--foreground-color", 10, 1 },
1428 { "-foreground", 0, 10, 1 },
1429 { "-bd", "--border-color", 10, 1 },
1430 { "-bw", "--border-width", 10, 1 },
1431 { "-ib", "--internal-border", 10, 1 },
1432 { "-ms", "--mouse-color", 10, 1 },
1433 { "-cr", "--cursor-color", 10, 1 },
1434 { "-fn", "--font", 10, 1 },
1435 { "-font", 0, 10, 1 },
1436 { "-g", "--geometry", 10, 1 },
1437 { "-geometry", 0, 10, 1 },
1438 { "-T", "--title", 10, 1 },
1439 { "-title", 0, 10, 1 },
1440 { "-name", "--name", 10, 1 },
1441 { "-xrm", "--xrm", 10, 1 },
1442 { "-r", "--reverse-video", 5, 0 },
1444 { "-reverse", 0, 5, 0 },
1445 { "-hb", "--horizontal-scroll-bars", 5, 0 },
1446 { "-vb", "--vertical-scroll-bars", 5, 0 },
1447 /* These have the same priority as ordinary file name args,
1448 so they are not reordered with respect to those. */
1449 { "-L", "--directory", 0, 1 },
1450 { "-directory", 0, 0, 1 },
1451 { "-l", "--load", 0, 1 },
1452 { "-load", 0, 0, 1 },
1453 { "-f", "--funcall", 0, 1 },
1454 { "-funcall", 0, 0, 1 },
1455 { "-eval", "--eval", 0, 1 },
1456 { "-find-file", "--find-file", 0, 1 },
1457 { "-visit", "--visit", 0, 1 },
1458 { "-insert", "--insert", 0, 1 },
1459 /* This should be processed after ordinary file name args and the like. */
1460 { "-kill", "--kill", -10, 0 },
1463 /* Reorder the elements of ARGV (assumed to have ARGC elements)
1464 so that the highest priority ones come first.
1465 Do not change the order of elements of equal priority.
1466 If an option takes an argument, keep it and its argument together.
1468 If an option that takes no argument appears more
1469 than once, eliminate all but one copy of it. */
1472 sort_args (argc
, argv
)
1476 char **new = (char **) xmalloc (sizeof (char *) * argc
);
1477 /* For each element of argv,
1478 the corresponding element of options is:
1479 0 for an option that takes no arguments,
1480 1 for an option that takes one argument, etc.
1481 -1 for an ordinary non-option argument. */
1482 int *options
= (int *) xmalloc (sizeof (int) * argc
);
1483 int *priority
= (int *) xmalloc (sizeof (int) * argc
);
1485 int incoming_used
= 1;
1488 int end_of_options
= argc
;
1490 /* Categorize all the options,
1491 and figure out which argv elts are option arguments. */
1492 for (from
= 1; from
< argc
; from
++)
1496 if (argv
[from
][0] == '-')
1501 /* If we have found "--", don't consider
1502 any more arguments as options. */
1503 if (argv
[from
][1] == '-' && argv
[from
][2] == 0)
1505 /* Leave the "--", and everything following it, at the end. */
1506 for (; from
< argc
; from
++)
1508 priority
[from
] = -100;
1514 /* Look for a match with a known old-fashioned option. */
1515 for (i
= 0; i
< sizeof (standard_args
) / sizeof (standard_args
[0]); i
++)
1516 if (!strcmp (argv
[from
], standard_args
[i
].name
))
1518 options
[from
] = standard_args
[i
].nargs
;
1519 priority
[from
] = standard_args
[i
].priority
;
1520 if (from
+ standard_args
[i
].nargs
>= argc
)
1521 fatal ("Option `%s' requires an argument\n", argv
[from
]);
1522 from
+= standard_args
[i
].nargs
;
1526 /* Look for a match with a known long option.
1527 MATCH is -1 if no match so far, -2 if two or more matches so far,
1528 >= 0 (the table index of the match) if just one match so far. */
1529 if (argv
[from
][1] == '-')
1532 thislen
= strlen (argv
[from
]);
1533 equals
= index (argv
[from
], '=');
1535 thislen
= equals
- argv
[from
];
1538 i
< sizeof (standard_args
) / sizeof (standard_args
[0]); i
++)
1539 if (standard_args
[i
].longname
1540 && !strncmp (argv
[from
], standard_args
[i
].longname
,
1549 /* If we found exactly one match, use that. */
1552 options
[from
] = standard_args
[match
].nargs
;
1553 priority
[from
] = standard_args
[match
].priority
;
1554 /* If --OPTION=VALUE syntax is used,
1555 this option uses just one argv element. */
1558 if (from
+ options
[from
] >= argc
)
1559 fatal ("Option `%s' requires an argument\n", argv
[from
]);
1560 from
+= options
[from
];
1567 /* Copy the arguments, in order of decreasing priority, to NEW. */
1569 while (incoming_used
< argc
)
1572 int best_priority
= -9999;
1574 /* Find the highest priority remaining option.
1575 If several have equal priority, take the first of them. */
1576 for (from
= 1; from
< argc
; from
++)
1578 if (argv
[from
] != 0 && priority
[from
] > best_priority
)
1580 best_priority
= priority
[from
];
1583 /* Skip option arguments--they are tied to the options. */
1584 if (options
[from
] > 0)
1585 from
+= options
[from
];
1591 /* Copy the highest priority remaining option, with its args, to NEW.
1592 Unless it is a duplicate of the previous one. */
1593 if (! (options
[best
] == 0
1594 && ! strcmp (new[to
- 1], argv
[best
])))
1596 new[to
++] = argv
[best
];
1597 for (i
= 0; i
< options
[best
]; i
++)
1598 new[to
++] = argv
[best
+ i
+ 1];
1601 incoming_used
+= 1 + (options
[best
] > 0 ? options
[best
] : 0);
1603 /* Clear out this option in ARGV. */
1605 for (i
= 0; i
< options
[best
]; i
++)
1606 argv
[best
+ i
+ 1] = 0;
1609 /* If duplicate options were deleted, fill up extra space with null ptrs. */
1613 bcopy (new, argv
, sizeof (char *) * argc
);
1620 DEFUN ("kill-emacs", Fkill_emacs
, Skill_emacs
, 0, 1, "P",
1621 "Exit the Emacs job and kill it.\n\
1622 If ARG is an integer, return ARG as the exit program code.\n\
1623 If ARG is a string, stuff it as keyboard input.\n\n\
1624 The value of `kill-emacs-hook', if not void,\n\
1625 is a list of functions (of no args),\n\
1626 all of which are called before Emacs is actually killed.")
1630 Lisp_Object hook
, hook1
;
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
;