all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Nick Dokos <ndokos@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: Re: void variable error in function diary-anniversary
Date: Thu, 21 Dec 2017 02:50:58 -0500	[thread overview]
Message-ID: <87k1xgpli5.fsf@alphaville.usersys.redhat.com> (raw)
In-Reply-To: 51030225-2859-15eb-abf5-c2f492377b88@gmail.com

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	other threads:[~2017-12-21  7:50 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-20  3:19 void variable error in function diary-anniversary stardiviner
2017-12-20 16:09 ` Stefan Monnier
2017-12-21  5:51   ` stardiviner
2017-12-21  7:50     ` Nick Dokos [this message]
2017-12-21 10:27       ` numbchild
2017-12-21 13:58     ` Stefan Monnier
2017-12-21 15:08       ` numbchild

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87k1xgpli5.fsf@alphaville.usersys.redhat.com \
    --to=ndokos@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.