From: Wanrong Lin <wrglin@gmail.com>
To: Thomas Plass <thunk2@arcor.de>
Cc: emacs-orgmode@gnu.org
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 [thread overview]
Message-ID: <86032d46-0fcf-f1d0-a250-ac696be11ed0@gmail.com> (raw)
In-Reply-To: <23706.37645.816738.515299@AGAME7.local>
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
prev parent reply other threads:[~2019-04-01 18:14 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-03 17:45 Bug: org-agenda-undo does not work on repeated tasks [7.9.3d (7.9.3d-dist @ /home/wlin/.emacs-lisp/org/lisp/)] Wanrong Lin
2013-04-10 12:38 ` Bastien
2019-03-26 14:23 ` Bug: Entries with diary-sexps in "scheduled" not exported properly to calendar file (.ics file) Wanrong Lin
2019-03-26 18:21 ` Thomas Plass
2019-03-26 19:20 ` Wanrong Lin
2019-03-26 21:01 ` Thomas Plass
2019-04-01 18:14 ` Wanrong Lin [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=86032d46-0fcf-f1d0-a250-ac696be11ed0@gmail.com \
--to=wrglin@gmail.com \
--cc=emacs-orgmode@gnu.org \
--cc=thunk2@arcor.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).