diff options
author | Craig Earls <enderw88@gmail.com> | 2013-06-03 16:39:36 -0700 |
---|---|---|
committer | Craig Earls <enderw88@gmail.com> | 2013-06-03 16:39:36 -0700 |
commit | c23c994b2204d52ee5b2a947556045be79607239 (patch) | |
tree | 37a1e2f0b0a7deea88b6e533f202cd73f1221574 /lisp | |
parent | cb6f4b98900b0b2f0d4167a37a0153fb290f998e (diff) | |
download | fork-ledger-c23c994b2204d52ee5b2a947556045be79607239.tar.gz fork-ledger-c23c994b2204d52ee5b2a947556045be79607239.tar.bz2 fork-ledger-c23c994b2204d52ee5b2a947556045be79607239.zip |
Fix Bug 966 Auto Indent conflicts with undo. Removed the auto-indent function and added an indent xact function
Diffstat (limited to 'lisp')
-rw-r--r-- | lisp/ldg-mode.el | 2 | ||||
-rw-r--r-- | lisp/ldg-post.el | 21 |
2 files changed, 7 insertions, 16 deletions
diff --git a/lisp/ldg-mode.el b/lisp/ldg-mode.el index 82d00d29..fdbd8966 100644 --- a/lisp/ldg-mode.el +++ b/lisp/ldg-mode.el @@ -153,6 +153,7 @@ Can indent, complete or align depending on context." (define-key map [(control ?c) (control ?l)] 'ledger-display-ledger-stats) (define-key map [tab] 'ledger-magic-tab) + (define-key map [(control tab)] 'ledger-post-align-xact) (define-key map [(control ?i)] 'ledger-magic-tab) (define-key map [(control ?c) tab] 'ledger-fully-complete-xact) (define-key map [(control ?c) (control ?i)] 'ledger-fully-complete-xact) @@ -188,6 +189,7 @@ Can indent, complete or align depending on context." (define-key map [sort-start] '(menu-item "Mark Sort Beginning" ledger-sort-insert-start-mark)) (define-key map [sort-buff] '(menu-item "Sort Buffer" ledger-sort-buffer)) (define-key map [sort-reg] '(menu-item "Sort Region" ledger-sort-region :enable mark-active)) + (define-key map [align-xact] '(menu-item "Align Xact" ledger-post-align-xact)) (define-key map [align-reg] '(menu-item "Align Region" ledger-post-align-postings :enable mark-active)) (define-key map [sep2] '(menu-item "--")) (define-key map [copy-xact] '(menu-item "Copy Trans at Point" ledger-copy-transaction-at-point)) diff --git a/lisp/ldg-post.el b/lisp/ldg-post.el index d83dc5ab..693b9e0e 100644 --- a/lisp/ldg-post.el +++ b/lisp/ldg-post.el @@ -31,11 +31,6 @@ "Options for controlling how Ledger-mode deals with postings and completion" :group 'ledger) -(defcustom ledger-post-auto-adjust-postings t - "If non-nil, adjust account and amount to columns set below" - :type 'boolean - :group 'ledger-post) - (defcustom ledger-post-account-alignment-column 4 "The column Ledger-mode attempts to align accounts to." :type 'integer @@ -141,6 +136,11 @@ at beginning of account" (goto-char (match-beginning 2))) (current-column)))) +(defun ledger-post-align-xact (pos) + (interactive "d") + (let ((bounds (ledger-find-xact-extents pos))) + (ledger-post-align-postings (car bounds) (cadr bounds)))) + (defun ledger-post-align-postings (&optional beg end) "Align all accounts and amounts within region, if there is no region align the posting on the current line." @@ -198,16 +198,6 @@ region align the posting on the current line." (setq inhibit-modification-hooks nil)))) -(defun ledger-post-maybe-align (beg end len) - "Align amounts only if point is in a posting. -BEG, END, and LEN control how far it can align." - (if ledger-post-auto-adjust-postings - (save-excursion - (goto-char beg) - (when (<= end (line-end-position)) - (goto-char (line-beginning-position)) - (if (looking-at ledger-post-line-regexp) - (ledger-post-align-postings)))))) (defun ledger-post-edit-amount () "Call 'calc-mode' and push the amount in the posting to the top of stack." @@ -248,7 +238,6 @@ BEG, END, and LEN control how far it can align." (defun ledger-post-setup () "Configure `ledger-mode' to auto-align postings." - (add-hook 'after-change-functions 'ledger-post-maybe-align t t) (add-hook 'after-save-hook #'(lambda () (setq ledger-post-current-list nil)) t t)) |