Skip to content

Commit

Permalink
Merge branch 'main' into more-xref
Browse files Browse the repository at this point in the history
  • Loading branch information
blais authored Jun 24, 2024
2 parents 146b84d + 142c5a4 commit b01c8c5
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
32 changes: 21 additions & 11 deletions beancount.el
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -1034,28 +1036,35 @@ 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.
(defun beancount-command-on-region (rmin rmax command)
"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"
Expand Down Expand Up @@ -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))))

Expand Down

0 comments on commit b01c8c5

Please sign in to comment.