refactored the auto-adjust to make it default
This commit is contained in:
parent
37ddc5f588
commit
cdd7f0675c
1 changed files with 11 additions and 10 deletions
|
|
@ -31,12 +31,11 @@
|
||||||
"Default indentation for account transactions in an entry."
|
"Default indentation for account transactions in an entry."
|
||||||
:type 'string
|
:type 'string
|
||||||
:group 'ledger-post)
|
: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)
|
||||||
|
|
||||||
(defcustom ledger-post-auto-adjust-postings nil
|
(defcustom ledger-post-auto-adjust-postings t
|
||||||
"If non-nil, adjust account and amount to columns set below"
|
"If non-nil, adjust account and amount to columns set below"
|
||||||
:type 'boolean
|
:type 'boolean
|
||||||
:group 'ledger-post)
|
:group 'ledger-post)
|
||||||
|
|
@ -138,8 +137,9 @@ the account"
|
||||||
(setq column ledger-post-amount-alignment-column))
|
(setq column ledger-post-amount-alignment-column))
|
||||||
(save-excursion
|
(save-excursion
|
||||||
;; Position the account
|
;; Position the account
|
||||||
(if (not (and (looking-at "[ \t]+\n")
|
(if (not (or (looking-at "[ \t]*[1-9]")
|
||||||
(looking-back "[ \n]" (- (point) 2))))
|
(and (looking-at "[ \t]+\n")
|
||||||
|
(looking-back "[ \n]" (- (point) 2)))))
|
||||||
(save-excursion
|
(save-excursion
|
||||||
(beginning-of-line)
|
(beginning-of-line)
|
||||||
(set-mark (point))
|
(set-mark (point))
|
||||||
|
|
@ -180,12 +180,13 @@ the account"
|
||||||
(defun ledger-post-maybe-align (beg end len)
|
(defun ledger-post-maybe-align (beg end len)
|
||||||
"Align amounts only if point is in a posting.
|
"Align amounts only if point is in a posting.
|
||||||
BEG, END, and LEN control how far it can align."
|
BEG, END, and LEN control how far it can align."
|
||||||
(save-excursion
|
(if ledger-post-auto-adjust-postings
|
||||||
(goto-char beg)
|
(save-excursion
|
||||||
(when (<= end (line-end-position))
|
(goto-char beg)
|
||||||
(goto-char (line-beginning-position))
|
(when (<= end (line-end-position))
|
||||||
(if (looking-at ledger-post-line-regexp)
|
(goto-char (line-beginning-position))
|
||||||
(ledger-post-align-postings)))))
|
(if (looking-at ledger-post-line-regexp)
|
||||||
|
(ledger-post-align-postings))))))
|
||||||
|
|
||||||
(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