Renamed ldg-account.el to ldg-post.el
This commit is contained in:
parent
f672ddafc3
commit
a5d99cc9d3
1 changed files with 29 additions and 29 deletions
|
|
@ -1,23 +1,23 @@
|
|||
(require 'ldg-regex)
|
||||
|
||||
(defgroup ledger-account nil
|
||||
(defgroup ledger-post nil
|
||||
""
|
||||
:group 'ledger)
|
||||
|
||||
(defcustom ledger-account-auto-adjust-amounts t
|
||||
(defcustom ledger-post-auto-adjust-amounts t
|
||||
"If non-nil, ."
|
||||
:type 'boolean
|
||||
:group 'ledger-account)
|
||||
:group 'ledger-post)
|
||||
|
||||
(declare-function iswitchb-read-buffer "iswitchb"
|
||||
(prompt &optional default require-match start matches-set))
|
||||
(defvar iswitchb-temp-buflist)
|
||||
|
||||
(defvar ledger-account-current-list nil)
|
||||
(defvar ledger-post-current-list nil)
|
||||
|
||||
(defun ledger-account-find-all ()
|
||||
(defun ledger-post-find-all ()
|
||||
(let ((origin (point))
|
||||
(ledger-account-list nil)
|
||||
(ledger-post-list nil)
|
||||
account-path elements)
|
||||
(save-excursion
|
||||
(goto-char (point-min))
|
||||
|
|
@ -27,11 +27,11 @@
|
|||
(< origin (match-end 0)))
|
||||
(setq account-path (match-string-no-properties 2))
|
||||
(unless (string-match "\\`\\s-*;" account-path)
|
||||
(add-to-list 'ledger-account-list account-path))))
|
||||
(setq ledger-account-current-list
|
||||
(nreverse ledger-account-list)))))
|
||||
(add-to-list 'ledger-post-list account-path))))
|
||||
(setq ledger-post-current-list
|
||||
(nreverse ledger-post-list)))))
|
||||
|
||||
(defun ledger-account-completing-read (prompt choices)
|
||||
(defun ledger-post-completing-read (prompt choices)
|
||||
"Use iswitchb as a completing-read replacement to choose from choices.
|
||||
PROMPT is a string to prompt with. CHOICES is a list of strings
|
||||
to choose from."
|
||||
|
|
@ -41,12 +41,12 @@ to choose from."
|
|||
(setq iswitchb-temp-buflist choices))))
|
||||
(iswitchb-read-buffer prompt)))
|
||||
|
||||
(defun ledger-account-select ()
|
||||
(defun ledger-post-pick-account ()
|
||||
(interactive)
|
||||
(let* ((account
|
||||
(ledger-account-completing-read "Account: "
|
||||
(or ledger-account-current-list
|
||||
(ledger-account-find-all))))
|
||||
(ledger-post-completing-read "Account: "
|
||||
(or ledger-post-current-list
|
||||
(ledger-post-find-all))))
|
||||
(account-len (length account))
|
||||
(pos (point)))
|
||||
(goto-char (line-beginning-position))
|
||||
|
|
@ -64,22 +64,22 @@ to choose from."
|
|||
(delete-char 1)))))))
|
||||
(goto-char pos)))
|
||||
|
||||
(defun ledger-account-align-amount ()
|
||||
(defun ledger-post-align-amount ()
|
||||
(interactive)
|
||||
(save-excursion
|
||||
(set-mark (line-beginning-position))
|
||||
(goto-char (1+ (line-end-position)))
|
||||
(ledger-align-amounts)))
|
||||
|
||||
(defun ledger-account-maybe-align (beg end len)
|
||||
(defun ledger-post-maybe-align (beg end len)
|
||||
(save-excursion
|
||||
(goto-char beg)
|
||||
(when (< end (line-end-position))
|
||||
(goto-char (line-beginning-position))
|
||||
(if (looking-at ledger-regex-post-line)
|
||||
(ledger-account-align-amount)))))
|
||||
(ledger-post-align-amount)))))
|
||||
|
||||
(defun ledger-account-edit-amount ()
|
||||
(defun ledger-post-edit-amount ()
|
||||
(interactive)
|
||||
(goto-char (line-beginning-position))
|
||||
(when (re-search-forward ledger-regex-post-line (line-end-position) t)
|
||||
|
|
@ -93,7 +93,7 @@ to choose from."
|
|||
(setq val (replace-match "" nil nil val)))
|
||||
(calc-eval val 'push)))))
|
||||
|
||||
(defun ledger-account-prev-xact ()
|
||||
(defun ledger-post-prev-xact ()
|
||||
(interactive)
|
||||
(backward-paragraph)
|
||||
(when (re-search-backward ledger-regex-xact-line nil t)
|
||||
|
|
@ -101,22 +101,22 @@ to choose from."
|
|||
(re-search-forward ledger-regex-post-line)
|
||||
(goto-char (match-end 3))))
|
||||
|
||||
(defun ledger-account-next-xact ()
|
||||
(defun ledger-post-next-xact ()
|
||||
(interactive)
|
||||
(when (re-search-forward ledger-regex-xact-line nil t)
|
||||
(goto-char (match-beginning 0))
|
||||
(re-search-forward ledger-regex-post-line)
|
||||
(goto-char (match-end 3))))
|
||||
|
||||
(defun ledger-account-setup ()
|
||||
(defun ledger-post-setup ()
|
||||
(let ((map (current-local-map)))
|
||||
(define-key map [(meta ?p)] 'ledger-account-prev-xact)
|
||||
(define-key map [(meta ?n)] 'ledger-account-next-xact)
|
||||
(define-key map [(control ?c) (control ?c)] 'ledger-account-select)
|
||||
(define-key map [(control ?c) (control ?e)] 'ledger-account-select))
|
||||
(if ledger-account-auto-adjust-amounts
|
||||
(add-hook 'after-change-functions 'ledger-account-maybe-align t t)))
|
||||
(define-key map [(meta ?p)] 'ledger-post-prev-xact)
|
||||
(define-key map [(meta ?n)] 'ledger-post-next-xact)
|
||||
(define-key map [(control ?c) (control ?c)] 'ledger-post-pick-account)
|
||||
(define-key map [(control ?c) (control ?e)] 'ledger-post-edit-amount))
|
||||
(if ledger-post-auto-adjust-amounts
|
||||
(add-hook 'after-change-functions 'ledger-post-maybe-align t t)))
|
||||
|
||||
(add-hook 'ledger-mode-hook 'ledger-account-setup)
|
||||
(add-hook 'ledger-mode-hook 'ledger-post-setup)
|
||||
|
||||
(provide 'ldg-account)
|
||||
(provide 'ldg-post)
|
||||
Loading…
Add table
Reference in a new issue