Skip to content

Instantly share code, notes, and snippets.

@blue0513
Last active December 27, 2018 14:12
Show Gist options
  • Save blue0513/fbce0339b689d5f47e7bb8b6038d22fd to your computer and use it in GitHub Desktop.
Save blue0513/fbce0339b689d5f47e7bb8b6038d22fd to your computer and use it in GitHub Desktop.
When flycheck detects errors, post desktop notification on Mac
(add-hook 'flycheck-status-changed-functions
(lambda (status)
(when (eq status 'finished)
(if(flycheck-has-current-errors-p 'error)
(notification-center "flycheck ERROR")))))
;; Mavericksで Emacsからデスクトップ通知を使う
;; http://syohex.hatenablog.com/entry/20131025/1382712857
(defvar notification-center-title "Emacs")
(defun notification-center (msg)
"HOGE MSG."
(let ((tmpfile (make-temp-file "notification-center")))
(with-temp-file tmpfile
(insert
(format "display notification \"%s\" with title \"%s\""
msg notification-center-title)))
(unless (zerop (call-process "osascript" tmpfile))
(message "Failed: Call AppleScript"))
(delete-file tmpfile)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment