summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCraig Earls <enderw88@gmail.com>2013-02-09 21:05:08 -0700
committerCraig Earls <enderw88@gmail.com>2013-02-09 21:05:08 -0700
commit0c8a660d6035d34a82a1cacaa47b93acafc9d47e (patch)
tree59a6672c3983b34deabba59b96825bb7ebe978b1
parent6fce572806eb39b5ba607bd5336adb6ca3ac2295 (diff)
downloadfork-ledger-0c8a660d6035d34a82a1cacaa47b93acafc9d47e.tar.gz
fork-ledger-0c8a660d6035d34a82a1cacaa47b93acafc9d47e.tar.bz2
fork-ledger-0c8a660d6035d34a82a1cacaa47b93acafc9d47e.zip
Forgot to stage ldg-xact.el in the last commit
-rw-r--r--lisp/ldg-xact.el40
1 files changed, 40 insertions, 0 deletions
diff --git a/lisp/ldg-xact.el b/lisp/ldg-xact.el
index 1df7d79a..e7402652 100644
--- a/lisp/ldg-xact.el
+++ b/lisp/ldg-xact.el
@@ -22,6 +22,46 @@
;; A sample entry sorting function, which works if entry dates are of
;; the form YYYY/mm/dd.
+(defcustom ledger-highlight-xact-under-point t
+ "If t highlight xact under point"
+ :type 'boolean
+ :group 'ledger)
+
+(defvar highlight-overlay (list))
+
+(defun ledger-find-xact-extents (pos)
+ "return point for beginning of xact and and of xact containing
+ position. Requires empty line separating xacts"
+ (interactive "d")
+ (save-excursion
+ (goto-char pos)
+ (let ((end-pos pos)
+ (beg-pos pos))
+ (backward-paragraph)
+ (forward-line)
+ (beginning-of-line)
+ (setq beg-pos (point))
+ (forward-paragraph)
+ (forward-line -1)
+ (end-of-line)
+ (setq end-pos (1+ (point)))
+ (list beg-pos end-pos))))
+
+
+(defun ledger-highlight-xact-under-point ()
+ (if ledger-highlight-xact-under-point
+ (let ((exts (ledger-find-xact-extents (point)))
+ (ovl highlight-overlay))
+ (if (not highlight-overlay)
+ (setq ovl
+ (setq highlight-overlay
+ (make-overlay (car exts)
+ (cadr exts)
+ (current-buffer) t nil)))
+ (move-overlay ovl (car exts) (cadr exts)))
+ (overlay-put ovl 'face 'ledger-font-highlight-face)
+ (overlay-put ovl 'priority 100))))
+
(provide 'ldg-xact) \ No newline at end of file