Discussion:
[O] How to set up anniversaries/birthdays with org-contacts-anniversaries?
Marius Hofert
2011-11-06 11:05:50 UTC
Permalink
How can I set up anniversaries with org-contact?

My agend.org file contains the following, as mentioned on the bottom of http://julien.danjou.info/org-contacts.html

#+STARTUP: showeverything
* Birthdays
%%(org-contacts-anniversaries)

My contacts.org file contains (e.g.):

* My contact :my.tag:
:PROPERTIES:
:EMAIL: ***@my.address.org
:URL:
:WORK:
:HOME:
:MOBILE:
:LOCATION:
:BIRTHDAY: 2000-01-01
:NOTE:
:END:

When I access agenda view via C-c a a, I obtain:

Bad sexp at line 3 in /Users/myusername/org/agenda.org: (org-contacts-anniversaries) [7 times]

Note that line three corresponds to "%%(org-contacts-anniversaries)"


Cheers,

Marius
Marius Hofert
2011-11-08 21:03:39 UTC
Permalink
see here: http://stackoverflow.com/questions/8036948/how-to-set-up-birthdays-with-org-contacts-error-bad-sexp
Post by Marius Hofert
How can I set up anniversaries with org-contact?
My agend.org file contains the following, as mentioned on the bottom of http://julien.danjou.info/org-contacts.html
#+STARTUP: showeverything
* Birthdays
%%(org-contacts-anniversaries)
:BIRTHDAY: 2000-01-01
Bad sexp at line 3 in /Users/myusername/org/agenda.org: (org-contacts-anniversaries) [7 times]
Note that line three corresponds to "%%(org-contacts-anniversaries)"
Cheers,
Marius
Nick Dokos
2011-11-08 21:33:16 UTC
Permalink
Post by Marius Hofert
see here: http://stackoverflow.com/questions/8036948/how-to-set-up-birthdays-with-org-contacts-error-bad-sexp
Post by Marius Hofert
How can I set up anniversaries with org-contact?
My agend.org file contains the following, as mentioned on the bottom of http://julien.danjou.info/org-contacts.html
#+STARTUP: showeverything
* Birthdays
%%(org-contacts-anniversaries)
:BIRTHDAY: 2000-01-01
Bad sexp at line 3 in /Users/myusername/org/agenda.org: (org-contacts-anniversaries) [7 times]
Note that line three corresponds to "%%(org-contacts-anniversaries)"
The org sexp handler issues this message whenever an error is signalled
when trying to evaluate the sexp.

In this case (as in most of these cases), the error is probably because
org-contacts-anniversaries is not defined, for whatever reason.

Try to eval

(org-contacts-anniversaries)

manually - what do you get? I get

,----
| Debugger entered--Lisp error: (void-function org-contacts-anniversaries)
| (org-contacts-anniversaries)
| eval((org-contacts-anniversaries) nil)
| eval-last-sexp-1(nil)
| eval-last-sexp(nil)
| call-interactively(eval-last-sexp nil nil)
`----

Then load org-contacts with

(require 'org-contacts)

or similar, and try the eval again. I get nil as a result, but more
importantly, no error. Assuming that you get no error either, try the
agenda again.

Nick
Marius Hofert
2011-11-08 21:43:22 UTC
Permalink
Post by Nick Dokos
The org sexp handler issues this message whenever an error is signalled
when trying to evaluate the sexp.
In this case (as in most of these cases), the error is probably because
org-contacts-anniversaries is not defined, for whatever reason.
Try to eval
(org-contacts-anniversaries)
manually - what do you get? I get
via M-x org-contacts-anniversaries? I get "No match"
Post by Nick Dokos
,----
| Debugger entered--Lisp error: (void-function org-contacts-anniversaries)
| (org-contacts-anniversaries)
| eval((org-contacts-anniversaries) nil)
| eval-last-sexp-1(nil)
| eval-last-sexp(nil)
| call-interactively(eval-last-sexp nil nil)
`----
Then load org-contacts with
(require 'org-contacts)
Yes, I already had this in .emacs (and obtained "No match")
Post by Nick Dokos
or similar, and try the eval again. I get nil as a result, but more
importantly, no error. Assuming that you get no error either, try the
agenda again.
Nick
I found out that the error happens due to either one of two reasons:
1) I have a :BIRTHDAY: tag which is <1970 or >2037
2) I have an empty :BIRTHDAY: tag
Have you seen my link to stackoverflow above? I got help there and finally realized that it's linked to the problem discussed here (involving posts of you, too):
http://thread.gmane.org/gmane.emacs.orgmode/39206

Is that solved? Will it be (automatically) solved if Emacs (for Mac) learns how to use the Mac's 64 bit architecture?

Cheers,

Marius
Nick Dokos
2011-11-08 22:07:22 UTC
Permalink
Post by Marius Hofert
Post by Nick Dokos
The org sexp handler issues this message whenever an error is signalled
when trying to evaluate the sexp.
In this case (as in most of these cases), the error is probably because
org-contacts-anniversaries is not defined, for whatever reason.
Try to eval
(org-contacts-anniversaries)
manually - what do you get? I get
via M-x org-contacts-anniversaries? I get "No match"
No, via

ESC ESC : (org-contacts-anniversaries) RET

or similar. M-x foo requires that foo is a command (aka an "interactive"
function): org-contacts-anniversaries is not.
Post by Marius Hofert
Post by Nick Dokos
,----
| Debugger entered--Lisp error: (void-function org-contacts-anniversaries)
| (org-contacts-anniversaries)
| eval((org-contacts-anniversaries) nil)
| eval-last-sexp-1(nil)
| eval-last-sexp(nil)
| call-interactively(eval-last-sexp nil nil)
`----
Then load org-contacts with
(require 'org-contacts)
Yes, I already had this in .emacs (and obtained "No match")
Post by Nick Dokos
or similar, and try the eval again. I get nil as a result, but more
importantly, no error. Assuming that you get no error either, try the
agenda again.
Nick
1) I have a :BIRTHDAY: tag which is <1970 or >2037
2) I have an empty :BIRTHDAY: tag
http://thread.gmane.org/gmane.emacs.orgmode/39206
Glanced at it, but didn't go far enough to read about those problems.
Post by Marius Hofert
Is that solved? Will it be (automatically) solved if Emacs (for Mac) learns how to use the Mac's 64 bit architecture?
Not sure.

Nick
Post by Marius Hofert
Cheers,
Marius
Marius Hofert
2011-11-08 22:16:21 UTC
Permalink
Okay, ESC ESC : (org-contacts-anniversaries) gives:


Debugger entered--Lisp error: (void-function diary-anniversary)
diary-anniversary(10 25 1970)
apply(diary-anniversary (10 25 1970))
(and anniv (apply (quote diary-anniversary) anniv))
(if (and anniv (apply (quote diary-anniversary) anniv)) (progn (push (format-spec format (\` ((108 \, (org-with-point-at ... ...)) (104 \, (car contact)) (121 \, (- ... ...)) (89 \, (let ... ...))))) --cl-var--)))
(while (consp --cl-var--) (setq contact (car --cl-var--)) (setq anniv (let ((anniv (cdr (assoc-string (or field org-contacts-birthday-property) (caddr contact))))) (when anniv (calendar-gregorian-from-absolute (org-time-string-to-absolute anniv))))) (if (and anniv (apply (quote diary-anniversary) anniv)) (progn (push (format-spec format (\` ((108 \, ...) (104 \, ...) (121 \, ...) (89 \, ...)))) --cl-var--))) (setq --cl-var-- (cdr --cl-var--)))
(let* ((--cl-var-- (org-contacts-filter)) (contact nil) (anniv nil) (--cl-var-- nil)) (while (consp --cl-var--) (setq contact (car --cl-var--)) (setq anniv (let ((anniv (cdr (assoc-string ... ...)))) (when anniv (calendar-gregorian-from-absolute (org-time-string-to-absolute anniv))))) (if (and anniv (apply (quote diary-anniversary) anniv)) (progn (push (format-spec format (\` (... ... ... ...))) --cl-var--))) (setq --cl-var-- (cdr --cl-var--))) (nreverse --cl-var--))
(catch (quote --cl-block-nil--) (let* ((--cl-var-- (org-contacts-filter)) (contact nil) (anniv nil) (--cl-var-- nil)) (while (consp --cl-var--) (setq contact (car --cl-var--)) (setq anniv (let ((anniv (cdr ...))) (when anniv (calendar-gregorian-from-absolute (org-time-string-to-absolute anniv))))) (if (and anniv (apply (quote diary-anniversary) anniv)) (progn (push (format-spec format (\` ...)) --cl-var--))) (setq --cl-var-- (cdr --cl-var--))) (nreverse --cl-var--)))
(cl-block-wrapper (catch (quote --cl-block-nil--) (let* ((--cl-var-- (org-contacts-filter)) (contact nil) (anniv nil) (--cl-var-- nil)) (while (consp --cl-var--) (setq contact (car --cl-var--)) (setq anniv (let ((anniv ...)) (when anniv (calendar-gregorian-from-absolute ...)))) (if (and anniv (apply (quote diary-anniversary) anniv)) (progn (push (format-spec format ...) --cl-var--))) (setq --cl-var-- (cdr --cl-var--))) (nreverse --cl-var--))))
(block nil (let* ((--cl-var-- (org-contacts-filter)) (contact nil) (anniv nil) (--cl-var-- nil)) (while (consp --cl-var--) (setq contact (car --cl-var--)) (setq anniv (let ((anniv (cdr ...))) (when anniv (calendar-gregorian-from-absolute (org-time-string-to-absolute anniv))))) (if (and anniv (apply (quote diary-anniversary) anniv)) (progn (push (format-spec format (\` ...)) --cl-var--))) (setq --cl-var-- (cdr --cl-var--))) (nreverse --cl-var--)))
(loop for contact in (org-contacts-filter) for anniv = (let ((anniv (cdr (assoc-string (or field org-contacts-birthday-property) (caddr contact))))) (when anniv (calendar-gregorian-from-absolute (org-time-string-to-absolute anniv)))) if (and anniv (apply (quote diary-anniversary) anniv)) collect (format-spec format (\` ((108 \, (org-with-point-at (cadr contact) (org-store-link nil))) (104 \, (car contact)) (121 \, (- (calendar-extract-year date) (calendar-extract-year anniv))) (89 \, (let ((years ...)) (format "%d%s" years (diary-ordinal-suffix years))))))))
(let ((calendar-date-style (quote american)) (entry "")) (unless format (setq format org-contacts-birthday-format)) (loop for contact in (org-contacts-filter) for anniv = (let ((anniv (cdr (assoc-string (or field org-contacts-birthday-property) (caddr contact))))) (when anniv (calendar-gregorian-from-absolute (org-time-string-to-absolute anniv)))) if (and anniv (apply (quote diary-anniversary) anniv)) collect (format-spec format (\` ((108 \, (org-with-point-at (cadr contact) (org-store-link nil))) (104 \, (car contact)) (121 \, (- (calendar-extract-year date) (calendar-extract-year anniv))) (89 \, (let (...) (format "%d%s" years ...))))))))
org-contacts-anniversaries()
eval((org-contacts-anniversaries) nil)
eval-expression((org-contacts-anniversaries) nil)
call-interactively(eval-expression nil nil)
Jambunathan K
2011-11-08 22:33:29 UTC
Permalink
Post by Marius Hofert
Debugger entered--Lisp error: (void-function diary-anniversary)
There is a universal solution to this problem

M-x load-library RET diary TAB

and choose which of the options make most sense or try each one of them
in turn.

Note that in the above load-library you are using "diary" because it is
the "prefix" of function (or variable) which reported as void.

The load-library call unvoids the void things.
Marius Hofert
2011-11-08 22:36:12 UTC
Permalink
Thanks for the explanation. Is there also an equivalent solution by just adjusting .emacs?
Post by Jambunathan K
Post by Marius Hofert
Debugger entered--Lisp error: (void-function diary-anniversary)
There is a universal solution to this problem
M-x load-library RET diary TAB
and choose which of the options make most sense or try each one of them
in turn.
Note that in the above load-library you are using "diary" because it is
the "prefix" of function (or variable) which reported as void.
The load-library call unvoids the void things.
Jambunathan K
2011-11-08 22:50:54 UTC
Permalink
Post by Marius Hofert
Thanks for the explanation. Is there also an equivalent solution by just adjusting .emacs?
C-h r
g Init Examples

Hint: search for load
Helpful tip: Learn to use Emacs Info system well.
Post by Marius Hofert
Post by Jambunathan K
Post by Marius Hofert
Debugger entered--Lisp error: (void-function diary-anniversary)
There is a universal solution to this problem
M-x load-library RET diary TAB
and choose which of the options make most sense or try each one of them
in turn.
Note that in the above load-library you are using "diary" because it is
the "prefix" of function (or variable) which reported as void.
The load-library call unvoids the void things.
--
Nick Dokos
2011-11-08 23:06:32 UTC
Permalink
Post by Marius Hofert
Thanks for the explanation. Is there also an equivalent solution by just adjusting .emacs?
If you are going to use emacs extensively, you probably should read the
emacs reference manual and maybe the emacs lisp introduction as
well.

M-x foo RET is entirely equivalent to evaluating

(foo)

which is a call to function foo. (foo) is the more general mechanism: it
works for any lisp function, M-x foo works iff foo is a command (aka an
"interactive" function). The form (foo) can be added to .emacs.

load-library is a command that takes an argument: the name of the library
to load. See its doc string for details. M-x load-library RET diary RET
is entirely equivalent to evaluating

(load-library "diary")

This calls the function load-library with the string argument "diary".
This form can be added to .emacs. Alternatively, you can use the
require form that I posted:

(require 'diary)

Note that load-library takes a string as argument, whereas require takes
a symbol.

Nick
Post by Marius Hofert
Post by Jambunathan K
Post by Marius Hofert
Debugger entered--Lisp error: (void-function diary-anniversary)
There is a universal solution to this problem
M-x load-library RET diary TAB
and choose which of the options make most sense or try each one of them
in turn.
Note that in the above load-library you are using "diary" because it is
the "prefix" of function (or variable) which reported as void.
The load-library call unvoids the void things.
Marius Hofert
2011-11-08 23:13:52 UTC
Permalink
Post by Nick Dokos
Post by Marius Hofert
Thanks for the explanation. Is there also an equivalent solution by just adjusting .emacs?
If you are going to use emacs extensively, you probably should read the
emacs reference manual and maybe the emacs lisp introduction as
well.
M-x foo RET is entirely equivalent to evaluating
(foo)
which is a call to function foo. (foo) is the more general mechanism: it
works for any lisp function, M-x foo works iff foo is a command (aka an
"interactive" function). The form (foo) can be added to .emacs.
load-library is a command that takes an argument: the name of the library
to load. See its doc string for details. M-x load-library RET diary RET
is entirely equivalent to evaluating
(load-library "diary")
This calls the function load-library with the string argument "diary".
This form can be added to .emacs. Alternatively, you can use the
(require 'diary)
I obtain (also for (load-library "diary") ):
File error: Cannot open load file, diary

I assume I'm missing some diary.el (?).

I'm wondering why diary is needed anyway? Julien does not specifically mention it:
http://julien.danjou.info/org-contacts.html

Cheers,

Marius
Post by Nick Dokos
Note that load-library takes a string as argument, whereas require takes
a symbol.
Nick
Post by Marius Hofert
Post by Jambunathan K
Post by Marius Hofert
Debugger entered--Lisp error: (void-function diary-anniversary)
There is a universal solution to this problem
M-x load-library RET diary TAB
and choose which of the options make most sense or try each one of them
in turn.
Note that in the above load-library you are using "diary" because it is
the "prefix" of function (or variable) which reported as void.
The load-library call unvoids the void things.
Marius Hofert
2011-11-08 23:17:30 UTC
Permalink
Okay, I assume it's (require 'diary-lib) then.
Post by Marius Hofert
Post by Nick Dokos
Post by Marius Hofert
Thanks for the explanation. Is there also an equivalent solution by just adjusting .emacs?
If you are going to use emacs extensively, you probably should read the
emacs reference manual and maybe the emacs lisp introduction as
well.
M-x foo RET is entirely equivalent to evaluating
(foo)
which is a call to function foo. (foo) is the more general mechanism: it
works for any lisp function, M-x foo works iff foo is a command (aka an
"interactive" function). The form (foo) can be added to .emacs.
load-library is a command that takes an argument: the name of the library
to load. See its doc string for details. M-x load-library RET diary RET
is entirely equivalent to evaluating
(load-library "diary")
This calls the function load-library with the string argument "diary".
This form can be added to .emacs. Alternatively, you can use the
(require 'diary)
File error: Cannot open load file, diary
I assume I'm missing some diary.el (?).
http://julien.danjou.info/org-contacts.html
Cheers,
Marius
Post by Nick Dokos
Note that load-library takes a string as argument, whereas require takes
a symbol.
Nick
Post by Marius Hofert
Post by Jambunathan K
Post by Marius Hofert
Debugger entered--Lisp error: (void-function diary-anniversary)
There is a universal solution to this problem
M-x load-library RET diary TAB
and choose which of the options make most sense or try each one of them
in turn.
Note that in the above load-library you are using "diary" because it is
the "prefix" of function (or variable) which reported as void.
The load-library call unvoids the void things.
ETH Zurich
Dr. Marius Hofert
RiskLab, Department of Mathematics
HG E 65.2
Rämistrasse 101
8092 Zurich
Switzerland

Phone +41 44 632 2423
***@math.ethz.ch
http://www.math.ethz.ch/~hofertj
Nick Dokos
2011-11-08 23:21:19 UTC
Permalink
Post by Marius Hofert
Post by Nick Dokos
(load-library "diary")
This calls the function load-library with the string argument "diary".
This form can be added to .emacs. Alternatively, you can use the
(require 'diary)
File error: Cannot open load file, diary
I assume I'm missing some diary.el (?).
Nope, I'm wrong: diary-anniversary is in diary-lib, so the
correct form is

(load-library "diary-lib")

or

(require 'diary-lib)
Marius Hofert
2011-11-08 23:25:46 UTC
Permalink
Post by Nick Dokos
Post by Marius Hofert
Post by Nick Dokos
(load-library "diary")
This calls the function load-library with the string argument "diary".
This form can be added to .emacs. Alternatively, you can use the
(require 'diary)
File error: Cannot open load file, diary
I assume I'm missing some diary.el (?).
Nope, I'm wrong: diary-anniversary is in diary-lib, so the
correct form is
(load-library "diary-lib")
or
(require 'diary-lib)
okay, that's also what I tried and it worked. However, I still see the "Bad sexp..." error when there is a BIRTHDAY tag *without* date, so just a line containing ":BIRTHDAY:" But that's of course not a big issue.
Jonathan Leech-Pepin
2011-11-08 23:37:52 UTC
Permalink
:BIRTHDAY: without any date is an invalid date for the sexp.

org-contacts-anniversaries loops through all valid contacts (headlines with
an :EMAIL: property) for any that contain the :BIRTHDAY: property (by
default, this can be customized).

When there is no date associated the value is nil.

(calendar-gregorian-from-absolute
(org-time-string-to-absolute anniv))

Where anniv is the date retrieved from :BIRTHDAY:. nil is not a valid date,
so the expression fails, giving you a bad sexp.
Post by Marius Hofert
Post by Nick Dokos
Post by Marius Hofert
Post by Nick Dokos
(load-library "diary")
This calls the function load-library with the string argument "diary".
This form can be added to .emacs. Alternatively, you can use the
(require 'diary)
File error: Cannot open load file, diary
I assume I'm missing some diary.el (?).
Nope, I'm wrong: diary-anniversary is in diary-lib, so the
correct form is
(load-library "diary-lib")
or
(require 'diary-lib)
okay, that's also what I tried and it worked. However, I still see the
"Bad sexp..." error when there is a BIRTHDAY tag *without* date, so just a
line containing ":BIRTHDAY:" But that's of course not a big issue.
Marius Hofert
2011-11-08 23:12:48 UTC
Permalink
Post by Jambunathan K
Post by Marius Hofert
Debugger entered--Lisp error: (void-function diary-anniversary)
There is a universal solution to this problem
M-x load-library RET diary TAB
and choose which of the options make most sense or try each one of them
in turn.
I have:
1) diary-lib
2) diary-loaddefs

I chose the first one. After that, I could define a :BIRTHDAY: with year < 1970 and it correctly showed up in the agenda view! Seems to work! :-)

Thanks a lot,

Marius
Post by Jambunathan K
Note that in the above load-library you are using "diary" because it is
the "prefix" of function (or variable) which reported as void.
The load-library call unvoids the void things.
Nick Dokos
2011-11-08 22:48:23 UTC
Permalink
Post by Marius Hofert
Debugger entered--Lisp error: (void-function diary-anniversary)
So you need to load diary.el and associated stuff:

(require 'diary)

is probably enough.
Loading...