summaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authorMatus Goljer <matus.goljer@gmail.com>2015-10-14 21:34:20 +0200
committerMatus Goljer <matus.goljer@gmail.com>2015-10-14 21:34:20 +0200
commit5a47fbebe468ee6a39132cfd6b42bdb309e3e7f0 (patch)
tree05b424d5f35731ea0ff78daaeeaabcd5966f0558 /lisp
parentb25eb27866bfed56e252607e1a24289431f993ad (diff)
downloadfork-ledger-5a47fbebe468ee6a39132cfd6b42bdb309e3e7f0.tar.gz
fork-ledger-5a47fbebe468ee6a39132cfd6b42bdb309e3e7f0.tar.bz2
fork-ledger-5a47fbebe468ee6a39132cfd6b42bdb309e3e7f0.zip
Add an option to change amount-alignment mode.
Make the default alignment behaviour the same as before 767ab3e, that is, align on the last digit by default. A new option `ledger-post-amount-alignment-at' now exists to adjust alignment preference.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/ledger-post.el16
1 files changed, 15 insertions, 1 deletions
diff --git a/lisp/ledger-post.el b/lisp/ledger-post.el
index d741442a..f4727342 100644
--- a/lisp/ledger-post.el
+++ b/lisp/ledger-post.el
@@ -41,6 +41,16 @@
:type 'integer
:group 'ledger-post)
+(defcustom ledger-post-amount-alignment-at :end
+ "Position at which the amount is ailgned.
+
+Can be :end to align on the last number of the amount (can be
+followed by unaligned commodity) or :decimal to align at the
+decimal separator."
+ :type '(radio (const :tag "align at the end of amount" :end)
+ (const :tag "align at the decimal separator" :decimal))
+ :group 'ledger-post)
+
(defcustom ledger-post-use-completion-engine :built-in
"Which completion engine to use, :iswitchb or :ido chose those engines.
:built-in uses built-in Ledger-mode completion"
@@ -79,7 +89,11 @@ point at beginning of the commodity."
(when (re-search-forward ledger-amount-regex end t)
(goto-char (match-beginning 0))
(skip-syntax-forward " ")
- (- (match-end 3) (point)))))
+ (cond
+ ((eq ledger-post-amount-alignment-at :end)
+ (- (or (match-end 4) (match-end 3)) (point)))
+ ((eq ledger-post-amount-alignment-at :decimal)
+ (- (match-end 3) (point)))))))
(defun ledger-next-account (&optional end)
"Move to the beginning of the posting, or status marker, limit to END.