From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Yuri Khan Newsgroups: gmane.emacs.help Subject: Re: writing ledger mode, date picker Date: Mon, 9 Nov 2015 08:42:04 +0600 Message-ID: References: <87r3k1362v.fsf@gmail.com> <87mvup33v0.fsf@gmail.com> <87611did59.fsf@debian.uxu> <87egg0z420.fsf@gmail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1447036960 666 80.91.229.3 (9 Nov 2015 02:42:40 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 9 Nov 2015 02:42:40 +0000 (UTC) Cc: "help-gnu-emacs@gnu.org" To: "jenia.ivlev" Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Nov 09 03:42:39 2015 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1ZvcPm-0008Pt-Bo for geh-help-gnu-emacs@m.gmane.org; Mon, 09 Nov 2015 03:42:38 +0100 Original-Received: from localhost ([::1]:49708 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZvcPl-0002GY-Pr for geh-help-gnu-emacs@m.gmane.org; Sun, 08 Nov 2015 21:42:37 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:45667) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZvcPa-0002GN-SW for help-gnu-emacs@gnu.org; Sun, 08 Nov 2015 21:42:27 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZvcPa-0002um-0v for help-gnu-emacs@gnu.org; Sun, 08 Nov 2015 21:42:26 -0500 Original-Received: from mail-lb0-x22a.google.com ([2a00:1450:4010:c04::22a]:33024) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZvcPZ-0002uh-Pw for help-gnu-emacs@gnu.org; Sun, 08 Nov 2015 21:42:25 -0500 Original-Received: by lbbkw15 with SMTP id kw15so83438128lbb.0 for ; Sun, 08 Nov 2015 18:42:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc:content-type:content-transfer-encoding; bh=WurcHvsO1Vh6tL99stphObUzqV9+8eA1vdq9/21BR4s=; b=0QyT/MlRLkJQ9Xa60u1Rtqg66zcD6b0zLK3//qOiPiUpyx9Tq55xtEbAuuxBdBdnCC lcfLuAO3Ynu+kYl7r3SMcm/BrNXDhLRMrlE35H8BwzLI5OTdkxxYVX3lTOJWSqrnB16c nahWiROYjFxW1FiHDgL6QyFF/xQfSh4uTJVHWq1dQeRIhikXW5RqfbpEWMPnHEenGg4Z Ln6l4Kb5OwbI8Fx22Ne3A904am4Kj0GoupDfCg77okZIEmXDM0XK70v5290HfjUXV/fQ f/GWfXNF1qtyW/X19OaAugZrn5OVj8/Vl4QiLK3bKVa00RK0bkDDjd1jLTrSePTLbzkh lKjg== X-Received: by 10.112.135.136 with SMTP id ps8mr12175146lbb.38.1447036943910; Sun, 08 Nov 2015 18:42:23 -0800 (PST) Original-Received: by 10.112.67.103 with HTTP; Sun, 8 Nov 2015 18:42:04 -0800 (PST) In-Reply-To: <87egg0z420.fsf@gmail.com> X-Google-Sender-Auth: LtmUncMUWuozT-ChgGSqGkdXvTU X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:4010:c04::22a X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 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-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:107996 Archived-At: On Mon, Nov 9, 2015 at 1:25 AM, jenia.ivlev wrote: > (insert format-time-string "%Y-%m-%d" x))))) > [=E2=80=A6] > The interpreter tells me, though, that `x` is nil basically: "Symbol's > value as a variable is void: format-time-string" No. It=E2=80=99s 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 =E2=80=9Cwhen=E2=80=9D form has no relation to = time or circumstances. It does not mean =E2=80=9Cplease remember to execute this fo= rm when this condition becomes true, and let=E2=80=99s go on with the followin= g forms=E2=80=9D. It means =E2=80=9Cevery time you come to interpret this exp= ression, test this condition right then and there, and when it is true, execute this form=E2=80=9D. 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 =E2=80=9Casynchronous call with continuation=E2=80=9D 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 =E2=80=A6) 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.