Add ability to posting the account in a posting using the iedger-default-acct-transaction-indent
This commit is contained in:
parent
497d668778
commit
9a86fe022c
3 changed files with 20 additions and 11 deletions
|
|
@ -596,8 +596,6 @@ for Ledger under the data options. Alternately you can choose
|
||||||
@node Ledger Customization Group, Ledger Reconcile Customization Group, Customization Variables, Customization Variables
|
@node Ledger Customization Group, Ledger Reconcile Customization Group, Customization Variables, Customization Variables
|
||||||
@subsection Ledger Customization Group
|
@subsection Ledger Customization Group
|
||||||
@table @code
|
@table @code
|
||||||
@item ledger-default-acct-transaction-indent
|
|
||||||
Default indentation for account transactions in an entry.
|
|
||||||
@item ledger-occur-use-face-unfolded
|
@item ledger-occur-use-face-unfolded
|
||||||
If non-nil use a custom face for xacts shown in `ledger-occur' mode using @code{ledger-occur-xact-face}.
|
If non-nil use a custom face for xacts shown in `ledger-occur' mode using @code{ledger-occur-xact-face}.
|
||||||
@item ledger-clear-whole-transactions
|
@item ledger-clear-whole-transactions
|
||||||
|
|
@ -678,11 +676,14 @@ Default face for pending (!) transactions in the reconcile window
|
||||||
@subsection Ledger Post Customization Group
|
@subsection Ledger Post Customization Group
|
||||||
Ledger Post :
|
Ledger Post :
|
||||||
@table @code
|
@table @code
|
||||||
|
|
||||||
@item ledger-post-auto-adjust-amounts
|
@item ledger-post-auto-adjust-amounts
|
||||||
If non-nil, then automatically align amounts to column specified in
|
If non-nil, then automatically align amounts to column specified in
|
||||||
@code{ledger-post-amount-alignment-column}
|
@code{ledger-post-amount-alignment-column}
|
||||||
@item ledger-post-amount-alignment-column
|
@item ledger-post-amount-alignment-column
|
||||||
The column Ledger-mode uses to align amounts
|
The column Ledger-mode uses to align amounts
|
||||||
|
@item ledger-default-acct-transaction-indent
|
||||||
|
Default indentation for account transactions in an entry.
|
||||||
@item ledger-post-use-completion-engine
|
@item ledger-post-use-completion-engine
|
||||||
Which completion engine to use, iswitchb, ido, or built-in
|
Which completion engine to use, iswitchb, ido, or built-in
|
||||||
@item ledger-post-use-ido
|
@item ledger-post-use-ido
|
||||||
|
|
|
||||||
|
|
@ -39,11 +39,6 @@
|
||||||
(defvar ledger-month (ledger-current-month)
|
(defvar ledger-month (ledger-current-month)
|
||||||
"Start a ledger session with the current month, but make it customizable to ease retro-entry.")
|
"Start a ledger session with the current month, but make it customizable to ease retro-entry.")
|
||||||
|
|
||||||
(defcustom ledger-default-acct-transaction-indent " "
|
|
||||||
"Default indentation for account transactions in an entry."
|
|
||||||
:type 'string
|
|
||||||
:group 'ledger)
|
|
||||||
|
|
||||||
(defun ledger-remove-overlays ()
|
(defun ledger-remove-overlays ()
|
||||||
"Remove all overlays from the ledger buffer."
|
"Remove all overlays from the ledger buffer."
|
||||||
(interactive)
|
(interactive)
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,11 @@
|
||||||
|
|
||||||
;;; Code:
|
;;; Code:
|
||||||
|
|
||||||
|
(defcustom ledger-default-acct-transaction-indent " "
|
||||||
|
"Default indentation for account transactions in an entry."
|
||||||
|
:type 'string
|
||||||
|
:group 'ledger-post)
|
||||||
|
|
||||||
(defgroup ledger-post nil
|
(defgroup ledger-post nil
|
||||||
"Options for controlling how Ledger-mode deals with postings and completion"
|
"Options for controlling how Ledger-mode deals with postings and completion"
|
||||||
:group 'ledger)
|
:group 'ledger)
|
||||||
|
|
@ -119,17 +124,25 @@ PROMPT is a string to prompt with. CHOICES is a list of
|
||||||
(match-end 3)) (point))))
|
(match-end 3)) (point))))
|
||||||
|
|
||||||
(defun ledger-align-amounts (&optional column)
|
(defun ledger-align-amounts (&optional column)
|
||||||
"Align amounts in the current region.
|
"Align amounts and accounts in the current region.
|
||||||
This is done so that the last digit falls in COLUMN, which
|
This is done so that the last digit falls in COLUMN, which
|
||||||
defaults to 52."
|
defaults to 52. ledger-default-acct-transaction-indent positions
|
||||||
|
the account"
|
||||||
(interactive "p")
|
(interactive "p")
|
||||||
(if (or (null column) (= column 1))
|
(if (or (null column) (= column 1))
|
||||||
(setq column ledger-post-amount-alignment-column))
|
(setq column ledger-post-amount-alignment-column))
|
||||||
(save-excursion
|
(save-excursion
|
||||||
|
;; Position the account
|
||||||
|
(beginning-of-line)
|
||||||
|
(set-mark (point))
|
||||||
|
(delete-horizontal-space)
|
||||||
|
(insert ledger-default-acct-transaction-indent)
|
||||||
|
(goto-char (1+ (line-end-position)))
|
||||||
(let* ((mark-first (< (mark) (point)))
|
(let* ((mark-first (< (mark) (point)))
|
||||||
(begin (if mark-first (mark) (point)))
|
(begin (if mark-first (mark) (point)))
|
||||||
(end (if mark-first (point-marker) (mark-marker)))
|
(end (if mark-first (point-marker) (mark-marker)))
|
||||||
offset)
|
offset)
|
||||||
|
;; Position the amount
|
||||||
(goto-char begin)
|
(goto-char begin)
|
||||||
(while (setq offset (ledger-next-amount end))
|
(while (setq offset (ledger-next-amount end))
|
||||||
(let ((col (current-column))
|
(let ((col (current-column))
|
||||||
|
|
@ -159,10 +172,10 @@ This is done so that the last digit falls in COLUMN, which
|
||||||
BEG, END, and LEN control how far it can align."
|
BEG, END, and LEN control how far it can align."
|
||||||
(save-excursion
|
(save-excursion
|
||||||
(goto-char beg)
|
(goto-char beg)
|
||||||
(when (< end (line-end-position))
|
(when (<= end (line-end-position))
|
||||||
(goto-char (line-beginning-position))
|
(goto-char (line-beginning-position))
|
||||||
(if (looking-at ledger-post-line-regexp)
|
(if (looking-at ledger-post-line-regexp)
|
||||||
(ledger-post-align-amount)))))
|
(ledger-align-amounts)))))
|
||||||
|
|
||||||
(defun ledger-post-edit-amount ()
|
(defun ledger-post-edit-amount ()
|
||||||
"Call 'calc-mode' and push the amount in the posting to the top of stack."
|
"Call 'calc-mode' and push the amount in the posting to the top of stack."
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue