From 6abcf2109dd5d7bb103affb54015683c8a4b8cb6 Mon Sep 17 00:00:00 2001 From: thdox Date: Wed, 25 Feb 2015 19:01:30 +0100 Subject: [PATCH 1/8] Fix baseline test for --no-pager. --- test/CheckBaselineTests.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/CheckBaselineTests.py b/test/CheckBaselineTests.py index 8c51ddef..1439cda4 100755 --- a/test/CheckBaselineTests.py +++ b/test/CheckBaselineTests.py @@ -29,7 +29,7 @@ class CheckBaselineTests (CheckOptions): 'help', 'import', 'no-color', - 'no-pager' + 'no-pager', 'options', 'price-exp', 'revalued-total', From d0f2b64cbebe54e32519f48819f2c55cb8417e99 Mon Sep 17 00:00:00 2001 From: Ilya T Date: Fri, 13 Mar 2015 08:20:37 +0700 Subject: [PATCH 2/8] Fix clang compile error (FreeBSD 10). --- src/output.cc | 6 +++--- src/output.h | 10 ++++++---- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/output.cc b/src/output.cc index ffd144e1..92b71387 100644 --- a/src/output.cc +++ b/src/output.cc @@ -291,7 +291,7 @@ void report_accounts::flush() void report_accounts::operator()(post_t& post) { - std::map::iterator i = accounts.find(post.account); + accounts_report_map::iterator i = accounts.find(post.account); if (i == accounts.end()) accounts.insert(accounts_pair(post.account, 1)); else @@ -362,7 +362,7 @@ void report_commodities::operator()(post_t& post) amount_t temp(post.amount.strip_annotations(report.what_to_keep())); commodity_t& comm(temp.commodity()); - std::map::iterator i = commodities.find(&comm); + commodities_report_map::iterator i = commodities.find(&comm); if (i == commodities.end()) commodities.insert(commodities_pair(&comm, 1)); else @@ -371,7 +371,7 @@ void report_commodities::operator()(post_t& post) if (comm.has_annotation()) { annotated_commodity_t& ann_comm(as_annotated_commodity(comm)); if (ann_comm.details.price) { - std::map::iterator ii = + commodities_report_map::iterator ii = commodities.find(&ann_comm.details.price->commodity()); if (ii == commodities.end()) commodities.insert diff --git a/src/output.h b/src/output.h index ec7ec6c2..1305fa77 100644 --- a/src/output.h +++ b/src/output.h @@ -142,9 +142,10 @@ class report_accounts : public item_handler protected: report_t& report; - std::map accounts; - typedef std::map::value_type accounts_pair; + typedef std::map accounts_report_map; + + accounts_report_map accounts; public: report_accounts(report_t& _report) : report(_report) { @@ -221,9 +222,10 @@ class report_commodities : public item_handler protected: report_t& report; - std::map commodities; - typedef std::map::value_type commodities_pair; + typedef std::map commodities_report_map; + + commodities_report_map commodities; public: report_commodities(report_t& _report) : report(_report) { From d3344243c94fb591c0f78131f63beb3a423b5138 Mon Sep 17 00:00:00 2001 From: thdox Date: Thu, 26 Feb 2015 18:14:15 +0100 Subject: [PATCH 3/8] [emacs] Fix bug 1108, enabling correct account context. The old way of working was keeping spaces before and after the account. Now the space before is associated to the "status" and "separator" is enlarged to not be maxed to 2 chars [ci skip] --- lisp/ledger-context.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lisp/ledger-context.el b/lisp/ledger-context.el index 0dfa4645..643ebdd3 100644 --- a/lisp/ledger-context.el +++ b/lisp/ledger-context.el @@ -32,9 +32,9 @@ ;; `ledger-single-line-config' macro to form the regex and list of ;; elements (defconst ledger-indent-string "\\(^[ \t]+\\)") -(defconst ledger-status-string "\\([*! ]?\\)") +(defconst ledger-status-string "\\(* \\|! \\)?") (defconst ledger-account-string "[\\[(]?\\(.*?\\)[])]?") -(defconst ledger-separator-string "\\s-\\s-") +(defconst ledger-separator-string "\\s-\\s-+") (defconst ledger-amount-string "\\(-?[0-9]+[\\.,][0-9]*\\)") (defconst ledger-comment-string "[ \t]*;[ \t]*\\(.*?\\)") (defconst ledger-nil-string "\\([ \t]\\)") From 47247ee9181f6caf41e0c42b6130700d52935c55 Mon Sep 17 00:00:00 2001 From: thdox Date: Thu, 26 Feb 2015 20:03:08 +0100 Subject: [PATCH 4/8] [doc] Improve documentation about "choose account to reconcile"". [ci skip] --- doc/ledger-mode.texi | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/doc/ledger-mode.texi b/doc/ledger-mode.texi index 4fe56d6b..7cc076b8 100644 --- a/doc/ledger-mode.texi +++ b/doc/ledger-mode.texi @@ -194,8 +194,10 @@ outside world. This process is called reconciliation (@pxref{Basics of Reconciliation}) and can be quite onerous. Ledger-mode attempts to make it as painless as possible. -In the @file{demo.ledger} buffer type @kbd{C-c C-r}. Emacs will prompt -for an account to reconcile in the Minibuffer. Enter @samp{Checking}. +In the @file{demo.ledger} buffer type @kbd{C-c C-r}. If cursor is on an +account, Ledger-mode will propose this account, or in the Minibuffer, +will prompt for an account to reconcile. Hit @kbd{RET} if you are happy +with proposed account, or enter @samp{Checking} as example. Emacs will then prompt for a target value. The target value is the amount you want the cleared transactions in the buffer to total. Normally this would be the ending value from your bank statement, or the @@ -550,17 +552,25 @@ about. You can get this from a monthly statement, or from checking your on-line transaction history. It also helps immensely to know the final cleared balance you are aiming for. -Use menu @samp{Reconcile Account} or keyboard shortcut @kbd{C-c C-r} and enter the account -you wish to reconcile in the Minibuffer. Ledger-mode is not particular -about what you enter for the account. You can leave it blank and -@file{*Reconcile*} buffer will show you @emph{all} uncleared -transactions. After you enter the account enter the target amount. -Ledger expects you to enter an amount with a commodity. It assumes -initially that you are using @samp{$} (USD) as your default commodity. -If you are working in a different currency you can change the default in -variable @option{ledger-reconcile-default-commodity} to whatever you -need. If you work in multiple commodities simply enter the commoditized -amount (for example @samp{340 VSDX}, for 340 shares of VSDX). +Use menu @samp{Reconcile Account} or keyboard shortcut @kbd{C-c C-r} to +start reconciliation. + +If cursor is on an account, Ledger-mode will propose this account, or in +the Minibuffer, will prompt for an account to reconcile. Hit @kbd{RET} +if you are happy with proposed account, or enter @samp{Checking} as +example. Ledger-mode is not particular about what you enter for the +account. You can leave it blank and @file{*Reconcile*} buffer will show +you @emph{all} uncleared transactions. + +After you enter the account enter the target amount. It is helpful to +enter an amount with a commodity. You can also leave it blank, you will +be able to clear transactions but not benefit from balance calculations. +It assumes initially that you are using @samp{$} (USD) as your default +commodity. If you are working in a different currency you can change +the default in variable @option{ledger-reconcile-default-commodity} to +whatever you need. If you work in multiple commodities simply enter the +commoditized amount (for example @samp{340 VSDX}, for 340 shares of +VSDX). Ledger-mode reconcile cannot currently reconcile accounts that have multiple commodities, such as brokerage accounts. You may use From f2dd9a6003e0e762e628b3fcff0a07cc43020810 Mon Sep 17 00:00:00 2001 From: thdox Date: Thu, 26 Feb 2015 16:43:37 +0100 Subject: [PATCH 5/8] [doc] Improve documentation about C-c C-c to clear a transaction. [ci skip] --- doc/ledger-mode.texi | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/doc/ledger-mode.texi b/doc/ledger-mode.texi index 4fe56d6b..74bb1c91 100644 --- a/doc/ledger-mode.texi +++ b/doc/ledger-mode.texi @@ -383,13 +383,15 @@ transaction. @end itemize -@kindex C-c C-e @kindex C-c C-c +@kindex C-c C-e -Clearing complete transactions is done by typing @kbd{C-c C-e} with -point in a transaction. This places an asterisk @samp{*} after the -date. Clearing individual postings is done by typing @kbd{C-c C-c} -while in a posting. This places an asterisk prior to the posting. +Typing @kbd{C-c C-c}, depending where is the point, will clear the +complete transaction, or an individual posting. This places an asterisk +@samp{*} prior to the payee for the complete transaction, or prior to +the account for an individual posting. When point is inside +a transaction, specifically on an individual posting, you can still +clear the complete transaction by typing @kbd{C-c C-e}. @node Formatting Transactions, Deleting Transactions, Marking Transactions, The Ledger Buffer @section Formatting Transactions From 1e3def2bb5d8a1dc65431d10f692e0c46e9ed9a1 Mon Sep 17 00:00:00 2001 From: thdox Date: Thu, 26 Feb 2015 20:12:10 +0100 Subject: [PATCH 6/8] [doc] Small typo. [ci skip] --- doc/ledger-mode.texi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/ledger-mode.texi b/doc/ledger-mode.texi index 74bb1c91..ddd29ce6 100644 --- a/doc/ledger-mode.texi +++ b/doc/ledger-mode.texi @@ -966,7 +966,7 @@ header will be displayed. Defaults to "Reconciling account %s\n\n". @item ledger-reconcile-buffer-line-format Format string for the ledger reconcile posting format. Available fields are date, status, code, payee, account, amount. The format for each -field is %WIDTH(FIELD), WIDTH can be preced by a minus sign which mean +field is %WIDTH(FIELD), WIDTH can be preceded by a minus sign which mean to left justify and pad the field. WIDTH is the minimum number of characters to display; if string is longer, it is not truncated unless ledger-reconcile-buffer-payee-max-chars or From 98d5d18993f82ccd0fe80e31e2a8b543fc3c7879 Mon Sep 17 00:00:00 2001 From: thdox Date: Thu, 26 Feb 2015 21:36:21 +0100 Subject: [PATCH 7/8] [doc] Use @option consistently. [ci skip] --- doc/ledger-mode.texi | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/ledger-mode.texi b/doc/ledger-mode.texi index ddd29ce6..6daf7601 100644 --- a/doc/ledger-mode.texi +++ b/doc/ledger-mode.texi @@ -868,7 +868,7 @@ recurrence relation to be specified. The day names are two character codes that default to Mo, Tu, We, Th, Fr, Sa, Su, for Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday respectively. You can change the codes to something more convenient for your locale by -customizing the ledger @var{ledger-schedule-week-days}. They must be two +customizing the ledger @option{ledger-schedule-week-days}. They must be two characters long. @@ -953,7 +953,7 @@ false toggle between uncleared and cleared @samp{*}. @item ledger-reconcile-default-date-format Date format for the reconcile buffer. Defaults to -ledger-default-date-format. +@option{ledger-default-date-format}. @item ledger-reconcile-target-prompt-string Prompt for recon target. Defaults to "Target amount for reconciliation ". @@ -969,8 +969,8 @@ are date, status, code, payee, account, amount. The format for each field is %WIDTH(FIELD), WIDTH can be preceded by a minus sign which mean to left justify and pad the field. WIDTH is the minimum number of characters to display; if string is longer, it is not truncated unless -ledger-reconcile-buffer-payee-max-chars or -ledger-reconcile-buffer-account-max-chars is defined. Defaults to +@option{ledger-reconcile-buffer-payee-max-chars} or +@option{ledger-reconcile-buffer-account-max-chars} is defined. Defaults to "%(date)s %-4(code)s %-50(payee)s %-30(account)s %15(amount)s\n" @item ledger-reconcile-buffer-payee-max-chars From f5ba76442c45a87f2eefe46c78a18ff291d85166 Mon Sep 17 00:00:00 2001 From: thdox Date: Thu, 26 Feb 2015 12:21:03 +0100 Subject: [PATCH 8/8] [emacs] Fix bug 1060. Set as an option to kill (or not) the reconcile buffer after ledger-reconcile-finish. The default is set to *not* kill the buffer. This is justified as the facts that: 1. In old ledger mode (the one from Ledger 2.6), the default is to *not* kill the buffer. Also for the ones who will migrate from 2.6 to 3 when package will be available in their linux distribution, this will be the path of least surprise. 2. The current documentation does state that the buffer is to be killed with 'q' after 'C-c C-c'. This has been made configurable, as killing buffer may already be part of the workflow of some persons. [ci skip] --- doc/ledger-mode.texi | 9 +++++++++ lisp/ledger-reconcile.el | 10 ++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/doc/ledger-mode.texi b/doc/ledger-mode.texi index 4fe56d6b..58aea6e8 100644 --- a/doc/ledger-mode.texi +++ b/doc/ledger-mode.texi @@ -596,11 +596,17 @@ mark the transaction if appropriate. @node Finalize Reconciliation, Adding and Deleting Transactions during Reconciliation, Edit Transactions During Reconciliation, The Reconcile Buffer @section Finalize Reconciliation @cindex reconciliation, finalizing +@kindex C-c C-c +@kindex q Once you have marked all transactions as pending and the cleared balance is correct. Finish the reconciliation by typing @kbd{C-c C-c}. This marks all pending transactions as cleared and saves the ledger buffer. +Type @kbd{q} to close out the reconciliation buffer. If variable +@var{ledger-reconcile-finish-force-quit} is set, the reconciliation +buffer will be killed automatically after @kbd{C-c C-c}. + @node Adding and Deleting Transactions during Reconciliation, Changing Reconciliation Account, Finalize Reconciliation, The Reconcile Buffer @section Adding and Deleting Transactions during Reconciliation @kindex a @@ -986,6 +992,9 @@ ledger file order. Defaults to '(0)'. If t, prompt for effective date when clearing transactions during reconciliation. +@item ledger-reconcile-finish-force-quit nil +If t, will force closing reconcile window after @kbd{C-c C-c}. + @end ftable @node Ledger Report Customization Group, Ledger Faces Customization Group, Ledger Reconcile Customization Group, Customization Variables diff --git a/lisp/ledger-reconcile.el b/lisp/ledger-reconcile.el index 2396748a..326266b7 100644 --- a/lisp/ledger-reconcile.el +++ b/lisp/ledger-reconcile.el @@ -118,6 +118,11 @@ Possible values are '(date)', '(amount)', '(payee)' or '(0)' for no sorting, i.e :type 'boolean :group 'ledger-reconcile) +(defcustom ledger-reconcile-finish-force-quit nil + "If t, will force closing reconcile window after \\[ledger-reconcile-finish]." + :type 'boolean + :group 'ledger-reconcile) + ;; s-functions below are copied from Magnars' s.el ;; prefix ledger-reconcile- is added to not conflict with s.el (defun ledger-reconcile-s-pad-left (len padding s) @@ -314,7 +319,7 @@ Return the number of uncleared xacts found." (defun ledger-reconcile-finish () "Mark all pending posting or transactions as cleared. Depends on ledger-reconcile-clear-whole-transactions, save the buffers -and exit reconcile mode" +and exit reconcile mode if `ledger-reconcile-finish-force-quit'" (interactive) (save-excursion (goto-char (point-min)) @@ -327,7 +332,8 @@ and exit reconcile mode" (ledger-toggle-current 'cleared)))) (forward-line 1))) (ledger-reconcile-save) - (ledger-reconcile-quit)) + (when ledger-reconcile-finish-force-quit + (ledger-reconcile-quit))) (defun ledger-reconcile-quit ()