From 26bc890d882586e808b9def9ddf68a752b4c8e18 Mon Sep 17 00:00:00 2001 From: Moritz Ulrich Date: Thu, 2 Jan 2014 18:43:53 +0100 Subject: `ledger-insert-effective-date': use `ledger-read-date'. Running `ledger-insert-effective-date' will now prompt for a date with a pre-filled value of the `(ledger-year-and-month)' ("2014/01/"). Just pressing RET without inserting the 'day'-portion will insert the date of today. --- lisp/ledger-mode.el | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'lisp') diff --git a/lisp/ledger-mode.el b/lisp/ledger-mode.el index e18529c9..4edd745f 100644 --- a/lisp/ledger-mode.el +++ b/lisp/ledger-mode.el @@ -184,22 +184,21 @@ Can indent, complete or align depending on context." nil 'noerr) (replace-match "")))))))) -(defun ledger-insert-effective-date (&optional arg) - "Insert an effective date to the transaction or posting. +(defun ledger-insert-effective-date (&optional date) + "Insert effective date `DATE' to the transaction or posting. + +If `DATE' is nil, prompt the user a date. Replace the current effective date if there's one in the same line. With a prefix argument, remove the effective date. " - (interactive "P") - (if (and (listp arg) - (= 4 (prefix-numeric-value arg))) + (interactive) + (if (and (listp current-prefix-arg) + (= 4 (prefix-numeric-value current-prefix-arg))) (ledger-remove-effective-date) (let* ((context (car (ledger-context-at-point))) - (date-format (or - (cdr (assoc "date-format" ledger-environment-alist)) - ledger-default-date-format)) - (date-string (format-time-string date-format))) + (date-string (or date (ledger-read-date "Effective date: ")))) (save-restriction (narrow-to-region (point-at-bol) (point-at-eol)) (cond -- cgit v1.2.3