ledger / ledger-mode

Emacs Lisp files for interacting with the C++Ledger accounting system
GNU General Public License v2.0
381 stars 76 forks source link

ledger-display-balance-at-point does not parse account name properly #31

Open vizietto opened 7 years ago

vizietto commented 7 years ago

When the currency unit is placed after the value, the account name is not parsed properly. Example :

Assets:AnyAccount                                              1000 EUR

C-c C-p gives

Assets:AnyAccount                                              1000 EUR is empty
enderw88 commented 7 years ago

Yes. This is a bug related to an error in the parser that doesn't pull out the account properly when the amount is followed by the commodity. I have been working on it for a while but overtime I think I have it fixed, the fix breaks something else.

On Thu, Apr 20, 2017 at 11:09 PM, vizietto notifications@github.com wrote:

When the currency unit is placed after the value, the account name is not parsed properly. Example :

Assets:AnyAccount 1000 EUR

C-c C-p gives

Assets:AnyAccount 1000 EUR is empty

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/ledger/ledger-mode/issues/31, or mute the thread https://github.com/notifications/unsubscribe-auth/AA1rLDj91cSkjuZvt-4crtHHcQVBjW4qks5ryEgsgaJpZM4ND5qh .

-- Craig, Corona De Tucson, AZ [image: missile_flyout] enderw88.wordpress.com

yurikhan commented 7 years ago

To my eye, in current master (9dca0962), it looks like the commodity regexp is missing a +. As is, it matches a quoted string or a single allowed character, whereas a commodity can be multiple allowed characters.


 (ledger-define-regexp commodity
                       (rx (group
                            (or (and ?\" (+ (not (any ?\"))) ?\")
+                               (+
                                (not (any blank ?\n
                                          digit
                                          ?- ?\[ ?\]
                                          ?. ?, ?\; ?+ ?* ?/ ?^ ?? ?: ?& ?| ?! ?=
                                          ?\< ?\> ?\{ ?\} ?\( ?\) ?@)))))
+                               )
                       "")

What breaks if this change is introduced?