Skip to content
Cezary Baginski edited this page May 17, 2016 · 1 revision

Emacs support (since version 0.1.0)

1. Requirements

  1. Emacs server needs to be running.

You can start it with M-x server-start or adding (server-start) to your emacs config.

2. Creating your own Emacs Elisp script

The default script doesn't do much and probably is useless. E.g. it doesn't reset the colors, it doesn't show messages, etc.

Instead, create a file e.g. ~/.emacs.notiffany.erb with the following contents:

(progn
  (unless (boundp 'notiffany-original-background) (setq notiffany-original-background (face-background 'mode-line)))
  (unless (boundp 'notiffany-original-foreground) (setq notiffany-original-foreground (face-foreground 'mode-line)))
  (set-face-attribute 'mode-line nil :background "<%= bgcolor %>" :foreground "<%= color %>")
  (message "<%= message %>")

  (run-at-time "5 sec" nil (lambda ()
                             (set-face-attribute 'mode-line nil
                                                 :background notiffany-original-background
                                                 :foreground notiffany-original-foreground)))
)

The above should add a message, highlight the modeline bar to green (with white text) and reset the colors after 5 seconds.

Notice that ERB is used to insert the values from Notiffany.

The following variables are currently available: color, bgcolor and message.

3. Configure your notifications

Set the elisp_file option to point to your file above.

E.g. if you're using Guard, you may want a ~/.guard.rb file with the following:

notification(:emacs, {
  elisp_file: '~/.emacs.notiffany.erb', 
  success:   "ForestGreen",  # background of modeline bar when successful
  failed:    "Firebrick",  # background of modeline bar when failed
  default:   "Black",  # default color (which is a bit silly since it's for both bg and font)
  fontcolor: "White", # color of the font
})

4. Troubleshooting

If you're using Guard, enable debugging with bundle exec guard -d and it should show you whether Emacs notifier is available and what was sent to it.

Open an issue otherwise.