diff options
author | Craig Earls <enderw88@gmail.com> | 2016-01-08 19:22:52 -0700 |
---|---|---|
committer | Craig Earls <enderw88@gmail.com> | 2016-01-08 19:22:52 -0700 |
commit | c88a9d0bd7758cabf3be1723c517060d7a4b6849 (patch) | |
tree | 08e7efb25eebf1d07dfd3ad436a788613af968c4 | |
parent | c9427aa47554b22343035df6f0aedd67be92c8b6 (diff) | |
parent | 9cb5bc0f4aa4f3e3d97aba5255d66f0c1b89d387 (diff) | |
download | fork-ledger-c88a9d0bd7758cabf3be1723c517060d7a4b6849.tar.gz fork-ledger-c88a9d0bd7758cabf3be1723c517060d7a4b6849.tar.bz2 fork-ledger-c88a9d0bd7758cabf3be1723c517060d7a4b6849.zip |
Merge pull request #442 from daniele-nicolodi/next
Very nice, I have been meaning to fix this one since I wrote the new overlay code. Thank you!
-rw-r--r-- | lisp/ledger-xact.el | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/lisp/ledger-xact.el b/lisp/ledger-xact.el index 5286d784..795df86a 100644 --- a/lisp/ledger-xact.el +++ b/lisp/ledger-xact.el @@ -44,20 +44,25 @@ (defvar ledger-xact-highlight-overlay (list)) (make-variable-buffer-local 'ledger-xact-highlight-overlay) +(defun ledger-highlight-make-overlay () + (let ((ovl (make-overlay 1 1))) + (overlay-put ovl 'face 'ledger-font-xact-highlight-face) + (overlay-put ovl 'priority '(nil . 99)) + ovl)) + (defun ledger-highlight-xact-under-point () "Move the highlight overlay to the current transaction." - (if ledger-highlight-xact-under-point - (let ((exts (ledger-navigate-find-element-extents (point))) - (ovl ledger-xact-highlight-overlay)) - (if (not ledger-xact-highlight-overlay) - (setq ovl - (setq ledger-xact-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-xact-highlight-face) - (overlay-put ovl 'priority '(nil . 99))))) + (when ledger-highlight-xact-under-point + (unless ledger-xact-highlight-overlay + (setq ledger-xact-highlight-overlay (ledger-highlight-make-overlay))) + (let ((exts (ledger-navigate-find-element-extents (point)))) + (let ((b (car exts)) + (e (cadr exts)) + (p (point))) + (if (and (> (- e b) 1) ; not an empty line + (<= p e) (>= p b)) ; point is within the boundaries + (move-overlay ledger-xact-highlight-overlay b (+ 1 e)) + (move-overlay ledger-xact-highlight-overlay 1 1)))))) (defun ledger-xact-payee () "Return the payee of the transaction containing point or nil." |