In my org-file, I have entries like this:

*** Some One
%%(org-anniversary 1940 10  27) Some One is %d years old

*** Some Two
%%(org-anniversary 2003 11  3) Some Two is %d years old

What do I do if I do not know the birth year? I have looked at the solution here. But is there a better solution? Like an agenda item that just says its Some One's birthday

  • 1
    The comment in the linked thread contains another solution different from the answer (if that interests you). – lawlist Nov 28 '17 at 5:01

is there a better solution?

Yes, org-anniversary directly supports the desired behaviour:

*** Some One
%%(org-anniversary nil 10 27) Some One's birthday

Its docstring does not mention this explicitly:

org-anniversary is a compiled Lisp function in ‘org-agenda.el’.

(org-anniversary YEAR MONTH DAY &optional MARK)

Like ‘diary-anniversary’, but with fixed (ISO) order of arguments.

But the signature of the linked diary-anniversary function alludes to the possibility for a nil YEAR argument:

diary-anniversary is a compiled Lisp function in ‘diary-lib.el’.

(diary-anniversary MONTH DAY &optional YEAR MARK)

Anniversary diary entry.
Entry applies if date is the anniversary of MONTH, DAY, YEAR.
The order of the input parameters changes according to
‘calendar-date-style’ (e.g. to DAY MONTH YEAR in the European style).

The diary entry can contain ‘%d’ or ‘%d%s’; the %d will be replaced
by the number of years since the MONTH, DAY, YEAR, and the %s will
be replaced by the ordinal ending of that number (that is, ‘st’,
‘nd’, ‘rd’ or ‘th’, as appropriate).  The anniversary of February 29
is considered to be March 1 in non-leap years.

An optional parameter MARK specifies a face or single-character
string to use when highlighting the day in the calendar.
| improve this answer | |
  • Thanks. nil shows any anniversary as 100th anniversary. So, you see 100 you know the year must have been nil. But I still think it would be better if for nil years, %d produced nothing – deshmukh Nov 28 '17 at 5:49
  • @deshmukh The idea is that you do not include %d and %s for entries without associated years, because the semantics of doing that would be unclear/nonsensical. If you want a custom diary sexp which automatically removes such format specifiers, you will likely have to write it from scratch. Either way that would warrant a new Emacs SE question. – Basil Nov 28 '17 at 5:55
  • @deshmukh Alternatively, you could send a feature request to the Org developers. – Basil Nov 28 '17 at 5:56
  • I agree. It is pointless/ contradictory to have a %d and not supply a year. The question came to my mind because I was copying a template (headline, sexp expression) and pasting it for different birthdays and editing necessary parts – deshmukh Nov 28 '17 at 5:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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