diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 941892f..bd864de 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -26,6 +26,6 @@ jobs: with: version: ${{ matrix.emacs }} - run: pip install beancount - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - run: make compile - run: make test diff --git a/beancount.el b/beancount.el index 00ffb15..0c33e10 100644 --- a/beancount.el +++ b/beancount.el @@ -163,7 +163,8 @@ from the open directive for the relevant account." "price" "query" "txn") - "Directive names that can appear after a date and are _not_ followed by an account.") + "Directive names that can appear after a date and are _not_ followed by an +account.") (defconst beancount-timestamped-directive-names (append beancount-account-directive-names @@ -194,6 +195,7 @@ from the open directive for the relevant account." "account_previous_conversions" "account_previous_earnings" "account_rounding" + "account_unrealized_gains" "allow_deprecated_none_for_tags_and_links" "allow_pipe_separator" "booking_method" @@ -1034,20 +1036,28 @@ Only useful if you have not installed Beancount properly in your PATH.") (put 'beancount-tag 'bounds-of-thing-at-point #'beancount--bounds-of-tag-at-point) -(defun beancount-linked () - "Get the \"linked\" info from `beancount-doctor-program'." - (interactive) +(defun beancount-linked--get-target-under-point () + "Get link, tag or line no under point, or nil." (let ((lnarg (if mark-active (format "%d:%d" (line-number-at-pos (region-beginning)) (line-number-at-pos (region-end))) (format "%d" (line-number-at-pos))))) - (let* ((word (thing-at-point 'beancount-link)) - (link (when (and word (string-match "\\^" word)) word))) - (let ((compilation-read-command nil)) - (beancount--run beancount-doctor-program "linked" - buffer-file-name - (or link lnarg)))))) + (let* ((link-word (thing-at-point 'beancount-link)) + (link (when (and link-word (string-match "\\^" link-word)) link-word)) + (tag-word (thing-at-point 'beancount-tag)) + (tag (when (and tag-word (string-match "\\#" tag-word)) tag-word))) + (or link tag lnarg)))) + +(defun beancount-linked () + "Get the \"linked\" info from `beancount-doctor-program', either linked or tags +transactions at point." + (interactive) + (let ((compilation-read-command nil) + (target (beancount-linked--get-target-under-point))) + (beancount--run beancount-doctor-program "linked" + buffer-file-name + target))) ;; Note: Eventually we'd like to be able to honor some metadata in the file that ;; would point to the top-level filename. @@ -1055,7 +1065,6 @@ Only useful if you have not installed Beancount properly in your PATH.") "Run a command with a region as the final arguments." (when (use-region-p) (let* ((compilation-read-command nil) - (region-command (or command "region")) (args (append command (list buffer-file-name (format "%d:%d" @@ -1266,6 +1275,7 @@ Essentially a much simplified version of `next-line'." (defun beancount--fava-filter (process output) "Open fava url as soon as the address is announced." + (ignore process) (if-let ((url (string-match "Running Fava on \\(http://.+:[0-9]+\\)\n" output))) (browse-url (match-string 1 output))))