From: Juanma Barranquero <lekktu@gmail.com>
To: Emacs developers <emacs-devel@gnu.org>
Subject: Delayed warnings
Date: Sun, 20 Mar 2011 06:44:13 +0100 [thread overview]
Message-ID: <AANLkTin8Fq7bSQjY6vOUvYMz=Q_12BoDNkVukE7yGPz9@mail.gmail.com> (raw)
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 <lekktu@gmail.com>
* 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 <lekktu@gmail.com>
* 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)
next reply other threads:[~2011-03-20 5:44 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-20 5:44 Juanma Barranquero [this message]
2011-03-21 8:01 ` Delayed warnings martin rudalics
2011-03-21 12:01 ` Juanma Barranquero
2011-03-21 13:17 ` martin rudalics
2011-03-21 13:43 ` Eli Zaretskii
2011-03-21 18:06 ` martin rudalics
2011-03-21 14:48 ` Juanma Barranquero
2011-03-21 18:06 ` martin rudalics
2011-03-21 20:19 ` Juanma Barranquero
2011-03-21 22:05 ` Stefan Monnier
2011-03-22 7:59 ` martin rudalics
2011-03-22 11:59 ` Juanma Barranquero
2011-03-23 13:50 ` Jeff Sparkes
2011-03-25 13:10 ` Juanma Barranquero
2011-04-27 0:55 ` Juanma Barranquero
2011-04-27 3:05 ` Eli Zaretskii
2011-04-27 11:27 ` Juanma Barranquero
2011-04-27 17:32 ` Stefan Monnier
2011-04-27 22:11 ` Juanma Barranquero
2011-04-28 0:40 ` Stefan Monnier
2011-04-28 0:59 ` Juanma Barranquero
2011-04-28 15:26 ` Stefan Monnier
2011-04-28 16:22 ` Juanma Barranquero
2011-04-28 18:39 ` Stefan Monnier
2011-05-08 17:58 ` Chong Yidong
2011-05-08 18:43 ` Juanma Barranquero
2011-05-09 14:15 ` Stefan Monnier
2011-05-09 18:28 ` Richard Stallman
2011-03-22 7:58 ` martin rudalics
2011-03-22 12:04 ` Juanma Barranquero
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='AANLkTin8Fq7bSQjY6vOUvYMz=Q_12BoDNkVukE7yGPz9@mail.gmail.com' \
--to=lekktu@gmail.com \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.