Skip to content

Instantly share code, notes, and snippets.

@hitode909
Created June 1, 2010 08:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save hitode909/420718 to your computer and use it in GitHub Desktop.
Save hitode909/420718 to your computer and use it in GitHub Desktop.
Emacsがブロックしたらポップアップを出す
(require 'cl)
(require 'popup)
(lexical-let ((interval 0.1)
(last-called nil)
(timer nil)
(diff nil))
(defun detect-block (flag)
"Start detecting block when flag is true."
(cond
((and flag timer) (detect-block nil))
(flag (progn (setq timer
(run-with-timer interval interval
(lambda ()
(unless last-called (setq last-called (float-time)))
(setq diff (- (float-time) last-called interval))
(setq last-called (float-time))
(when (>= diff interval)
(popup-tip (format "Blocked about %.3f secs." diff))
;; (twittering-http-post twittering-api-host
;; "1/statuses/update"
;; `(("status" . ,(format "Emacs blocked about %.3f secs." diff))))
))))
(message "Start detecting block.")
))
(timer (cancel-timer timer)
(setq timer nil)
(message "Cancel detecting block.")
)
)))
(provide 'detect-block)
; (detect-block t)
; (detect-block nil)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment