# HG changeset patch # User Adrian Robert # Date 1232704682 0 # Node ID 5b58e8f46076b1a9fb05586dda6a1ae97eb42760 # Parent 6b87429f988f08ad35abad0e45d7280aa377e3b4 * emacs.c (ns_no_defaults): New declaration. (main): Use it. * nsterm.h (ns_no_defaults): New declaration. * nsfns.m (x_get_string_resource): Don't read when ns_no_defaults. * nsterm.m (ns_no_defaults): New variable. (ns_initialize): Don't read defaults when ns_no_defaults. diff -r 6b87429f988f -r 5b58e8f46076 src/emacs.c --- a/src/emacs.c Fri Jan 23 09:12:53 2009 +0000 +++ b/src/emacs.c Fri Jan 23 09:58:02 2009 +0000 @@ -202,6 +202,10 @@ int display_arg; #endif +#ifdef HAVE_NS +extern char ns_no_defaults; +#endif + /* An address near the bottom of the stack. Tells GC how to save a copy of the stack. */ char *stack_bottom; @@ -1473,6 +1477,16 @@ { char *tmp; display_arg = 4; + if (argmatch (argv, argc, "-q", "--no-init-file", 6, NULL, &skip_args)) + { + ns_no_defaults = 1; + skip_args--; + } + if (argmatch (argv, argc, "-Q", "--quick", 5, NULL, &skip_args)) + { + ns_no_defaults = 1; + skip_args--; + } #ifdef NS_IMPL_COCOA if (skip_args < argc) { diff -r 6b87429f988f -r 5b58e8f46076 src/nsfns.m --- a/src/nsfns.m Fri Jan 23 09:12:53 2009 +0000 +++ b/src/nsfns.m Fri Jan 23 09:58:02 2009 +0000 @@ -2184,9 +2184,10 @@ toCheck = name + (!strncmp (name, "emacs.", 6) ? 6 : 0); /*fprintf (stderr, "Checking '%s'\n", toCheck); */ - - res = [[[NSUserDefaults standardUserDefaults] objectForKey: - [NSString stringWithUTF8String: toCheck]] UTF8String]; + + res = ns_no_defaults ? NULL : + [[[NSUserDefaults standardUserDefaults] objectForKey: + [NSString stringWithUTF8String: toCheck]] UTF8String]; return !res ? NULL : (!strncasecmp (res, "YES", 3) ? "true" : (!strncasecmp (res, "NO", 2) ? "false" : res)); diff -r 6b87429f988f -r 5b58e8f46076 src/nsterm.h --- a/src/nsterm.h Fri Jan 23 09:12:53 2009 +0000 +++ b/src/nsterm.h Fri Jan 23 09:58:02 2009 +0000 @@ -726,6 +726,7 @@ extern int ns_lisp_to_cursor_type (); extern Lisp_Object ns_cursor_type_to_lisp (int arg); extern Lisp_Object Qnone; +extern char ns_no_defaults; /* XColor defined in dispextern.h (we use color_def->pixel = NSColor id), but this causes an #include snafu, so we can't declare it. */ diff -r 6b87429f988f -r 5b58e8f46076 src/nsterm.m --- a/src/nsterm.m Fri Jan 23 09:12:53 2009 +0000 +++ b/src/nsterm.m Fri Jan 23 09:58:02 2009 +0000 @@ -151,9 +151,17 @@ EmacsPrefsController *prefsController; -/* Defaults managed through the OpenStep defaults system. These pertain to - the NS interface specifically. Although a customization group could be - created, it's more natural to manage them via defaults. */ +/* Preferences equivalent to those set by X resources under X are managed + through the OpenStep defaults system. These pertain to behavior of the + graphical interface components. The one difference from X is that the + values below are SET when the user chooses save-options. This makes + things easier for users, but sometimes violates expectations when some + user-set options appear when running under -q/Q. Therefore we depart + from X behavior and refuse to read defaults when started under these + options. */ + +/* Set in emacs.c. */ +char ns_no_defaults; /* Specifies which emacs modifier should be generated when NS receives the Alternate modifer. May be Qnone or any of the modifier lisp symbols. */ @@ -3801,9 +3809,6 @@ /* Put it on ns_display_name_list */ ns_display_name_list = Fcons (Fcons (display_name, Qnil), ns_display_name_list); -/* ns_display_name_list = Fcons (Fcons (display_name, - Fcons (Qnil, dpyinfo->xrdb)), - ns_display_name_list); */ dpyinfo->name_list_element = XCAR (ns_display_name_list); /* Set the name of the terminal. */ @@ -3815,34 +3820,38 @@ /* Read various user defaults. */ ns_set_default_prefs (); - ns_default ("AlternateModifier", &ns_alternate_modifier, - Qnil, Qnil, NO, YES); - if (NILP (ns_alternate_modifier)) - ns_alternate_modifier = Qmeta; - ns_default ("CommandModifier", &ns_command_modifier, - Qnil, Qnil, NO, YES); - if (NILP (ns_command_modifier)) - ns_command_modifier = Qsuper; - ns_default ("ControlModifier", &ns_control_modifier, - Qnil, Qnil, NO, YES); - if (NILP (ns_control_modifier)) - ns_control_modifier = Qcontrol; - ns_default ("FunctionModifier", &ns_function_modifier, - Qnil, Qnil, NO, YES); - if (NILP (ns_function_modifier)) - ns_function_modifier = Qnone; - ns_default ("ExpandSpace", &ns_expand_space, - make_float (0.5), make_float (0.0), YES, NO); - ns_default ("GSFontAntiAlias", &ns_antialias_text, - Qt, Qnil, NO, NO); - tmp = Qnil; - ns_default ("AppleAntiAliasingThreshold", &tmp, - make_float (10.0), make_float (6.0), YES, NO); - ns_antialias_threshold = NILP (tmp) ? 10.0 : XFLOATINT (tmp); - ns_default ("UseQuickdrawSmoothing", &ns_use_qd_smoothing, - Qt, Qnil, NO, NO); - ns_default ("UseSystemHighlightColor", &ns_use_system_highlight_color, - Qt, Qnil, NO, NO); + if (!ns_no_defaults) + { + ns_default ("AlternateModifier", &ns_alternate_modifier, + Qnil, Qnil, NO, YES); + if (NILP (ns_alternate_modifier)) + ns_alternate_modifier = Qmeta; + ns_default ("CommandModifier", &ns_command_modifier, + Qnil, Qnil, NO, YES); + if (NILP (ns_command_modifier)) + ns_command_modifier = Qsuper; + ns_default ("ControlModifier", &ns_control_modifier, + Qnil, Qnil, NO, YES); + if (NILP (ns_control_modifier)) + ns_control_modifier = Qcontrol; + ns_default ("FunctionModifier", &ns_function_modifier, + Qnil, Qnil, NO, YES); + if (NILP (ns_function_modifier)) + ns_function_modifier = Qnone; + ns_default ("ExpandSpace", &ns_expand_space, + make_float (0.5), make_float (0.0), YES, NO); + ns_default ("GSFontAntiAlias", &ns_antialias_text, + Qt, Qnil, NO, NO); + tmp = Qnil; + ns_default ("AppleAntiAliasingThreshold", &tmp, + make_float (10.0), make_float (6.0), YES, NO); + ns_antialias_threshold = NILP (tmp) ? 10.0 : XFLOATINT (tmp); + ns_default ("UseQuickdrawSmoothing", &ns_use_qd_smoothing, + Qt, Qnil, NO, NO); + ns_default ("UseSystemHighlightColor", &ns_use_system_highlight_color, + Qt, Qnil, NO, NO); + } + if (EQ (ns_use_system_highlight_color, Qt)) { ns_selection_color = [[NSUserDefaults standardUserDefaults]