ledger-mode icon indicating copy to clipboard operation
ledger-mode copied to clipboard

Request: color code debits and credit differently

Open jmrgithub opened this issue 8 years ago • 8 comments

I'd like to request that debits and credits in the reconcile window be colorized differently, so it's easy to distinguish them.

jmrgithub avatar Feb 04 '17 17:02 jmrgithub

This is an interesting idea. i will look into it.

enderw88 avatar Feb 08 '17 02:02 enderw88

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.

akater avatar Dec 29 '17 12:12 akater

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?

akater avatar Dec 31 '17 03:12 akater

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.

purcell avatar Dec 31 '17 03:12 purcell

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?

akater avatar Dec 31 '17 15:12 akater

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.

purcell avatar Dec 31 '17 23:12 purcell

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)

akater avatar Jan 04 '18 07:01 akater

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-reconcile output 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.

akater avatar Jan 20 '18 05:01 akater