From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrea Giugliano Subject: Re: Org mode repeated dates to do spaced learning Date: Sun, 6 Jan 2019 17:17:23 +0000 Message-ID: References: <20131330-A314-4FB8-BD15-A3E9B352DFEF@gmail.com> <87o98zhcyd.fsf@mbork.pl> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggsout.gnu.org ([209.51.188.92]:40054 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ggC3V-00033q-Jg for emacs-orgmode@gnu.org; Sun, 06 Jan 2019 12:17:46 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ggC3S-0006oM-E1 for emacs-orgmode@gnu.org; Sun, 06 Jan 2019 12:17:45 -0500 Received: from mail-oln040092068012.outbound.protection.outlook.com ([40.92.68.12]:6019 helo=EUR02-HE1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ggC3Q-0006ca-Ec for emacs-orgmode@gnu.org; Sun, 06 Jan 2019 12:17:42 -0500 In-Reply-To: <87o98zhcyd.fsf@mbork.pl> Content-Language: en-US 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" To: Marcin Borkowski Cc: "emacs-orgmode@gnu.org" , Bingo Hi there, That was a very helpful suggestion. At the bottom of the mail I attached my first (working) stab at it. The idea is to have an headline with the :spaced: tag and another tag maintaining the number of repetition performed so far. At the beginning I was thinking to use scheduled times instead of a "counter" tag, but it was not worth the complexity of the code. If anybody else finds this feature useful, what would be the best way to share this? #+begin_src elisp (defun my/space-repeat-if-tag-spaced (e) "Resets the header on the TODO states and increases the scheduled date according to a suggested spaced repetition interval." (let* ((spaced-rep-map '((0 . "++1d") (1 . "++2d") (2 . "++10d") (3 . "++30d") (4 . "++60d") (5 . "++4m"))) (spaced-key "spaced") (tags (org-get-tags nil t)) (spaced-todo-p (member spaced-key tags)) (repetition-n (first (cdr spaced-todo-p))) (n+1 (if repetition-n (+ 1 (string-to-number (substring repetition= -n (- (length repetition-n) 1) (length repetition-n)))) 0)) (spaced-repetition-p (alist-get n+1 spaced-rep-map)) (new-repetition-tag (concat "repetition" (number-to-string n+1))) (new-tags (reverse (if repetition-n (seq-reduce (lambda (a x) (if (string-equal x repetiti= on-n) (cons new-repetition-tag a) (cons x a))) tags '()) (seq-reduce (lambda (a x) (if (string-equal x spaced-key= ) (cons new-repetition-tag (cons x a)) (cons x a))) tags '()))))) (if (and spaced-todo-p spaced-repetition-p) (progn ;; avoid infinitive looping (remove-hook 'org-trigger-hook 'my/space-repeat-if-tag-spaced) ;; reset to previous state (org-call-with-arg 'org-todo 'left) ;; schedule to next spaced repetition (org-schedule nil (alist-get n+1 spaced-rep-map)) ;; rewrite local tags (org-set-tags new-tags) (add-hook 'org-trigger-hook 'my/space-repeat-if-tag-spaced)) ))) (add-hook 'org-trigger-hook 'my/space-repeat-if-tag-spaced) #+end_src Thanks, Andrea On Wed 02 Jan 2019 at 05:59, Marcin Borkowski wrote: > On 2019-01-01, at 17:34, Andrea Giugliano wrote: > >> Hi, >> >> Thanks for your reply. You are right org-drill does spaced repetition. I >> just was unclear: I would like to see that in the agenda as a normal >> item (that gets space-repeated every time I mark it DONE though). >> I could not get from the docs if org-drill does that. > > That is an interesting idea. I am pretty sure you could make it happen > with `org-trigger-hook' or `org-after-todo-state-change-hook' (I am not > entirely sure why both exist, btw). > >> Thanks, >> >> Andrea > > Hth,