X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/fd95644b937fb3e6e1285b21c2fc1ab901199e87..b78f97676f9c1e47c127275ae542f344f300310d:/src/emacs.c diff --git a/src/emacs.c b/src/emacs.c index 4ebf136063..71ffa998bf 100644 --- a/src/emacs.c +++ b/src/emacs.c @@ -1,7 +1,7 @@ /* Fully extensible Emacs, running on Unix, intended for GNU. Copyright (C) 1985, 1986, 1987, 1993, 1994, 1995, 1997, 1998, 1999, - 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 - Free Software Foundation, Inc. + 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, + 2010 Free Software Foundation, Inc. This file is part of GNU Emacs. @@ -26,6 +26,7 @@ along with GNU Emacs. If not, see . */ #include #include +#include #ifdef HAVE_UNISTD_H #include @@ -106,7 +107,7 @@ int gdb_use_union = 1; #endif EMACS_INT gdb_valbits = VALBITS; EMACS_INT gdb_gctypebits = GCTYPEBITS; -#ifdef DATA_SEG_BITS +#if defined (DATA_SEG_BITS) && ! defined (USE_LSB_TAG) EMACS_INT gdb_data_seg_bits = DATA_SEG_BITS; #else EMACS_INT gdb_data_seg_bits = 0; @@ -156,7 +157,7 @@ void *malloc_state_ptr; extern void *malloc_get_state (); /* From glibc, a routine that overwrites the malloc internal state. */ extern int malloc_set_state (); -/* Non-zero if the MALLOC_CHECK_ enviroment variable was set while +/* Non-zero if the MALLOC_CHECK_ environment variable was set while dumping. Used to work around a bug in glibc's malloc. */ int malloc_using_checking; #endif @@ -235,6 +236,9 @@ int noninteractive; int noninteractive1; +/* Nonzero means Emacs was run in --quick mode. */ +int inhibit_x_resources; + /* Name for the server started by the daemon.*/ static char *daemon_name; @@ -267,7 +271,6 @@ Initialization options:\n\ --daemon start a server in the background\n\ --debug-init enable Emacs Lisp debugger for init file\n\ --display, -d DISPLAY use X server DISPLAY\n\ ---multibyte, --no-unibyte inhibit the effect of EMACS_UNIBYTE\n\ --no-desktop do not load a saved desktop\n\ --no-init-file, -q load neither ~/.emacs nor default.el\n\ --no-shared-memory, -nl do not use shared memory\n\ @@ -277,7 +280,6 @@ Initialization options:\n\ --quick, -Q equivalent to -q --no-site-file --no-splash\n\ --script FILE run FILE as an Emacs Lisp script\n\ --terminal, -t DEVICE use DEVICE for terminal I/O\n\ ---unibyte, --no-multibyte run Emacs in unibyte mode\n\ --user, -u USER load ~USER/.emacs instead of your own\n\ \n%s" @@ -317,6 +319,7 @@ Display options:\n\ --fullheight, -fh make the first frame high as the screen\n\ --fullscreen, -fs make first frame fullscreen\n\ --fullwidth, -fw make the first frame wide as the screen\n\ +--maximized, -mm make the first frame maximized\n\ --geometry, -g GEOMETRY window geometry\n\ --no-bitmap-icon, -nbi do not use picture of gnu for Emacs icon\n\ --iconic start Emacs in iconified state\n\ @@ -744,7 +747,7 @@ void (*__malloc_initialize_hook) () = malloc_initialize_hook; #define REPORT_EMACS_BUG_ADDRESS "bug-gnu-emacs@gnu.org" -#define REPORT_EMACS_BUG_PRETEST_ADDRESS "emacs-pretest-bug@gnu.org" +#define REPORT_EMACS_BUG_PRETEST_ADDRESS "bug-gnu-emacs@gnu.org" /* This function is used to determine an address to which bug report should be sent. */ @@ -797,12 +800,20 @@ main (int argc, char **argv) int no_loadup = 0; char *junk = 0; char *dname_arg = 0; +#ifdef NS_IMPL_COCOA + char dname_arg2[80]; +#endif #if GC_MARK_STACK extern Lisp_Object *stack_base; stack_base = &dummy; #endif +#if defined (USE_GTK) && defined (G_SLICE_ALWAYS_MALLOC) + /* This is used by the Cygwin build. */ + setenv ("G_SLICE", "always-malloc", 1); +#endif + if (!initialized) { extern char my_endbss[]; @@ -840,8 +851,8 @@ main (int argc, char **argv) && initialized) { Lisp_Object tem, tem2; - tem = Fsymbol_value (intern ("emacs-version")); - tem2 = Fsymbol_value (intern ("emacs-copyright")); + tem = Fsymbol_value (intern_c_string ("emacs-version")); + tem2 = Fsymbol_value (intern_c_string ("emacs-copyright")); if (!STRINGP (tem)) { fprintf (stderr, "Invalid value of `emacs-version'\n"); @@ -1108,7 +1119,20 @@ main (int argc, char **argv) exit (1); } +#ifndef NS_IMPL_COCOA f = fork (); +#else /* NS_IMPL_COCOA */ + /* Under Cocoa we must do fork+exec as CoreFoundation lib fails in + forked process: http://developer.apple.com/ReleaseNotes/ + CoreFoundation/CoreFoundation.html) + We mark being in the exec'd process by a daemon name argument of + form "--daemon=\nFD0,FD1\nNAME" where FD are the pipe file descriptors, + NAME is the original daemon name, if any. */ + if (!dname_arg || !strchr (dname_arg, '\n')) + f = fork (); /* in orig */ + else + f = 0; /* in exec'd */ +#endif /* NS_IMPL_COCOA */ if (f > 0) { int retval; @@ -1144,6 +1168,42 @@ main (int argc, char **argv) exit (1); } +#ifdef NS_IMPL_COCOA + { + /* In orig process, forked as child, OR in exec'd. */ + if (!dname_arg || !strchr (dname_arg, '\n')) + { /* In orig, child: now exec w/special daemon name. */ + char fdStr[80]; + + if (dname_arg && strlen (dname_arg) > 70) + { + fprintf (stderr, "daemon: child name too long\n"); + exit (1); + } + + sprintf (fdStr, "--daemon=\n%d,%d\n%s", daemon_pipe[0], + daemon_pipe[1], dname_arg ? dname_arg : ""); + argv[skip_args] = fdStr; + + execv (argv[0], argv); + fprintf (stderr, "emacs daemon: exec failed: %d\n", errno); + exit (1); + } + + /* In exec'd: parse special dname into pipe and name info. */ + if (!dname_arg || !strchr (dname_arg, '\n') + || strlen (dname_arg) < 1 || strlen (dname_arg) > 70) + { + fprintf (stderr, "emacs daemon: daemon name absent or too long\n"); + exit(1); + } + dname_arg2[0] = '\0'; + sscanf (dname_arg, "\n%d,%d\n%s", &(daemon_pipe[0]), &(daemon_pipe[1]), + dname_arg2); + dname_arg = strlen (dname_arg2) ? dname_arg2 : NULL; + } +#endif /* NS_IMPL_COCOA */ + if (dname_arg) daemon_name = xstrdup (dname_arg); /* Close unused reading end of the pipe. */ @@ -1329,7 +1389,6 @@ main (int argc, char **argv) syms_of_coding (); /* This should be after syms_of_fileio. */ init_window_once (); /* Init the window system. */ - init_fileio_once (); /* Must precede any path manipulation. */ #ifdef HAVE_WINDOW_SYSTEM init_fringe_once (); /* Swap bitmaps if necessary. */ #endif /* HAVE_WINDOW_SYSTEM */ @@ -1382,8 +1441,8 @@ main (int argc, char **argv) Lisp_Object old_log_max; Lisp_Object symbol, tail; - symbol = intern ("default-enable-multibyte-characters"); - Fset (symbol, Qnil); + symbol = intern_c_string ("enable-multibyte-characters"); + Fset_default (symbol, Qnil); if (initialized) { @@ -1410,6 +1469,7 @@ main (int argc, char **argv) set_buffer_temp (current); } } + message ("Warning: unibyte sessions are obsolete and will disappear"); } } @@ -1420,8 +1480,6 @@ main (int argc, char **argv) ns_alloc_autorelease_pool(); if (!noninteractive) { - char *tmp; - display_arg = 4; #ifdef NS_IMPL_COCOA if (skip_args < argc) { @@ -1436,16 +1494,7 @@ main (int argc, char **argv) chdir (getenv ("HOME")); } } -#endif - /* This used for remote operation.. not fully implemented yet. */ - if (argmatch (argv, argc, "-_NSMachLaunch", 0, 3, &tmp, &skip_args)) - display_arg = 4; - else if (argmatch (argv, argc, "-MachLaunch", 0, 3, &tmp, &skip_args)) - display_arg = 4; - else if (argmatch (argv, argc, "-macosx", 0, 2, NULL, &skip_args)) - display_arg = 4; - else if (argmatch (argv, argc, "-NSHost", 0, 3, &tmp, &skip_args)) - display_arg = 4; +#endif /* COCOA */ } #endif /* HAVE_NS */ @@ -1563,10 +1612,8 @@ main (int argc, char **argv) if (!initialized) { - /* The basic levels of Lisp must come first. */ - /* And data must come first of all - for the sake of symbols like error-message. */ - syms_of_data (); + /* The basic levels of Lisp must come first. Note that + syms_of_data and some others have already been called. */ syms_of_chartab (); syms_of_lread (); syms_of_print (); @@ -1627,6 +1674,7 @@ main (int argc, char **argv) syms_of_xfns (); syms_of_xmenu (); syms_of_fontset (); + syms_of_xsettings (); #ifdef HAVE_X_SM syms_of_xsmfns (); #endif @@ -1706,17 +1754,18 @@ main (int argc, char **argv) init_sound (); #endif init_window (); - + init_font (); + if (!initialized) { char *file; /* Handle -l loadup, args passed by Makefile. */ if (argmatch (argv, argc, "-l", "--load", 3, &file, &skip_args)) - Vtop_level = Fcons (intern ("load"), + Vtop_level = Fcons (intern_c_string ("load"), Fcons (build_string (file), Qnil)); /* Unless next switch is -nl, load "loadup.el" first thing. */ if (! no_loadup) - Vtop_level = Fcons (intern ("load"), + Vtop_level = Fcons (intern_c_string ("load"), Fcons (build_string ("loadup.el"), Qnil)); } @@ -1743,9 +1792,7 @@ main (int argc, char **argv) /* Set up for profiling. This is known to work on FreeBSD, GNU/Linux and MinGW. It might work on some other systems too. Give it a try and tell us if it works on your system. To compile - for profiling, add -pg to the switches your platform uses in - CFLAGS and LDFLAGS. For example: - `make CFLAGS="-pg -g -O -DPROFILING=1" LDFLAGS="-pg -g"'. */ + for profiling, use the configure option --enable-profiling. */ #if defined (__FreeBSD__) || defined (GNU_LINUX) || defined(__MINGW32__) #ifdef PROFILING if (initialized) @@ -1795,13 +1842,13 @@ main (int argc, char **argv) struct standard_args { - char *name; - char *longname; + const char *name; + const char *longname; int priority; int nargs; }; -struct standard_args standard_args[] = +const struct standard_args standard_args[] = { { "-version", "--version", 150, 0 }, #ifdef HAVE_SHM @@ -1822,7 +1869,7 @@ struct standard_args standard_args[] = /* -d must come last before the options handled in startup.el. */ { "-d", "--display", 60, 1 }, { "-display", 0, 60, 1 }, - /* Now for the options handled in startup.el. */ + /* Now for the options handled in `command-line' (startup.el). */ { "-Q", "--quick", 55, 0 }, { "-quick", 0, 55, 0 }, { "-q", "--no-init-file", 50, 0 }, @@ -1831,10 +1878,12 @@ struct standard_args standard_args[] = { "-u", "--user", 30, 1 }, { "-user", 0, 30, 1 }, { "-debug-init", "--debug-init", 20, 0 }, - { "-nbi", "--no-bitmap-icon", 15, 0 }, { "-iconic", "--iconic", 15, 0 }, { "-D", "--basic-display", 12, 0}, { "-basic-display", 0, 12, 0}, + { "-nbc", "--no-blinking-cursor", 12, 0 }, + /* Now for the options handled in `command-line-1' (startup.el). */ + { "-nbi", "--no-bitmap-icon", 10, 0 }, { "-bg", "--background-color", 10, 1 }, { "-background", 0, 10, 1 }, { "-fg", "--foreground-color", 10, 1 }, @@ -1844,12 +1893,12 @@ struct standard_args standard_args[] = { "-ib", "--internal-border", 10, 1 }, { "-ms", "--mouse-color", 10, 1 }, { "-cr", "--cursor-color", 10, 1 }, - { "-nbc", "--no-blinking-cursor", 10, 0 }, { "-fn", "--font", 10, 1 }, { "-font", 0, 10, 1 }, { "-fs", "--fullscreen", 10, 0 }, { "-fw", "--fullwidth", 10, 0 }, { "-fh", "--fullheight", 10, 0 }, + { "-mm", "--maximized", 10, 0 }, { "-g", "--geometry", 10, 1 }, { "-geometry", 0, 10, 1 }, { "-T", "--title", 10, 1 }, @@ -2499,7 +2548,7 @@ from the parent process and its tty file descriptors. */) void syms_of_emacs () { - Qfile_name_handler_alist = intern ("file-name-handler-alist"); + Qfile_name_handler_alist = intern_c_string ("file-name-handler-alist"); staticpro (&Qfile_name_handler_alist); #ifndef CANNOT_DUMP @@ -2522,16 +2571,18 @@ syms_of_emacs () 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: /* The value is a symbol indicating the type of operating system you are using. Special values: - `gnu' compiled for a GNU Hurd system. - `gnu/linux' compiled for a GNU/Linux system. - `darwin' compiled for Darwin (GNU-Darwin, Mac OS X, ...). - `ms-dos' compiled as an MS-DOS application. - `windows-nt' compiled as a native W32 application. - `cygwin' compiled using the Cygwin library. -Anything else indicates some sort of Unix system. */); - Vsystem_type = intern (SYSTEM_TYPE); + `gnu' compiled for a GNU Hurd system. + `gnu/linux' compiled for a GNU/Linux system. + `gnu/kfreebsd' compiled for a GNU system with a FreeBSD kernel. + `darwin' compiled for Darwin (GNU-Darwin, Mac OS X, ...). + `ms-dos' compiled as an MS-DOS application. + `windows-nt' compiled as a native W32 application. + `cygwin' compiled using the Cygwin library. +Anything else (in Emacs 23.1, the possibilities are: aix, berkeley-unix, +hpux, irix, lynxos 3.0.1, usg-unix-v) indicates some sort of Unix system. */); + Vsystem_type = intern_c_string (SYSTEM_TYPE); DEFVAR_LISP ("system-configuration", &Vsystem_configuration, doc: /* Value is string indicating configuration Emacs was built for. @@ -2614,6 +2665,10 @@ was found. */); This is nil during initialization. */); Vafter_init_time = Qnil; + DEFVAR_BOOL ("inhibit-x-resources", &inhibit_x_resources, + doc: /* If non-nil, X resources, Windows Registry settings, and NS defaults are not used. */); + inhibit_x_resources = 0; + /* Make sure IS_DAEMON starts up as false. */ daemon_pipe[1] = 0; }