From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: "numbchild@gmail.com" Newsgroups: gmane.emacs.help Subject: Re: void variable error in function diary-anniversary Date: Thu, 21 Dec 2017 18:27:07 +0800 Message-ID: References: <47c16b80-c229-07b8-b787-9ed4d69b2404@gmail.com> <51030225-2859-15eb-abf5-c2f492377b88@gmail.com> <87k1xgpli5.fsf@alphaville.usersys.redhat.com> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" X-Trace: blaine.gmane.org 1513851975 29779 195.159.176.226 (21 Dec 2017 10:26:15 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 21 Dec 2017 10:26:15 +0000 (UTC) Cc: emacs-help To: Nick Dokos Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Dec 21 11:26:11 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 1eRy3E-0006yO-2a for geh-help-gnu-emacs@m.gmane.org; Thu, 21 Dec 2017 11:26:08 +0100 Original-Received: from localhost ([::1]:43680 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eRy59-00086c-5a for geh-help-gnu-emacs@m.gmane.org; Thu, 21 Dec 2017 05:28:07 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:50602) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eRy4i-00085t-58 for help-gnu-emacs@gnu.org; Thu, 21 Dec 2017 05:27:41 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eRy4g-0000ZK-Rd for help-gnu-emacs@gnu.org; Thu, 21 Dec 2017 05:27:40 -0500 Original-Received: from mail-ot0-x236.google.com ([2607:f8b0:4003:c0f::236]:44876) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eRy4g-0000Yj-K5 for help-gnu-emacs@gnu.org; Thu, 21 Dec 2017 05:27:38 -0500 Original-Received: by mail-ot0-x236.google.com with SMTP id d27so22071308ote.11 for ; Thu, 21 Dec 2017 02:27:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=P3vFOW9cnk4rezj86WWdqXl/8XVGecCNb5Crkt4/1iU=; b=U/lpjx6tXPaJzsx1e7rQiXv20QvEimwW1jLPSyh60rDqrzidKwGKTe91oCnimOFNTB tDT40V6UTuBiUjGYqTuDd+ek8VeQ0fZXay7muBT6bcu0C5NodJXzOOMyB8Z1Uxb/64Km ePSnWzMxufABqa8VkC6zxaNbyxPFP1dqy1lQSadnivT2mNH40ik/Y72OlJo4Mh7kjckr p0Y1NJsd4HbZBmYubgIUH+5QIkwRfcwrl94jKn0TPsD/60cdS4ewolqWss0fJ/dJwbeL AAaGUSPnXfT4IM7RMSRypd0M2ikprXAXSJexJDiofn8PgrS6lrDfvcXC5GvtQ/DYNcgc u9fw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=P3vFOW9cnk4rezj86WWdqXl/8XVGecCNb5Crkt4/1iU=; b=Zt5uyODRKtqt8dvuyIwRIXcPH7lFVUpD8w3tg8nHZD2fVGwL1vfWhMipHoT4cm63Y5 012sSlzLOl/5vMhrDSdwLBny/jJzalu4XNUqm+1JU/8FT5W3I7eij9rlgB0YGwgmZjeo HvsiMqNrNyr18bDLZfDleVSgikKY729/feiDMJ5pzhUq2APf9J3PWdpBXpafDUq1mwiA DyZjDdo2NUjVzZzTeF8OF/kKaiH37zPLWXl+/Xvrvkk+Cd135g+70nqmbSIs1juJnOUq g88YHXpNyUApUiZE8asv9zldmaiM9bD8WjsfDfULYuHuIwK+vTgKZLPuwXWJcmj5p/e6 iFHA== X-Gm-Message-State: AKGB3mLrh1CKFojuWzlU6JR3MOLYSvyv2eByWxs3s/EcIftgNDu14lph 2AyPIEvwv0Ao4ICmfphhjHlws3bnsSwckZa43A== X-Google-Smtp-Source: ACJfBot5mGNuJneDmehOnPgfAuG+K9pnpaZo7EvXJyvFugOq7EB56hoUDfz7R8rRSVsMihDNxdP9kWzyvLCmpBEEnk0= X-Received: by 10.157.48.209 with SMTP id r17mr3283774otg.375.1513852057908; Thu, 21 Dec 2017 02:27:37 -0800 (PST) Original-Received: by 10.157.42.19 with HTTP; Thu, 21 Dec 2017 02:27:07 -0800 (PST) In-Reply-To: <87k1xgpli5.fsf@alphaville.usersys.redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4003:c0f::236 X-Content-Filtered-By: Mailman/MimeDel 2.1.21 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:115422 Archived-At: I see, thanks. @Nick. [stardiviner] 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 wrote: > 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 > > >