summaryrefslogtreecommitdiff
path: root/lisp/ldg-post.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/ldg-post.el')
-rw-r--r--lisp/ldg-post.el98
1 files changed, 49 insertions, 49 deletions
diff --git a/lisp/ldg-post.el b/lisp/ldg-post.el
index 492f9467..da4a2806 100644
--- a/lisp/ldg-post.el
+++ b/lisp/ldg-post.el
@@ -26,14 +26,14 @@
(defun ledger-post-all-accounts ()
(let ((origin (point))
- (ledger-post-list nil)
- account elements)
+ (ledger-post-list nil)
+ account elements)
(save-excursion
(goto-char (point-min))
(while (re-search-forward ledger-post-line-regexp nil t)
- (unless (and (>= origin (match-beginning 0))
- (< origin (match-end 0)))
- (add-to-list 'ledger-post-list (ledger-regex-post-line-account))))
+ (unless (and (>= origin (match-beginning 0))
+ (< origin (match-end 0)))
+ (add-to-list 'ledger-post-list (ledger-regex-post-line-account))))
(nreverse ledger-post-list))))
(declare-function iswitchb-read-buffer "iswitchb"
@@ -47,9 +47,9 @@ to choose from."
(cond
(ledger-post-use-iswitchb
(let* ((iswitchb-use-virtual-buffers nil)
- (iswitchb-make-buflist-hook
- (lambda ()
- (setq iswitchb-temp-buflist choices))))
+ (iswitchb-make-buflist-hook
+ (lambda ()
+ (setq iswitchb-temp-buflist choices))))
(iswitchb-read-buffer prompt)))
(ledger-post-use-ido
(ido-completing-read prompt choices))
@@ -61,26 +61,26 @@ to choose from."
(defun ledger-post-pick-account ()
(interactive)
(let* ((account
- (ledger-post-completing-read
- "Account: " (or ledger-post-current-list
- (setq ledger-post-current-list
- (ledger-post-all-accounts)))))
- (account-len (length account))
- (pos (point)))
+ (ledger-post-completing-read
+ "Account: " (or ledger-post-current-list
+ (setq ledger-post-current-list
+ (ledger-post-all-accounts)))))
+ (account-len (length account))
+ (pos (point)))
(goto-char (line-beginning-position))
(when (re-search-forward ledger-post-line-regexp (line-end-position) t)
(let ((existing-len (length (ledger-regex-post-line-account))))
- (goto-char (match-beginning ledger-regex-post-line-group-account))
- (delete-region (match-beginning ledger-regex-post-line-group-account)
- (match-end ledger-regex-post-line-group-account))
- (insert account)
- (cond
- ((> existing-len account-len)
- (insert (make-string (- existing-len account-len) ? )))
- ((< existing-len account-len)
- (dotimes (n (- account-len existing-len))
- (if (looking-at "[ \t]\\( [ \t]\\|\t\\)")
- (delete-char 1)))))))
+ (goto-char (match-beginning ledger-regex-post-line-group-account))
+ (delete-region (match-beginning ledger-regex-post-line-group-account)
+ (match-end ledger-regex-post-line-group-account))
+ (insert account)
+ (cond
+ ((> existing-len account-len)
+ (insert (make-string (- existing-len account-len) ? )))
+ ((< existing-len account-len)
+ (dotimes (n (- account-len existing-len))
+ (if (looking-at "[ \t]\\( [ \t]\\|\t\\)")
+ (delete-char 1)))))))
(goto-char pos)))
(defun ledger-next-amount (&optional end)
@@ -88,7 +88,7 @@ to choose from."
(goto-char (match-beginning 0))
(skip-syntax-forward " ")
(- (or (match-end 4)
- (match-end 3)) (point))))
+ (match-end 3)) (point))))
(defun ledger-align-amounts (&optional column)
"Align amounts in the current region.
@@ -98,24 +98,24 @@ This is done so that the last digit falls in COLUMN, which defaults to 52."
(setq column ledger-post-amount-alignment-column))
(save-excursion
(let* ((mark-first (< (mark) (point)))
- (begin (if mark-first (mark) (point)))
- (end (if mark-first (point-marker) (mark-marker)))
- offset)
+ (begin (if mark-first (mark) (point)))
+ (end (if mark-first (point-marker) (mark-marker)))
+ offset)
(goto-char begin)
(while (setq offset (ledger-next-amount end))
- (let ((col (current-column))
- (target-col (- column offset))
- adjust)
- (setq adjust (- target-col col))
- (if (< col target-col)
- (insert (make-string (- target-col col) ? ))
- (move-to-column target-col)
- (if (looking-back " ")
- (delete-char (- col target-col))
- (skip-chars-forward "^ \t")
- (delete-horizontal-space)
- (insert " ")))
- (forward-line))))))
+ (let ((col (current-column))
+ (target-col (- column offset))
+ adjust)
+ (setq adjust (- target-col col))
+ (if (< col target-col)
+ (insert (make-string (- target-col col) ? ))
+ (move-to-column target-col)
+ (if (looking-back " ")
+ (delete-char (- col target-col))
+ (skip-chars-forward "^ \t")
+ (delete-horizontal-space)
+ (insert " ")))
+ (forward-line))))))
(defun ledger-post-align-amount ()
(interactive)
@@ -130,7 +130,7 @@ This is done so that the last digit falls in COLUMN, which defaults to 52."
(when (< end (line-end-position))
(goto-char (line-beginning-position))
(if (looking-at ledger-post-line-regexp)
- (ledger-post-align-amount)))))
+ (ledger-post-align-amount)))))
(defun ledger-post-edit-amount ()
(interactive)
@@ -139,12 +139,12 @@ This is done so that the last digit falls in COLUMN, which defaults to 52."
(goto-char (match-end ledger-regex-post-line-group-account))
(when (re-search-forward "[-.,0-9]+" (line-end-position) t)
(let ((val (match-string 0)))
- (goto-char (match-beginning 0))
- (delete-region (match-beginning 0) (match-end 0))
- (calc)
- (while (string-match "," val)
- (setq val (replace-match "" nil nil val)))
- (calc-eval val 'push)))))
+ (goto-char (match-beginning 0))
+ (delete-region (match-beginning 0) (match-end 0))
+ (calc)
+ (while (string-match "," val)
+ (setq val (replace-match "" nil nil val)))
+ (calc-eval val 'push)))))
(defun ledger-post-prev-xact ()
(interactive)