ledger-mode
ledger-mode copied to clipboard
Request: color code debits and credit differently
I'd like to request that debits and credits in the reconcile window be colorized differently, so it's easy to distinguish them.
This is an interesting idea. i will look into it.
Debits and credits are color coded by ledger itself. I managed to propagate those colors into emacs but it required an unpackaged elisp source ftp://download.tuxfamily.org/user42/tty-format.el I'll submit a PR when I figure out how to include tty-format.el (or the relevant bits) properly.
I was wrong: tty-format.el is actually available as package, from the repository ("user42" . "https://download.tuxfamily.org/user42/elpa/packages/"). However, as of now, package.el has issues with the signature on tty-format.el, I'm looking into it.
I'd appreciate if someone told me how to specify tty-format as dependency properly. Do I simply (require 'tty-format) in ledger-mode.el?
I'd appreciate if someone told me how to specify tty-format as dependency properly. Do I simply (require 'tty-format) in ledger-mode.el?
That's how you'd do it, yes, together with a Package-Requires header entry, but if the package isn't available via a major repository, it's not something we'd want to add as a dependency of ledger-mode.
if the package isn't available via a major repository, it's
not something we'd want to add as a dependency of
ledger-mode.
Pity. I will talk to the tty-format developer, and suggest relocation or mirroring.
Straightforward (“static”) inclusion of el files (one file in this case) in not welcome either?
Pity. I will talk to the tty-format developer, and suggest relocation or mirroring.
Yeah, I'd be happy to host it in MELPA, but it would need a couple of little fixes first (primarily because it introduces top-level symbols that aren't prefixed with the package name).
Straightforward (“static”) inclusion of el files (one file in this case) in not welcome either?
No, because then we'd have to adopt and maintain the code, and also prefix it with ledger- etc.
No need for tty-format dependency. Following a suggestion by tty-format developer Kevin Ryde, I have successfully tested a more straightforward way to do it. Once we're done with #61, I'll submit a patch. (it requires inserting some ledger options, as in #61)
With ansi-color (built-in into Emacs since at least 25, probably goes earlier than that), we can propagate native ledger ansi colors into Emacs buffer. See https://github.com/ledger/ledger-mode/commit/54c3299a0d2a848b082b7cdc702a03c2699f1e0a which deals with ledger-report output. In particular, credits are colored red in native ledger output.
Issues:
- Some output from ledger-mode is pre-painted;
ledger-reconcileoutput is one example of this, not the only one, as far as I can remember. With ansi colors on top it didn't look stellar in my Emacs (although it might be possible to fix by some faces customization). - Some users might find this feature overall annoying, so I propose only doing it if a custom variable is true; say, “ledger-enforce-native-ansi-output”?
Notes:
- I don't use ledger-reconcile at all, will have to look into that separately.
- I'm not experienced with git, and my native-ansi-colors branch starts from an (yet?) unmerged branch dedicated to width adjustment as the mechanism is similar.