summaryrefslogtreecommitdiff
path: root/lisp/ldg-xact.el
diff options
context:
space:
mode:
authorCraig Earls <enderw88@gmail.com>2013-02-14 13:20:16 -0700
committerCraig Earls <enderw88@gmail.com>2013-02-14 13:20:16 -0700
commit6eb97a7c38ba236f7cf38f694e2f579b6406bae5 (patch)
tree4142606bbe9a084a923e5d9b14f255bba0e09f6b /lisp/ldg-xact.el
parent67201ee8508737cf35c5916953a7b30d01890780 (diff)
downloadfork-ledger-6eb97a7c38ba236f7cf38f694e2f579b6406bae5.tar.gz
fork-ledger-6eb97a7c38ba236f7cf38f694e2f579b6406bae5.tar.bz2
fork-ledger-6eb97a7c38ba236f7cf38f694e2f579b6406bae5.zip
Added a copy transaction function to ledger-mode
Diffstat (limited to 'lisp/ldg-xact.el')
-rw-r--r--lisp/ldg-xact.el24
1 files changed, 22 insertions, 2 deletions
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