* diary-lib.el how about adding diary-schedule
@ 2021-08-20 9:57 Gijs Hillenius
2021-08-21 13:09 ` Lars Ingebrigtsen
0 siblings, 1 reply; 9+ messages in thread
From: Gijs Hillenius @ 2021-08-20 9:57 UTC (permalink / raw)
To: emacs-devel
Hello
On the emacs wiki¹ I found a useful bit of code that allows adding an
weekly appointment in the diary file between two dates. Something that I
can't do with diary-block or diary-cyclic.
The code on the wiki seems out of date, so I reworked it a tiny bit.
Example:
%%(diary-schedule 15 7 2020 30 6 2021 3) 14:00 some weekly meeting
(defun diary-schedule (m1 d1 y1 m2 d2 y2 dayname)
"Schedule diary entry.
Entry applies if date is between, or on one of, two dates on
DAYNAME. The order of the input parameters changes according to
`calendar-date-style' \(e.g. to D1, M1, Y1, D2, M2, Y2 in the
European style)."
(let ((date1 (calendar-absolute-from-gregorian
(diary-make-date m1 d1 y1)) )
(date2 (calendar-absolute-from-gregorian
(diary-make-date m2 d2 y2)))
(d (calendar-absolute-from-gregorian date)))
(if (and
(<= date1 d) (<= d date2) (= (calendar-day-of-week date) dayname))
entry)))
Would it be useful to add this to diary-lib.el?
1) https://www.emacswiki.org/emacs/DiaryMode
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: diary-lib.el how about adding diary-schedule
2021-08-20 9:57 diary-lib.el how about adding diary-schedule Gijs Hillenius
@ 2021-08-21 13:09 ` Lars Ingebrigtsen
2021-08-22 7:33 ` Gijs Hillenius
0 siblings, 1 reply; 9+ messages in thread
From: Lars Ingebrigtsen @ 2021-08-21 13:09 UTC (permalink / raw)
To: Gijs Hillenius; +Cc: emacs-devel
Gijs Hillenius <gijs@hillenius.net> writes:
> On the emacs wiki¹ I found a useful bit of code that allows adding an
> weekly appointment in the diary file between two dates. Something that I
> can't do with diary-block or diary-cyclic.
>
> The code on the wiki seems out of date, so I reworked it a tiny bit.
[...]
> %%(diary-schedule 15 7 2020 30 6 2021 3) 14:00 some weekly meeting
[...]
> Would it be useful to add this to diary-lib.el?
>
> 1) https://www.emacswiki.org/emacs/DiaryMode
Seems useful to me -- perhaps it should be called
`diary-schedule-weekly'?
But I don't use the diary, so I'm not sure... Hm... there's something
called `diary-cyclic'? With a cycle of 7, that's almost the same thing,
although you have to be more careful about starting on the wrong day...
Any Diary users here with an opinion?
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: diary-lib.el how about adding diary-schedule
2021-08-21 13:09 ` Lars Ingebrigtsen
@ 2021-08-22 7:33 ` Gijs Hillenius
2021-08-22 21:59 ` Lars Ingebrigtsen
2021-08-24 14:37 ` Michael Heerdegen
0 siblings, 2 replies; 9+ messages in thread
From: Gijs Hillenius @ 2021-08-22 7:33 UTC (permalink / raw)
To: emacs-devel
On 21 August 2021 15:09 Lars Ingebrigtsen, wrote:
>> On the emacs wiki¹ I found a useful bit of code that allows adding an
>> weekly appointment in the diary file between two dates. Something that I
>> can't do with diary-block or diary-cyclic.
>>
>> The code on the wiki seems out of date, so I reworked it a tiny bit.
>
> [...]
>
>> %%(diary-schedule 15 7 2020 30 6 2021 3) 14:00 some weekly meeting
>
> [...]
>
>> Would it be useful to add this to diary-lib.el?
>>
>> 1) https://www.emacswiki.org/emacs/DiaryMode
>
> Seems useful to me -- perhaps it should be called
> `diary-schedule-weekly'?
>
> But I don't use the diary, so I'm not sure... Hm... there's something
> called `diary-cyclic'? With a cycle of 7, that's almost the same thing,
> although you have to be more careful about starting on the wrong day...
The way I understand it (..) : diary-cyclic does not let me set an
end-date, so a weekly entry is repeated "forever".
End-date is in diary-block, but then the entry is added every day
between begin and end date, instead of say, every Monday.
Perhaps diary-block could be improved to allow setting 'every N days'
like in diary-cyclic?
> Any Diary users here with an opinion?
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: diary-lib.el how about adding diary-schedule
2021-08-22 7:33 ` Gijs Hillenius
@ 2021-08-22 21:59 ` Lars Ingebrigtsen
2021-08-24 14:37 ` Michael Heerdegen
1 sibling, 0 replies; 9+ messages in thread
From: Lars Ingebrigtsen @ 2021-08-22 21:59 UTC (permalink / raw)
To: Gijs Hillenius; +Cc: emacs-devel
Gijs Hillenius <gijs@hillenius.net> writes:
> Perhaps diary-block could be improved to allow setting 'every N days'
> like in diary-cyclic?
Yeah, that sounds useful.
Your proposed diary-schedule also sounds useful -- a weekly appointment
is very common, I think, so being able to more directly say "on Mondays"
directly instead of trying to work that out by choosing the right start
date sounds nice, too. But this new diary-schedule-weekly could then
use the extended diary-block to do the actual work.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: diary-lib.el how about adding diary-schedule
2021-08-22 7:33 ` Gijs Hillenius
2021-08-22 21:59 ` Lars Ingebrigtsen
@ 2021-08-24 14:37 ` Michael Heerdegen
2021-08-25 7:39 ` Gijs Hillenius
1 sibling, 1 reply; 9+ messages in thread
From: Michael Heerdegen @ 2021-08-24 14:37 UTC (permalink / raw)
To: Gijs Hillenius; +Cc: emacs-devel
Gijs Hillenius <gijs@hillenius.net> writes:
> The way I understand it (..) : diary-cyclic does not let me set an
> end-date, so a weekly entry is repeated "forever".
>
> End-date is in diary-block, but then the entry is added every day
> between begin and end date, instead of say, every Monday.
>
> Perhaps diary-block could be improved to allow setting 'every N days'
> like in diary-cyclic?
Diary expressions are normal Elisp forms, so just use e.g.:
%%(and (diary-cyclic 10 08 24 2021) (diary-block 08 24 2021 12 31 2021))
Michael.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: diary-lib.el how about adding diary-schedule
2021-08-24 14:37 ` Michael Heerdegen
@ 2021-08-25 7:39 ` Gijs Hillenius
2021-08-25 10:55 ` Michael Heerdegen
2021-08-26 15:22 ` Michael Heerdegen
0 siblings, 2 replies; 9+ messages in thread
From: Gijs Hillenius @ 2021-08-25 7:39 UTC (permalink / raw)
To: Michael Heerdegen; +Cc: emacs-devel
On 24 August 2021 16:37 Michael Heerdegen, wrote:
>> The way I understand it (..) : diary-cyclic does not let me set an
>> end-date, so a weekly entry is repeated "forever".
>>
>> End-date is in diary-block, but then the entry is added every day
>> between begin and end date, instead of say, every Monday.
>>
>> Perhaps diary-block could be improved to allow setting 'every N days'
>> like in diary-cyclic?
>
> Diary expressions are normal Elisp forms, so just use e.g.:
>
> %%(and (diary-cyclic 10 08 24 2021) (diary-block 08 24 2021 12 31 2021))
Ow! And thanks!
this indeed does what I want:
%%(and (diary-block 15 07 2020 30 06 2021) (diary-cyclic 7 15 07 2020))
14:00-14:30 some weekly meeting
I should have known. Back to my Lisp books!
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: diary-lib.el how about adding diary-schedule
2021-08-25 7:39 ` Gijs Hillenius
@ 2021-08-25 10:55 ` Michael Heerdegen
2021-08-26 15:22 ` Michael Heerdegen
1 sibling, 0 replies; 9+ messages in thread
From: Michael Heerdegen @ 2021-08-25 10:55 UTC (permalink / raw)
To: Gijs Hillenius; +Cc: emacs-devel
Gijs Hillenius <gijs@hillenius.net> writes:
> this indeed does what I want:
>
> %%(and (diary-block 15 07 2020 30 06 2021) (diary-cyclic 7 15 07 2020))
> 14:00-14:30 some weekly meeting
If you need this often, you can also just define something like
#+begin_src emacs-lisp
(defun my-diary-block-cyclic (m1 d1 y1 m2 d2 y2 n &optional mark)
(and (diary-cyclic n m1 d1 y1)
(diary-block m1 d1 y1 m2 d2 y2 mark)))
#+end_src
in your config and use that in your diary.
Michael.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: diary-lib.el how about adding diary-schedule
2021-08-25 7:39 ` Gijs Hillenius
2021-08-25 10:55 ` Michael Heerdegen
@ 2021-08-26 15:22 ` Michael Heerdegen
2021-08-26 19:48 ` Lars Ingebrigtsen
1 sibling, 1 reply; 9+ messages in thread
From: Michael Heerdegen @ 2021-08-26 15:22 UTC (permalink / raw)
To: Gijs Hillenius; +Cc: emacs-devel
Gijs Hillenius <gijs@hillenius.net> writes:
> this indeed does what I want:
>
> %%(and (diary-block 15 07 2020 30 06 2021) (diary-cyclic 7 15 07 2020))
> 14:00-14:30 some weekly meeting
Gijs, Lars, should we try to improve the manual a bit?
(1) Would it be helpful to add something like the above as an example?
(2) This paragraph in (info "(emacs) Sexp Diary Entries"):
| The generality of sexp diary entries lets you specify any diary entry
| that you can describe algorithmically. A sexp diary entry contains an
| expression that computes whether the entry applies to any given date.
| If its value is non-‘nil’, the entry applies to that date; otherwise, it
| does not. The expression can use the variable ‘date’ to find the date
| being considered; its value is a list (MONTH DAY YEAR) that refers to
| the Gregorian calendar.
explains what we talked about. It could say clearer that DATE is bound
as a (dynamical) variable, and it should also say that the variable
ENTRY is also provided (bound to the text found after the expression in
the diary file - see the docstring of `diary-list-sexp-entries' which
explains this better.)
Maybe also say that the predefined diary sexp functions use these
variables implicitly, so that users are not confused about the fact that
most diary sexps don't contain a reference to DATE.
(3) Something else? What I don't like about the diary part of the
manual is that it tells so many details before you get to the above
paragraph that most people think this is complicated magic. Whereby
diary sexps are only trivial Elisp sexps that can refer to the variables
DATE and ENTRY and whose return value is interpreted by the
diary/calendar (how the return value is actually interpreted is
explained quite well OTOH).
What do you think?
I also ask Lars because I very much hope he is motivated to make the
change, should we agree about something. This is because I don't speak
texinfo, and I will soon be on vacation. Nonetheless I'm happy to
answer any questions if I can.
Michael.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: diary-lib.el how about adding diary-schedule
2021-08-26 15:22 ` Michael Heerdegen
@ 2021-08-26 19:48 ` Lars Ingebrigtsen
0 siblings, 0 replies; 9+ messages in thread
From: Lars Ingebrigtsen @ 2021-08-26 19:48 UTC (permalink / raw)
To: Michael Heerdegen; +Cc: Gijs Hillenius, emacs-devel
Michael Heerdegen <michael_heerdegen@web.de> writes:
> It could say clearer that DATE is bound
> as a (dynamical) variable, and it should also say that the variable
> ENTRY is also provided (bound to the text found after the expression in
> the diary file - see the docstring of `diary-list-sexp-entries' which
> explains this better.)
>
> Maybe also say that the predefined diary sexp functions use these
> variables implicitly, so that users are not confused about the fact that
> most diary sexps don't contain a reference to DATE.
Yup, sounds like a good idea.
> (3) Something else? What I don't like about the diary part of the
> manual is that it tells so many details before you get to the above
> paragraph that most people think this is complicated magic. Whereby
> diary sexps are only trivial Elisp sexps that can refer to the variables
> DATE and ENTRY and whose return value is interpreted by the
> diary/calendar (how the return value is actually interpreted is
> explained quite well OTOH).
>
> What do you think?
Well, the node starts with some examples, and that shows users how
simple these are, really... we don't get into all the details until
after that.
> I also ask Lars because I very much hope he is motivated to make the
> change, should we agree about something. This is because I don't speak
> texinfo, and I will soon be on vacation.
I you have a new text here, I can do the texification.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2021-08-26 19:48 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-08-20 9:57 diary-lib.el how about adding diary-schedule Gijs Hillenius
2021-08-21 13:09 ` Lars Ingebrigtsen
2021-08-22 7:33 ` Gijs Hillenius
2021-08-22 21:59 ` Lars Ingebrigtsen
2021-08-24 14:37 ` Michael Heerdegen
2021-08-25 7:39 ` Gijs Hillenius
2021-08-25 10:55 ` Michael Heerdegen
2021-08-26 15:22 ` Michael Heerdegen
2021-08-26 19:48 ` Lars Ingebrigtsen
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.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).