From 3ff5fddafd6bff3c0768eeae032f7eb6ab32db5b Mon Sep 17 00:00:00 2001 From: Moritz Ulrich Date: Thu, 2 Jan 2014 18:24:54 +0100 Subject: Add `ledger-read-date' - Read date & default to today. --- lisp/ledger-mode.el | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'lisp') diff --git a/lisp/ledger-mode.el b/lisp/ledger-mode.el index 0d683168..e18529c9 100644 --- a/lisp/ledger-mode.el +++ b/lisp/ledger-mode.el @@ -99,6 +99,17 @@ nil))) (ledger-read-string-with-default prompt default))) +(defun ledger-read-date (prompt) + "Returns user-supplied date after `PROMPT', defaults to today." + (let* ((default (ledger-year-and-month)) + (date (read-string prompt default))) + (if (or (string= date default) + (string= "" date)) + (format-time-string + (or (cdr (assoc "date-format" ledger-environment-alist)) + ledger-default-date-format)) + date))) + (defun ledger-read-string-with-default (prompt default) "Return user supplied string after PROMPT, or DEFAULT." (read-string (concat prompt -- cgit v1.2.3