summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniele Nicolodi <daniele@grinta.net>2016-01-08 21:36:34 +0100
committerDaniele Nicolodi <daniele@grinta.net>2016-01-08 21:36:34 +0100
commit0c448cde2f02e7ae2e59a049c206136cb83484e7 (patch)
tree00b537dcd1b280e45e9c9e7b06c2b214fd0d451e
parentc9427aa47554b22343035df6f0aedd67be92c8b6 (diff)
downloadfork-ledger-0c448cde2f02e7ae2e59a049c206136cb83484e7.tar.gz
fork-ledger-0c448cde2f02e7ae2e59a049c206136cb83484e7.tar.bz2
fork-ledger-0c448cde2f02e7ae2e59a049c206136cb83484e7.zip
Fix highlight of the transaction under point
Extend the highlighting of the last line in the transaction to the right margin of the buffer. Do not highlight empty lines.
-rw-r--r--lisp/ledger-xact.el27
1 files changed, 15 insertions, 12 deletions
diff --git a/lisp/ledger-xact.el b/lisp/ledger-xact.el
index 5286d784..dad5ff5b 100644
--- a/lisp/ledger-xact.el
+++ b/lisp/ledger-xact.el
@@ -44,20 +44,23 @@
(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)))
+ (if (> (- e b) 1)
+ (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."