From 36651d6e6662cfe5e784f39936cf10df888db785 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Wed, 20 Sep 2023 16:05:34 +0200 Subject: [PATCH] tweak(beancount): include directives for next/prev transaction +beancount/next-transaction and +beancount/previous-transaction would formerly skip timestampped directives, e.g. 2016-09-15 * "Foo" "" Expenses:Y 779.00 DKK Assets:X:Checkings 2016-11-16 balance Assets:X:Checkings 8,417.58 DKK 2016-12-13 * "Bar" "" Assets:X:Checkings 2,100.00 DKK Income:Z The `balance` directive would be skipped over. This commit changes that to include them. Perhaps the commands should be renamed to +beancount/{next,previous}-entry to better reflect my intended purpose for them? --- modules/lang/beancount/autoload.el | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/modules/lang/beancount/autoload.el b/modules/lang/beancount/autoload.el index 1c9710342..d894a2245 100644 --- a/modules/lang/beancount/autoload.el +++ b/modules/lang/beancount/autoload.el @@ -172,12 +172,19 @@ Updates the date to today." (defun +beancount/next-transaction (&optional count) "Jump to the start of the next COUNT-th transaction." (interactive "p") - (dotimes (_ (or count 1)) - (beancount-goto-next-transaction))) + (let ((beancount-transaction-regexp + ;; Don't skip over timestamped directives (like balance or event + ;; declarations). + (concat beancount-timestamped-directive-regexp + "\\|" beancount-transaction-regexp))) + (dotimes (_ (or count 1)) + (beancount-goto-next-transaction)))) ;;;###autoload (defun +beancount/previous-transaction (&optional count) "Jump to the start of current or previous COUNT-th transaction." (interactive "p") (re-search-backward - beancount-transaction-regexp nil t (or count 1))) + (concat beancount-timestamped-directive-regexp + "\\|" beancount-transaction-regexp) + nil t))