From mboxrd@z Thu Jan 1 00:00:00 1970 From: Wanrong Lin Subject: Re: Bug: Entries with diary-sexps in "scheduled" not exported properly to calendar file (.ics file) Date: Mon, 1 Apr 2019 14:14:33 -0400 Message-ID: <86032d46-0fcf-f1d0-a250-ac696be11ed0@gmail.com> References: <51338C37.9020604@gmail.com> <87li8qfrrv.fsf@bzg.ath.cx> <23706.28088.983119.50420@AGAME7.local> <96b9e6c5-a283-bfef-d128-bfdd246b3629@gmail.com> <23706.37645.816738.515299@AGAME7.local> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Return-path: Received: from eggs.gnu.org ([209.51.188.92]:38855) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hB1SA-0001oS-LR for emacs-orgmode@gnu.org; Mon, 01 Apr 2019 14:14:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hB1S9-0000sL-Pm for emacs-orgmode@gnu.org; Mon, 01 Apr 2019 14:14:38 -0400 Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]:46185) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hB1S9-0000rq-GK for emacs-orgmode@gnu.org; Mon, 01 Apr 2019 14:14:37 -0400 Received: by mail-pl1-x62b.google.com with SMTP id y6so4873526pll.13 for ; Mon, 01 Apr 2019 11:14:37 -0700 (PDT) In-Reply-To: <23706.37645.816738.515299@AGAME7.local> 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: Thomas Plass Cc: emacs-orgmode@gnu.org I just wrote a function to do it, and hope it can help other people with similar needs: ;; example: (dates-from-diary-sexp "2019-04-01" "2019-09-01" "(diary-float t 1 2)") ;; => ((8 12 2019) (7 8 2019) (6 10 2019) (5 13 2019) (4 8 2019)) (defun dates-from-diary-sexp (start end diary-sexp)   "Given a start and ending date, returns all valid dates between them that satisfy diary-sexp"   (let ((day-absolute (org-time-string-to-absolute start))         (end-absolute (org-time-string-to-absolute end))         (sexp (car (read-from-string diary-sexp)))         (dates))     (while (< day-absolute end-absolute)       (let ((date (calendar-gregorian-from-absolute day-absolute))             (entry nil))         (when (eval sexp)           (setf dates (cons date dates)))         (incf day-absolute)))     dates)) On 3/26/2019 5:01 PM, Thomas Plass wrote: > Wanrong Lin wrote at 15:20 on March 26, 2019: > : > : As a work around, do you know if there is a way > : to generate a series of dates / org entries from a diary-sexps? Thanks. > > Evaluating those sexp is done in diary-lib. But it's no use simply > supplying arguments to functions there as they require external setup, > in particular variables such the current DATE (mon day year), itself > coming from calendar.el. However, it's exactly such dates that you > are looking for in the first place. I guess, in your example > (diary-float t 1 2) you might have to loop through all the days of all > months (calendar knows about those) to see whether your sexp evaluates > to something useful. But I haven't looked at that in detail. > > Thomas