* org-prefere-future for other applications
@ 2010-02-27 12:29 Łukasz Stelmach
2010-03-01 12:38 ` Carsten Dominik
2010-03-01 12:40 ` Carsten Dominik
0 siblings, 2 replies; 4+ messages in thread
From: Łukasz Stelmach @ 2010-02-27 12:29 UTC (permalink / raw)
To: emacs-orgmode
Hello.
I've tried to rearrange org-read-date and some other helper function to
make them usable from other applications which might not want to prefere
future dates. Unfortunatelly I can't do it without making org-read-date
*require* additional argument (prefer-future) everytime it is called in
orgmode like this:
(org-read-date ... org-read-date-prefer-future)
Is it possible to refactor the code the way I've described it (without
too much fuss)?
--
Miłego dnia,
Łukasz Stelmach
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: org-prefere-future for other applications
2010-02-27 12:29 org-prefere-future for other applications Łukasz Stelmach
@ 2010-03-01 12:38 ` Carsten Dominik
2010-03-01 12:40 ` Carsten Dominik
1 sibling, 0 replies; 4+ messages in thread
From: Carsten Dominik @ 2010-03-01 12:38 UTC (permalink / raw)
To: Łukasz Stelmach; +Cc: emacs-orgmode
On Feb 27, 2010, at 1:29 PM, Łukasz Stelmach wrote:
> Hello.
>
> I've tried to rearrange org-read-date and some other helper function
> to
> make them usable from other applications which might not want to
> prefere
> future dates. Unfortunatelly I can't do it without making org-read-
> date
> *require* additional argument (prefer-future) everytime it is called
> in
> orgmode like this:
>
> (org-read-date ... org-read-date-prefer-future)
Hi Lukasz, I do not yet understand what is the issue...
- Carsten
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: org-prefere-future for other applications
2010-02-27 12:29 org-prefere-future for other applications Łukasz Stelmach
2010-03-01 12:38 ` Carsten Dominik
@ 2010-03-01 12:40 ` Carsten Dominik
2010-03-02 10:38 ` Łukasz Stelmach
1 sibling, 1 reply; 4+ messages in thread
From: Carsten Dominik @ 2010-03-01 12:40 UTC (permalink / raw)
To: Łukasz Stelmach; +Cc: emacs-orgmode
On Feb 27, 2010, at 1:29 PM, Łukasz Stelmach wrote:
> Hello.
>
> I've tried to rearrange org-read-date and some other helper function
> to
> make them usable from other applications which might not want to
> prefere
> future dates. Unfortunatelly I can't do it without making org-read-
> date
> *require* additional argument (prefer-future) everytime it is called
> in
> orgmode like this:
>
> (org-read-date ... org-read-date-prefer-future)
Ah, may be this is what this is about:
(defun org-my-read-date (&optional prefer-future)
(let ((org-read-date-prefer-future prefer-future))
(org-read-date)))
?????
- Carsten
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: org-prefere-future for other applications
2010-03-01 12:40 ` Carsten Dominik
@ 2010-03-02 10:38 ` Łukasz Stelmach
0 siblings, 0 replies; 4+ messages in thread
From: Łukasz Stelmach @ 2010-03-02 10:38 UTC (permalink / raw)
To: emacs-orgmode
Carsten Dominik <carsten.dominik@gmail.com> writes:
> On Feb 27, 2010, at 1:29 PM, Łukasz Stelmach wrote:
>> I've tried to rearrange org-read-date and some other helper function
>> to make them usable from other applications which might not want to
>> prefere future dates. Unfortunatelly I can't do it without making
>> org-read- date *require* additional argument (prefer-future)
>> everytime it is called in orgmode like this:
>>
>> (org-read-date ... org-read-date-prefer-future)
>
>
> Ah, may be this is what this is about:
>
> (defun org-my-read-date (&optional prefer-future)
> (let ((org-read-date-prefer-future prefer-future))
> (org-read-date)))
>
> ?????
So this is dynamic soping? Thats what I needed, thanks.
Scoping is one of subjects that always gives me a bit of a headache, no
matter what language I use.
Now with a function like this:
--8<---------------cut here---------------start------------->8---
(defun stl/org-read-date (&optional with-time to-time from-string
prompt default-time default-input
prefer-future)
"A wrapper around `org-read-date' to make it ignore the global
`org-read-date-prefer-future' value."
(let ((org-read-date-prefer-future prefer-future))
(org-read-date with-time to-time from-string prompt
default-time default-input)))
--8<---------------cut here---------------end--------------->8---
and a two others
--8<---------------cut here---------------start------------->8---
(defun stl/org-ledger-ask-cleared ()
(let (c)
(while (not (member (setq c (read-char "Cleared [Y/n/p]?")) '(?y ?n ?p ?\n ?\r ?\ ))))
(cond ((eq c ?n) "") ((eq c ?p) "! ") (t "* "))))
(defun stl/org-ledger-read-invoice ()
(let ((c (read-string "Invoice number:")))
(if (string-match ".+" c) (concat "(" c ") ") "")))
--8<---------------cut here---------------end--------------->8---
and a template:
--8<---------------cut here---------------start------------->8---
("Expense" ?E
"%(format-time-string \"%Y-%m-%d\" (stl/org-read-date nil 'to-time)) %(stl/org-ledger-ask-cleared)%(stl/org-ledger-read-invoice)%^{Description}
%^{Debit||Expense:Cash|Assets:Checking|Liabilities:Visa}
%^{Credit||Expense:Food|Expense:Supplies}\t%^{Amount}\n\n%!"
"~/org/ledger.dat" bottom)
--8<---------------cut here---------------end--------------->8---
I can use remember to add transactions to my ledger *without* havig to
specify full date (most of times you register transactions from the
past, right?). Cool :-)
--
Miłego dnia,
Łukasz Stelmach
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2010-03-02 10:39 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-02-27 12:29 org-prefere-future for other applications Łukasz Stelmach
2010-03-01 12:38 ` Carsten Dominik
2010-03-01 12:40 ` Carsten Dominik
2010-03-02 10:38 ` Łukasz Stelmach
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
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).