Skip to content

Instantly share code, notes, and snippets.

@stphung
Created November 16, 2010 00:56
Show Gist options
  • Select an option

  • Save stphung/701265 to your computer and use it in GitHub Desktop.

Select an option

Save stphung/701265 to your computer and use it in GitHub Desktop.
;; Initialize a variable to count actions
(defvar apm-num-chars)
(setq apm-num-chars 0)
;; Calculates actions per minute
(defun apm (duration-seconds actions)
(truncate (* (/ actions (float duration-seconds)) 60)))
;; Increase actions and display
(defun update-apm (a b c)
(setq apm-num-chars (+ 1 apm-num-chars))
(message (number-to-string
(apm (string-to-number (emacs-uptime "%s"))
apm-num-chars))))
;; Mode to add and remove hook
(define-minor-mode apm-mode
:init-value nil
:lighter " APM"
(if apm-mode (add-hook 'after-change-functions 'update-apm nil t)
(remove-hook 'after-change-functions 'update-apm t)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment