From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.bugs Subject: bug#30051: 27.0.50; diary-lib.el uses lexical scoping when dynamic scope is needed Date: Wed, 10 Jan 2018 14:27:09 -0500 Message-ID: References: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1515612151 22485 195.159.176.226 (10 Jan 2018 19:22:31 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 10 Jan 2018 19:22:31 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Cc: 30051-done@debbugs.gnu.org, Richard.Kim1@synopsys.com To: Glenn Morris Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Jan 10 20:22:26 2018 Return-path: Envelope-to: geb-bug-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 1eZLx2-0005DK-Ts for geb-bug-gnu-emacs@m.gmane.org; Wed, 10 Jan 2018 20:22:17 +0100 Original-Received: from localhost ([::1]:34032 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZLz2-0000o2-Im for geb-bug-gnu-emacs@m.gmane.org; Wed, 10 Jan 2018 14:24:20 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:36183) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eZLyo-0000mi-Lk for bug-gnu-emacs@gnu.org; Wed, 10 Jan 2018 14:24:07 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eZLyk-000465-Lp for bug-gnu-emacs@gnu.org; Wed, 10 Jan 2018 14:24:06 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:43422) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eZLyk-00045w-E3 for bug-gnu-emacs@gnu.org; Wed, 10 Jan 2018 14:24:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1eZLyk-0000Ci-7q for bug-gnu-emacs@gnu.org; Wed, 10 Jan 2018 14:24:02 -0500 Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-To: bug-gnu-emacs@gnu.org Resent-Date: Wed, 10 Jan 2018 19:24:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: cc-closed 30051 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Mail-Followup-To: 30051@debbugs.gnu.org, monnier@IRO.UMontreal.CA, Richard.Kim1@synopsys.com Original-Received: via spool by 30051-done@debbugs.gnu.org id=D30051.1515612215741 (code D ref 30051); Wed, 10 Jan 2018 19:24:02 +0000 Original-Received: (at 30051-done) by debbugs.gnu.org; 10 Jan 2018 19:23:35 +0000 Original-Received: from localhost ([127.0.0.1]:51318 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eZLyJ-0000Bt-1f for submit@debbugs.gnu.org; Wed, 10 Jan 2018 14:23:35 -0500 Original-Received: from pruche.dit.umontreal.ca ([132.204.246.22]:55414) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eZLyG-0000Bk-Dp for 30051-done@debbugs.gnu.org; Wed, 10 Jan 2018 14:23:34 -0500 Original-Received: from lechazo.home (lechon.iro.umontreal.ca [132.204.27.242]) by pruche.dit.umontreal.ca (8.14.7/8.14.1) with ESMTP id w0AJNUTv010467; Wed, 10 Jan 2018 14:23:30 -0500 Original-Received: by lechazo.home (Postfix, from userid 20848) id A3D0D60085; Wed, 10 Jan 2018 14:27:09 -0500 (EST) In-Reply-To: (Glenn Morris's message of "Tue, 09 Jan 2018 19:41:53 -0500") X-NAI-Spam-Flag: NO X-NAI-Spam-Threshold: 5 X-NAI-Spam-Score: 0 X-NAI-Spam-Rules: 2 Rules triggered EDT_SA_DN_PASS=0, RV6197=0 X-NAI-Spam-Version: 2.3.0.9418 : core <6197> : inlines <6303> : streams <1775678> : uri <2567406> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:141994 Archived-At: >> Debugger entered--Lisp error: (void-variable number) >> appt-make-list() >> run-hooks(diary-hook) >> diary-list-entries((1 8 2018) 1) [...] >> This appears to be due to using lexical binding for diary-lib.el. Indeed. >> However appt-make-list depends on dynamically scoped `number' variable >> to be defined by diary-list-entries as documented in the doc-string: >> >> We assume that the variables DATE and NUMBER hold the arguments that >> `diary-list-entries' received. Indeed, thanks. I pushed the patch below which should fix this problem. Thank you, Stefan diff --git a/lisp/calendar/diary-lib.el b/lisp/calendar/diary-lib.el index 159dd9ba3d..c327717c8a 100644 --- a/lisp/calendar/diary-lib.el +++ b/lisp/calendar/diary-lib.el @@ -151,8 +151,10 @@ diary-comment-end :group 'diary) (defcustom diary-hook nil - "List of functions called after the display of the diary. -Used for example by the appointment package - see `appt-activate'." + "Hook run after displaying the diary. +Used for example by the appointment package - see `appt-activate'. +The variables `number' and `original-date' are dynamically bound around +the call." :type 'hook :group 'diary) @@ -779,10 +781,10 @@ diary-list-entries `diary-hook' runs last, after the diary is displayed. This is used e.g. by `appt-check'. -Functions called by these hooks may use the variables ORIGINAL-DATE -and NUMBER, which are the arguments with which this function was called. -Note that hook functions should _not_ use DATE, but ORIGINAL-DATE. -\(Sexp diary entries may use DATE - see `diary-list-sexp-entries'.) +Functions called by these hooks may use the variables `original-date' +and `number', which are the arguments with which this function was called. +Note that hook functions should _not_ use `date', but `original-date'. +\(Sexp diary entries may use `date' - see `diary-list-sexp-entries'.) This function displays the list using `diary-display-function', unless LIST-ONLY is non-nil, in which case it just returns the list." @@ -872,7 +874,9 @@ diary-list-entries (copy-sequence (car display-buffer-fallback-action)))))) (funcall diary-display-function))) - (run-hooks 'diary-hook))))) + (calendar-dlet* ((number number) + (original-date original-date)) + (run-hooks 'diary-hook)))))) (and temp-buff (buffer-name temp-buff) (kill-buffer temp-buff))) (or d-incp (message "Preparing diary...done")) diary-entries-list)))