emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/beancount dcb317ed0a 064/103: If the cursor is over a link


From: ELPA Syncer
Subject: [nongnu] elpa/beancount dcb317ed0a 064/103: If the cursor is over a link, invoke 'bean-doctor linked' command with the link
Date: Mon, 29 Apr 2024 15:59:46 -0400 (EDT)

branch: elpa/beancount
commit dcb317ed0a7582243f30ffc44aaf31717a81502b
Author: Martin Blais <blais@furius.ca>
Commit: Martin Blais <blais@furius.ca>

    If the cursor is over a link, invoke 'bean-doctor linked' command with the 
link
    instead of the line number.
    
    Note that the result is different from invocation over a line number, which
    pulls all the related transactions through any link, recursively. If you 
specify
    a link, only the transactions with that particular link will be included.
---
 beancount.el | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/beancount.el b/beancount.el
index 9ac5c1484d..0ba8d88784 100644
--- a/beancount.el
+++ b/beancount.el
@@ -33,6 +33,7 @@
 (autoload 'ido-completing-read "ido")
 (require 'subr-x)
 (require 'outline)
+(require 'thingatpt)
 
 (defgroup beancount ()
   "Editing mode for Beancount files."
@@ -317,11 +318,11 @@ from the open directive for the relevant account."
 
   (setq-local tab-always-indent 'complete)
   (setq-local completion-ignore-case t)
-  
+
   (add-hook 'completion-at-point-functions #'beancount-completion-at-point nil 
t)
   (add-hook 'post-command-hook #'beancount-highlight-transaction-at-point nil 
t)
   (add-hook 'post-self-insert-hook #'beancount--electric-currency nil t)
-  
+
   (setq-local font-lock-defaults '(beancount-font-lock-keywords))
   (setq-local font-lock-syntax-table t)
 
@@ -839,14 +840,21 @@ Only useful if you have not installed Beancount properly 
in your PATH.")
                     (file-relative-name buffer-file-name)
                     (number-to-string (line-number-at-pos)))))
 
+;; Define a type for (thing-at-point) for Beancount links.
+(defvar beancount-link-chars "[:alnum:]-_\\.\\^"
+  "Characters allowable in Beancount links.")
+
+(define-thing-chars beancount-link beancount-link-chars)
 
 (defun beancount-linked ()
   "Get the \"linked\" info from `beancount-doctor-program'."
   (interactive)
-  (let ((compilation-read-command nil))
-    (beancount--run beancount-doctor-program "linked"
-                    (file-relative-name buffer-file-name)
-                    (number-to-string (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"
+                      (file-relative-name buffer-file-name)
+                      (or link (number-to-string (line-number-at-pos)))))))
 
 (defvar beancount-price-program "bean-price"
   "Program to run the price fetching commands.")



reply via email to

[Prev in Thread] Current Thread [Next in Thread]