[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#30051: 27.0.50; diary-lib.el uses lexical scoping when dynamic scope
From: |
Stefan Monnier |
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 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) |
>> 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)))