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?
This commit is contained in:
Henrik Lissner 2023-09-20 16:05:34 +02:00
parent 96e6b72be6
commit 36651d6e66
No known key found for this signature in database
GPG key ID: B60957CA074D39A3

View file

@ -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))