class Guard::Notifier::Emacs
notification :emacs
@example Add the ‘:emacs` notifier to your `Guardfile`
Send a notification to Emacs with emacsclient (www.emacswiki.org/emacs/EmacsClient).
def self._emacs_client_available?(opts)
-
(Boolean)- whether or not the emacs client is available
Other tags:
- Private: -
def self._emacs_client_available?(opts) result = `#{opts.fetch(:client, DEFAULTS[:client])} --eval '1' 2> #{DEV_NULL} || echo 'N/A'` !%w(N/A 'N/A').include?(result.chomp!) end
def self.available?(opts = {})
def self.available?(opts = {}) super and _emacs_client_available?(opts) end
def _run_cmd(*args)
def _run_cmd(*args) IO.popen(args).readlines end
def emacs_color(type, options = {})
-
(String)- the name of the emacs color
Options Hash:
(**options)-
default(String) -- the default color to use (default is 'Black') -
pending(String) -- the color to use for pending notifications -
failed(String) -- the color to use for failure notifications (default is 'Firebrick') -
success(String) -- the color to use for success notifications (default is 'ForestGreen')
Parameters:
-
options(Hash) -- aditional notification options -
type(String) -- the notification type
def emacs_color(type, options = {}) default = options.fetch(:default, DEFAULTS[:default]) options.fetch(type.to_sym, default) end
def notify(message, opts = {})
(**opts)-
priority(String, Integer) -- specify an int or named key -
client(String) -- the client to use for notification -
default(String) -- the default color to use (default is -
pending(String) -- the color to use for pending -
failed(String) -- the color to use for failure -
success(String) -- the color to use for success
Parameters:
-
opts(Hash) -- additional notification library options -
image(String) -- the path to the notification image -
message(String) -- the notification message body -
title(String) -- the notification title -
type(String) -- the notification type. Either 'success',
def notify(message, opts = {}) super opts = DEFAULTS.merge(opts) color = emacs_color(opts[:type], opts) fontcolor = emacs_color(:fontcolor, opts) elisp = <<-EOF.gsub(/\s+/, ' ').strip (set-face-attribute 'mode-line nil :background "#{color}" :foreground "#{fontcolor}") EOF _run_cmd(opts[:client], '--eval', elisp) end