From cf6a23b2fe27e67536bd389737ed0e3379c2ae14 Mon Sep 17 00:00:00 2001 From: Rémi Vanicat Date: Sat, 9 Feb 2013 11:16:52 +0100 Subject: Unconditionally activate the occur stuff in ledger-occur-mode Well, we still deactivate it when regex is nil, but the function should not look at previous value of ledger-occur-mode: - the interactive function (ledger-occur) already do it, we don't need to do it there, - caller that want to deactivate the occur stuff only have to call ledger-occur with a nil regex - the old behavior make ledger-reconcile to turn off occur stuff if it was already turn on, when what we do want is that the occur stuff change to the new account. --- lisp/ldg-occur.el | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'lisp/ldg-occur.el') diff --git a/lisp/ldg-occur.el b/lisp/ldg-occur.el index 2958c94c..5a7c8ed7 100644 --- a/lisp/ldg-occur.el +++ b/lisp/ldg-occur.el @@ -69,13 +69,14 @@ "A list of currently active overlays to the ledger buffer.") (make-variable-buffer-local 'ledger-occur-overlay-list) - (defun ledger-occur-mode (regex buffer) + "Higlight transaction that match REGEX, hiding others + +When REGEX is nil, unhide everything, and remove higlight" (progn (set-buffer buffer) (setq ledger-occur-mode - (if (or ledger-occur-mode - (null regex) + (if (or (null regex) (zerop (length regex))) nil (concat " Ledger-Folded: " regex))) -- cgit v1.2.3 From d3964b66d556557b16053aa781220d298dc60d3a Mon Sep 17 00:00:00 2001 From: Rémi Vanicat Date: Sat, 9 Feb 2013 11:33:33 +0100 Subject: In ledger-occur, hide nothing if there is no match This could cause error when reconciling transaction that are included. Some message should be shown to explain why nothing happen when interactively call ledger-occur. --- lisp/ldg-occur.el | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) (limited to 'lisp/ldg-occur.el') diff --git a/lisp/ldg-occur.el b/lisp/ldg-occur.el index 5a7c8ed7..e830f339 100644 --- a/lisp/ldg-occur.el +++ b/lisp/ldg-occur.el @@ -128,31 +128,32 @@ When REGEX is nil, unhide everything, and remove higlight" prompt)) (defun ledger-occur-create-folded-overlays(buffer-matches) - (let ((overlays - (let ((prev-end (point-min)) - (temp (point-max))) - (mapcar (lambda (match) - (progn - (setq temp prev-end) ;need a swap so that the + (if buffer-matches + (let ((overlays + (let ((prev-end (point-min)) + (temp (point-max))) + (mapcar (lambda (match) + (progn + (setq temp prev-end) ;need a swap so that the ;last form in the lambda ;is the (make-overlay) - (setq prev-end (1+ (cadr match))) ;add 1 so + (setq prev-end (1+ (cadr match))) ;add 1 so ;that we skip ;the empty ;line after ;the xact - (make-overlay - temp - (car match) - (current-buffer) t nil))) - buffer-matches)))) - (mapcar (lambda (ovl) - (overlay-put ovl ledger-occur-overlay-property-name t) - (overlay-put ovl 'invisible t) - (overlay-put ovl 'intangible t)) - (push (make-overlay (cadr (car(last buffer-matches))) - (point-max) - (current-buffer) t nil) overlays)))) + (make-overlay + temp + (car match) + (current-buffer) t nil))) + buffer-matches)))) + (mapcar (lambda (ovl) + (overlay-put ovl ledger-occur-overlay-property-name t) + (overlay-put ovl 'invisible t) + (overlay-put ovl 'intangible t)) + (push (make-overlay (cadr (car(last buffer-matches))) + (point-max) + (current-buffer) t nil) overlays))))) (defun ledger-occur-create-xact-overlays (ovl-bounds) -- cgit v1.2.3