Skip to content

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

Description

@Bodertz

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions