diff options
author | Juanma Barranquero <lekktu@gmail.com> | 2011-04-28 21:35:20 +0200 |
---|---|---|
committer | Juanma Barranquero <lekktu@gmail.com> | 2011-04-28 21:35:20 +0200 |
commit | 638f053a0eb0c69390c29346ac465f30abd80a88 (patch) | |
tree | c15ffc9513f1c0dde205dad566573b7b990e0ca8 | |
parent | f042970d4c3c5b93ce302a6447b7b998649325f5 (diff) | |
download | emacs-638f053a0eb0c69390c29346ac465f30abd80a88.tar.gz |
Add delayed warnings support.
* etc/NEWS: Document `delayed-warnings-list' and `delayed-warnings-hook'.
* lisp/subr.el (display-delayed-warnings): New function.
(delayed-warnings-hook): New variable.
* src/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.
-rw-r--r-- | etc/ChangeLog | 4 | ||||
-rw-r--r-- | etc/NEWS | 3 | ||||
-rw-r--r-- | lisp/ChangeLog | 5 | ||||
-rw-r--r-- | lisp/subr.el | 15 | ||||
-rw-r--r-- | src/ChangeLog | 8 | ||||
-rw-r--r-- | src/keyboard.c | 19 |
6 files changed, 53 insertions, 1 deletions
diff --git a/etc/ChangeLog b/etc/ChangeLog index 48324a6be90..c75af6a0eb3 100644 --- a/etc/ChangeLog +++ b/etc/ChangeLog @@ -1,3 +1,7 @@ +2011-04-28 Juanma Barranquero <lekktu@gmail.com> + + * NEWS: Document `delayed-warnings-list' and `delayed-warnings-hook'. + 2011-04-26 Daniel Colascione <dan.colascione@gmail.com> * DEBUG: Document debug-on-event default behavior and utility for @@ -909,6 +909,9 @@ displayed with a "spinning bar". ** New variable `revert-buffer-in-progress-p' is true while a buffer is being reverted, even if the buffer has a local `revert-buffer-function'. +** New variables `delayed-warnings-list' and `delayed-warnings-hook' allow +deferring warnings until the main command loop is executed. + * Changes in Emacs 24.1 on non-free operating systems diff --git a/lisp/ChangeLog b/lisp/ChangeLog index fee3f07ccca..1444a9ebe5f 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,8 @@ +2011-04-28 Juanma Barranquero <lekktu@gmail.com> + + * subr.el (display-delayed-warnings): New function. + (delayed-warnings-hook): New variable. + 2011-04-28 Stefan Monnier <monnier@iro.umontreal.ca> * pcomplete.el (pcomplete-completions-at-point): diff --git a/lisp/subr.el b/lisp/subr.el index e374b56d2a8..7f0066548a4 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -1772,6 +1772,19 @@ This makes or adds to an entry on `after-load-alist'. FILE should be the name of a library, with no directory name." (eval-after-load file (read))) (make-obsolete 'eval-next-after-load `eval-after-load "23.2") + +(defun display-delayed-warnings () + "Display delayed warnings from `delayed-warnings-list'. +This is the default value of `delayed-warnings-hook'." + (dolist (warning (nreverse 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. @@ -2522,7 +2535,7 @@ Note: :data and :device are currently not supported on Windows." (concat "\"" result (substring argument start) "\""))) ((and (eq system-type 'windows-nt) (w32-shell-dos-semantics)) - + ;; First, quote argument so that CommandLineToArgvW will ;; understand it. See ;; http://msdn.microsoft.com/en-us/library/17w5ykft%28v=vs.85%29.aspx diff --git a/src/ChangeLog b/src/ChangeLog index 107d6f0073a..e20feb0f6f7 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,11 @@ +2011-04-28 Juanma Barranquero <lekktu@gmail.com> + + * 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. + 2011-04-28 Eli Zaretskii <eliz@gnu.org> * doprnt.c (doprnt): Don't return value smaller than the buffer diff --git a/src/keyboard.c b/src/keyboard.c index fac098ddffd..a94456fce2e 100644 --- a/src/keyboard.c +++ b/src/keyboard.c @@ -267,6 +267,8 @@ static Lisp_Object Qpost_command_hook; 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 @@ command_loop_1 (void) 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 @@ command_loop_1 (void) 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 @@ syms_of_keyboard (void) 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 @@ This function is called with no arguments after each command 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. |