[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: writing ledger mode, date picker
From: |
Emanuel Berg |
Subject: |
Re: writing ledger mode, date picker |
Date: |
Sun, 08 Nov 2015 22:38:39 +0000 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux) |
jenia.ivlev@gmail.com (jenia.ivlev) writes:
> Hello Emanuel.
>
> I'm trying to write a program that will prompt the
> user for a date and insert it into a buffer called
> "asti" ;)
(require 'calendar)
(defun prompt-date-into-asti ()
(interactive)
(let*((date (calendar-read-date))
(date-string (format-time-string "%Y-%m-%d\n" date))
(buffer (get-buffer-create "asti")) )
(with-current-buffer buffer
(insert date-string) )))
> I'm having some success but also some problems.
> My problem, I think, is that I'm using the
> `(when...)` function wrong.
`when' is equivalent to `if' with no need for `progn',
only `when' doesn't come with an "else" branch, as do
`if'. So this
(when something do)
is the same as
(if something do)
The rule of thumb is:
1. When you need an "else" branch, use `if' (or
`cond'), with `progn' if necessary to scope
the branches.
2. When you don't need an "else" branch, and the
condition is positive, i.e. (if something ... )
then use `when' and there is no need for
a progn (in the `if' sense at least).
3. When you don't need an "else" branch, and the
condition is *negative*, i.e. (if (not
something) ... ) then use `unless', otherwise
it is as with `when'.
> Here is the newest iteration of the program ...
> (define-key calendar-mode-map (kbd "RET") 'get-date)
That isn't anything you'd do in a defun. Do that when
you initialize calendar-mode if so. On the whole, you
code is too complicated, like you try to do to many
things at once. If you can describe what you want to
do, it'll be more easy to help.
--
underground experts united
http://user.it.uu.se/~embe8573
- writing ledger mode, date picker, jenia.ivlev, 2015/11/07
- Re: writing ledger mode, date picker, jenia.ivlev, 2015/11/07
- Re: writing ledger mode, date picker, Emanuel Berg, 2015/11/07
- Re: writing ledger mode, date picker, jenia.ivlev, 2015/11/08
- Re: writing ledger mode, date picker,
Emanuel Berg <=
- Re: writing ledger mode, date picker, Yuri Khan, 2015/11/08
- Re: writing ledger mode, date picker, Emanuel Berg, 2015/11/08
- Re: writing ledger mode, date picker, jenia.ivlev, 2015/11/08
RE: writing ledger mode, date picker, Drew Adams, 2015/11/07
Re: writing ledger mode, date picker, jenia.ivlev, 2015/11/09