emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Delayed warnings


From: Juanma Barranquero
Subject: Re: Delayed warnings
Date: Thu, 28 Apr 2011 18:22:55 +0200

On Thu, Apr 28, 2011 at 17:26, Stefan Monnier <address@hidden> wrote:

> Yup.  Let's wait to get some experience with it first.

OK. I want to install this patch, with is a simplifed version of the
previous one: `delayed-warnings-filter' does not exist, and
`delayed-warnings-function' has become `delayed-warnings-hook', a true
hook.

The idea is that functions in the hook can process and remove as many
elements from `delayed-warnings-list' as they want. The function
`display-delayed-warnings', which is set by default to run last, of
course removes and displays them all.

That makes the delayed warnings infrastructure both simpler and more
flexible. Redisplay warnings would mean (other than pushing the
relevant warnings to `delayed-warnings-list', of course) just adding a
new `display-redisplay-warnings' to the hook.

    Juanma



2011-04-28  Juanma Barranquero  <address@hidden>

        * subr.el (display-delayed-warnings): New function.
        (delayed-warnings-hook): New variable.


2011-04-28  Juanma Barranquero  <address@hidden>

        * keyboard.c (Qdelayed_warnings_hook): Define.
        (command_loop_1): Run `delayed-warnings-hook'
        if Vdelayed_warnings_list is non-nil.
        (syms_of_keyboard) <delayed-warnings-hook>: DEFSYM it.
        (syms_of_keyboard) <delayed-warnings-list>: DEFVAR_LISP it.



=== modified file 'lisp/subr.el'
--- lisp/subr.el        2011-04-27 07:56:55 +0000
+++ lisp/subr.el        2011-04-28 08:31:03 +0000
@@ -1773,6 +1773,19 @@
   (eval-after-load file (read)))
 (make-obsolete 'eval-next-after-load `eval-after-load "23.2")
 
+(defun display-delayed-warnings ()
+  "Display delayed warnings in `delayed-warnings-list'.
+This is the default value of `delayed-warnings-hook'."
+  (dolist (warning (reverse delayed-warnings-list))
+    (apply 'display-warning warning))
+  (setq delayed-warnings-list nil))
+
+(defvar delayed-warnings-hook '(display-delayed-warnings)
+  "Normal hook run to process delayed warnings.
+Functions in this hook should access the `delayed-warnings-list'
+variable (which see) and remove from it the warnings they process.")
+
+
 ;;;; Process stuff.

 (defun process-lines (program &rest args)

=== modified file 'src/keyboard.c'
--- src/keyboard.c      2011-04-26 18:02:10 +0000
+++ src/keyboard.c      2011-04-28 08:28:51 +0000
@@ -267,6 +267,8 @@

 static Lisp_Object Qdeferred_action_function;

+static Lisp_Object Qdelayed_warnings_hook;
+
 static Lisp_Object Qinput_method_exit_on_first_char;
 static Lisp_Object Qinput_method_use_echo_area;

@@ -1356,6 +1358,10 @@
       if (!NILP (echo_area_buffer[0]))
        resize_echo_area_exactly ();

+      /* If there are warnings waiting, process them.  */
+      if (!NILP (Vdelayed_warnings_list))
+        safe_run_hooks (Qdelayed_warnings_hook);
+
       if (!NILP (Vdeferred_action_list))
        safe_run_hooks (Qdeferred_action_function);
     }
@@ -1573,6 +1579,10 @@
       if (!NILP (echo_area_buffer[0]))
        resize_echo_area_exactly ();

+      /* If there are warnings waiting, process them.  */
+      if (!NILP (Vdelayed_warnings_list))
+        safe_run_hooks (Qdelayed_warnings_hook);
+
       safe_run_hooks (Qdeferred_action_function);

       /* If there is a prefix argument,
@@ -11498,6 +11508,7 @@
   DEFSYM (Qpre_command_hook, "pre-command-hook");
   DEFSYM (Qpost_command_hook, "post-command-hook");
   DEFSYM (Qdeferred_action_function, "deferred-action-function");
+  DEFSYM (Qdelayed_warnings_hook, "delayed-warnings-hook");
   DEFSYM (Qfunction_key, "function-key");
   DEFSYM (Qmouse_click, "mouse-click");
   DEFSYM (Qdrag_n_drop, "drag-n-drop");
@@ -12069,6 +12080,14 @@
 whenever `deferred-action-list' is non-nil.  */);
   Vdeferred_action_function = Qnil;

+  DEFVAR_LISP ("delayed-warnings-list", Vdelayed_warnings_list,
+               doc: /* List of warnings to be displayed as soon as possible.
+Each element must be a list (TYPE MESSAGE [LEVEL [BUFFER-NAME]]),
+as per the args of `display-warning' (which see).
+If this variable is non-nil, `delayed-warnings-hook' will be run
+immediately after running `post-command-hook'.  */);
+  Vdelayed_warnings_list = Qnil;
+
   DEFVAR_LISP ("suggest-key-bindings", Vsuggest_key_bindings,
               doc: /* *Non-nil means show the equivalent key-binding when
M-x command has one.
 The value can be a length of time to show the message for.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]