From 5ff724c451fb09e73f055bcadc8b7ed2f79e0914 Mon Sep 17 00:00:00 2001 From: Hans Erik van Elburg Date: Sun, 4 Jan 2015 22:46:26 +0100 Subject: ledger-mode bug 1089 introduce sticky cursor for report auto refresh --- lisp/ledger-report.el | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'lisp/ledger-report.el') diff --git a/lisp/ledger-report.el b/lisp/ledger-report.el index dee96205..c477707f 100644 --- a/lisp/ledger-report.el +++ b/lisp/ledger-report.el @@ -71,6 +71,11 @@ text that should replace the format specifier." :type 'boolean :group 'ledger-report) +(defcustom ledger-report-auto-refresh-sticky-cursor nil + "If t then try to place cursor at same relative position as it was before auto-refresh." + :type 'boolean + :group 'ledger-report) + (defvar ledger-report-buffer-name "*Ledger Report*") (defvar ledger-report-name nil) @@ -83,6 +88,7 @@ text that should replace the format specifier." (defvar ledger-report-mode-abbrev-table) (defvar ledger-report-is-reversed nil) +(defvar ledger-report-cursor-line-number nil) (defun ledger-report-reverse-report () "Reverse the order of the report." @@ -391,10 +397,12 @@ Optional EDIT the command." (pop-to-buffer (get-buffer ledger-report-buffer-name)) (shrink-window-if-larger-than-buffer) (setq buffer-read-only nil) + (setq ledger-report-cursor-line-number (line-number-at-pos)) (erase-buffer) (ledger-do-report ledger-report-cmd) (setq buffer-read-only nil) (if ledger-report-is-reversed (ledger-report-reverse-lines)) + (if ledger-report-auto-refresh-sticky-cursor (forward-line (- ledger-report-cursor-line-number 5))) (pop-to-buffer cur-buf))))) (defun ledger-report-quit () -- cgit v1.2.3