• Stars
    star
    426
  • Rank 101,884 (Top 3 %)
  • Language
    Emacs Lisp
  • Created over 13 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A Growl-like alerts notifier for Emacs

Alert is a Growl-workalike for Emacs which uses a common notification interface and multiple, selectable "styles", whose use is fully customizable by the user.

For desktop notifications, the notifications package that is installed with emacs, provides a probably better alternative for most users.

For module writers

Just use alert instead of message as follows:

(require 'alert)

;; This is the most basic form usage
(alert "This is an alert")

;; You can adjust the severity for more important messages
(alert "This is an alert" :severity 'high)

;; Or decrease it for purely informative ones
(alert "This is an alert" :severity 'trivial)

;; Alerts can have optional titles.  Otherwise, the title is the
;; buffer-name of the (current-buffer) where the alert originated.
(alert "This is an alert" :title "My Alert")

;; Further, alerts can have categories.  This allows users to
;; selectively filter on them.
(alert "This is an alert" :title "My Alert" :category 'debug)

;; If a backend allows replacing alerts, you may pass an id
;; to your alert; then the next one with the same id will replace the
;; first one:
(alert "You have 30 unread mails" :title "Mail!" :id 'new-mail-alert)
(alert "You have 49 unread mails" :title "Mail!" :id 'new-mail-alert)
;; This avoids piling up lots of alerts, when only the last one is
;; relevant.

For users

For the user, there are several variables to control when and how alerts are presented. By default, they appear in the minibuffer much the same as a normal Emacs message. But there are many more possibilities:

  • alert-fade-time Normally alerts disappear after this many seconds, if the style supports it. The default is 5 seconds.

  • alert-default-style Pick the style to use if no other config rule matches. The default is message, but growl works well too.

  • alert-reveal-idle-time If a config rule choose to match on idle, this is how many seconds idle the user has to be. Defaults to 5 so that users don't miss any alerts, but 120 is also good.

  • alert-persist-idle-time After this many idle seconds, alerts will become sticky, and not fade away more. The default is 15 minutes.

  • alert-log-messages By default, all alerts are logged to *Alerts* (and to *Messages*, if the message style is being used). Set to nil to disable.

  • alert-hide-all-notifications Want alerts off entirely? They still get logged, however, unless you've turned that off too.

  • alert-user-configuration This variable lets you control exactly how and when a particular alert, a class of alerts, or all alerts, get reported -- or if at all. Use this to make some alerts use Growl, while others are completely silent.

Programmatically adding rules

Users can also programmatically add configuration rules, in addition to customizing alert-user-configuration. Here is one that the author currently uses with ERC, so that the fringe gets colored whenever people chat on BitlBee:

(alert-add-rule :status   '(buried visible idle)
                :severity '(moderate high urgent)
                :mode     'erc-mode
                :predicate
                #'(lambda (info)
                    (string-match (concat "\\`[^&].*@BitlBee\\'")
                                  (erc-format-target-and/or-network)))
                :persistent
                #'(lambda (info)
                    ;; If the buffer is buried, or the user has been
                    ;; idle for `alert-reveal-idle-time' seconds,
                    ;; make this alert persistent.  Normally, alerts
                    ;; become persistent after
                    ;; `alert-persist-idle-time' seconds.
                    (memq (plist-get info :status) '(buried idle)))
                :style 'fringe
                :continue t)

Builtin alert styles

There are several builtin styles, and it is trivial to create new ones. The builtins are:

Name Summary
fringe Changes the current frame's fringe background color
mode-line Changes the current frame's mode-line background color
gntp Uses gntp, it requires gntp.el
growl Uses Growl on OS X, if growlnotify is on the PATH
ignore Ignores the alert entirely
libnotify Uses libnotify if notify-send is on the PATH
log Logs the alert text to Alerts, with a timestamp
message Uses the Emacs message facility
notifications Uses notifications library via D-Bus
notifier Uses terminal-notifier on OS X, if it is on the PATH
osx-notifier Native OSX notification using AppleScript
toaster Use the toast notification system
x11 Changes the urgency property of the window in the X Window System
termux Use termux-notification from the Termux API

Defining new styles

To create a new style, you need to at least write a notifier, which is a function that receives the details of the alert. These details are given in a plist which uses various keyword to identify the parts of the alert. Here is a prototypical style definition:

(alert-define-style 'style-name :title "My Style's title"
                    :notifier
                    (lambda (info)
                      ;; The message text is :message
                      (plist-get info :message)
                      ;; The :title of the alert
                      (plist-get info :title)
                      ;; The :category of the alert
                      (plist-get info :category)
                      ;; The major-mode this alert relates to
                      (plist-get info :mode)
                      ;; The buffer the alert relates to
                      (plist-get info :buffer)
                      ;; Severity of the alert.  It is one of:
                      ;;   `urgent'
                      ;;   `high'
                      ;;   `moderate'
                      ;;   `normal'
                      ;;   `low'
                      ;;   `trivial'
                      (plist-get info :severity)
                      ;; Whether this alert should persist, or fade away
                      (plist-get info :persistent)
                      ;; Data which was passed to `alert'.  Can be
                      ;; anything.
                      (plist-get info :data))

                    ;; Removers are optional.  Their job is to remove
                    ;; the visual or auditory effect of the alert.
                    :remover
                    (lambda (info)
                      ;; It is the same property list that was passed to
                      ;; the notifier function.
                      ))

More Repositories

1

use-package

A use-package declaration for simplifying your .emacs
Emacs Lisp
4,399
star
2

git-scripts

A bunch of random scripts I've either written, downloaded or clipped from #git.
Shell
1,322
star
3

emacs-async

Simple library for asynchronous processing in Emacs
Emacs Lisp
832
star
4

git-from-the-bottom-up

An introduction to the architecture and design of the Git content manager
766
star
5

category-theory

An axiom-free formalization of category theory in Coq for personal study and practical work
Coq
744
star
6

dot-emacs

My .emacs.el file and other personal Emacs goodies
Emacs Lisp
606
star
7

nix-config

My local Nix configuration
Emacs Lisp
399
star
8

gitlib

Haskell
176
star
9

coq-haskell

A library for formalizing Haskell types and functions in Coq
Coq
159
star
10

org-mode

This is a very old fork of Org-mode, but it's the version I still use every day
Emacs Lisp
155
star
11

emacs-chess

A complete chess client written in Emacs Lisp.
Emacs Lisp
122
star
12

coq-pipes

Coq
100
star
13

git-undo-el

A command for Emacs to regress or "undo" a region back through its Git history
Emacs Lisp
87
star
14

control-theory

Control theory in Haskell: Data structures, algorithms and adapters
Haskell
80
star
15

putting-lenses-to-work

A presentation for BayHac 2017 on how I uses lenses at work
Haskell
75
star
16

nix-update-el

An Emacs command for updating fetch declarations in place
Emacs Lisp
71
star
17

una

A universal interface to multiple unarchiving tools
Haskell
68
star
18

use-package-examples

Example declarations to demonstrate the features of use-package
52
star
19

regex-tool

A regular expression IDE for Emacs, to help with the creation and testing of regular expressions.
Emacs Lisp
50
star
20

git-annex-el

Emacs integration for the git-annex tool by Joey Hess
Emacs Lisp
43
star
21

notes

Haskell
42
star
22

z3cat

Use Conal Elliott's concat library to compile regular Haskell functions into Z3 equations
Haskell
38
star
23

emacs-release

A history of Emacs releases, under version control
Emacs Lisp
36
star
24

newartisans

HTML
35
star
25

emacs-pl

Emacs Lisp
31
star
26

bytestring-fiat

An implementation of the Haskell ByteString library using the Fiat system from MIT
Coq
31
star
27

periods

Common Lisp library for manipulating date/time objects at a higher level
Common Lisp
29
star
28

c2hsc

Utility for creating .hsc files from C API header files
Haskell
26
star
29

trade-journal

Code for keep an investment trade journal
Haskell
25
star
30

simple-conduit

Haskell
25
star
31

gdtoa

David M. Gay's floating-point conversion library
C
25
star
32

hours

Utility for showing hours worked within a work month against a target
Haskell
24
star
33

thinking-with-functions

A brief presentation on Denotational Design, based on Conal Elliott's work
Nix
23
star
34

comparable

A library for comparing data structures in Rust, oriented toward testing
Rust
21
star
35

async-pool

Haskell
21
star
36

parsec-free

Haskell
20
star
37

pushme

A script I use for synchronizing directories and ZFS pools between systems
Haskell
20
star
38

haskell-config

My haskell-mode configuration for Emacs
Emacs Lisp
19
star
39

categorical

Compiling to STLC to categories in Haskell and Coq, using Conal Elliot's work
Haskell
19
star
40

ghc-dynamic-example

An example of dynamically loading a Haskell source module
Haskell
18
star
41

scripts

Various and sundry shell scripts used on my system
Shell
17
star
42

linearscan

Coq
17
star
43

coq-lattice

A reflection-based proof tactic for lattices in Coq
Coq
16
star
44

git-all

Utility for finding all Git repositories that need attention
Haskell
16
star
45

coq-cds4ltl

A formalization of finite, constructive log analysis using linear temporal logic
Coq
16
star
46

springboard

An Emacs mode based on Helm that makes it easy to bounce around projects
Emacs Lisp
15
star
47

logging

Haskell
15
star
48

ready-lisp

A distribution of Aquamacs, SBCL and SLIME which offers the simplest way to run Common Lisp on Mac OS X
Emacs Lisp
14
star
49

haskell-to-c

Sample code to build a C library from a Haskell module, then call it from C
Haskell
12
star
50

markdown.net

A Markdown and SmartyPants processor written in C# for .NET.
C#
12
star
51

svndump

Library for parsing Subversion dump files from Haskell
Haskell
12
star
52

hello

Hello world project templates for getting started quickly with Nix
Nix
11
star
53

software-foundations

Nix-enabled and fully building mirror of Software Foundations WITHOUT SOLUTIONS
HTML
10
star
54

remember

A mode for Emacs which makes it easy to quickly jot down information.
Emacs Lisp
10
star
55

dirscan

Stateful directory scanning in Python. Makes a great ~/.Trash cleaner.
Python
9
star
56

pipes-files

Haskell
9
star
57

monad-extras

Haskell
9
star
58

cambl

Common Lisp library for working with commoditized amounts and balances
Common Lisp
9
star
59

sizes

Recursively show space (size and i-nodes) used in subdirectories
Haskell
9
star
60

disk-catalog

A Python script for cataloging offline media and disk archives.
Python
8
star
61

erc-yank

Automagically create a Gist in ERC if pasting more than 5 lines
Emacs Lisp
8
star
62

hierarchy

Haskell
8
star
63

simple-ltl

A simple compiler from LTL formulas to state machines
Haskell
7
star
64

linearscan-hoopl

Haskell
7
star
65

pcomplete

A programmable TAB completion facility for Emacs Lisp programmers. Used by Eshell.
Emacs Lisp
7
star
66

subconvert

A script to faithfully convert Subversion repositories to Git
C++
7
star
67

red-black

An efficient implementation of red-black trees for Common Lisp, by Jรผrgen Bรถhms Heimatseiten
Common Lisp
6
star
68

stringable

A Stringable type class, in the spirit of Foldable and Traversable
Haskell
6
star
69

gnus-harvest

Harvest e-mail addresses from read/written Gnus articles
Emacs Lisp
5
star
70

start-kadena

My own Nix script for starting and testing a Kadena node
Nix
5
star
71

ipcvar

Haskell
5
star
72

set-theory

Coq
5
star
73

pipes-async

Haskell
5
star
74

eval-expr

Enhanced eval-expression command
Emacs Lisp
5
star
75

planner

A day-planner-like planning tool for Emacs; uses Muse to publish plan pages.
Emacs Lisp
5
star
76

sacred-writings

A bilingual typesetting of the Hidden Words
TeX
4
star
77

sitebuilder

Common Hakyll builder for my websites
Haskell
4
star
78

bcalc

Haskell
4
star
79

refine-freer

Experiments with an extensible refinement framework
Coq
4
star
80

wallet

Information about staking and management ICP tokens on the Internet Computer
Nix
4
star
81

haskell-infra

Some files related to administration of Haskell infrastructure
4
star
82

firewall

A rigorous set of firewall scripts for BSD ipfw, and Linux iptables
Shell
4
star
83

linkdups

Intelligently hard-link duplicate files in a directory tree
Python
4
star
84

haskell-c-stack

Experiments to determine how the C stack relates to the Haskell FFI
Haskell
3
star
85

runmany

Run multiple commands, interleaving output and errors
Haskell
3
star
86

johnwiegley

My personal website, at johnwiegley.com
HTML
3
star
87

zomega

A computational reflection based solver for expressions involving Z (but tunable)
Coq
3
star
88

rehoo

Utility to combine lots and lots of .hoo files in parallel
Haskell
3
star
89

consistent

Haskell
3
star
90

sshify

Script for setting up publickey authentication on new hosts
Shell
3
star
91

monad-base-control

A rewrite of monad-control which provides only MonadBaseControl
Haskell
3
star
92

haskell-quantification

Presentation on quantification in Haskell for South Bay Haskell
Haskell
3
star
93

muse

The Emacs Muse, a complete publishing environment written for Emacs.
Emacs Lisp
3
star
94

helm-hoogle

Use helm to navigate query results from Hoogle
Emacs Lisp
2
star
95

org-beamer-template

A quick template from which to start new presentations
Emacs Lisp
2
star
96

aasaan

A library for transliterating between different representations of the Arabic alphabet.
C++
2
star
97

kleisli

Haskell
2
star
98

z3-generate-api

A tool to generate Haskell wrappers around the Z3 C API
Haskell
2
star
99

project-euler

My solutions to Project Euler in Haskell
Haskell
2
star
100

church-list

Haskell
2
star