Alternatives to Emacs “message”.
Alert.el provides alternatives to Emacs’ built-in
‘message’ function. This library is generally only useful when programming in Emacs Lisp. However, some end-users may find it useful to control messaging, especially for the case of quietening chatty libraries in their ~/.emacs files (see “message alternatives” section below).
‘alert’ function by default works differently from
‘message’ in almost every respect.
The arguments to the familiar
‘message’ function are a format string followed by any number of arguments which may be substituted into the format string. This flexible syntax obviates any arguments to control the behavior of
‘Alert’, by contrast, takes as its first argument a preformatted string, followed by a number of optional arguments to control its behavior. The full argument spec is:
content &optional quiet seconds nocolor log notify popup
‘Alert’ transiently and noticeably displays CONTENT in the echo area.
CONTENT should be a pre-formatted string.
Optional QUIET suppresses the bell, which is on by default.
Optional SECONDS determines the number of seconds CONTENT will be displayed before reverting to the previous content of the echo area. Default is
‘alert-message-seconds’. If SECONDS is 0, or non-numeric, the message is not timed out, and remains visible until the next write to the echo area.
Optional NOCOLOR suppresses coloring the message with face held in the variable
Optional LOG enables logging of CONTENT for any non-nil value. If LOG is ‘log-only, then CONTENT goes only to the \*Messages\* buffer and all other options are ignored.
Optional NOTIFY enables sending the message via the notifications system of the underlying OS. The default is nil. If NOTIFY is ‘replace-echo, then the notification will be used instead of the echo area. For any other non-nil value, the notification will be used in addition to the echo area.
Optional POPUP enables sending the message via
‘popup-tip’ from popup.el. The default is nil. If POPUP is ‘replace-echo, then the popup will be used instead of the echo area. For any other non-nil value, the popup will be used in addition to the echo area.
The behavior of
‘alert’ is very different from
The following forms using
‘alert’ are equivalent:
(message "hello, %s" name) (alert (format "hello, %s" name) 'quiet 0 'nocolor 'log)
The following functions provided by this library are drop-in alternatives to
alert-message-nolog alert-message-logonly alert-message-highlight alert-message-insert alert-message-notify alert-message-popup alert-message-temp
which may be useful in an
‘flet’ construct to control messaging. For example, the following code would redirect messages from a very chatty library to the log:
(flet ((message (&rest args) (apply 'alert-message-logonly args))) (require 'very-chatty-library))
The same method may also be handy with
(defadvice very-chatty-function (around very-chatty-redirect activate) (flet ((message (&rest args) (apply 'alert-message-logonly args))) ad-do-it))
Similarly, important messages may be redirected to a more visible form:
(defadvice an-important-function (around an-important-function activate) (flet ((message (&rest args) (apply 'alert-message-notify args))) ad-do-it))
‘alert-install-aliases’ provides shorter aliases for the message alternative functions, outside of the
‘message-noformat’ is also available, but it is not quite a drop-in replacement for
Some of the functions require the availability of notify.el, todochiku.el or popup.el. In all cases, the function will degrade to an ordinary message if the external library is not present.
Tested only on GNU Emacs version 24.1
Alert.el is available at github:
and via EmacsWiki: