unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: "numbchild@gmail.com" <numbchild@gmail.com>
To: Nick Dokos <ndokos@gmail.com>
Cc: emacs-help <help-gnu-emacs@gnu.org>
Subject: Re: void variable error in function diary-anniversary
Date: Thu, 21 Dec 2017 18:27:07 +0800	[thread overview]
Message-ID: <CAL1eYuJSHHeyxX9mNsSeYvVUPOcoQsE5zLRSBiv1XrdVY7ryPw@mail.gmail.com> (raw)
In-Reply-To: <87k1xgpli5.fsf@alphaville.usersys.redhat.com>

I see, thanks. @Nick.

[stardiviner]           <Hack this world!>      GPG key ID: 47C32433
IRC(freeenode): stardiviner                     Twitter:  @numbchild
Key fingerprint = 9BAA 92BC CDDD B9EF 3B36  CB99 B8C4 B8E5 47C3 2433
Blog: http://stardiviner.github.io/

On Thu, Dec 21, 2017 at 3:50 PM, Nick Dokos <ndokos@gmail.com> wrote:

> 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 10:27 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
2017-12-21 10:27       ` numbchild [this message]
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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=CAL1eYuJSHHeyxX9mNsSeYvVUPOcoQsE5zLRSBiv1XrdVY7ryPw@mail.gmail.com \
    --to=numbchild@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    --cc=ndokos@gmail.com \
    /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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).