help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: void variable error in function diary-anniversary


From: Nick Dokos
Subject: Re: void variable error in function diary-anniversary
Date: Thu, 21 Dec 2017 02:50:58 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

stardiviner <numbchild@gmail.com> writes:

> I'm using latest Emacs version from `master` branch.
>
> Current version: GNU Emacs 27.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ 
> Version 3.22.26) of 2017-12-16
>
>
> And here is the edebug backtrace (check out the FIXME):
>
> #+begin_src emacs-lisp
>
> (defun 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."
>    (with-no-warnings (defvar date) (defvar entry))
>    (let* ((ddate (diary-make-date month day year))
>           (dd (calendar-extract-day ddate))
>           (mm (calendar-extract-month ddate))
>           (yy (calendar-extract-year ddate))
>           (y (calendar-extract-year date)) ; FIXME: here date is void.
>           (diff (if yy (- y yy) 100)))
>      (and (= mm 2) (= dd 29) (not (calendar-leap-year-p y))
>           (setq mm 3
>                 dd 1))
>      (and (> diff 0) (calendar-date-equal (list mm dd y) date)
>           (cons mark (format entry diff (diary-ordinal-suffix diff))))))
>
> #+end_src
>
> On 12/21/2017 12:09 AM, Stefan Monnier wrote:
>>> I have:
>>> ```org
>>> * test anniversary
>>> %%(diary-anniversary 12 8 2007)
>>> ```
>>> When I execute [M-: (diary-anniversary 12 8 2007) RET], I got error:
>>> Symbol's value as variable is vodi: date

The calendar and diary modules assume that the symbol 'date' is
(dynamically) bound to today's date.  So if you want to evaluate a
function like diary-anniversary by hand (so to speak), you have to do
something like this (N.B. the (month day year) format for the date):

(setq date '(12 21 2017))
(12 21 2017)
(setq entry "foo %d")
"Test anniversary %d"
(org-anniversary 2015 12 21)
(nil . "Test anniversary 2")

-- 
Nick




reply via email to

[Prev in Thread] Current Thread [Next in Thread]