summaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
Diffstat (limited to 'lisp')
-rw-r--r--lisp/ldg-mode.el16
-rw-r--r--lisp/ldg-new.el13
-rw-r--r--lisp/ldg-reconcile.el2
-rw-r--r--lisp/ldg-report.el64
-rw-r--r--lisp/ldg-xact.el1
5 files changed, 50 insertions, 46 deletions
diff --git a/lisp/ldg-mode.el b/lisp/ldg-mode.el
index caa57e8e..e36dc969 100644
--- a/lisp/ldg-mode.el
+++ b/lisp/ldg-mode.el
@@ -1,3 +1,16 @@
+(defsubst ledger-current-year ()
+ (format-time-string "%Y"))
+(defsubst ledger-current-month ()
+ (format-time-string "%m"))
+
+(defvar ledger-year (ledger-current-year)
+ "Start a ledger session with the current year, but make it
+customizable to ease retro-entry.")
+(defvar ledger-month (ledger-current-month)
+ "Start a ledger session with the current month, but make it
+customizable to ease retro-entry.")
+
+
(defcustom ledger-default-acct-transaction-indent " "
"Default indentation for account transactions in an entry."
:type 'string
@@ -152,7 +165,8 @@ Return the difference in the format of a time value."
(setq ledger-month (format "%02d" newmonth))))
(defun ledger-add-entry (entry-text &optional insert-at-point)
- (interactive "sEntry: ")
+ (interactive (list
+ (read-string "Entry: " (concat ledger-year "/" ledger-month "/"))))
(let* ((args (with-temp-buffer
(insert entry-text)
(eshell-parse-arguments (point-min) (point-max))))
diff --git a/lisp/ldg-new.el b/lisp/ldg-new.el
index 8505fe4a..d9e0fc60 100644
--- a/lisp/ldg-new.el
+++ b/lisp/ldg-new.el
@@ -32,12 +32,17 @@
;;; Commentary:
-(require 'ldg-post)
-(require 'ldg-mode)
(require 'ldg-complete)
-(require 'ldg-state)
+(require 'ldg-exec)
+(require 'ldg-mode)
+(require 'ldg-post)
+(require 'ldg-reconcile)
+(require 'ldg-register)
(require 'ldg-report)
-
+(require 'ldg-state)
+(require 'ldg-test)
+(require 'ldg-texi)
+(require 'ldg-xact)
;(autoload #'ledger-mode "ldg-mode" nil t)
;(autoload #'ledger-fully-complete-entry "ldg-complete" nil t)
;(autoload #'ledger-toggle-current "ldg-state" nil t)
diff --git a/lisp/ldg-reconcile.el b/lisp/ldg-reconcile.el
index 73409e66..08dbc587 100644
--- a/lisp/ldg-reconcile.el
+++ b/lisp/ldg-reconcile.el
@@ -203,3 +203,5 @@
(define-key map [menu-bar ldg-recon-menu sav] '("Save" . ledger-reconcile-save))
(use-local-map map)))
+
+(provide 'ldg-reconcile) \ No newline at end of file
diff --git a/lisp/ldg-report.el b/lisp/ldg-report.el
index efd9bdb4..a1ffe3b0 100644
--- a/lisp/ldg-report.el
+++ b/lisp/ldg-report.el
@@ -246,72 +246,54 @@ the default."
(ledger-reports-custom-save))
report-cmd))
-(defvar ledger-report-patch-alist nil)
-
-(defun ledger-report-patch-reports (buf)
- (when ledger-report-patch-alist
- (let ((entry (assoc (expand-file-name (buffer-file-name buf))
- ledger-report-patch-alist)))
- (when entry
- (dolist (b (cdr entry))
- (if (buffer-live-p b)
- (with-current-buffer b
- (save-excursion
- (goto-char (point-min))
- (while (not (eobp))
- (let ((record (get-text-property (point) 'ledger-source)))
- (if (and record (not (markerp (cdr record))))
- (setcdr record (with-current-buffer buf
- (save-excursion
- (goto-char (point-min))
- (forward-line (cdr record))
- (point-marker))))))
- (forward-line 1))))))))))
-
(defun ledger-do-report (cmd)
"Run a report command line."
(goto-char (point-min))
(insert (format "Report: %s\n" ledger-report-name)
(format "Command: %s\n" cmd)
(make-string (- (window-width) 1) ?=)
- "\n")
- (let ((register-report (string-match " reg\\(ister\\)? " cmd))
+ "\n\n")
+ (let ((data-pos (point))
+ (register-report (string-match " reg\\(ister\\)? " cmd))
files-in-report)
(shell-command
(if register-report
(concat cmd " --prepend-format='%(filename):%(beg_line):'")
cmd) t nil)
(when register-report
- (goto-char (point-min))
+ (goto-char data-pos)
(while (re-search-forward "^\\([^:]+\\)?:\\([0-9]+\\)?:" nil t)
(let ((file (match-string 1))
- (line (string-to-number (match-string 2))))
+ (line (string-to-number (match-string 2))))
(delete-region (match-beginning 0) (match-end 0))
(set-text-properties (line-beginning-position) (line-end-position)
- (list 'ledger-source (cons file line)))
- (let* ((fullpath (expand-file-name file))
- (entry (assoc fullpath ledger-report-patch-alist)))
- (if entry
- (nconc (cdr entry) (list (current-buffer)))
- (push (cons (expand-file-name file)
- (list (current-buffer)))
- ledger-report-patch-alist))
- (add-to-list 'files-in-report fullpath)))
-
- (dolist (path files-in-report)
- (let ((buf (get-file-buffer path)))
- (if (and buf (buffer-live-p buf))
- (ledger-report-patch-reports buf))))))))
+ (list 'ledger-source (cons file (save-window-excursion
+ (save-excursion
+ (find-file file)
+ (widen)
+ (goto-char (point-min))
+ (forward-line (1- line))
+ (point-marker))))))
+ (end-of-line))))
+ (goto-char data-pos)))
+
(defun ledger-report-visit-source ()
(interactive)
(let ((prop (get-text-property (point) 'ledger-source)))
(destructuring-bind (file . line-or-marker) prop
(find-file-other-window file)
+ (widen)
(if (markerp line-or-marker)
(goto-char line-or-marker)
(goto-char (point-min))
- (forward-line (1- line-or-marker))))))
+ (forward-line (1- line-or-marker))
+ (re-search-backward "^[0-9]+")
+ (beginning-of-line)
+ (let ((start-of-txn (point)))
+ (forward-paragraph)
+ (narrow-to-region start-of-txn (point))
+ (backward-paragraph))))))
(defun ledger-report-goto ()
"Goto the ledger report buffer."
diff --git a/lisp/ldg-xact.el b/lisp/ldg-xact.el
index e1f165a7..6e14a14c 100644
--- a/lisp/ldg-xact.el
+++ b/lisp/ldg-xact.el
@@ -18,3 +18,4 @@
(lambda ()
(forward-paragraph))))))
+(provide 'ldg-xact) \ No newline at end of file