From mboxrd@z Thu Jan 1 00:00:00 1970 From: Thorsten Jolitz Subject: Re: random weekly event Date: Tue, 15 Jul 2014 23:58:47 +0200 Message-ID: <87bnsq1dyg.fsf@gmail.com> References: <877g3e9yzc.fsf@kanis.fr> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:52769) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X7Akc-0004nI-27 for emacs-orgmode@gnu.org; Tue, 15 Jul 2014 17:59:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X7AkW-0006qj-9k for emacs-orgmode@gnu.org; Tue, 15 Jul 2014 17:59:06 -0400 Received: from plane.gmane.org ([80.91.229.3]:56490) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X7AkW-0006qW-3N for emacs-orgmode@gnu.org; Tue, 15 Jul 2014 17:59:00 -0400 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1X7AkV-0005FJ-2D for emacs-orgmode@gnu.org; Tue, 15 Jul 2014 23:58:59 +0200 Received: from g231111139.adsl.alicedsl.de ([92.231.111.139]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 15 Jul 2014 23:58:59 +0200 Received: from tjolitz by g231111139.adsl.alicedsl.de with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 15 Jul 2014 23:58:59 +0200 List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode@gnu.org Ivan Kanis writes: > Hi, > > I need to have org agenda (and then appt) manage an event once a week. > The catch is that is should happen at a random day and hour. > > My thinking is that populating programmatically a year entry is probably > the sanest way to go about it. > > Has anyone else done it? This is not an arcane scientific solution, but should give a random timestamp for between tomorrow and the end of the current week. You could write a function (using run-with-timer) that runs this sunday at 00:00h and inserts a todo item with the returned timestamp into an agenda file: #+begin_src emacs-lisp (defun tj/return-random-timestamp-this-week () "Insert random timestamp for this week." (interactive) (let* ((cal-info (decode-time (current-time))) (dow (nth 6 cal-info)) (year (nth 5 cal-info)) (month (nth 4 cal-info)) (day (nth 3 cal-info)) (hour (nth 2 cal-info)) (random-day (+ day (1+ (random (- 5 dow))))) (random-hour (random 23)) (random-minute (random 59)) (random-second (random 59))) (format-time-string "%D %R" (encode-time random-second random-minute random-hour random-day month year)))) #+end_src #+results: : tj/return-random-timestamp-this-week #+begin_src emacs-lisp :results raw (let (res) (dotimes (i 10 res) (setq res (concat res (format "%d: %s\n" (1+ i) (tj/return-random-timestamp-this-week)))))) #+end_src #+results: 1: 07/17/14 17:39 2: 07/16/14 18:18 3: 07/18/14 19:21 4: 07/17/14 12:58 5: 07/16/14 15:30 6: 07/16/14 16:17 7: 07/16/14 04:10 8: 07/16/14 21:37 9: 07/17/14 19:22 10: 07/16/14 13:39 -- cheers, Thorsten