help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: writing ledger mode, date picker


From: Yuri Khan
Subject: Re: writing ledger mode, date picker
Date: Mon, 9 Nov 2015 08:42:04 +0600

On Mon, Nov 9, 2015 at 1:25 AM, jenia.ivlev <jenia.ivlev@gmail.com> wrote:

>                 (insert format-time-string "%Y-%m-%d" x)))))
> […]
> The interpreter tells me, though, that `x` is nil basically: "Symbol's
> value as a variable is void: format-time-string"

No. It’s telling you, in its own way, that you forgot parentheses
around the format-time-string function call and are instead trying to
insert the value of a non-existant variable. The fix for that is:

>                 (insert (format-time-string "%Y-%m-%d" x))))))


To your other question, the “when” form has no relation to time or
circumstances. It does not mean “please remember to execute this form
when this condition becomes true, and let’s go on with the following
forms”. It means “every time you come to interpret this expression,
test this condition right then and there, and when it is true, execute
this form”.


You want to ask a user to select a date on the calendar and then
insert that date into a buffer. The steps to that are, in a typical
“asynchronous call with continuation” pattern:

1. Cause the next press of RET in a calendar-mode buffer to call a
function specified by you. (By adding a binding to calendar-mode-map,
for example.)
2. Open the calendar.

When (and if) your code you specified in step 1 gets called:

101. Figure out the currently selected date. (By calling
calendar-cursor-to-date.)
102. Activate the buffer you want to insert into.
103. Insert the date from step 101, formatted suitably.
104. Do any cleanup work you might need. (Bury or close the calendar
buffer, and/or restore the previous binding of RET in
calendar-mode-map, if any.)


Looking at your code, it seems to me that it can be achieved by moving
the whole (when …) form from your insert-new-entry into get-date to
replace the reference to the undefined calendar-cursor-to-date
variable and fixing the missing parentheses on the format-time-string
call.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]