Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Alternatives to Emacs "message"
branch: master

This branch is 136 commits behind rolandwalker:master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
README.markdown
alert.el

README.markdown

Overview

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

The principal 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 message.

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 alert-face.

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 message:

  • CONTENT must already be formatted.

  • The content is displayed with added color.

  • The bell is rung.

  • CONTENT is not written to the messages buffer (log).

  • After display, the previous contents of the echo area are restored.

The following forms using message and alert are equivalent:

(message "hello, %s" name)
(alert (format "hello, %s" name) 'quiet 0 'nocolor 'log)

message alternatives

The following functions provided by this library are drop-in alternatives to message:

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:

(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))

Notes

The function alert-install-aliases provides shorter aliases for the message alternative functions, outside of the alert- namespace.

The function message-noformat is also available, but it is not quite a drop-in replacement for message.

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.

Something went wrong with that request. Please try again.