Delayed Warnings
Sometimes, you may wish to avoid showing a warning while a command is running, and only show it only after the end of the command. You can use the function delay-warning for this. Emacs automatically delays any warnings emitted during the early stages of startup, and shows them only after the init files are processed.
- Function: delay-warning type message &optional level buffer-name
This function is the delayed counterpart to
display-warning(see Warning Basics), and it is called with the same arguments. The warning message is queued intodelayed-warnings-list.
- Variable: delayed-warnings-list
-
The value of this variable is a list of warnings to be displayed after the current command has finished. Each element must be a list
(type message [level [buffer-name]])
with the same form, and the same meanings, as the argument list of
display-warning. Immediately after runningpost-command-hook(see Command Loop Overview), the Emacs command loop displays all the warnings specified by this variable, then resets the variable tonil.
Programs which need to further customize the delayed warnings mechanism can change the variable delayed-warnings-hook:
- Variable: delayed-warnings-hook
-
This is a normal hook which is run by the Emacs command loop, after
post-command-hook, in order to process and display delayed warnings. Emacs also runs this hook during startup, after loading the site-start and user init files (see Summary: Sequence of Actions at Startup), because warnings emitted before that are automatically delayed.Its default value is a list of two functions:
(collapse-delayed-warnings display-delayed-warnings)
The function
collapse-delayed-warningsremoves repeated entries fromdelayed-warnings-list. The functiondisplay-delayed-warningscallsdisplay-warningon each of the entries indelayed-warnings-list, in turn, and then setsdelayed-warnings-listtonil.
Copyright © 1990-1996, 1998-2026 Free Software Foundation, Inc.
Licensed under the GNU GPL license.
https://www.gnu.org/software/emacs/manual/html_node/elisp/Delayed-Warnings.html