[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Delayed warnings
From: |
Juanma Barranquero |
Subject: |
Delayed warnings |
Date: |
Sun, 20 Mar 2011 06:44:13 +0100 |
I want to warn the user for the case that the Windows port defaults to
setting HOME=C:\ because HOME is not set but C:/.emacs exists.
The only problem is that I want to use a warning, not a message,
because a warning is much more visible and less easy to overlook.
So, I need to set up a warning, delaying it until the right moment
(during startup.el, when the display is set up, lisp code can be
executed and everything's just right).
To such effect I want to add a new C-level variable Vdelayed_warnings
that C code can use to warn the user of problems during
initialization.
Already existing similar facilities are the
pending_malloc_warning/display_malloc_warning stuff and
deferred_action_list/deferred_action_function:
- *_malloc_warning could be used, but it is too specifically tied to
malloc, and it's best left alone.
- deferred_action_* is undocumented (see my other message).
Am I missing some other facility that would make Vdelayed_warnings unnecessary?
The following patch is just a proof-of-concept for discussion, BTW.
Juanma
2011-03-20 Juanma Barranquero <address@hidden>
* emacs.c (syms_of_emacs) <Vdelayed_warnings>: New variable.
* w32.c (init_environment): Use it to warn about default HOME=C:\.
2011-03-20 Juanma Barranquero <address@hidden>
* startup.el (command-line): Show delayed warnings.
=== modified file 'lisp/startup.el'
--- lisp/startup.el 2011-03-19 18:27:55 +0000
+++ lisp/startup.el 2011-03-20 04:41:59 +0000
@@ -1249,6 +1249,10 @@
;; If -batch, terminate after processing the command options.
(if noninteractive (kill-emacs t))
+ ;; If we have delayed warnings, show them
+ (dolist (warning (nreverse delayed-warnings))
+ (apply 'display-warning warning))
+
;; In daemon mode, start the server to allow clients to connect.
;; This is done after loading the user's init file and after
;; processing all command line arguments to allow e.g. `server-name'
=== modified file 'src/emacs.c'
--- src/emacs.c 2011-03-17 16:32:03 +0000
+++ src/emacs.c 2011-03-20 04:22:09 +0000
@@ -2484,6 +2484,16 @@
Vdynamic_library_alist = Qnil;
Fput (intern_c_string ("dynamic-library-alist"), Qrisky_local_variable, Qt);
+ DEFVAR_LISP ("delayed-warnings", Vdelayed_warnings,
+ doc: /* List of warnings to be displayed during startup.
+For each item of the list,
+
+ (apply 'display-warning ITEM)
+
+is called, so ITEM must be a list of (TYPE MESSAGE [LEVEL [BUFFER-NAME]]),
+as per the args of `display-warning' (which see). */);
+ Vdelayed_warnings = Qnil;
+
/* Make sure IS_DAEMON starts up as false. */
daemon_pipe[1] = 0;
}
=== modified file 'src/w32.c'
--- src/w32.c 2011-03-14 17:07:53 +0000
+++ src/w32.c 2011-03-20 05:25:36 +0000
@@ -1554,6 +1554,7 @@
char locale_name[32];
struct stat ignored;
char default_home[MAX_PATH];
+ int appdata = 0;
static const struct env_entry
{
@@ -1607,7 +1608,10 @@
/* If we can't get the appdata dir, revert to old behavior. */
if (profile_result == S_OK)
+ {
env_vars[0].def_value = default_home;
+ appdata = 1;
+ }
}
}
@@ -1694,6 +1698,14 @@
lpval = env_vars[i].def_value;
dwType = REG_EXPAND_SZ;
dont_free = 1;
+ if (!strcmp (env_vars[i].name, "HOME") && !appdata)
+ {
+ Lisp_Object warning[2];
+ warning[0] = intern ("initialization");
+ warning[1] = build_string ("Setting HOME to C:\\ by default
is
deprecated");
+ Vdelayed_warnings = Fcons (Flist (2, warning),
+ Vdelayed_warnings);
+ }
}
if (lpval)
- Delayed warnings,
Juanma Barranquero <=
- Re: Delayed warnings, martin rudalics, 2011/03/21
- Re: Delayed warnings, Juanma Barranquero, 2011/03/21
- Re: Delayed warnings, Juanma Barranquero, 2011/03/21
- Re: Delayed warnings, martin rudalics, 2011/03/21
- Re: Delayed warnings, Juanma Barranquero, 2011/03/21
- Re: Delayed warnings, Stefan Monnier, 2011/03/21
- Re: Delayed warnings, martin rudalics, 2011/03/22