Carsten Dominik <carsten.domi...@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 _______________________________________________ Emacs-orgmode mailing list Please use `Reply All' to send replies to the list. Emacs-orgmode@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-orgmode