branch: elpa/beancount
commit 687775da63784d153a3c1cfee9801090c6b51842
Author: blais <[email protected]>
Commit: blais <[email protected]>
Minor refactoring of region commands (with no expected functionality
changes).
---
beancount.el | 24 ++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/beancount.el b/beancount.el
index 76b878eea0..c3f5614ec4 100644
--- a/beancount.el
+++ b/beancount.el
@@ -923,34 +923,34 @@ Only useful if you have not installed Beancount properly
in your PATH.")
buffer-file-name
(or link lnarg))))))
-(defun beancount-region (rmin rmax &optional command &rest args)
- "Get the info from \"region\" from `beancount-doctor-program'."
+;; 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 (list beancount-doctor-program
- region-command
- buffer-file-name)
- args
- (list (format "%d:%d"
+ (args (append command
+ (list buffer-file-name
+ (format "%d:%d"
(line-number-at-pos rmin)
(line-number-at-pos
(if (= 0 (save-excursion (goto-char
rmax) (current-column)))
- (1- rmax) rmax)))))))
- ;(message args)))
+ (1- rmax) rmax)))
+ ))))
(apply #'beancount--run args))))
(defun beancount-region-default (rmin rmax)
(interactive "r")
- (beancount-region rmin rmax "region"))
+ (beancount-command-on-region rmin rmax (list beancount-doctor-program
"region")))
(defun beancount-region-value (rmin rmax)
(interactive "r")
- (beancount-region rmin rmax "region" "--conversion=value"))
+ (beancount-command-on-region rmin rmax (list beancount-doctor-program
"region" "--conversion=value")))
(defun beancount-region-cost (rmin rmax)
(interactive "r")
- (beancount-region rmin rmax "region" "--conversion=cost"))
+ (beancount-command-on-region rmin rmax (list beancount-doctor-program
"region" "--conversion=cost")))
(defvar beancount-price-program "bean-price"
"Program to run the price fetching commands.")