0

I've inserted this entry:

%%(diary-anniversary 01 27 1948) Arthur's birthday (%d years old) 

in an .org file (that Emacs evaluates when I press C-c a ato obtain the agenda view) but in the agenda, on this week day (tomorrow, 01 27) the entry does not appear. What have I missed?

2
  • Even if you cannot use C-c [ , the key sequence is bound to org-agenda-file-to-front so you can ALWAYS use the extended command M-x org-agenda-file-to-front to do the same thing. This is used mostly for testing: it adds the file to the front of the current org-agenda-files list, so its contents are scanned in order to construct the agenda, If the file is already a member of that list, you do NOT need to add it.
    – NickD
    Commented Jan 27, 2023 at 19:55
  • Please stop adding spurious answers. All of the clarifications should be added to your questions and the spurious answers should be deleted.
    – NickD
    Commented Jan 27, 2023 at 19:55

2 Answers 2

2

The two possibilities I can think of are: 1) you have not added the file to your org-agenda-files or 2) you have redefined calendar-date-style to use a different order from the default month, day, year.

To test the first possibility:

  • start with emacs -q
  • create an Org mode file with the following contents:
* Anniversaries
%%(diary-anniversary 01 27 1948) Arthur's birthday (%d years old)
  • save the buffer and add the file to the agenda list with C-c [
  • create an agenda with M-x org-agenda RET a

Since you start with emacs -q you are not going to have C-c a a available to you - that's why I specified M-x org-agenda RET a above.

The entry should appear in the agenda, regardless of what you have done in your init file (since -q does not use it).

If you now start with emacs i.e. with your init file, visit the file you created above, add it to the agenda list and create an agenda with C-c a a (presumably the key binding is now available). If the entry appears, you are done: just make sure that the file is made part of your agenda list wherever org-agenda-files is initialized.

If not, check calendar-date-style with C-h v calendar-date-style where you will see:

Your preferred style for writing dates.
The options are:
‘american’ - month/day/year
‘european’ - day/month/year
‘iso’      - year/month/day
This affects how dates written in your diary are interpreted.

If you have set that to european e.g. you have to specify the date as (27 1 1948).

The Timestamps section of the Org mode manual warns about this in a footnote:

   (2) When working with the standard diary expression functions, you
need to be very careful with the order of the arguments.  That order
depends evilly on the variable ‘calendar-date-style’.  For example, to
specify a date December 1, 2005, the call might look like ‘(diary-date
12 1 2005)’ or ‘(diary-date 1 12 2005)’ or ‘(diary-date 2005 12 1)’,
depending on the settings.  This has been the source of much confusion.
Org mode users can resort to special versions of these functions, namely
‘org-date’, ‘org-anniversary’, ‘org-cyclic, and ~org-block’.  These work
just like the corresponding ‘diary-’ functions, but with stable ISO
order of arguments (year, month, day) wherever applicable, independent
of the value of ‘calendar-date-style’.

I use ISO dates exclusively, so I prefer to use the suggested org-anniversary form:

%%(org-anniversary  1948 01 27) Arthur's birthday (%d years old)

which is not affected by calendar-date-style.

0

Finaly I've solved... this two entry works fine:

%%(diary-anniversary 01 30 1948) Arthur's birthday (%d years old)

or this

%%(org-anniversary 1948 01 30) Arthur's birthday (%d years old)

both works well... maibe the prob was in the date format: this is not the format I've choosen for emacs. This is the format of this function.

Thank you all

Renato

5
  • I'm glad you solved it, but it is not clear how: the only difference between the form in your question and the one in your answer is that the day is 30, instead of 27. Although Arthur might object to having his birthday shifted like this, that makes no difference to Emacs. So what exactly was it that resolved the problem?
    – NickD
    Commented Jan 31, 2023 at 19:18
  • you can use: %%(org-anniversary 1948 02 01) Arthur's birthday (%d years old)
    – RenatoP
    Commented Feb 1, 2023 at 12:01
  • you can use: %%(org-anniversary 1948 02 01) Arthur's birthday (%d years old) or %%(diary-anniversary 02 01 1948) Arthur's birthday (%d years old con diary) the difference is on the date format. YYYY MM dd (for org-anniversary) MM dd YYY for diary-anniversary. I still can't understand why I didn't get any error messages abot the wrong format, but emacs has just ignored the text (or maybe MY emacs is setted to not display error messages)
    – RenatoP
    Commented Feb 1, 2023 at 12:08
  • I know all this (as my answer clearly indicated). What is not clear is what was wrong, but it seems you don't know either: you did something and it fixed it but what exactly you did, nobody knows.
    – NickD
    Commented Feb 1, 2023 at 14:46
  • ... More or less like this. I tried many ways to let that be understood. The only one I have found is the one explained in the previous posts
    – RenatoP
    Commented Feb 2, 2023 at 9:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.