(when (emacs-achievement-unlocks achievement)
(require (emacs-achievement-unlocks achievement) nil t))
(unless (emacs-achievement-transient achievement)
+ (when (and achievements-display-when-earned
+ (not (equal (emacs-achievement-predicate achievement) t)))
+ (message "You earned the %s achievement!" (emacs-achievement-name achievement)))
(setf (emacs-achievement-predicate achievement) t)))))
;; Save the updated list of achievements
+(defvar achievements-timer nil
+ "Holds the idle timer.")
+(defcustom achievements-display-when-earned t
+ "If non-nil, various debug messages will be printed regarding achievements activity."
+(defcustom achievements-idle-time 10
+ "Number of seconds for Emacs to be idle before checking if achievements have been earned."
+ "Turns on automatic earning of achievements when idle."
+ ;; The lighter is a trophy
+ (unless achievements-timer
+ (setq achievements-timer
+ (run-with-idle-timer achievements-idle-time t #'achievements-update-score)))
+ (setq achievements-timer (cancel-timer achievements-timer))))