Sometimes there is an Emacs command that makes delightfully short work of a plain text accounting task.
This was the case recently when I was trying to catch up on a couple of months of neglecting to track rewards vs. cost of a membership program. You can read more about my membership reward tracking at https://hledgerfan.com/does-a-membership-program-pay-for-itself-part-5/.
I will pause to make clear that I am not saying that everyone should track costs vs. rewards of a membership program. Yes, it’s good to evaluate membership programs, but not necessarily to track the rewards and costs in plain text accounting.
For example, I have one membership program where the money that I save on milk alone more than pays the yearly cost. There are other additional savings, but it’s good enough for me to know that the program is more than paying for itself.
However, mostly for learning purposes, I am tracking one of my membership programs. Or should I say, I had been tracking, but I fell off the wagon a couple of months ago.
The other day I decided to catch up. At one point I realized that the easiest way to catch up would be to copy an earlier transaction. This previous transaction had extensive, useful comments on what went in each of the 4 lines of the transaction. So, the comments were an important part of what I needed.
I noticed the Emacs ledger-mode had a ledger-copy-transaction-at-point (C-c C-k) command. This command does a few neat things. First, it includes the comments in the copy. I have noticed that when I use iadd to create a new transaction based on an older one, it very nicely prompts me with the default values of just about everything in the most previous instance of that transaction. However, it doesn’t preserve the comments from the previous transaction. I can see where sometimes you wouldn’t want the comments from your previous transaction, but in this case I did. So C-c C-k let gave me a new transaction with the comments included.
Second, ledger-copy-transaction-at-point has some advantages over simply copying an old instance of the transaction. As the name implies, you can have the pointer at any place in the transaction, and it automatically copies the entire transaction. In contrast, if I am copying manually, there are several steps: Move to the beginning of the transaction, set the mark, highlight to the end of the transaction, and then copy the highlighted transaction.
In addition, ledger-copy-transaction-at-point prompts you for the new date, via Emacs calendar, which is handy. Finally, it inserts the copy into your accounting data in the correct date order.
In short, ledger-copy-transaction-at-point took away several drudge steps and helped me catch up with a task that I had been neglecting.