[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

zen-reward.el, emacs gamification

From: joakim
Subject: zen-reward.el, emacs gamification
Date: Tue, 09 Dec 2014 00:00:23 +0100
User-agent: Gnus/5.130012 (Ma Gnus v0.12) Emacs/24.4.50 (gnu/linux)

I use this code to gamify emacs. Its actually quite effective.
I've been meaning to clean it up and stuff, but here it is anyway.

What it does is give you "zen reward points" when you do stuff, like
typing. You get 1 zen point per character.

Closing TODO:s in org gives you lots of points! So its more efficient to
close todos then to type.

You inspect your reward, and then claim it. For instance, when I get
1000 zen points, I claim the reward and get to waste time on 9gag or
something. This part is up to your self discipline, but it can also hook
inte my larger zen mode, which has stuff like disabling surfing, etc.

(define-minor-mode zen-reward-mode
  "type a lot and get a reward!."
  :global t
  :init-value nil
  :lighter nil
  :keymap nil
  :group 'zen

  (if zen-reward-mode
      (progn (add-hook 'pre-command-hook 'zen-reward-pre-command-hook)
             (add-hook 'org-after-todo-state-change-hook 
    (progn (remove-hook 'pre-command-hook 'zen-reward-pre-command-hook)
           (remove-hook 'org-after-todo-state-change-hook 

(defvar  zen-reward-accumulator 0)

(defun zen-reward-todo-state-change-hook ()
  (message "todo hook %s %s" org-state (org-show-priority))
  ;;if you toggle a task back and forth you get super rich.
  ;;you get rewarded for CANCELLED also, but that is good!
  (if  (equal org-state "DONE")
        (let ((reward (string-to-number (substring (org-show-priority) (length 
"Priority is ") ))))
          ;;priority A is 4001, B 3001 and so on. probably can be negative as 
well. so reward needs to be modified a bit
          (message "todo reward %d!" reward)
          (setq zen-reward-accumulator (+ reward zen-reward-accumulator) ))
;testing. only get reward for typing, not for cursor movement and other things
(defun zen-reward-pre-command-hook ()
  "accumulate typing reward."
  (if (or (eq real-last-command 'self-insert-command)
          (eq real-last-command 'org-self-insert-command))
      (setq zen-reward-accumulator (1+ zen-reward-accumulator) ))
;;  (message "reward:%d %s %d" zen-reward-accumulator real-last-command 
(defun zen-claim-reward ()
  "cash in your bountiful reward, spend it on fun and games!"
  (interactive )
  (message "reward:%d" zen-reward-accumulator)
  (setq zen-reward-accumulator 0))
(defun zen-inspect-reward ()
  "how soon can i afford fun and games?"
  (interactive )
  (message "zen reward:%d" zen-reward-accumulator)


Joakim Verona

reply via email to

[Prev in Thread] Current Thread [Next in Thread]