Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C-c C-p: bad suggestion with inline math, e.g. ($20 + $10) #196

Open
Bodertz opened this issue Sep 22, 2019 · 1 comment
Open

C-c C-p: bad suggestion with inline math, e.g. ($20 + $10) #196

Bodertz opened this issue Sep 22, 2019 · 1 comment

Comments

@Bodertz
Copy link

Bodertz commented Sep 22, 2019

ledger-mode-version: 3.0.0

2019-09-21 Store - Buy Two Get One 1/2 Off!
    Expenses:Items  (2 * $60.00 + $30.00)
    Equity:Example

Place point over 'Expenses:Items' and do M-x ledger-display-balance-at-point (or C-c C-p).

Look at the minibuffer:

Result:

Account balance to show (Expenses:Items  (2 \* \$60\.00 \+ \$30\.00):

Press RET.
Ledger error: Error: Missing ')'

Expected Result:

Account balance to show (Expenses:Items):

Press RET.

         $150.00                   0                 Expenses:Items

ledger-display-balance-at-point eventually calls ledger-read-account-with-prompt:

 (let* ((account (ledger-read-account-with-prompt "Account balance to show"))
        ...))
(defun ledger-read-account-with-prompt (prompt)
  "Read an account from the minibuffer with PROMPT."
  (let* ((context (ledger-context-at-point))
         (account (ledger-context-field-value context 'account)))
    (ledger-completing-read-with-default prompt
                                         (when account
                                           (regexp-quote account))
                                         (ledger-accounts-list))))

Note that the result of (ledger-accounts-list) is correct; it is merely the default suggestion given by (ledger-context-field-value context 'account) that is wrong.

Running ledger-context-at-point on the "Expenses" line gives as the result:

(acct-transaction indent ((indent "   " 45) (status nil nil) (account "Expenses:Items  (2 * $60.00 + $30.00" 49)))

I think this means that a regular expression failed to match something,
and so the 'account' regexp matched more than it should have.

I think the issue lies in the constant ledger-line-config,
which is referred to by the function ledger-extract-context-info,
which is called by the function ledger-context-at-point,
which is called by the function ledger-context-field-info,
which is called by the function ledger-context-field-value,
which is called by the function ledger-read-account-with-prompt,
which, finally, is called by ledger-display-balance-at-point.

There's a whole big thing of regex matching here which I don't understand, and I'm not getting much further than this.

@Bodertz
Copy link
Author

Bodertz commented Sep 22, 2019

I noticed Issue #158 and PR #161. The fix does not appear to help here.

I kinda figured it would, so I might have been going down the wrong path here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant