Format of Report: Double Line Spacing Between Entries

66 views
Skip to first unread message

Keith David Bershatsky

unread,
Jan 9, 2021, 7:44:00 PM1/9/21
to Ledger
Is there a way to double-space the output of reports (e.g., a register report) so that there is a blank line between each entry?

What appears to be happening is that ledger has a built-in replace-regexp that removes any extra `\n` beyond just one at the end of the report format.  Through trial and error, I have found two workarounds, neither of them being absolutely perfect.

#1 workaround:  Place a `\n` at the beginning of the format string and another `\n` at the end of the format string.

#2 workaround:  Place a `\n` form-feed `\n` at the end of the format string.

With workaround #1, there is an extra blank line at the beginning of the report.

With workaround #2, each line without an entry has a form-feed character.

Sure, I can use Emacs to fix anything after the report has been generated, either by modifying the report string before it is inserted into the buffer or modifying the buffer after the report string has been inserted.  I could also use Emacs to change the form-feed character into anything else using the buffer-display-table to modify that entry.  I could use another ascii character instead of form-feed, such as a zero-width-space (although I haven't tried that).  After a few days, I might even start to like seeing the form-feed character -- who knows...

All of that being said, is there any way to just use `\n\n` or another setting that accomplishes the same thing?

Here is my report format.  I need to use a custom register format because the ledger executable has a bug that cannot deal with very long payee lines when using the built-in register-format where mandatory truncation fails and the report stops being generated at the segfault something 1024.  At some point, I'll file a formal bug report.  I'm actually quite happy using my own report format ... I just need some double-spacing for readability ...

    (let ((register-format (concat "\"%(!cleared"
                                " ? ansify_if (date, bold)"
                                " : ansify_if (date, blue if color))"
                             "  %(ansify_if (justify (truncated (display_account, int(account_width), int(abbrev_len)), int(account_width)),"
                                            " white if color))"
                             " %((display_amount < 0)"
                                " ? (!cleared"
                                    " ? ansify_if (justify (scrub (display_amount), 13, -1, true, color), bold)"
                                    " : justify (scrub (display_amount), 13, -1, true, color))"
                                " : ansify_if (justify (scrub (display_amount), 13, -1, true, color), black if color))"
                             " %((display_total < 0)"
                                " ? justify (scrub (display_total), 13, -1, true, color)"
                                " : ansify_if (justify (scrub (display_total), 13, -1, true, color), black if color))"
                             "  %(cleared"
                                 " ? ansify_if (\\\"*\\\", yellow if color)"
                                 " : (pending"
                                     " ? ansify_if (\\\"!\\\", magenta if color)"
                                     " : \\\" \\\"))"
                             "  %(ansify_if (payee, blink if color and !cleared and actual))\n \n\"")))
      ...)

Keith David Bershatsky

unread,
Jan 10, 2021, 11:18:04 PM1/10/21
to Ledger
**SOLVED**:  Ansify the additional newline so that it is not stripped/disregarded by the ledger executable.

    (let ((register-format (concat "\"%(!cleared"
                                      " ? ansify_if (date, bold)"
                                      " : ansify_if (date, blue if color))"
                                   "  %(ansify_if (justify (truncated (display_account, int(account_width), int(abbrev_len)), int(account_width)),"
                                                  " white if color))"
                                   " %((display_amount < 0)"
                                      " ? (!cleared"
                                          " ? ansify_if (justify (scrub (display_amount), 13, -1, true, color), bold)"
                                          " : justify (scrub (display_amount), 13, -1, true, color))"
                                      " : ansify_if (justify (scrub (display_amount), 13, -1, true, color), black if color))"
                                   " %((display_total < 0)"
                                      " ? justify (scrub (display_total), 13, -1, true, color)"
                                      " : ansify_if (justify (scrub (display_total), 13, -1, true, color), black if color))"
                                   "  %(cleared"
                                       " ? ansify_if (\\\"*\\\", yellow if color)"
                                       " : (pending"
                                           " ? ansify_if (\\\"!\\\", magenta if color)"
                                           " : \\\" \\\"))"
                                   "  %(ansify_if (payee, blink if color and !cleared and actual))"
                                   "%(ansify_if (\\\"\\n\\\", bold))\n"
                                   "%/\"")))
      [INSERT COMMAND LINE ARGS HERE])

Reply all
Reply to author
Forward
0 new messages