help-gnu-emacs
[Top][All Lists]
Advanced

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

Calling a function every random number of minutes, where random amount


From: metaperl.com
Subject: Calling a function every random number of minutes, where random amount changes
Date: Thu, 29 Nov 2007 07:51:16 -0800 (PST)
User-agent: G2/1.0

The code below randomly selects one of my favorite color-themes. I
would like to set something up so that (color-theme-random) is called
after n minutes have elapsed. Where n is non-constant and randomly
chosen between 5 and 60.

In other words, after 7 minutes it calll the function. Then after 30
minutes it calls it again. Then 12 minutes... and so on and so on.

(require 'color-theme)

(random t)

(defvar *color-theme-favorites*
  '(

    arjen andreas billw blippblopp blue-mood blue-sea calm-forest
    classic comidia dark-blue dark-blue2 deep-blue
    euphoria feng-shui fischmeister goldenrod gray1 gray30
    high-contrast hober infodoc jb-simple jonadabian
    jsc-dark jsc-light
kingsajz
    late-night lawrence lethe
    marine marquardt midnight mistyday montz oswald parus
    robin-hood simple-1 subtle-blue tty-dark
    word-perfect
    xp

    ))

(defun color-theme-random()
     (interactive)



     (let* ((choice (nth (random (length *color-theme-favorites*))
                         *color-theme-favorites*))
            (fn (intern (format "color-theme-%s" choice))))
       (funcall fn)))

(color-theme-random)

(provide 'color-theme-random)
;;;


reply via email to

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