* Not loading the Registry settings @ 2009-09-12 11:45 Juanma Barranquero 2009-09-12 12:28 ` David De La Harpe Golden 0 siblings, 1 reply; 19+ messages in thread From: Juanma Barranquero @ 2009-09-12 11:45 UTC (permalink / raw) To: Emacs developers I'd like to have a way to start Emacs with "emacs -Q" and have it not to load the values from the Windows registry. Adding a new command line option is easy, but I'm looking for the best, non-Windows-specific way. How it's Emacs currently forced to ignore X settings? Juanma ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Not loading the Registry settings 2009-09-12 11:45 Not loading the Registry settings Juanma Barranquero @ 2009-09-12 12:28 ` David De La Harpe Golden 2009-09-12 12:50 ` Adrian Robert 2009-09-12 14:22 ` Juanma Barranquero 0 siblings, 2 replies; 19+ messages in thread From: David De La Harpe Golden @ 2009-09-12 12:28 UTC (permalink / raw) To: Juanma Barranquero; +Cc: Emacs developers Juanma Barranquero wrote: > I'd like to have a way to start Emacs with "emacs -Q" and have it not > to load the values from the Windows registry. > > Adding a new command line option is easy, but I'm looking for the > best, non-Windows-specific way. How it's Emacs currently forced to > ignore X settings? > If you mean X resource database settings, I suspect they are always used unless you go all the way and -nw _However_ you can override them on the command line with --xrm i.e even if I have 'Emacs.Fontbackend: xft' in my x resource database, I can still do $ emacs -Q --xrm 'Emacs.FontBackend: x' and enjoy awful font rendering. looking at w32_make_rdb(), --xrm may work on w32 to override registry settings? (untested). ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Not loading the Registry settings 2009-09-12 12:28 ` David De La Harpe Golden @ 2009-09-12 12:50 ` Adrian Robert 2009-09-12 14:22 ` Juanma Barranquero 1 sibling, 0 replies; 19+ messages in thread From: Adrian Robert @ 2009-09-12 12:50 UTC (permalink / raw) To: David De La Harpe Golden; +Cc: Juanma Barranquero, Emacs developers David De La Harpe Golden <david@harpegolden.net> writes: > Juanma Barranquero wrote: >> I'd like to have a way to start Emacs with "emacs -Q" and have it not >> to load the values from the Windows registry. >> >> Adding a new command line option is easy, but I'm looking for the >> best, non-Windows-specific way. How it's Emacs currently forced to >> ignore X settings? >> > > If you mean X resource database settings, I suspect they are always > used unless you go all the way and -nw FWIW, under OS X the user consensus was that the semantics of -q/Q implied that user customizations should not be loaded even if they come from the resource database instead of .emacs. Thus, there is the "ns_no_defaults" hack in emacs.c. It would be easier to do this cleanly if other platforms choose to implement it as well. ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Not loading the Registry settings 2009-09-12 12:28 ` David De La Harpe Golden 2009-09-12 12:50 ` Adrian Robert @ 2009-09-12 14:22 ` Juanma Barranquero 2009-09-12 19:14 ` Stefan Monnier 1 sibling, 1 reply; 19+ messages in thread From: Juanma Barranquero @ 2009-09-12 14:22 UTC (permalink / raw) To: David De La Harpe Golden; +Cc: Emacs developers On Sat, Sep 12, 2009 at 14:28, David De La Harpe Golden <david@harpegolden.net> wrote: > If you mean X resource database settings, I suspect they are always used > unless you go all the way and -nw Hmm. The trouble is, I want something to override all Registry settings, precisely when I'm in window mode. So I can test some bug, for example, without my Emacs.Background, Emacs.Foreground and Emacs.Geometry settings getting in the way. > looking at w32_make_rdb(), --xrm may work on w32 to override > registry settings? (untested). That works, but it is awfully ugly if you have many Registry settings. I'd like a simple way to just say "no Registry settings AT ALL". I can workaround now by running Emacs with a script doing emacs -Q -xrm Emacs.Geometry: -xrm Emacs.Foreground: -xrm Emacs.Background: but it is a PITA. Juanma ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Not loading the Registry settings 2009-09-12 14:22 ` Juanma Barranquero @ 2009-09-12 19:14 ` Stefan Monnier 2009-09-13 2:29 ` Miles Bader 0 siblings, 1 reply; 19+ messages in thread From: Stefan Monnier @ 2009-09-12 19:14 UTC (permalink / raw) To: Juanma Barranquero; +Cc: Emacs developers, David De La Harpe Golden >> If you mean X resource database settings, I suspect they are always used >> unless you go all the way and -nw > Hmm. The trouble is, I want something to override all Registry > settings, precisely when I'm in window mode. So I can test some bug, > for example, without my Emacs.Background, Emacs.Foreground and > Emacs.Geometry settings getting in the way. Agreed. Actually, I think that "-Q" should do that. After all, to me the main use of "-Q" is to have a clean start state that is independent of any user settings. Stefan ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Not loading the Registry settings 2009-09-12 19:14 ` Stefan Monnier @ 2009-09-13 2:29 ` Miles Bader 2009-09-14 0:34 ` Juanma Barranquero 0 siblings, 1 reply; 19+ messages in thread From: Miles Bader @ 2009-09-13 2:29 UTC (permalink / raw) To: Stefan Monnier Cc: Juanma Barranquero, David De La Harpe Golden, Emacs developers Stefan Monnier <monnier@iro.umontreal.ca> writes: >> Hmm. The trouble is, I want something to override all Registry >> settings, precisely when I'm in window mode. So I can test some bug, >> for example, without my Emacs.Background, Emacs.Foreground and >> Emacs.Geometry settings getting in the way. > > Agreed. Actually, I think that "-Q" should do that. After all, to me > the main use of "-Q" is to have a clean start state that is independent > of any user settings. I agree. [Currently now I do this by using "HOME=/tmp emacs -Q" (since I use ~/.Xdefaults, not the server's xrdb db), but it's a slight pain 'cause I don't always remember...] -Miles -- Alone, adj. In bad company. ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Not loading the Registry settings 2009-09-13 2:29 ` Miles Bader @ 2009-09-14 0:34 ` Juanma Barranquero 2009-09-14 13:29 ` Stefan Monnier 0 siblings, 1 reply; 19+ messages in thread From: Juanma Barranquero @ 2009-09-14 0:34 UTC (permalink / raw) To: Miles Bader; +Cc: David De La Harpe Golden, Stefan Monnier, Emacs developers This a sample patch, not nearly ready (no docs, for example), just to check whether I'm going in the right direction. It is the simplest patch that works on Windows. Comments: - It piggybacks on -Q, as Stefan suggested. Personally I think (but not very strongly) that a new option would be clearer. - It basically turns w32reg:x_get_string_resource() into a no-op. Would the same approach for xrdb:x_get_string_resource() work? In particular, in the ~/.Xdefaults case mentioned by Miles? - As defined, it is an irreversible operation. Once -Q is used, x_get_string_resource is a no-op for the duration of the Emacs instance. I've assumed that is the intended effect. Thoughts? Juanma diff --git a/src/emacs.c b/src/emacs.c index 2c14be5..2f25248 100644 --- a/src/emacs.c +++ b/src/emacs.c @@ -239,6 +239,9 @@ int noninteractive; int noninteractive1; +/* Nonzero means Emacs was started with --quick. */ +int emacs_quick_startup; + /* Name for the server started by the daemon.*/ static char *daemon_name; @@ -1472,6 +1475,16 @@ main (int argc, char **argv) no_loadup = argmatch (argv, argc, "-nl", "--no-loadup", 6, NULL, &skip_args); + /* Check the -quick switch, which means don't load init or site files, nor X + settings or Windows registry, and no splash; but pass it back for startup.el. */ + if (argmatch (argv, argc, "-Q", "--quick", 5, NULL, &skip_args)) + { + emacs_quick_startup = 1; + skip_args--; + } + else + emacs_quick_startup = 0; + #ifdef HAVE_NS ns_alloc_autorelease_pool(); if (!noninteractive) diff --git a/src/lisp.h b/src/lisp.h index 820c258..38e4854 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -3128,6 +3128,7 @@ extern Lisp_Object Vinvocation_name, Vinvocation_directory; extern Lisp_Object Vbefore_init_time, Vafter_init_time; extern Lisp_Object Vinstallation_directory; extern Lisp_Object empty_unibyte_string, empty_multibyte_string; +extern int emacs_quick_startup; EXFUN (Fkill_emacs, 1); #if HAVE_SETLOCALE void fixup_locale P_ ((void)); diff --git a/src/w32reg.c b/src/w32reg.c index d2330e7..89294f8 100644 --- a/src/w32reg.c +++ b/src/w32reg.c @@ -150,6 +150,9 @@ x_get_string_resource (rdb, name, class) XrmDatabase rdb; char *name, *class; { + /* --quick was passed, so this is a no-op. */ + if (emacs_quick_startup) return NULL; + if (rdb) { char *resource; ^ permalink raw reply related [flat|nested] 19+ messages in thread
* Re: Not loading the Registry settings 2009-09-14 0:34 ` Juanma Barranquero @ 2009-09-14 13:29 ` Stefan Monnier 2009-09-14 13:48 ` Juanma Barranquero 0 siblings, 1 reply; 19+ messages in thread From: Stefan Monnier @ 2009-09-14 13:29 UTC (permalink / raw) To: Juanma Barranquero Cc: David De La Harpe Golden, Emacs developers, Miles Bader > - It basically turns w32reg:x_get_string_resource() into a no-op. Interesting approach. > Would the same approach for xrdb:x_get_string_resource() work? In > particular, in the ~/.Xdefaults case mentioned by Miles? I do not know, but I'd think so, yes. > - As defined, it is an irreversible operation. Once -Q is used, > x_get_string_resource is a no-op for the duration of the Emacs > instance. I've assumed that is the intended effect. I think that's OK, but the double-parsing of -Q is not very satisfactory. I'd rather see a new variable Vinhibit_x_resources instead, which the Lisp code could set to non-nil when it parses the -Q argument. Stefan ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Not loading the Registry settings 2009-09-14 13:29 ` Stefan Monnier @ 2009-09-14 13:48 ` Juanma Barranquero 2009-09-14 13:54 ` Juanma Barranquero ` (2 more replies) 0 siblings, 3 replies; 19+ messages in thread From: Juanma Barranquero @ 2009-09-14 13:48 UTC (permalink / raw) To: Stefan Monnier; +Cc: David De La Harpe Golden, Emacs developers, Miles Bader On Mon, Sep 14, 2009 at 15:29, Stefan Monnier <monnier@iro.umontreal.ca> wrote: > Interesting approach. It's simple. In my patch, "emacs -Q -xrm resource" won't obey -xrm either, but it is trivially easy to change it to allow that, if desired (it's just moving the "if() ... return" down a few lines in w32reg:x_get_resource_string). > I think that's OK, but the double-parsing of -Q is not > very satisfactory. I'd rather see a new variable Vinhibit_x_resources > instead, which the Lisp code could set to non-nil when it parses > the -Q argument. I had in fact done that before (though I reused instead the currently undocumented emacs-quick-startup variable that startup.el uses now). But I didn't want to mess with the processing of -Q/--quick in the HAVE_NS block immediately following: #ifdef HAVE_NS ns_alloc_autorelease_pool(); if (!noninteractive) { 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) { if (!strncmp(argv[skip_args], "-psn", 4)) { skip_args += 1; chdir (getenv ("HOME")); } else if (skip_args+1 < argc && !strncmp(argv[skip_args+1], "-psn", 4)) { skip_args += 2; 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 /* HAVE_NS */ I think intermixing this with the new processing of -Q/--quick will lead to uglier code... Juanma ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Not loading the Registry settings 2009-09-14 13:48 ` Juanma Barranquero @ 2009-09-14 13:54 ` Juanma Barranquero 2009-09-14 21:53 ` Stefan Monnier 2009-09-14 14:51 ` Adrian Robert [not found] ` <jwv63bl5onb.fsf-monnier+emacs@gnu.org> 2 siblings, 1 reply; 19+ messages in thread From: Juanma Barranquero @ 2009-09-14 13:54 UTC (permalink / raw) To: Stefan Monnier; +Cc: David De La Harpe Golden, Emacs developers, Miles Bader On Mon, Sep 14, 2009 at 15:48, Juanma Barranquero <lekktu@gmail.com> wrote: > I think that's OK, but the double-parsing of -Q is not > very satisfactory. I'd rather see a new variable Vinhibit_x_resources > instead, which the Lisp code could set to non-nil when it parses > the -Q argument. I think I've misread this bit in my previous answer. Do you mean that all the -Q processing would be done in startup.el? I think it is too late then to affect to some initializations that read from X resources / Registry. What I did instead was to process -Q in emacs.c and set a Lisp variable for startup.el. Juanma ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Not loading the Registry settings 2009-09-14 13:54 ` Juanma Barranquero @ 2009-09-14 21:53 ` Stefan Monnier 2009-09-14 22:24 ` Juanma Barranquero 0 siblings, 1 reply; 19+ messages in thread From: Stefan Monnier @ 2009-09-14 21:53 UTC (permalink / raw) To: Juanma Barranquero Cc: David De La Harpe Golden, Emacs developers, Miles Bader >> I think that's OK, but the double-parsing of -Q is not >> very satisfactory. I'd rather see a new variable Vinhibit_x_resources >> instead, which the Lisp code could set to non-nil when it parses >> the -Q argument. > I think I've misread this bit in my previous answer. Do you mean that > all the -Q processing would be done in startup.el? Yes. > I think it is too late then to affect to some initializations that > read from X resources / Registry. What I did instead was to > process -Q in emacs.c and set a Lisp variable for startup.el. I guess it'd be OK to move it from Lisp to C, but I'd first like to understand which initializations take place too early to be affected by Lisp code. Stefan ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Not loading the Registry settings 2009-09-14 21:53 ` Stefan Monnier @ 2009-09-14 22:24 ` Juanma Barranquero 2009-09-15 1:31 ` Stefan Monnier 0 siblings, 1 reply; 19+ messages in thread From: Juanma Barranquero @ 2009-09-14 22:24 UTC (permalink / raw) To: Stefan Monnier; +Cc: David De La Harpe Golden, Emacs developers, Miles Bader On Mon, Sep 14, 2009 at 23:53, Stefan Monnier <monnier@iro.umontreal.ca> wrote: > but I'd first like to > understand which initializations take place too early to be affected by > Lisp code. Attached is a backtrace of the first call to w32reg.c:x_get_string_resource on an emacs -Q run. As for the Lisp variable, `inhibit-x-resources' suggests that it can be toggled by the user or lisp code. Is that the intended effect? Juanma Breakpoint 3, x_get_string_resource (rdb=0x0, name=0x82ea80 "emacs.fontset-0", class=0x82ea60 "Emacs.Fontset-0") at w32reg.c:153 153 if (rdb) (gdb) bt #0 x_get_string_resource (rdb=0x0, name=0x82ea80 "emacs.fontset-0", class=0x82ea60 "Emacs.Fontset-0") at w32reg.c:153 #1 0x0124d96a in xrdb_get_resource (rdb=0x0, attribute=49875811, class=49875843, component=48252929, subclass=48252929) at frame.c:3858 #2 0x0124d9c5 in Fx_get_resource (attribute=49875811, class=49875843, component=48252929, subclass=48252929) at frame.c:3884 #3 0x0103dc51 in Ffuncall (nargs=3, args=0x82ebf0) at eval.c:3056 #4 0x011df179 in Fbyte_code (bytestr=20903515, vector=20903580, maxdepth=40) at bytecode.c:678 #5 0x0103e77d in funcall_lambda (fun=20903492, nargs=0, arg_vector=0x82ef14) at eval.c:3233 #6 0x0103dfd9 in Ffuncall (nargs=1, args=0x82ef10) at eval.c:3092 #7 0x011df179 in Fbyte_code (bytestr=20914331, vector=20914564, maxdepth=48) at bytecode.c:678 #8 0x0103e77d in funcall_lambda (fun=20914300, nargs=0, arg_vector=0x82f234) at eval.c:3233 #9 0x0103dfd9 in Ffuncall (nargs=1, args=0x82f230) at eval.c:3092 #10 0x011df179 in Fbyte_code (bytestr=20369283, vector=20369364, maxdepth=32) at bytecode.c:678 #11 0x0103be89 in Feval (form=20369269) at eval.c:2383 #12 0x01039b9a in internal_lisp_condition_case (var=48316609, bodyform=20369269, handlers=20369461) at eval.c:1458 #13 0x011dfe32 in Fbyte_code (bytestr=20367203, vector=20368132, maxdepth=56) at bytecode.c:868 #14 0x0103e77d in funcall_lambda (fun=20367180, nargs=0, arg_vector=0x82f924) at eval.c:3233 #15 0x0103dfd9 in Ffuncall (nargs=1, args=0x82f920) at eval.c:3092 #16 0x011df179 in Fbyte_code (bytestr=20363323, vector=20363540, maxdepth=48) at bytecode.c:678 #17 0x0103e77d in funcall_lambda (fun=20363300, nargs=0, arg_vector=0x82fbb0) at eval.c:3233 #18 0x0103e21a in apply_lambda (fun=20363300, args=48252929, eval_flag=1) at eval.c:3157 #19 0x0103c268 in Feval (form=48920549) at eval.c:2419 #20 0x01006e92 in top_level_2 () at keyboard.c:1366 #21 0x01039c96 in internal_condition_case (bfun=0x1006e7e <top_level_2>, handlers=48316609, hfun=0x10069d0 <cmd_error>) at eval.c:1513 #22 0x01006ec7 in top_level_1 () at keyboard.c:1374 #23 0x010396ef in internal_catch (tag=48312729, func=0x1006e97 <top_level_1>, arg=48252929) at eval.c:1249 #24 0x01006e02 in command_loop () at keyboard.c:1329 #25 0x01006127 in recursive_edit_1 () at keyboard.c:951 #26 0x010065fc in Frecursive_edit () at keyboard.c:1013 #27 0x01002a8d in main (argc=2, argv=0xa92748) at emacs.c:1849 Lisp Backtrace: "x-get-resource" (0x82ebf4) "create-fontset-from-x-resource" (0x82ef14) "w32-initialize-window-system" (0x82f234) "byte-code" (0x82f4b0) "command-line" (0x82f924) "normal-top-level" (0x82fbb0) ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Not loading the Registry settings 2009-09-14 22:24 ` Juanma Barranquero @ 2009-09-15 1:31 ` Stefan Monnier 2009-09-15 9:26 ` Juanma Barranquero 0 siblings, 1 reply; 19+ messages in thread From: Stefan Monnier @ 2009-09-15 1:31 UTC (permalink / raw) To: Juanma Barranquero Cc: David De La Harpe Golden, Emacs developers, Miles Bader >> but I'd first like to understand which initializations take place too >> early to be affected by Lisp code. > Attached is a backtrace of the first call to > w32reg.c:x_get_string_resource on an emacs -Q run. Thanks. The patch below should address this issue (it just moves code around). > As for the Lisp variable, `inhibit-x-resources' suggests that it can > be toggled by the user or lisp code. Is that the intended effect? Well, I'm not sure if it would be useful, but the name seems to reflect more precisely the effect of the variable, and indeed it can later on be changed from Lisp, tho it's not clear whether that would be useful. Stefan === modified file 'lisp/startup.el' --- lisp/startup.el 2009-09-13 04:07:30 +0000 +++ lisp/startup.el 2009-09-15 01:28:52 +0000 @@ -727,44 +727,6 @@ (setq eol-mnemonic-dos "(DOS)" eol-mnemonic-mac "(Mac)"))) - ;; Make sure window system's init file was loaded in loadup.el if - ;; using a window system. - (condition-case error - (unless noninteractive - (if (and initial-window-system - (not (featurep - (intern - (concat (symbol-name initial-window-system) "-win"))))) - (error "Unsupported window system `%s'" initial-window-system)) - ;; Process window-system specific command line parameters. - (setq command-line-args - (funcall - (or (cdr (assq initial-window-system handle-args-function-alist)) - (error "Unsupported window system `%s'" initial-window-system)) - command-line-args)) - ;; Initialize the window system. (Open connection, etc.) - (funcall - (or (cdr (assq initial-window-system window-system-initialization-alist)) - (error "Unsupported window system `%s'" initial-window-system)))) - ;; If there was an error, print the error message and exit. - (error - (princ - (if (eq (car error) 'error) - (apply 'concat (cdr error)) - (if (memq 'file-error (get (car error) 'error-conditions)) - (format "%s: %s" - (nth 1 error) - (mapconcat (lambda (obj) (prin1-to-string obj t)) - (cdr (cdr error)) ", ")) - (format "%s: %s" - (get (car error) 'error-message) - (mapconcat (lambda (obj) (prin1-to-string obj t)) - (cdr error) ", ")))) - 'external-debugging-output) - (terpri 'external-debugging-output) - (setq initial-window-system nil) - (kill-emacs))) - (set-locale-environment nil) ;; Convert preloaded file names in load-history to absolute. @@ -869,6 +831,44 @@ (and command-line-args (setcdr command-line-args args))) + ;; Make sure window system's init file was loaded in loadup.el if + ;; using a window system. + (condition-case error + (unless noninteractive + (if (and initial-window-system + (not (featurep + (intern + (concat (symbol-name initial-window-system) "-win"))))) + (error "Unsupported window system `%s'" initial-window-system)) + ;; Process window-system specific command line parameters. + (setq command-line-args + (funcall + (or (cdr (assq initial-window-system handle-args-function-alist)) + (error "Unsupported window system `%s'" initial-window-system)) + command-line-args)) + ;; Initialize the window system. (Open connection, etc.) + (funcall + (or (cdr (assq initial-window-system window-system-initialization-alist)) + (error "Unsupported window system `%s'" initial-window-system)))) + ;; If there was an error, print the error message and exit. + (error + (princ + (if (eq (car error) 'error) + (apply 'concat (cdr error)) + (if (memq 'file-error (get (car error) 'error-conditions)) + (format "%s: %s" + (nth 1 error) + (mapconcat (lambda (obj) (prin1-to-string obj t)) + (cdr (cdr error)) ", ")) + (format "%s: %s" + (get (car error) 'error-message) + (mapconcat (lambda (obj) (prin1-to-string obj t)) + (cdr error) ", ")))) + 'external-debugging-output) + (terpri 'external-debugging-output) + (setq initial-window-system nil) + (kill-emacs))) + (run-hooks 'before-init-hook) (if (daemonp) ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Not loading the Registry settings 2009-09-15 1:31 ` Stefan Monnier @ 2009-09-15 9:26 ` Juanma Barranquero 2009-09-15 13:34 ` Stefan Monnier 0 siblings, 1 reply; 19+ messages in thread From: Juanma Barranquero @ 2009-09-15 9:26 UTC (permalink / raw) To: Stefan Monnier; +Cc: David De La Harpe Golden, Emacs developers, Miles Bader On Tue, Sep 15, 2009 at 03:31, Stefan Monnier <monnier@iro.umontreal.ca> wrote: > Thanks. The patch below should address this issue (it just moves code > around). After your patch, setting the variable in Lisp woks (see code below; it does not include X changes, only Windows). The only drawback is that, on Windows, environment variables (HOME, SHELL, TERM, LANG, PRELOAD_WINSOCK and a few others) can also be defined in the registry, and they are loaded in w32.c:init_environment(), so -Q will not affect them. That is bad, because it negates one of the advantages of this change, i.e., making emacs -Q more useful for testing. > Well, I'm not sure if it would be useful, but the name seems to reflect > more precisely the effect of the variable, and indeed it can later on > be changed from Lisp, tho it's not clear whether that would be useful. BTW, the question of whether "emacs -Q -xrm myresouce" should obey myresource or not is still open. Juanma diff --git a/lisp/startup.el b/lisp/startup.el index 72c185c..3ffc4b8 100644 --- a/lisp/startup.el +++ b/lisp/startup.el @@ -366,8 +366,6 @@ from being initialized." string) :group 'auto-save) -(defvar emacs-quick-startup nil) - (defvar emacs-basic-display nil) (defvar init-file-debug nil) @@ -799,7 +797,7 @@ opening the first frame (e.g. open a connection to an X server).") ((member argi '("-Q" "-quick")) (setq init-file-user nil site-run-file nil - emacs-quick-startup t)) + inhibit-x-resources t)) ((member argi '("-D" "-basic-display")) (setq no-blinking-cursor t emacs-basic-display t) @@ -2272,7 +2270,7 @@ A fancy display is used on graphic displays, normal otherwise." (if (or inhibit-startup-screen initial-buffer-choice noninteractive - emacs-quick-startup) + inhibit-x-resources) ;; Not displaying a startup screen. If 3 or more files ;; visited, and not all visible, show user what they all are. diff --git a/src/emacs.c b/src/emacs.c index 2c14be5..9538e3c 100644 --- a/src/emacs.c +++ b/src/emacs.c @@ -239,6 +239,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; @@ -1483,11 +1486,6 @@ main (int argc, char **argv) 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) { @@ -2680,6 +2678,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 and Windows Registry settings are not used. */); + inhibit_x_resources = 0; + /* Make sure IS_DAEMON starts up as false. */ daemon_pipe[1] = 0; } diff --git a/src/lisp.h b/src/lisp.h index 820c258..f837708 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -3143,6 +3143,9 @@ void shut_down_emacs P_ ((int, int, Lisp_Object)); /* Nonzero means don't do interactive redisplay and don't change tty modes */ extern int noninteractive; +/* Nonzero means don't load X resources or Windows Registry settings. */ +extern int inhibit_x_resources; + /* Pipe used to send exit notification to the daemon parent at startup. */ extern int daemon_pipe[2]; diff --git a/src/w32reg.c b/src/w32reg.c index d2330e7..e31fba0 100644 --- a/src/w32reg.c +++ b/src/w32reg.c @@ -150,6 +150,10 @@ x_get_string_resource (rdb, name, class) XrmDatabase rdb; char *name, *class; { + if (inhibit_x_resources) + /* --quick was passed, so this is a no-op. */ + return NULL; + if (rdb) { char *resource; ^ permalink raw reply related [flat|nested] 19+ messages in thread
* Re: Not loading the Registry settings 2009-09-15 9:26 ` Juanma Barranquero @ 2009-09-15 13:34 ` Stefan Monnier 2009-09-15 14:27 ` Juanma Barranquero 0 siblings, 1 reply; 19+ messages in thread From: Stefan Monnier @ 2009-09-15 13:34 UTC (permalink / raw) To: Juanma Barranquero Cc: David De La Harpe Golden, Emacs developers, Miles Bader >> Thanks. The patch below should address this issue (it just moves code >> around). > After your patch, setting the variable in Lisp works (see code below; > it does not include X changes, only Windows). Good, thanks. > The only drawback is that, on Windows, environment variables (HOME, > SHELL, TERM, LANG, PRELOAD_WINSOCK and a few others) can also be > defined in the registry, and they are loaded in > w32.c:init_environment(), so -Q will not affect them. That is bad, > because it negates one of the advantages of this change, i.e., making > emacs -Q more useful for testing. OTOH, it's just the same behavior as under POSIX where environment variables are not provided via xrm but directly (and -Q does not override them). For HOME settings, I think it's TRT. For other variables, it's less clear, but I think it's OK for now. >> Well, I'm not sure if it would be useful, but the name seems to reflect >> more precisely the effect of the variable, and indeed it can later on >> be changed from Lisp, tho it's not clear whether that would be useful. > BTW, the question of whether "emacs -Q -xrm myresouce" should obey > myresource or not is still open. I think it *should* obey myresource. I don't know how to implement that behavior, tho. Stefan ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Not loading the Registry settings 2009-09-15 13:34 ` Stefan Monnier @ 2009-09-15 14:27 ` Juanma Barranquero 0 siblings, 0 replies; 19+ messages in thread From: Juanma Barranquero @ 2009-09-15 14:27 UTC (permalink / raw) To: Stefan Monnier; +Cc: David De La Harpe Golden, Emacs developers, Miles Bader On Tue, Sep 15, 2009 at 15:34, Stefan Monnier <monnier@iro.umontreal.ca> wrote: > OTOH, it's just the same behavior as under POSIX where environment > variables are not provided via xrm but directly (and -Q does not > override them). For HOME settings, I think it's TRT. For other > variables, it's less clear, but I think it's OK for now. OK > I think it *should* obey myresource. I don't know how to implement that > behavior, tho. On Windows it is trivial, so I'll add it to my patch. OK, there it goes. I've added the "if (...) return" code to xrdb.c:x_get_string_resource, so I'd be glad if someone on GNU/Linux can test that it works as expected (or at least that it does nothing bad). Once that is verified and you've installed your startup.el patch, I can go on installing this and then Adrian can tweak for NextStep and the X integration can be ironed out. Juanma * NEWS: Mention new behavior of -Q and new variable `inhibit-x-resources'. * startup.el (emacs-quick-startup): Remove variable and all uses. (command-line): Set `inhibit-x-resources' instead. (command-line-1): Use `inhibit-x-resources' instead. * emacs.c (inhibit_x_resources): New variable. (main) [HAVE_NS]: Don't process --quick command line option. (syms_of_emacs) <inhibit-x-resources>: DEFVAR_BOOL it. * lisp.h (inhibit_x_resources): Declare it extern. * w32reg.c (x_get_string_resource): * xrdb.c (x_get_string_resource): Obey inhibit_x_resources. diff --git a/etc/NEWS b/etc/NEWS index 3db3f53..9e3a2f8 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -38,6 +38,11 @@ world-readable install. * Changes in Emacs 23.2 +** Command-line option -Q (--quick) now also disables loading X resources. +On Windows, Registry settings are ignored, though environment variables set +on the Registry are still honored. The new variable `inhibit-x-resources' +shows whether X resources were loaded or not. + ** New completion-style `initials' to complete M-x lch to list-command-history. ** Unibyte sessions are declared obsolete. diff --git a/lisp/startup.el b/lisp/startup.el index 72c185c..3ffc4b8 100644 --- a/lisp/startup.el +++ b/lisp/startup.el @@ -366,8 +366,6 @@ from being initialized." string) :group 'auto-save) -(defvar emacs-quick-startup nil) - (defvar emacs-basic-display nil) (defvar init-file-debug nil) @@ -799,7 +797,7 @@ opening the first frame (e.g. open a connection to an X server).") ((member argi '("-Q" "-quick")) (setq init-file-user nil site-run-file nil - emacs-quick-startup t)) + inhibit-x-resources t)) ((member argi '("-D" "-basic-display")) (setq no-blinking-cursor t emacs-basic-display t) @@ -2272,7 +2270,7 @@ A fancy display is used on graphic displays, normal otherwise." (if (or inhibit-startup-screen initial-buffer-choice noninteractive - emacs-quick-startup) + inhibit-x-resources) ;; Not displaying a startup screen. If 3 or more files ;; visited, and not all visible, show user what they all are. diff --git a/src/emacs.c b/src/emacs.c index 2c14be5..9538e3c 100644 --- a/src/emacs.c +++ b/src/emacs.c @@ -239,6 +239,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; @@ -1483,11 +1486,6 @@ main (int argc, char **argv) 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) { @@ -2680,6 +2678,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 and Windows Registry settings are not used. */); + inhibit_x_resources = 0; + /* Make sure IS_DAEMON starts up as false. */ daemon_pipe[1] = 0; } diff --git a/src/lisp.h b/src/lisp.h index 820c258..f837708 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -3143,6 +3143,9 @@ void shut_down_emacs P_ ((int, int, Lisp_Object)); /* Nonzero means don't do interactive redisplay and don't change tty modes */ extern int noninteractive; +/* Nonzero means don't load X resources or Windows Registry settings. */ +extern int inhibit_x_resources; + /* Pipe used to send exit notification to the daemon parent at startup. */ extern int daemon_pipe[2]; diff --git a/src/w32reg.c b/src/w32reg.c index d2330e7..2b5b352 100644 --- a/src/w32reg.c +++ b/src/w32reg.c @@ -76,7 +76,7 @@ w32_get_rdb_resource (rdb, resource) return NULL; } -LPBYTE +static LPBYTE w32_get_string_resource (name, class, dwexptype) char *name, *class; DWORD dwexptype; @@ -160,6 +160,10 @@ x_get_string_resource (rdb, name, class) return resource; } + if (inhibit_x_resources) + /* --quick was passed, so this is a no-op. */ + return NULL; + return (w32_get_string_resource (name, class, REG_SZ)); } diff --git a/src/xrdb.c b/src/xrdb.c index 0a74c08..fac97e4 100644 --- a/src/xrdb.c +++ b/src/xrdb.c @@ -693,6 +693,10 @@ x_get_string_resource (rdb, name, class) { XrmValue value; + if (inhibit_x_resources) + /* --quick was passed, so this is a no-op. */ + return NULL; + if (x_get_resource (rdb, name, class, x_rm_string, &value)) return (char *) value.addr; ^ permalink raw reply related [flat|nested] 19+ messages in thread
* Re: Not loading the Registry settings 2009-09-14 13:48 ` Juanma Barranquero 2009-09-14 13:54 ` Juanma Barranquero @ 2009-09-14 14:51 ` Adrian Robert [not found] ` <jwv63bl5onb.fsf-monnier+emacs@gnu.org> 2 siblings, 0 replies; 19+ messages in thread From: Adrian Robert @ 2009-09-14 14:51 UTC (permalink / raw) To: Juanma Barranquero Cc: Miles Bader, Emacs developers, Stefan Monnier, David De La Harpe Golden Juanma Barranquero <lekktu@gmail.com> writes: > On Mon, Sep 14, 2009 at 15:29, Stefan Monnier <monnier@iro.umontreal.ca> wrote: >> I think that's OK, but the double-parsing of -Q is not >> very satisfactory. I'd rather see a new variable Vinhibit_x_resources >> instead, which the Lisp code could set to non-nil when it parses >> the -Q argument. > > I had in fact done that before (though I reused instead the currently > undocumented emacs-quick-startup variable that startup.el uses now). > But I didn't want to mess with the processing of -Q/--quick in the > HAVE_NS block immediately following: You can remove the -q/-Q part of that after this because it is just doing what you are trying to do with the new patch. (Vocal NS port user consensus a while back was that the semantics of -Q implied that user customizations should not be loaded even if they come from the resource database instead of .emacs.) ^ permalink raw reply [flat|nested] 19+ messages in thread
[parent not found: <jwv63bl5onb.fsf-monnier+emacs@gnu.org>]
* Re: Not loading the Registry settings [not found] ` <jwv63bl5onb.fsf-monnier+emacs@gnu.org> @ 2009-09-14 19:39 ` Adrian Robert 2009-09-17 23:09 ` Juanma Barranquero 0 siblings, 1 reply; 19+ messages in thread From: Adrian Robert @ 2009-09-14 19:39 UTC (permalink / raw) To: Stefan Monnier; +Cc: lekktu, Emacs-Devel devel On Sep 14, 2009, at 3:14 PM, Stefan Monnier wrote: > Something Emacs.app-related came up while discussing something else: Ouch, I've tried twice to reply to this thread on emacs-devel, but something must be wrong with my GNUs configuration. Let me try again below. > Juanma Barranquero <lekktu@gmail.com> wrote: >> I had in fact done that before (though I reused instead the currently >> undocumented emacs-quick-startup variable that startup.el uses now). >> But I didn't want to mess with the processing of -Q/--quick in the >> HAVE_NS block immediately following: The -Q/-q portion of this can be removed once you've implemented your change, since it implements the same thing. I can clean up the rest in other files once this happens. (A consensus of NS port users and developers decided a while ago that the semantics of -Q implied that user customizations should not be loaded, even if they come from the resource database instead of .emacs.) -Adrian ^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Not loading the Registry settings 2009-09-14 19:39 ` Adrian Robert @ 2009-09-17 23:09 ` Juanma Barranquero 0 siblings, 0 replies; 19+ messages in thread From: Juanma Barranquero @ 2009-09-17 23:09 UTC (permalink / raw) To: Adrian Robert; +Cc: Stefan Monnier, Emacs-Devel devel On Mon, Sep 14, 2009 at 21:39, Adrian Robert <adrian.b.robert@gmail.com> wrote: > The -Q/-q portion of this can be removed once you've implemented your > change, since it implements the same thing. I can clean up the rest in > other files once this happens. OK, I've installed it, removing the -Q part from inside the #idfef HAVE_NS. Now please change (or fix) to your heart's content. Juanma ^ permalink raw reply [flat|nested] 19+ messages in thread
end of thread, other threads:[~2009-09-17 23:09 UTC | newest] Thread overview: 19+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2009-09-12 11:45 Not loading the Registry settings Juanma Barranquero 2009-09-12 12:28 ` David De La Harpe Golden 2009-09-12 12:50 ` Adrian Robert 2009-09-12 14:22 ` Juanma Barranquero 2009-09-12 19:14 ` Stefan Monnier 2009-09-13 2:29 ` Miles Bader 2009-09-14 0:34 ` Juanma Barranquero 2009-09-14 13:29 ` Stefan Monnier 2009-09-14 13:48 ` Juanma Barranquero 2009-09-14 13:54 ` Juanma Barranquero 2009-09-14 21:53 ` Stefan Monnier 2009-09-14 22:24 ` Juanma Barranquero 2009-09-15 1:31 ` Stefan Monnier 2009-09-15 9:26 ` Juanma Barranquero 2009-09-15 13:34 ` Stefan Monnier 2009-09-15 14:27 ` Juanma Barranquero 2009-09-14 14:51 ` Adrian Robert [not found] ` <jwv63bl5onb.fsf-monnier+emacs@gnu.org> 2009-09-14 19:39 ` Adrian Robert 2009-09-17 23:09 ` Juanma Barranquero
Code repositories for project(s) associated with this public inbox https://git.savannah.gnu.org/cgit/emacs.git This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).