unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Yuri Khan <yuri.v.khan@gmail.com>
To: "jenia.ivlev" <jenia.ivlev@gmail.com>
Cc: "help-gnu-emacs@gnu.org" <help-gnu-emacs@gnu.org>
Subject: Re: writing ledger mode, date picker
Date: Mon, 9 Nov 2015 08:42:04 +0600	[thread overview]
Message-ID: <CAP_d_8X9U5ttJBeQLEQ9Mxk-pd7pJ=Gxs6A9seNOUvsu6GNDkA@mail.gmail.com> (raw)
In-Reply-To: <87egg0z420.fsf@gmail.com>

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.



  parent reply	other threads:[~2015-11-09  2:42 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-07 20:30 writing ledger mode, date picker jenia.ivlev
2015-11-07 21:18 ` jenia.ivlev
2015-11-07 23:49   ` Emanuel Berg
2015-11-08 19:25     ` jenia.ivlev
2015-11-08 22:38       ` Emanuel Berg
2015-11-09  2:42       ` Yuri Khan [this message]
2015-11-09  3:45         ` Emanuel Berg
2015-11-09  4:35           ` jenia.ivlev
2015-11-08  0:47 ` Drew Adams
2015-11-08 19:37   ` jenia.ivlev
2015-11-09  5:39 ` jenia.ivlev
2015-11-10  1:15   ` Emanuel Berg
2015-11-10  1:22   ` Emanuel Berg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAP_d_8X9U5ttJBeQLEQ9Mxk-pd7pJ=Gxs6A9seNOUvsu6GNDkA@mail.gmail.com' \
    --to=yuri.v.khan@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    --cc=jenia.ivlev@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).