diff options
-rw-r--r-- | lisp/ldg-mode.el | 12 | ||||
-rw-r--r-- | lisp/ldg-xact.el | 24 |
2 files changed, 29 insertions, 7 deletions
diff --git a/lisp/ldg-mode.el b/lisp/ldg-mode.el index ea780279..fc018853 100644 --- a/lisp/ldg-mode.el +++ b/lisp/ldg-mode.el @@ -71,16 +71,17 @@ customizable to ease retro-entry.") (let ((map (current-local-map))) (define-key map [(control ?c) (control ?a)] 'ledger-add-transaction) - (define-key map [(control ?c) (control ?d)] 'ledger-delete-current-transaction) - (define-key map [(control ?c) (control ?y)] 'ledger-set-year) - (define-key map [(control ?c) (control ?m)] 'ledger-set-month) + (define-key map [(control ?c) (control ?b)] 'ledger-post-edit-amount) (define-key map [(control ?c) (control ?c)] 'ledger-toggle-current) + (define-key map [(control ?c) (control ?d)] 'ledger-delete-current-transaction) (define-key map [(control ?c) (control ?e)] 'ledger-toggle-current-transaction) + (define-key map [(control ?c) (control ?f)] 'ledger-occur) + (define-key map [(control ?c) (control ?k)] 'ledger-copy-transaction) + (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 ?b)] 'ledger-post-edit-amount) - (define-key map [(control ?c) (control ?f)] 'ledger-occur) + (define-key map [(control ?c) (control ?y)] 'ledger-set-year) (define-key map [tab] 'pcomplete) (define-key map [(control ?i)] 'pcomplete) (define-key map [(control ?c) tab] 'ledger-fully-complete-entry) @@ -114,6 +115,7 @@ customizable to ease retro-entry.") (define-key map [sort-buff] '(menu-item "Sort Buffer" ledger-sort-buffer)) (define-key map [sort-reg] '(menu-item "Sort Region" ledger-sort-region :enable mark-active)) (define-key map [sep2] '(menu-item "--")) + (define-key map [copy-xact] '(menu-item "Copy Trans at Point" ledger-copy-transaction)) (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-entry)) (define-key map [sep4] '(menu-item "--")) diff --git a/lisp/ldg-xact.el b/lisp/ldg-xact.el index 306401af..a1c768ca 100644 --- a/lisp/ldg-xact.el +++ b/lisp/ldg-xact.el @@ -27,8 +27,6 @@ :type 'boolean :group 'ledger) - - (defvar highlight-overlay (list)) (defun ledger-find-xact-extents (pos) @@ -92,4 +90,26 @@ (t (ignore (goto-char here)))))) +(defun ledger-copy-transaction-at-point (date) + (interactive (list + (read-string "Copy to date: " + (concat ledger-year "/" ledger-month "/")))) + (let* ((here (point)) + (extents (ledger-find-xact-extents (point))) + (transaction (buffer-substring (car extents) (cadr extents))) + encoded-date) + (if (string-match "\\([0-9]+\\)/\\([0-9]+\\)/\\([0-9]+\\)" date) + (setq encoded-date + (encode-time 0 0 0 (string-to-number (match-string 3 date)) + (string-to-number (match-string 2 date)) + (string-to-number (match-string 1 date))))) + (ledger-find-slot encoded-date) + (insert transaction "\n") + (backward-paragraph) + (re-search-forward "\\([0-9]+\\)/\\([0-9]+\\)/\\([0-9]+\\)") + (replace-match date) + (re-search-forward "[1-9][0-9]+\.[0-9]+"))) + + + (provide 'ldg-xact)
\ No newline at end of file |