summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCraig Earls <enderw88@gmail.com>2013-03-24 18:12:44 -0400
committerCraig Earls <enderw88@gmail.com>2013-03-24 18:12:44 -0400
commite8a2ebb6993eb025d536495caae02852caf291d1 (patch)
treeb19a9d690b1837043e0c2f1e9e53760e8d0b56e5
parent6a753e155eb8b4c1bb6dada200582d293985e0f2 (diff)
downloadfork-ledger-e8a2ebb6993eb025d536495caae02852caf291d1.tar.gz
fork-ledger-e8a2ebb6993eb025d536495caae02852caf291d1.tar.bz2
fork-ledger-e8a2ebb6993eb025d536495caae02852caf291d1.zip
Insert Effective Date to xact
-rw-r--r--lisp/ldg-mode.el16
1 files changed, 14 insertions, 2 deletions
diff --git a/lisp/ldg-mode.el b/lisp/ldg-mode.el
index dafd0740..434d7448 100644
--- a/lisp/ldg-mode.el
+++ b/lisp/ldg-mode.el
@@ -55,6 +55,17 @@ Can be pcomplete, or align-posting"
(defvar ledger-mode-abbrev-table)
+(defun ledger-insert-effective-date ()
+ (interactive)
+ (let ((context (car (ledger-context-at-point)))
+ (date-string (format-time-string (cdr (assoc "date-format" ledger-environment-alist)))))
+ (cond ((eq 'entry context)
+ (beginning-of-line)
+ (insert date-string "="))
+ ((eq 'acct-transaction context)
+ (end-of-line)
+ (insert " ; [=" date-string "]")))))
+
;;;###autoload
(define-derived-mode ledger-mode text-mode "Ledger"
"A mode for editing ledger data files."
@@ -94,7 +105,7 @@ Can be pcomplete, or align-posting"
(define-key map [(control ?c) (control ?m)] 'ledger-set-month)
(define-key map [(control ?c) (control ?r)] 'ledger-reconcile)
(define-key map [(control ?c) (control ?s)] 'ledger-sort-region)
- (define-key map [(control ?c) (control ?t)] 'ledger-test-run)
+ (define-key map [(control ?c) (control ?t)] 'ledger-insert-effective-date)
(define-key map [(control ?c) (control ?y)] 'ledger-set-year)
(define-key map [tab] 'ledger-magic-tab)
(define-key map [(control ?i)] 'ledger-magic-tab)
@@ -126,6 +137,7 @@ Can be pcomplete, or align-posting"
(interactive)
(customize-group 'ledger))))
(define-key map [sep1] '("--"))
+ (define-key map [effective-date] '(menu-item "Set effective date" ledger-insert-effective-date))
(define-key map [sort-end] '(menu-item "Mark Sort End" ledger-sort-insert-end-mark))
(define-key map [sort-start] '(menu-item "Mark Sort Beginning" ledger-sort-insert-start-mark))
(define-key map [sort-buff] '(menu-item "Sort Buffer" ledger-sort-buffer))
@@ -136,7 +148,7 @@ Can be pcomplete, or align-posting"
(define-key map [toggle-post] '(menu-item "Toggle Current Posting" ledger-toggle-current))
(define-key map [toggle-xact] '(menu-item "Toggle Current Transaction" ledger-toggle-current-transaction))
(define-key map [sep4] '(menu-item "--"))
- (define-key map [edit-amount] '(menu-item "Reconcile Account" ledger-reconcile))
+ (define-key map [recon-account] '(menu-item "Reconcile Account" ledger-reconcile))
(define-key map [sep6] '(menu-item "--"))
(define-key map [edit-amount] '(menu-item "Calc on Amount" ledger-post-edit-amount))
(define-key map [sep] '(menu-item "--"))