From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Nick Dokos Newsgroups: gmane.emacs.help Subject: Re: void variable error in function diary-anniversary Date: Thu, 21 Dec 2017 02:50:58 -0500 Message-ID: <87k1xgpli5.fsf@alphaville.usersys.redhat.com> References: <47c16b80-c229-07b8-b787-9ed4d69b2404@gmail.com> <51030225-2859-15eb-abf5-c2f492377b88@gmail.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: blaine.gmane.org 1513842581 29275 195.159.176.226 (21 Dec 2017 07:49:41 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 21 Dec 2017 07:49:41 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Dec 21 08:49:37 2017 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eRvbj-0007E8-UG for geh-help-gnu-emacs@m.gmane.org; Thu, 21 Dec 2017 08:49:36 +0100 Original-Received: from localhost ([::1]:37643 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eRvdi-0001bT-5T for geh-help-gnu-emacs@m.gmane.org; Thu, 21 Dec 2017 02:51:38 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:53768) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eRvdH-0001bA-IF for help-gnu-emacs@gnu.org; Thu, 21 Dec 2017 02:51:12 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eRvdD-0007Mo-Jj for help-gnu-emacs@gnu.org; Thu, 21 Dec 2017 02:51:11 -0500 Original-Received: from [195.159.176.226] (port=53224 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eRvdD-0007MF-CD for help-gnu-emacs@gnu.org; Thu, 21 Dec 2017 02:51:07 -0500 Original-Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1eRvbB-0004rd-OY for help-gnu-emacs@gnu.org; Thu, 21 Dec 2017 08:49:01 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 64 Original-X-Complaints-To: usenet@blaine.gmane.org Cancel-Lock: sha1:2uxXrEJMZBpySV7d8y4gddYZ++8= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 195.159.176.226 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:115420 Archived-At: stardiviner 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