/* Fully extensible Emacs, running on Unix, intended for GNU.
- Copyright (C) 1985,86,87,93,94,95,97,98,1999,2001
+ Copyright (C) 1985,86,87,93,94,95,97,98,1999,2001,02,2003
Free Software Foundation, Inc.
This file is part of GNU Emacs.
#include <sys/ioctl.h>
#endif
+#ifdef WINDOWSNT
+#include <fcntl.h>
+#endif
+
#include "lisp.h"
#include "commands.h"
#include "intervals.h"
#include "buffer.h"
+#include "window.h"
#include "systty.h"
#include "blockinput.h"
#ifdef DATA_SEG_BITS
EMACS_INT gdb_data_seg_bits = DATA_SEG_BITS;
#else
-EMACS_INT gdb_data_seg_bits = 0;
+EMACS_INT gdb_data_seg_bits = 0;
#endif
EMACS_INT PVEC_FLAG = PSEUDOVECTOR_FLAG;
Lisp_Object Vsystem_time_locale;
Lisp_Object Vprevious_system_time_locale;
-/* If non-zero, emacs should not attempt to use an window-specific code,
+/* If non-zero, emacs should not attempt to use a window-specific code,
but instead should use the virtual terminal under which it was started. */
int inhibit_window_system;
/* If nonzero, set Emacs to run at this priority. This is also used
in child_setup and sys_suspend to make sure subshells run at normal
priority; those functions have their own extern declaration. */
-int emacs_priority;
+EMACS_INT emacs_priority;
/* If non-zero, a filter or a sentinel is running. Tested to save the match
data on the first attempt to change it inside asynchronous code. */
Initialization options:\n\
\n\
--batch do not do interactive display; implies -q\n\
+--script FILE run FILE as an Emacs Lisp script.\n\
--debug-init enable Emacs Lisp debugger during init file\n\
--help display this help message and exit\n\
--multibyte, --no-unibyte run Emacs in multibyte mode\n\
--no-init-file, -q load neither ~/.emacs nor default.el\n\
--no-shared-memory, -nl do not use shared memory\n\
--no-site-file do not load site-start.el\n\
+--no-splash do not display a splash screen on startup\n\
--no-window-system, -nw don't communicate with X, ignoring $DISPLAY\n\
--terminal, -t DEVICE use DEVICE for terminal I/O\n\
--unibyte, --no-multibyte run Emacs in unibyte mode\n\
{
register int i;
Lisp_Object name, dir, tem;
- int count = specpdl_ptr - specpdl;
+ int count = SPECPDL_INDEX ();
Lisp_Object raw_name;
initial_argv = argv;
{
Lisp_Object found;
int yes = openp (Vexec_path, Vinvocation_name,
- Vexec_suffixes, &found, 1);
+ Vexec_suffixes, &found, make_number (X_OK));
if (yes == 1)
{
/* Add /: to the front of the name
{}
void __do_global_dtors ()
{}
-/* Linux has a bug in its library; avoid an error. */
+/* GNU/Linux has a bug in its library; avoid an error. */
#ifndef GNU_LINUX
char * __CTOR_LIST__[2] = { (char *) (-1), 0 };
#endif
if (!STRINGP(temp))
return REPORT_EMACS_BUG_ADDRESS;
- string = XSTRING (temp)->data;
+ string = SDATA (temp);
/* Count dots in `emacs-version'. */
while (*string)
/* ARGSUSED */
int
-main (argc, argv, envp)
+main (argc, argv
+#ifdef VMS
+, envp
+#endif
+)
int argc;
char **argv;
+#ifdef VMS
char **envp;
+#endif
{
#if GC_MARK_STACK
Lisp_Object dummy;
struct rlimit rlim;
#endif
int no_loadup = 0;
+ char *junk = 0;
#if GC_MARK_STACK
extern Lisp_Object *stack_base;
run_time_remap (argv[0]);
#endif
+#ifdef MAC_OSX
+ if (!initialized)
+ unexec_init_emacs_zone ();
+#endif
+
sort_args (argc, argv);
argc = 0;
while (argv[argc]) argc++;
}
else
{
- printf ("GNU Emacs %s\n", XSTRING (tem)->data);
- printf ("Copyright (C) 2001 Free Software Foundation, Inc.\n");
+ printf ("GNU Emacs %s\n", SDATA (tem));
+ printf ("Copyright (C) 2002 Free Software Foundation, Inc.\n");
printf ("GNU Emacs comes with ABSOLUTELY NO WARRANTY.\n");
printf ("You may redistribute copies of Emacs\n");
printf ("under the terms of the GNU General Public License.\n");
}
#endif /* NeXT */
+#ifdef MAC_OSX
+ /* Skip process serial number passed in the form -psn_x_y as
+ command-line argument. */
+ if (argc > skip_args + 1 && strncmp (argv[skip_args+1], "-psn_", 5) == 0)
+ skip_args++;
+#endif /* MAC_OSX */
+
#ifdef VMS
/* If -map specified, map the data file in. */
{
uninterrupt_malloc ();
#endif /* not SYSTEM_MALLOC */
-#ifdef MSDOS
+#if defined (MSDOS) || defined (WINDOWSNT)
/* We do all file input/output as binary files. When we need to translate
newlines, we do that manually. */
_fmode = O_BINARY;
+#endif /* MSDOS || WINDOWSNT */
+#ifdef MSDOS
#if __DJGPP__ >= 2
if (!isatty (fileno (stdin)))
setmode (fileno (stdin), O_BINARY);
noninteractive = 0;
if (argmatch (argv, argc, "-batch", "--batch", 5, NULL, &skip_args))
noninteractive = 1;
+ if (argmatch (argv, argc, "-script", "--script", 3, &junk, &skip_args))
+ {
+ noninteractive = 1; /* Set batch mode. */
+ /* Convert --script to -l, un-skip it, and sort again so that -l will be
+ handled in proper sequence. */
+ argv[skip_args - 1] = "-l";
+ skip_args -= 2;
+ sort_args (argc, argv);
+ }
/* Handle the --help option, which gives a usage message. */
if (argmatch (argv, argc, "-help", "--help", 3, NULL, &skip_args))
CANNOT_DUMP is defined. */
syms_of_keyboard ();
-#ifdef macintosh
+#ifdef MAC_OS8
/* init_window_once calls make_terminal_frame which on Mac OS
creates a full-fledge output_mac type frame. This does not
work correctly before syms_of_textprop, syms_of_macfns,
syms_of_ccl, syms_of_fontset, syms_of_xterm, syms_of_search,
- syms_of_frame, x_term_init, and init_keyboard have already
+ syms_of_frame, mac_initialize, and init_keyboard have already
been called. */
syms_of_textprop ();
syms_of_macfns ();
syms_of_search ();
syms_of_frame ();
- x_term_init ();
+ mac_initialize ();
init_keyboard ();
#endif
/* Handle --unibyte and the EMACS_UNIBYTE envvar,
but not while dumping. */
- if (
-#ifndef CANNOT_DUMP
- ! noninteractive || initialized
-#else
- 1
-#endif
- )
+ if (1)
{
int inhibit_unibyte = 0;
/* --multibyte overrides EMACS_UNIBYTE. */
if (argmatch (argv, argc, "-no-unibyte", "--no-unibyte", 4, NULL, &skip_args)
- || argmatch (argv, argc, "-multibyte", "--multibyte", 4, NULL, &skip_args))
+ || argmatch (argv, argc, "-multibyte", "--multibyte", 4, NULL, &skip_args)
+ /* Ignore EMACS_UNIBYTE before dumping. */
+ || (!initialized && noninteractive))
inhibit_unibyte = 1;
/* --unibyte requests that we set up to do everything with single-byte
Lisp_Object buffer;
buffer = Fcdr (XCAR (tail));
- /* Make all multibyte buffers unibyte. */
+ /* Make a multibyte buffer unibyte. */
if (BUF_Z_BYTE (XBUFFER (buffer)) > BUF_Z (XBUFFER (buffer)))
{
struct buffer *current = current_buffer;
set_buffer_temp (XBUFFER (buffer));
- Fset_buffer_multibyte (Qnil, Qnil);
+ Fset_buffer_multibyte (Qnil);
set_buffer_temp (current);
}
}
#endif /* MSDOS */
#ifdef WINDOWSNT
+ globals_of_w32 ();
/* Initialize environment from registry settings. */
init_environment (argv);
init_ntproc (); /* must precede init_editfns. */
#endif
+#ifdef HAVE_CARBON
+ if (initialized)
+ init_mac_osx_environment ();
+#endif
+
/* egetenv is a pretty low-level facility, which may get called in
many circumstances; it seems flimsy to put off initializing it
until calling init_callproc. */
/* The basic levels of Lisp must come first. */
/* And data must come first of all
for the sake of symbols like error-message. */
-#ifndef macintosh
- /* Called before init_window_once for Mac OS. */
+#ifndef MAC_OS8
+ /* Called before init_window_once for Mac OS Classic. */
syms_of_data ();
#endif
syms_of_alloc ();
syms_of_casetab ();
syms_of_callproc ();
syms_of_category ();
-#ifndef macintosh
- /* Called before init_window_once for Mac OS. */
+#ifndef MAC_OS8
+ /* Called before init_window_once for Mac OS Classic. */
syms_of_ccl ();
#endif
syms_of_character ();
syms_of_marker ();
syms_of_minibuf ();
syms_of_process ();
-#ifndef macintosh
- /* Called before init_window_once for Mac OS. */
+#ifndef MAC_OS8
+ /* Called before init_window_once for Mac OS Classic. */
syms_of_search ();
syms_of_frame ();
#endif
#ifdef HAVE_SOUND
syms_of_sound ();
#endif
-#ifndef macintosh
- /* Called before init_window_once for Mac OS. */
+#ifndef MAC_OS8
+ /* Called before init_window_once for Mac OS Classic. */
syms_of_textprop ();
#endif
syms_of_composite ();
syms_of_xterm ();
syms_of_xfns ();
syms_of_fontset ();
+#ifdef HAVE_X_SM
+ syms_of_xsmfns ();
+#endif
#ifdef HAVE_X11
syms_of_xselect ();
#endif
#endif /* HAVE_X_WINDOWS */
#ifndef HAVE_NTGUI
-#ifndef macintosh
+#ifndef MAC_OS
+ /* Called before init_window_once for Mac OS Classic. */
syms_of_xmenu ();
#endif
#endif
syms_of_fontset ();
#endif /* HAVE_NTGUI */
+#ifdef HAVE_CARBON
+ syms_of_macterm ();
+ syms_of_macfns ();
+ syms_of_macmenu ();
+ syms_of_fontset ();
+#endif /* HAVE_CARBON */
+
#ifdef SYMS_SYSTEM
SYMS_SYSTEM;
#endif
keys_of_keymap ();
keys_of_minibuf ();
keys_of_window ();
+ }
+ else
+ {
+ /*
+ Initialization that must be done even if the global variable
+ initialized is non zero
+ */
+#ifdef HAVE_NTGUI
+ globals_of_w32fns ();
+ globals_of_w32menu ();
+#endif /* end #ifdef HAVE_NTGUI */
}
if (!noninteractive)
#endif /* VMS */
init_display (); /* Determine terminal type. init_sys_modes uses results. */
}
-#ifndef macintosh
- /* Called before init_window_once for Mac OS. */
+#ifndef MAC_OS8
+ /* Called before init_window_once for Mac OS Classic. */
init_keyboard (); /* This too must precede init_sys_modes. */
#endif
#ifdef VMS
init_vmsproc (); /* And this too. */
#endif /* VMS */
init_sys_modes (); /* Init system terminal modes (RAW or CBREAK, etc.). */
-#ifdef HAVE_X_WINDOWS
+#if defined (HAVE_X_WINDOWS) || defined (WINDOWSNT)
init_xfns ();
#endif /* HAVE_X_WINDOWS */
init_fns ();
if (argmatch (argv, argc, "-l", "--load", 3, &file, &skip_args))
Vtop_level = Fcons (intern ("load"),
Fcons (build_string (file), Qnil));
-#ifdef CANNOT_DUMP
/* Unless next switch is -nl, load "loadup.el" first thing. */
if (! no_loadup)
Vtop_level = Fcons (intern ("load"),
Fcons (build_string ("loadup.el"), Qnil));
-#endif /* CANNOT_DUMP */
}
if (initialized)
{ "-nw", "--no-window-system", 110, 0 },
{ "-nw", "--no-windows", 110, 0 },
{ "-batch", "--batch", 100, 0 },
+ { "-script", "--script", 100, 1 },
{ "-help", "--help", 90, 0 },
{ "-no-unibyte", "--no-unibyte", 83, 0 },
{ "-multibyte", "--multibyte", 82, 0 },
{ "-unibyte", "--unibyte", 81, 0 },
{ "-no-multibyte", "--no-multibyte", 80, 0 },
-#ifdef CANNOT_DUMP
{ "-nl", "--no-loadup", 70, 0 },
-#endif
/* -d must come last before the options handled in startup.el. */
{ "-d", "--display", 60, 1 },
{ "-display", 0, 60, 1 },
{ "-q", "--no-init-file", 50, 0 },
{ "-no-init-file", 0, 50, 0 },
{ "-no-site-file", "--no-site-file", 40, 0 },
+ { "-no-splash", "--no-splash", 40, 0 },
{ "-u", "--user", 30, 1 },
{ "-user", 0, 30, 1 },
{ "-debug-init", "--debug-init", 20, 0 },
kill it because we are exiting Emacs deliberately (not crashing).
Do it after shut_down_emacs, which does an auto-save. */
if (STRINGP (Vauto_save_list_file_name))
- unlink (XSTRING (Vauto_save_list_file_name)->data);
+ unlink (SDATA (Vauto_save_list_file_name));
exit (INTEGERP (arg) ? XINT (arg)
#ifdef VMS
#ifdef HAVE_X_WINDOWS
/* It's not safe to call intern here. Maybe we are crashing. */
if (!noninteractive && SYMBOLP (Vwindow_system)
- && XSYMBOL (Vwindow_system)->name->size == 1
- && XSYMBOL (Vwindow_system)->name->data[0] == 'x'
+ && SCHARS (SYMBOL_NAME (Vwindow_system)) == 1
+ && SREF (SYMBOL_NAME (Vwindow_system), 0) == 'x'
&& ! no_x)
Fx_close_current_connection ();
#endif /* HAVE_X_WINDOWS */
#ifndef SYSTEM_MALLOC
memory_warnings (my_edata, malloc_warning);
#endif
- map_out_data (XSTRING (filename)->data);
+ map_out_data (SDATA (filename));
Vpurify_flag = tem;
extern char my_edata[];
Lisp_Object tem;
Lisp_Object symbol;
- int count = BINDING_STACK_SIZE ();
+ int count = SPECPDL_INDEX ();
check_pure_size ();
/* Bind `command-line-processed' to nil before dumping,
so that the dumped Emacs will process its command line
and set up to work with X windows if appropriate. */
- symbol = intern ("command-line-process");
+ symbol = intern ("command-line-processed");
specbind (symbol, Qnil);
CHECK_STRING (filename);
if (!NILP (symfile))
{
CHECK_STRING (symfile);
- if (XSTRING (symfile)->size)
+ if (SCHARS (symfile))
symfile = Fexpand_file_name (symfile, Qnil);
}
fflush (stdout);
#ifdef VMS
- mapout_data (XSTRING (filename)->data);
+ mapout_data (SDATA (filename));
#else
/* Tell malloc where start of impure now is. */
/* Also arrange for warnings when nearly out of space. */
#ifdef USE_MMAP_FOR_BUFFERS
mmap_set_vars (0);
#endif
- unexec (XSTRING (filename)->data,
- !NILP (symfile) ? XSTRING (symfile)->data : 0, my_edata, 0, 0);
+ unexec (SDATA (filename),
+ !NILP (symfile) ? SDATA (symfile) : 0, my_edata, 0, 0);
#ifdef USE_MMAP_FOR_BUFFERS
mmap_set_vars (1);
#endif
{
*plocale = desired_locale;
setlocale (category, (STRINGP (desired_locale)
- ? (char *)(XSTRING (desired_locale)->data)
+ ? (char *)(SDATA (desired_locale))
: ""));
}
}
/* Add /: to the front of the name
if it would otherwise be treated as magic. */
tem = Ffind_file_name_handler (element, Qt);
+
+ /* However, if the handler says "I'm safe",
+ don't bother adding /:. */
+ if (SYMBOLP (tem))
+ {
+ Lisp_Object prop;
+ prop = Fget (tem, intern ("safe-magic"));
+ if (! NILP (prop))
+ tem = Qnil;
+ }
+
if (! NILP (tem))
element = concat2 (build_string ("/:"), element);
defsubr (&Sinvocation_directory);
DEFVAR_LISP ("command-line-args", &Vcommand_line_args,
- doc: /* Args passed by shell to Emacs, as a list of strings. */);
+ doc: /* Args passed by shell to Emacs, as a list of strings.
+Many arguments are deleted from the list as they are processed. */);
DEFVAR_LISP ("system-type", &Vsystem_type,
doc: /* Value is symbol indicating type of operating system you are using. */);
doc: /* Non-nil means Emacs is running without interactive terminal. */);
DEFVAR_LISP ("kill-emacs-hook", &Vkill_emacs_hook,
- doc: /* Hook to be run whenever kill-emacs is called.
-Since kill-emacs may be invoked when the terminal is disconnected (or
+ doc: /* Hook to be run when kill-emacs is called.
+Since `kill-emacs' may be invoked when the terminal is disconnected (or
in other similar situations), functions placed on this hook should not
expect to be able to interact with the user. To ask for confirmation,
-see `kill-emacs-query-functions' instead. */);
+see `kill-emacs-query-functions' instead.
+
+The hook is not run in batch mode, i.e., if `noninteractive' is non-nil. */);
Vkill_emacs_hook = Qnil;
empty_string = build_string ("");