 
 (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."

      (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 ?y)] 'ledger-set-year)
      (define-key map [tab] 'ledger-magic-tab)
      (define-key map [(control ?i)] 'ledger-magic-tab)

								    (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))
