I work on different ledger files. Currently, each time I call ledger-report I have to retype the command ledger -f [filename] bal. How can I get the current buffer filename to appear by default in this command?

  • 1
    There is a variable ledger-reports which can be customized to contain the entire command including a dynamic determination of the filename derived from the (current-buffer). If a predefined command does not exist in ledger-reports, then the default behavior is to memorize the new command and add it to the aforementioned variable and store it in the .emacs file for future use. I am careful not to type in new commands that have not been predefined because I don't want to populate the .emacs file. Instead, I just use the down arrow key to select from the available choices ... – lawlist Dec 27 '20 at 17:01
  • 1
    Here is the Github link to the exact location where the variable ledger-reports (which can be customized) is defined with four (4) default settings of bal, reg, payee, and account: github.com/ledger/ledger-mode/blob/master/ledger-report.el#L47 You can get very elaborate when creating custom commands, especially if you decide to use a little bit of Lisp to take full control over the variable ledger-reports and instead forego M-x customize-variable .... Or, you could just use the aforementioned command. – lawlist Dec 27 '20 at 17:05
  • @lawlist Thanks, that solved it! Upvoting now but can't select as correct answer since it's in comments. – Gavin Dec 28 '20 at 5:28
  • 1
    @lawlist: please consider making your comment an answer. – NickD Dec 30 '20 at 15:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.