From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Juanma Barranquero Newsgroups: gmane.emacs.devel Subject: Delayed warnings Date: Sun, 20 Mar 2011 06:44:13 +0100 Message-ID: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1300599910 15894 80.91.229.12 (20 Mar 2011 05:45:10 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sun, 20 Mar 2011 05:45:10 +0000 (UTC) To: Emacs developers Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Mar 20 06:45:06 2011 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Q1BRq-00021P-0W for ged-emacs-devel@m.gmane.org; Sun, 20 Mar 2011 06:45:06 +0100 Original-Received: from localhost ([127.0.0.1]:58849 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q1BRo-000149-OP for ged-emacs-devel@m.gmane.org; Sun, 20 Mar 2011 01:45:04 -0400 Original-Received: from [140.186.70.92] (port=40464 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Q1BRf-000113-5T for emacs-devel@gnu.org; Sun, 20 Mar 2011 01:44:57 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Q1BRd-0002Md-V4 for emacs-devel@gnu.org; Sun, 20 Mar 2011 01:44:55 -0400 Original-Received: from mail-yw0-f41.google.com ([209.85.213.41]:55913) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Q1BRd-0002MZ-SW for emacs-devel@gnu.org; Sun, 20 Mar 2011 01:44:53 -0400 Original-Received: by yws5 with SMTP id 5so2542295yws.0 for ; Sat, 19 Mar 2011 22:44:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:from:date:message-id:subject:to :content-type:content-transfer-encoding; bh=e12lFqJXnHZB5n8DX6dn48RYu1zqk7w+s0uE4MXf/FI=; b=iYxxwYhZsdSsId6lYa00ZzrCWJ9jyBl20Qad87u82IsAxC4zWW6PuoYosTfLkPAzrb hbnlHf+ChllWbAMYhWiGf9am3+3kCCr+Ft2VRHM45fENAChZNC+Skzted2AuK3Iw1DUX ek4dndNUYm8vE1Z4pcKSQk+Bg83W8deqk+paw= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:from:date:message-id:subject:to:content-type :content-transfer-encoding; b=Dsjj7tyWOAbWuBU5jkjoPJjxRTyOJI5KglKBi975MtLHodegbQ9d8JSlRJrzmYw9Mi QXVwLNpqZuL1q4QYyJRpRXCzb3ieWfTlzxrRszHTVp4cG8L9ibCZyQfZjXWGxZNPrCAL YfyEavccQPbdSF44XwJsg5rMWZqM7mvT5YBhw= Original-Received: by 10.236.140.67 with SMTP id d43mr3765467yhj.103.1300599893306; Sat, 19 Mar 2011 22:44:53 -0700 (PDT) Original-Received: by 10.147.34.11 with HTTP; Sat, 19 Mar 2011 22:44:13 -0700 (PDT) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 209.85.213.41 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:137448 Archived-At: I want to warn the user for the case that the Windows port defaults to setting HOME=3DC:\ 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 unnecess= ary? The following patch is just a proof-of-concept for discussion, BTW. =C2=A0 =C2=A0 Juanma 2011-03-20 Juanma Barranquero * emacs.c (syms_of_emacs) : New variable. * w32.c (init_environment): Use it to warn about default HOME=3DC:\. 2011-03-20 Juanma Barranquero * startup.el (command-line): Show delayed warnings. =3D=3D=3D 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' =3D=3D=3D 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 =3D 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 =3D Qnil; + /* Make sure IS_DAEMON starts up as false. */ daemon_pipe[1] =3D 0; } =3D=3D=3D 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 =3D 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 =3D=3D S_OK) + { env_vars[0].def_value =3D default_home; + appdata =3D 1; + } } } @@ -1694,6 +1698,14 @@ lpval =3D env_vars[i].def_value; dwType =3D REG_EXPAND_SZ; dont_free =3D 1; + if (!strcmp (env_vars[i].name, "HOME") && !appdata) + { + Lisp_Object warning[2]; + warning[0] =3D intern ("initialization"); + warning[1] =3D build_string ("Setting HOME to C:\\ by default is deprecated"); + Vdelayed_warnings =3D Fcons (Flist (2, warning), + Vdelayed_warnings); + } } if (lpval)