Last active
December 27, 2018 14:12
-
-
Save blue0513/fbce0339b689d5f47e7bb8b6038d22fd to your computer and use it in GitHub Desktop.
When flycheck detects errors, post desktop notification on Mac
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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