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

Enhancement: ledger-add-note

Open heikkil opened this issue 7 years ago • 0 comments

I have written an interactive convenience function to add notes about the transaction to the ledger entry under the point. It saves time and effort in finding the right spot and writing the tag.

I could not find anything similar in the ledger-mode, so this might be useful to others, too.

The comment tag is hard coded to 'note' but the function can easily be made more flexible.

(defun ledger-add-note ()
  "Add a note to the current ledger entry.

Adds a new comment line starting with ' ; note: ' and places
point to the end. The new line is always placed after other
comments."
  (interactive)
  (ledger-navigate-beginning-of-xact)
  (let ((beg-of-xact (point)))
    (ledger-navigate-end-of-xact)
    (unless (re-search-backward "^ +;" beg-of-xact t)
      (goto-char beg-of-xact))
    (end-of-line)
    (insert "\n\t; note: ")
    (ledger-magic-tab)))

heikkil avatar Feb 17 '18 09:02 heikkil